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
48
votes
2 answers

How to disable a linting rule inline in flutter

Is there a way to disable a linting rule for a line in flutter? I have a specific use case where I want to disable linting for two lines. I have a lot of business logic already written so I cannot change the code. abstract class ReviewName { …
SRAVAN
  • 769
  • 1
  • 7
  • 11
46
votes
3 answers

How to automate the correctness-checking of makefiles?

I know there are many linters for programming languages, like pep8 for python, but I have never come across one for a makefile. Are there any such linters for makefiles? Any other ways to programmatically detect errors or problems in makefiles…
msakya
  • 9,311
  • 5
  • 23
  • 31
45
votes
9 answers

JSLint: control comments (selective ignore)

Does JSLint have anything like JavaScript Lint's control comments (e.g. /*jsl:fallthru*/) to make it ignore certain passages?
AnC
43
votes
4 answers

ng lint command - How can I execute it on only one typescript file?

I am using "ng lint" command from the latest 'angular cli'. Is it possible to run this command on only one typescript file instead of running on all the typescript files in the entire project ? Thanks Adam
Adam
  • 1,221
  • 4
  • 13
  • 27
43
votes
2 answers

Retrolambda: Lint crashes when using lambda expressions with retrolambda

I'm trying to use retrolambda along with gradle-retrolambda plugin. In general it works fine, but when I compile for release, the lint stage fails with exception: :playground.dagger:lintVitalReleaseFailed converting ECJ parse tree to Lombok for file…
41
votes
1 answer

How to correctly declare a GraphQL query without parameters.

I'm using vs code + graphql-cli for validating & linting the schema. In the following declaration (in the graphql schema file): type Query { users(): Int } The users declaration above is marked as en error, but it doesn't make any problem (or…
Robert Zaremba
  • 8,081
  • 7
  • 47
  • 78
41
votes
6 answers

Clean up unused Android permissions

If I wanted to research how and where permissions [requested in the Mainfest.xml] were used in an Android app for the purposes of removing them is there an easy way of doing this? Does lint or findbugs offer some sort of support for tracking…
Cliff
  • 10,586
  • 7
  • 61
  • 102
39
votes
9 answers

Where can I find an actively developed lint tool for Ruby?

Most of the code I write is in Ruby, and every once in a while, I make some typo which only gets caught after a while. This is irritating when I have my scripts running long tasks, and return to find I had a typo. Is there an actively developed lint…
Geo
  • 93,257
  • 117
  • 344
  • 520
38
votes
1 answer

Why is lint giving a warning ineffectual assignment to (ineffassign)

Getting a lint warning ineffectual assignment to "cfg" at line cfg := &utils.Config{}. Why is that ? cfg := &utils.Config{} env := os.Getenv("TEST") if strings.EqualFold(env, "INT") { cfg = utils.GetIntConfig() } else { …
Ishmeet
  • 1,540
  • 4
  • 17
  • 34
38
votes
2 answers

Conflicting lint messages regarding paddingStart usage

After API 17 / RTL support was released, I added the following to my manifest android:supportsRtl="true" which caused Lint to rightfully give me these warnings wherever I had paddingLeft/Right in my views: Consider adding…
tabjsina
  • 1,582
  • 15
  • 26
37
votes
1 answer

How can I configure Pylint to check all things PEP8 checks?

Searching for an answer on Pylint's mailing list brings no interesting results. Pylint is known to be very customizable, so I guess this should be possible... The reason I would like Pylint to check compliance with PEP8 is because PyDev has much…
Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
37
votes
10 answers

avoid lint when gradle execute check

could someone tell me a way to avoid executing "lint" each time I run in gradle check? I've defined in build.gradle lintOptions { quiet true } However, it keeps doing this task. The problem is that it takes ages each time I have to do a…
Jose M Lechon
  • 5,766
  • 6
  • 44
  • 60
36
votes
2 answers

Custom linting lib in android

My team and I develop Android apps and have decided on coding guidelines that all should follow. I therefore started implementing custom lint rules as per the following links: Post written by Matt Compton Git Repo The problem that I'm having is…
hopeman
  • 2,778
  • 3
  • 18
  • 33
36
votes
2 answers

Lint error "Do not treat position as fixed; only use immediately..."

I'm contributing to open source library and got lint error "Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later" for this code: @Override public void…
Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114
36
votes
1 answer

Android Studio lint reports "cannot infer argument types."

I have reviewed the Inspection report for my project that is provided by Android Studio after having executed the following command: Analyze->Inspect Code... The report indicates a problem with this code snippet in my gradle.build file: buildTypes…
gonzobrains
  • 7,856
  • 14
  • 81
  • 132