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
24
votes
3 answers

How to ignore complete folders for lint checking with gradle?

I have an Android project that includes generated code. This code has some lint violations in it that I don't want to show up in the lint reports because we won't fix this code problems manually. Is it somehow possible to exclude folders in the…
Janusz
  • 187,060
  • 113
  • 301
  • 369
24
votes
5 answers

Android Lint report duplication

I run ./gradlew clean lint command in console and get Lint report in build/lint/ReleaseOutput.html and build/lint/ReleaseOutput.xml I got 6 times the same error: And I also see 6 times the same times one issue in XML file:
Borys
  • 1,793
  • 2
  • 17
  • 32
23
votes
17 answers

Is JSLint available for offline use?

I'd like to use JSLint, but I am wary of tools that have access to my unfiltered source code. Is there an offline version or is there another similar tool that does "lint error checking" for JavaScript offline? Edit: One with a GUI and that shows…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
23
votes
2 answers

How can I produce github annotations by creating report files on disk?

I am trying to find a portable way to produce code annotations for GitHub in a way that would avoid a vendor-lockin. Mainly I want to dump annotations inside a file (yaml, json,...) during build process and have a task at the end that does transform…
sorin
  • 161,544
  • 178
  • 535
  • 806
23
votes
2 answers

What is the actual duration of a Snackbar with LENGTH_LONG

Since I've migrated my Android Project to AndroidX i am receiving the following lint error: Error: Must be one of: Snackbar.LENGTH_INDEFINITE, Snackbar.LENGTH_SHORT, Snackbar.LENGTH_LONG [WrongConstant] Snackbar snackbar =…
ice_chrysler
  • 2,633
  • 1
  • 21
  • 27
23
votes
4 answers

How can I get ESLint to lint HTML files in VSCode?

I have a Javascript browser project split over multiple files and can't get ESLint to lint the script tags of my HTML file under the same global scope so that declarations and calls of classes and functions in one file are recognised in…
Alex McDermott
  • 151
  • 1
  • 1
  • 8
23
votes
5 answers

How can I check (My)SQL statements for syntactical correctness

we're currently setting up out integration server and during that process we've set up pre-commit hooks on the SVN so that our developers can't check in files that are syntactically invalid (primarily PHP and XML). We also have a bunch of .sql files…
n3rd
  • 5,989
  • 4
  • 39
  • 56
23
votes
2 answers

How to debug java source code when I implement a custom Detector for Lint?

I am a Android developer. I have already design my own lint rules by implementing new XXXDetector and XXXIssueRegistry, here is my source code snip: My XXXIssueRegistry file: public class MyIssueRegistry extends IssueRegistry { @Override public…
ljfxyj2008
  • 231
  • 1
  • 4
22
votes
1 answer

library_private_types_in_public_api and StatefulWidget

After upgrade the linter to the new version (flutter_lints: 2.0.1) in my pubspec the linter enables this rule: library_private_types_in_public_api by default. I don't understand why. In my App project there are a lot of widget classes extended by…
Maurice Raguse
  • 4,437
  • 2
  • 29
  • 46
22
votes
5 answers

Want to extend empty interface but getting lint error: no-empty-interface

Today, I tried to do this in my angular 6 application: export interface AuthConfig {} export interface BasicAuthConfig extends AuthConfig { username: string; password: string; } export interface OAuth2AuthConfig extends AuthConfig { …
Gibran Shah
  • 333
  • 1
  • 2
  • 9
22
votes
3 answers

Simplifying an 'if' statement with bool()

I have some code that causes Pylint to complain: The if statement can be replaced with 'var = bool(test)' (simplifiable-if-statement)` The code (with obfuscated variable names) is below. A = True B = 1 C = [1] D = False E = False if A and B in…
Gary
  • 3,891
  • 8
  • 38
  • 60
22
votes
3 answers

Pylint giving me "Final new line missing"

Pylint complains on last line where I'm calling function deletdcmfiles(). Final newline missing. I'm new to python and I'm not sure what is triggering this? Here is the code of the program: ''' This program will go through all Work subdirectorys in…
Nermin Kekic
  • 393
  • 2
  • 6
  • 12
22
votes
1 answer

ESLint --fix not editing files

I am trying to lint and fix my code using ESLint. When I run ESLint with my config file and without the fix flag, it runs fine, and this is what it outputs. eslint-c .eslintrc.json…
lonewaft
  • 812
  • 2
  • 11
  • 28
22
votes
2 answers

Having scss-lint ignore a particular line

How do you tell scss-lint to ignore a particular line in a .scss file? i.e. can you do something like this: .example { display: block !important; // sass-lint: ignore }
coffee-grinder
  • 26,940
  • 19
  • 56
  • 82
22
votes
3 answers

What does "(...) interpreted as grouped expression" mean?

I'm using a Ruby linter in Atom and for some lines it gives the following warning: (...) interpreted as grouped expression An example of a line that get's this warning is this: elsif not (params[:vacancy].nil? or params[:vacancy]['company_id'].nil?…
Jasper Kennis
  • 3,225
  • 6
  • 41
  • 74