Questions tagged [lint]

Please tag questions about static analysis tools "static-analysis" unless they're actually about the Lint utility. One of the first static analyzers was the Lint utility which appeared in 1979 as part of the Unix 7 distribution kit. Lint was originally used to analyze C source code. This command was so popular that the word "lint" has become the generic term for static analysis tools.

Introduction

The first version of Lint was developed by Stephen C. Johnson while at Bell Laboratories in an effort to detect bugs that may have otherwise gone unnoticed in C programs. The following is from the abstract for "Lint, a C Program Checker" written by Johnson in 1978.

Lint is a command which examines C source programs, detecting a number of bugs and obscurities. It enforces the type rules of C more strictly than the C compilers. It may also be used to enforce a number of portability restrictions involved in moving programs between different machines and/or operating systems. Another option detects a number of wasteful, or error prone, constructions which nevertheless are, strictly speaking, legal.

Johnson's Lint command first appeared (outside of Bell Laboratories) in 1979 as part of the Unix 7 distribution kit (see lint(1) man page). A version of the command still exists today and a description of the utility can be found in the FreeBSD 11.2 lint(1) man page:

The lint utility attempts to detect features of the named C program files that are likely to be bugs, to be non-portable, or to be wasteful. It also performs stricter type checking than does the C compiler.

Among the possible problems that are currently noted are unreachable statements, loops not entered at the top, variables declared and not used, and logical expressions with constant values. Function calls are checked for inconsistencies, such as calls to functions that return values in some places and not in others, functions called with varying numbers of arguments, function calls that pass arguments of a type other than the type the function expects to receive, functions whose values are not used, and calls to functions not returning values that use the nonexistent return value of the function.

Due primarily to the popularity of the original Lint command, the term "lint" has come to signify static analysis tools in general. A myriad of tools exist today, some of which include:

Open source:

Commercial:

Usage of the Stack Overflow "lint" tag

Only use this tag for questions involving the various Lint tools from Gimpel Software.

Please refrain from using this tag regarding general questions about static analysis. Questions in regard to the static analysis of code and the use of static analysis tools should use .

References

Karpov, Andrey, Parallel Lint: Verifying parallel programs, Dr. Dobb's The World of Software Development, 2009.

Johnson, S.C., Lint, a C Program Verifier, Bell Laboratories, Murray Hill, New Jersey, 1978.

1825 questions
83
votes
11 answers

How to auto format JSON on save in Vim

To be honest go has spoiled me. With go I got used to having a strict formatting standard that is being enforced by my editor (vim) and is almost accepted and followed by everybody else on the team and around the world. I wanted to format JSON files…
Ali
  • 18,665
  • 21
  • 103
  • 138
73
votes
4 answers

How to set .eslintrc to recognize 'require'?

I am new to ESLint, and I have successfully integrated ESLint with IntelliJ. Out of the box, my integration of ESLint did not recognize node, but basic review of documentation made clear that by creating the configuration file named .eslintrc at the…
Dan Nissenbaum
  • 13,558
  • 21
  • 105
  • 181
67
votes
6 answers

how to avoid "Octal literals are not allowed in strict mode" with createWriteStream

I have the following code fs.createWriteStream( fileName, { flags: 'a', encoding: 'utf8', mode: 0644 }); I get a lint error Octal literals are not allowed in strict mode. What is the correct way to do this code so I won't get a lint error?
guy mograbi
  • 27,391
  • 16
  • 83
  • 122
65
votes
1 answer

Lint error: Implement lifecycle hook interfaces

I got a linting error and I am not sure what it is talking about, this is the error: src/app/particles/particles.component.ts[4, 1]: Implement lifecycle hook interfaces (https://angular.io/docs/ts/latest/guide/style-guide.html#!#09-01) Row nr 4 is…
Björn Hjorth
  • 2,459
  • 5
  • 25
  • 31
64
votes
4 answers

ignore eslint error: 'import' and 'export' may only appear at the top level

Is it possible to deactivate this error in eslint? Parsing error: 'import' and 'export' may only appear at the top level
user3142695
  • 15,844
  • 47
  • 176
  • 332
62
votes
6 answers

How to ignore Pyflakes errors ‘imported but unused’ in ‘__init__.py’ files?

I split my tests across multiple Python files: tests ├── __init__.py ├── test_apples.py └── test_bananas.py.py I import the tests in the ‘__init__.py’ file: from test_apples import ApplesTest from test_bananas import BananasTest However running…
Venkatesh Bachu
  • 2,348
  • 1
  • 18
  • 28
62
votes
6 answers

How to recompile with -Xlint:deprecation

I don't use Android Studio but I build everything from the command line using build.gradle. I generate a Lint report like this: ./gradlew lint This correctly generates a Lint report but it also says this: Note: MyActivity.java uses or overrides a…
Andreas
  • 9,245
  • 9
  • 49
  • 97
60
votes
6 answers

What linters are there for C#?

Is there a lint-like tool for C#? I've got the compiler to flag warnings-as-errors, and I've got Stylecop, but these only catch the most egregious errors. Are there any other must-have tools that point out probably-dumb things I'm doing?
Ken
  • 2,651
  • 3
  • 19
  • 17
58
votes
7 answers

Resolved color instead of a resource id

Recently I've seen appeared a lint error in my code: Should pass resolved color instead of resource id here: getResources().getColor(R.color.maps_list_background_color) MyClass.java /myapp/android/maps line 107 Android Lint Problem I know…
Leoz
  • 733
  • 1
  • 7
  • 10
53
votes
7 answers

Can't get Atom Linter to work

I'm new to Atom, the text edit, and I installed many packages, including Linter https://github.com/AtomLinter/Linter But it's not showing errors or highlighting code, it's just getting ignored. Do any of you know what I should do to get this to…
Victor Ferreira
  • 6,151
  • 13
  • 64
  • 120
51
votes
4 answers

Waiting asynchronously for Navigator.push() - linter warning appears: use_build_context_synchronously

In Flutter, all Navigator functions that push a new element onto the navigation stack return a Future as it's possible for the caller to wait for the execution and handle the result. I make heavy use of it e. g. when redirecting the user (via…
Schnodderbalken
  • 3,257
  • 4
  • 34
  • 60
51
votes
4 answers

One var per function in JavaScript?

I've been using JSLint to make me feel bad about my JavaScript. It is great, by the way. There is one check that I don't quite understand and I'd like your views, please. From jslint.com: In languages with block scope, it is usually recommended…
Scott McKenzie
  • 16,052
  • 8
  • 45
  • 70
51
votes
10 answers

Ignoring return values in C

Lately, I started using lint for static code analysis. One of the warning I get sometimes is regarding this issue. Let's say for instance that I've got the following function: uint32_t foo( void ); And let's say that I delibertly ignore the return…
stdcall
  • 27,613
  • 18
  • 81
  • 125
50
votes
9 answers

Android Lint: how to ignore missing translation warnings in a regional locale string file that purposely only overrides some default translations?

Is it possible to translate some strings, but not all, in a separate resource file without Lint complaining about MissingTranslation? For example: my app's strings are all in res/values/strings.xml. One of the strings is
Steveo
  • 2,238
  • 1
  • 21
  • 34
49
votes
11 answers

NOT SUPPORTED: keyword "id", use "$id" for schema ID : TSLint (ng add @angular-eslint/schematics)

I am upgrading my Angular 10 application to Angular 13. I did well with other compatibilities of dependencies. The project is compiling and working fine. Now the time for TSLint I tried to update the lint with the below command. ng add…
Satish Singh
  • 2,169
  • 3
  • 23
  • 32