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
1282
votes
8 answers

What is "Linting"?

PHPLint, JSLint, and I recently came across "you can lint your JS code on the fly" while reading something about some IDE. So, what is "linting"?
Ashkan Kh. Nazary
  • 21,844
  • 13
  • 44
  • 68
742
votes
19 answers

Turning off eslint rule for a specific file

Is it possible to turn off the eslint rule for the whole file? Something such as: // eslint-disable-file no-use-before-define (Analogous to eslint-disable-line.) It happens to me quite often, that in a certain file, I'm breaking a specific rule on…
Tomas Kulich
  • 14,388
  • 4
  • 30
  • 35
246
votes
22 answers

How to resolve "Missing PendingIntent mutability flag" lint warning in android api 30+?

As soon as I updated the target SDK to 30+ (Android R or later), a lint warning Missing PendingIntent mutability flag appeared on my PendingIntent.FLAG_UPDATE_CURRENT flag when I want to define PendingIntent. How should I handle this lint with no…
Amir Hossein Ghasemi
  • 20,623
  • 10
  • 57
  • 53
220
votes
9 answers

JSHint and jQuery: '$' is not defined

The following JS: (function() { "use strict"; $("#target").click(function(){ console.log("clicked"); }); }()); Yields: test.js: line 5, col 3, '$' is not defined. When linted using JSHint 0.5.5. Any ideas?
Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130
157
votes
8 answers

The result of subscribe is not used

I've upgraded to Android Studio 3.1 today, which seems to have added a few more lint checks. One of these lint checks is for one-shot RxJava2 subscribe() calls that are not stored in a variable. For example, getting a list of all players from my…
Michael Dodd
  • 10,102
  • 12
  • 51
  • 64
153
votes
6 answers

Visual Studio Code formatting for "{ }"

I'm on Ubuntu. C++ in Visual Studio Code automatically lints like if (condition == true) { DoStuff(); } Instead I want to do : if (condition == true) { DoStuff(); } How do I do that? I've already installed the C/C++ extension from the…
radbrawler
  • 2,391
  • 2
  • 15
  • 22
151
votes
18 answers

"is translated here but not found in default locale" error in strings.xml with translatable="false"

Here is my values\strings.xml (the default file) and everything is self explanatory: My question(s): How can it be "not found in default locale" if I am editing the default locale (values\strings.xml)? How can it be a lint translation error if I…
PIXP
  • 2,382
  • 3
  • 19
  • 28
148
votes
7 answers

How to add -Xlint:unchecked to my Android Gradle based project?

I tried to add the following to the root build.gradle file: subprojects { gradle.projectsEvaluated { tasks.withType(Compile) { options.compilerArgs << "-Xlint:unchecked -Xlint:deprecation" } } } But I'm getting…
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
121
votes
6 answers

How to do JSLint in Vim

I spend my days in vim, currently writing a lot of JavaScript. I've been trying to find a way to integrate JSLint or something similar into vim to improve my coding. Has anyone managed to do something like this? I tried this: Javascript Syntax…
ben lemasurier
  • 2,582
  • 4
  • 22
  • 37
115
votes
7 answers

Permission is only granted to system app

I have a System app that uses system permissions and I have those permissions listed in the manifest. Eclipse gives the following error when I try to make a build(command line build works): Permission is only granted to system apps I'm already…
Caner
  • 57,267
  • 35
  • 174
  • 180
109
votes
4 answers

How to configure package.json to run eslint script

I am using eslint as a linter for my react project and I would like it to check all of my .js files. I am able to do this through the script: "lint": "eslint back/*.js && eslint backTest/*.js && eslint front/actions/*.js" how can I get it to…
Sam Houston
  • 3,413
  • 2
  • 30
  • 46
100
votes
15 answers

Could not find com.android.tools.lint:lint-gradle Android Studio 3

I have updated Android Studio to 3.0 and now received a lot of issues.. now stoped on point with such issue: Could not resolve all files for configuration ':applib:_lintClassPath'. > Could not find com.android.tools.lint:lint-gradle:26.1.0-alpha01. …
D.K.
  • 1,315
  • 2
  • 11
  • 20
100
votes
1 answer

What is better: @SuppressLint or @TargetApi?

I have issues in my app regarding StrictMode and added the code snippet that basically disables the StrictModeHelper. However, Lint complains about setThreadPolicy() now and proposes to either add @SuppressLint 'NewApi' or…
richey
  • 3,890
  • 9
  • 35
  • 49
98
votes
3 answers

Is there a simple CLI Java linter?

I've been trying to find a Java linter capable of running on the CLI that is separate from Eclipse that I can call as a commit hook for git or from our automated build script. Does such a thing exist? Ideally it needs to check for unused imports and…
BlueDragonX
  • 983
  • 1
  • 7
  • 4
84
votes
12 answers

ESLint in VSCode not fixing on save

I am using ESLint in my Vue(Nuxt) project in VSCode. When I save I would like my ESLint to run automatically and fix all the warnings for me automatically. This is my settings.json file in VSCode: { "editor.codeActionsOnSave": { …
Dennis
  • 3,044
  • 2
  • 33
  • 52
1
2 3
99 100