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
21
votes
6 answers

How to enable Pylint in VSCode?

I can't get pylint errors to show up in VSCode. I installed pylint globally (sudo apt install pylint), I created venv and installed it there with pip, I selected pylint as linter in VSCode, enabled it, ran it, and it doesnt show any errors in my…
atlau
  • 881
  • 1
  • 7
  • 16
21
votes
2 answers

Ignore the indentation in a template literal, with the ESLint `indent` rule

The ESLint rule for indent allows for you to specify which nodes are ignored, when determining whether the rule should apply to that node, using the ignoredNodes option. I've got the following code that I want to ignore with this rule: const a = b …
Gary
  • 3,891
  • 8
  • 38
  • 60
21
votes
2 answers

Firestore: Invalid package reference in library

After updating to com.google.firebase:firebase-firestore:16.0.0 I get the following lint error: Error: Invalid package reference in library; not included in Android: javax.naming.directory. Referenced from…
Sam Stern
  • 24,624
  • 13
  • 93
  • 124
21
votes
2 answers

TSLint - Preventing error: The key is not sorted alphabetically

I'm doing a test app with Ionic2 / Cordova / Typescript / Angular. I'm using tslint 5.6.0. I'm using the following module: https://www.npmjs.com/package/tslint Focusing on just one file... when linting the following file: import { NgModule,…
davidesp
  • 3,743
  • 10
  • 39
  • 77
21
votes
3 answers

How to detect unused variables in Typescript?

Is there a way to detect unused variables in Typescript (something like ESLint in Javascript)?
Damjan Pavlica
  • 31,277
  • 10
  • 71
  • 76
21
votes
3 answers

Why doesn't lint tell me the line number and nature of the parse error?

I'm calling php lint from a Windows batch file, like so: @echo off for %%f in (*.php) do php -l %%f When a file contains a syntax error, it only outputs Errors parsing xxx.php. Is there any way to get it to tell me what the nature of the error is,…
Hammerite
  • 21,755
  • 6
  • 70
  • 91
21
votes
3 answers

How to find gradle lintOptions document for android?

I got "...is not translated in ... [MissingTranslation]"error in my android project. I searched by google find something works as abortOnError false and a document about lintOptions. But I do not want to ignore all lint errors, so I copied xml…
Malloc
  • 659
  • 2
  • 9
  • 20
21
votes
5 answers

For Android, where do I find a complete list of @SuppressLint valid issue ids

At the moment, I need to ignore a string concatenation warning relative to internationalization, but would like to "learn how to fish" for other specialized warnings in the future.
Steven Stamps
  • 353
  • 1
  • 3
  • 6
20
votes
2 answers

How do I download and install lint?

Does anyone know how to obtain lint for Mac, Windows, and Linux? sudo port install lint can't find it.
mcandre
  • 22,868
  • 20
  • 88
  • 147
20
votes
2 answers

Specify per-file-ignores with pyproject.toml and flake8

I am using flake8 (with flakehell but that should not interfere) and keep its configuration in a pyproject.toml file. I want to add a per-file-ignores config but nothing works and there is no documentation on how it is supposed to be formatted in a…
Piotr Zakrzewski
  • 3,591
  • 6
  • 26
  • 28
20
votes
4 answers

How can I generate a new Angular project that honors specified indention styles

I've been an angular dev for a long time and it always bugs me that running ng new did not seem to provide a way to create a new project with a specified indentation type (tabs vs. spaces) or amount (2 vs. 4). I'm starting a new Angular 7 project…
Mordred
  • 3,734
  • 3
  • 36
  • 55
19
votes
5 answers

eslint / typescript: Unable to resolve path to module

My .eslintrc.json is: { "env": { "browser": true, "commonjs": true, "es6": true, "node": true, "jest": true }, "parserOptions": { "ecmaFeatures": { "jsx": true }, …
Shamoon
  • 41,293
  • 91
  • 306
  • 570
19
votes
2 answers

Dart linting exclude folders under analyzer

My linting works fine if I add rules and errors but excluding something does not have any effect. Here is my analysis_options.yaml in the project root directory. include: package:pedantic/analysis_options.yaml analyzer: exclude: -…
Ricky
  • 553
  • 6
  • 21
19
votes
1 answer

How to resolve Consider preallocating (prealloc) lint?

I catch Consider preallocating [to] (prealloc) this problen in golangci-lint my code is: var to []string for _, t := range s.To { to = append(to, t.String()) } Do you have an idea to resolve this problem in lint?
19
votes
4 answers

Support v7 MenuPopupHelper is now hidden and restricted to LIBRARY_GROUP

Recently i've been getting a lint error on my usage of android.support.v7.view.menu.MenuPopupHelper which is now hidden and restricted to be only used within its library group. Exact message: MenuPopupHelper constructor can only be called from…
MiaN KhaLiD
  • 1,478
  • 1
  • 16
  • 28