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
35
votes
4 answers

Eslint glob (**) is not considering all directories recursively

I am using OSX, in my package.json file I have the script entry: "lint": "eslint ./src/**/*.js" However, when I run npm lint only the 1st level of directories are being considered for linting, eg. ./src/dir/* not ./src/dir/nested_dir/*. I was under…
jfunk
  • 7,176
  • 4
  • 37
  • 38
35
votes
8 answers

Proper way to handle Android Studio's NullPointerException lint warning

I'm new to android/java programming and am confused how to properly deal with this warning. Method invocation '' may produce 'Java.lang.NullPointerException' Should I be ussing assert to remove the warning? Or rather a runtime exception? Any…
Hackmodford
  • 3,901
  • 4
  • 35
  • 78
34
votes
4 answers

How to use Flake8 in VSCode?

My VSCode is using a locally installed anaconda environment, at the default directory, which places it in Program Files. Because of this I'm unable to install flake8 through VSCode, I get a permission error. If I update my conda environment at the…
Chris Macaluso
  • 1,372
  • 2
  • 14
  • 33
34
votes
6 answers

Sublime Text 3 Sublimelinter phplint and php not found?

I have been playing with this for over an hour to get the sublimelinter working. So I now have the following packages installed: SublimeLinter SublimeLinter-php SublimeLinter-phplint Does someone know why it still does not lint the PHP I write? I…
Andy
  • 631
  • 1
  • 6
  • 13
33
votes
9 answers

How to avoid lint problem "Depend on referenced packages" for gen_l10n/app_localizations.dart

On my Flutter app, I've got this problem with lint rule : depend_on_referenced_packages This file is generated here Do you have any idea how to solve this without passing by ignore 'depend_on_referenced_packages' ? in my pubspec.yaml, I only have…
NonowPoney
  • 982
  • 4
  • 14
  • 30
33
votes
4 answers

DialogFragment getActivity() "might be null" lint warning in AndroidStudio 3.0.1

The closest existing question I can find regarding this is Android Studio 3.0 lint warnings for references to activity, but it does not help. Using AndroidStudio 3.0.1, I have a DialogFragment where I do this usual stuff: @Override @NonNull …
Trevor
  • 10,903
  • 5
  • 61
  • 84
33
votes
3 answers

Using JSLint in Notepad++

I have seen other text editors use extensions to allow syntax checkers such as JSLint, is this possible with Notepad++?
alumb
  • 4,401
  • 8
  • 42
  • 52
32
votes
5 answers

tslint Error - Shadowed name: 'err'

tslint is currently throwing the following error Shadowed name: 'err' Here is the code fs.readdir(fileUrl, (err, files) => { fs.readFile(path.join(fileUrl, files[0]), function (err, data) { if (!err) { …
bobdolan
  • 563
  • 3
  • 9
  • 21
31
votes
6 answers

Webpack config has an unknown property 'preLoaders'

I'm learning webpack from scratch. I've learned how to link javascript files with require. I'm bundling and minifying my js files and i'm listening for changes with watch. I'm setting up loaders to convert my sass files to css. But when I try to…
bakerTX
  • 321
  • 1
  • 3
  • 4
31
votes
4 answers

Android Studio's "expected resource of type" checks?

Android Studio Beta (0.8) has a nifty new feature where it checks that some int parameters are not arbitrary integers, but rather have some properties. For example, calling something like: setContentView(R.id.textView1); will correctly report that…
matiash
  • 54,791
  • 16
  • 125
  • 154
30
votes
4 answers

Error: Expected resource of type styleable [ResourceType] error

Take a look at this code snippet. I am getting an error with the last line, because I am passing an 'index' instead of a resource. I thought it was a lint issue and tried to suppress it. Then I noticed I am getting this error only when I building…
Codevalley
  • 4,593
  • 7
  • 42
  • 56
29
votes
5 answers

Android Studio 3.0 vector drawables and LINT tools:ignore="VectorPath"

After upgrading to 3.0 Android Studio has started to complain about long paths in vector drawables. The warning says: Very long vector path (7958 characters), which is bad for performance. Considering reducing precision, removing minor details or…
Ove Stoerholt
  • 3,843
  • 4
  • 25
  • 33
29
votes
2 answers

Check Android Permissions in a Method

here is my code and it works perfectly fine. if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(activity,…
29
votes
2 answers

android lint unused resources from library module are used in app

My app is split up in a main app and different library modules. When I run ./gradlew lint each module is checked independently and for each module a lint.xml file is generated. In the lint.xml files there were tons of unused resources warnings,…
sbo
  • 951
  • 2
  • 12
  • 25
29
votes
8 answers

How to suppress specific Lint warning for deprecated Android function?

I use a version switch to support older Android versions. int sdk = Build.VERSION.SDK_INT; if (sdk < Build.VERSION_CODES.HONEYCOMB) { ColorDrawable colorDrawable = new ColorDrawable(shapeColor); //noinspection deprecation …
JJD
  • 50,076
  • 60
  • 203
  • 339