Lint (software): Difference between revisions
Fixed inconsistent capitalization (*nix is case sensitive and "lint" is not capitalized). |
FreeBSD removed xlint in 2018, NetBSD maintains the program |
||
(218 intermediate revisions by more than 100 users not shown) | |||
Line 1: | Line 1: | ||
{{Short description|Tool to flag poor computer code}} |
|||
{{lowercase|lint}} |
|||
'''Lint''' is the [[computer science]] term for a [[Static program analysis|static code analysis]] tool used to flag programming errors, [[Software bug|bugs]], stylistic errors and suspicious constructs.<ref>{{cite web|url=http://www.sublimelinter.com/en/v3.10.10/about.html|title=About SublimeLinter|work=The SublimeLinter Community, revision 1cecc79c|archive-url=http://web.archive.org/web/20230606032819/http://www.sublimelinter.com/en/v3.10.10/about.html |access-date=2020-03-29|archive-date=2023-06-06 }}</ref> The term originates from a [[Unix]] [[List of utility software|utility]] that examined [[C (programming language)|C language]] source code.<ref name="BellLabs">{{cite journal |last=Johnson |first=Stephen C. |author-link=Stephen C. Johnson |date=25 October 1978 |title=Lint, a C Program Checker |url=https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.56.1841 |url-status=dead |journal=Comp. Sci. Tech. Rep. |publisher=Bell Labs |pages=78–1273 |citeseerx=10.1.1.56.1841 |archive-url=https://web.archive.org/web/20220123141016/https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.56.1841&rep=rep1&type=pdf |archive-date=2022-01-23}}</ref> A program which performs this function is also known as a "linter". |
|||
==History== |
|||
In [[computer programming]], '''lint''' was the original name given to a particular tool that flagged suspicious and non-portable constructs (ie, likely to be bugs) in [[C language]] [[source code]]. The term is now applied generically to tools that flag suspicious usage in software written in any [[computer language]]. The term '''lint-like behavior''' is sometimes applied to the process of flagging suspicious [[computer language|language]] usage. lint-like tools generally perform [[static code analysis|static analysis]] of [[source code]]. |
|||
{{Infobox Software |
|||
| name = Lint |
|||
| logo = |
|||
| screenshot = |
|||
| screenshot size = |
|||
| caption = |
|||
| author = [[Stephen C. Johnson]] |
|||
| developer = [[AT&T Bell Laboratories]] |
|||
| released = {{Release date and age|1978|07|26}}<ref name="BellLabs"/> |
|||
| latest release version = |
|||
| latest release date = |
|||
| operating system = [[Cross-platform]] |
|||
| language = English |
|||
| genre = [[List of tools for static code analysis|Static program analysis tools]] |
|||
| license = Originally [[Proprietary software|proprietary]] [[commercial software]], now [[free software]] under a [[BSD-license|BSD-like]] license<ref>{{cite web |url=http://www.lemis.com/grog/UNIX/|publisher=lemis.com |title=UNIX is free! |date=2002-01-24}}</ref><ref>{{cite web|url=http://www.tuhs.org/Archive/Caldera-license.pdf |archive-url=https://web.archive.org/web/20090219220353/http://www.tuhs.org/Archive/Caldera-license.pdf|archive-date=February 19, 2009 |title=Dear Unix enthusiasts |last=Broderick |first=Bill |date=January 23, 2002 |publisher=[[Caldera International]]}}</ref> |
|||
| website = |
|||
| programming language = [[C (programming language)|C]] |
|||
}} |
|||
[[Stephen C. Johnson]], a computer scientist at [[Bell Labs]], came up with the term "lint" in 1978 while debugging the [[yacc]] grammar he was writing for [[C (programming language)|C]] and dealing with [[Software portability|portability]] issues stemming from porting [[Unix]] to a [[32-bit]] machine.<ref name="red"/><ref name="BellLabs"/> The term was borrowed from the word [[Lint (material)|lint]], the tiny bits of fiber and fluff shed by clothing, as the command he wrote would act like a lint trap in a clothes dryer, capturing waste fibers while leaving whole fabrics intact. In 1979, lint programming was used outside of Bell Labs for the first time, in the seventh version ([[Version 7 Unix|V7]]) of Unix. |
|||
Over the years, different versions of lint have been developed for many [[C (programming language)|C]] and [[C++]] [[compiler]]s, and while modern-day compilers have lint-like functions, lint-like tools have also advanced their capabilities. For example, Gimpel's [[PC-Lint]], introduced in 1985 and used to analyze C++ source code, is still for sale.<ref name="red">{{cite news|last1=Morris|first1=Richard|title=Stephen Curtis Johnson: Geek of the Week|url=https://www.red-gate.com/simple-talk/opinion/geek-of-the-week/stephen-curtis-johnson-geek-of-the-week/|access-date=19 January 2018|work=Red Gate Software|date=1 October 2009}}</ref> |
|||
Suspicious usage includes things like variables being used before being set, conditions that are always true/false and calculations whose result is likely to be outside the range of values representable in the [[datatype|type]] used. |
|||
==Overview== |
|||
The term was derived from the name of the undesirable bits of fiber and fluff found in [[sheep]]'s [[wool]]. |
|||
In his original 1978 paper Johnson stated his reasoning in creating a separate program to detect errors, distinct from that which it analyzed: "...the general notion of having two programs is a good one" [because they concentrate on different things, thereby allowing the programmer to] "concentrate at one stage of the programming process solely on the [[algorithm]]s, [[data structure]]s, and correctness of the program, and then later retrofit, with the aid of lint, the desirable properties of universality and portability".<ref name="BellLabs"/> |
|||
== Successor linters == |
|||
Many of the forms of analysis performed by lint-like tools are also performed by [[optimizing compiler]]s (whose prime motivation is to generate higher quality code), and such [[compiler]]s are also starting to support the detection of many of the constructs traditionally warned about by lint. |
|||
The analysis performed by lint-like tools can also be performed by an [[optimizing compiler]], which aims to generate faster code. Even though modern [[compiler]]s have evolved to include many of lint's historical functions, lint-like tools have also evolved to detect an even wider variety of suspicious constructs. These include "warnings about syntax errors, uses of [[Undefined variable|undeclared variables]], calls to deprecated functions, spacing and formatting conventions, misuse of scope, implicit fallthrough in [[Switch statement|switch statements]], missing license headers, [and]...dangerous language features".<ref name="phab">{{cite web|title=Arcanist User Guide: Lint|url=https://secure.phabricator.com/book/phabricator/article/arcanist_lint/|website=Phabricator|access-date=19 January 2018}}</ref> |
|||
Lint-like tools are especially useful for [[Type system#DYNAMIC|dynamically typed languages]] like [[JavaScript]] and [[Python (programming language)|Python]]. Because the interpreters of such languages typically do not enforce as many and as strict rules during [[Execution (computing)|execution]], linter tools can also be used as simple [[debugger]]s for finding common errors (e.g. syntactic discrepancies) as well as hard-to-find errors such as [[heisenbug]]s (drawing attention to suspicious code as "possible errors").<ref>{{Cite web|url=https://www.thecodecampus.de/blog/eslint-customizable-javascript-linting-tool-1/|title=ESLint - Customizable JavaScript linting tool (1)|date=2015-06-09|website=theCodeCampus|language=en-US|access-date=2019-04-21}}</ref> Lint-like tools generally perform [[static code analysis|static analysis]] of source code.<ref>{{cite news|url=https://barrgroup.com/Embedded-Systems/How-To/Lint-Static-Analysis-Tool|title=How to Use Lint for Static Code Analysis|date=1 May 2002|work=Barr Group|first=Nigel| last = Jones}}</ref> |
|||
Writers of lint-like tools have continued to improve the range of suspicious constructs that are detected. Modern tools (see [[List of tools for static code analysis]]) perform forms of analysis that many optimizing compilers typically don't do, such as cross-module consistency checking, checking that the code will be portable to other compilers, and support for annotations to specify the intended behavior or properties of code. |
|||
Lint-like tools have also been developed for other aspects of software development: enforcing grammar and style guides for given language source code.{{cn|date=July 2020}} Some tools (such as [[ESLint]]) also allow rules to be auto-fixable: a rule definition can also come with the definition of a transform that makes the rule no longer not triggered. Rules about style are especially likely to come with an auto-fix. If the linter is run in "fix all" mode on a file that triggers only rules about formatting, the linter will act just like a formatter. |
|||
Lint first appeared (outside of [[Bell Labs]]) in the seventh version (V7) of the [[Unix|UNIX]] [[operating system]] in [[1979]]. It was a part of PCC, the [[Portable C Compiler]], which was a second compiler included with that system (aside from the principal [[PDP-11]] compiler). Lint and the PCC were developed by [[Stephen C. Johnson]], who also authored the parser tool [[yacc]]. |
|||
==See also== |
==See also== |
||
⚫ | |||
*[[List of tools for static code analysis]] |
*[[List of tools for static code analysis]] |
||
⚫ | |||
==External links== |
|||
*[http://www.netrino.com/Articles/Lint/ A Brief Introduction to Lint's Features] |
|||
*Book: [http://www.oreilly.com/catalog/lint/ Checking C Programs with Lint] by Ian F. Darwin (ISBN 0-937175-30-7) |
|||
==References== |
==References== |
||
{{Reflist}} |
|||
*[[Stephen C. Johnson|Stephen Johnson]]. ''Lint, a C program checker''. Computer Science Technical Report 65, [[Bell Laboratories]], December [[1977]]. |
|||
==Further reading== |
|||
⚫ | |||
* {{cite book|last1=Darwin|first1=Ian F.|title=Checking C Programs with Lint: C Programming Utility|date=1991|publisher=O'Reilly Media|location=United States |isbn=978-0937175309|edition=Revised|url=https://books.google.com/books?id=vweTteq3OLQC}} |
|||
* {{cite web |
|||
| url=https://man.netbsd.org/lint.1 |
|||
| title=LINT(1) |
|||
| work=NetBSD General Commands Manual |
|||
| date=2024-01-24}} |
|||
⚫ | |||
[[de:Lint (Programmierwerkzeug)]] |
|||
[[Category:Unix software]] |
|||
[[es:Lint]] |
|||
[[Category:Formerly proprietary software]] |
|||
[[eo:Lint (komputiko)]] |
|||
[[Category:Software using the BSD license]] |
|||
[[ia:Lint]] |
|||
[[ja:Lint]] |
|||
[[pl:Lint]] |
Latest revision as of 16:18, 1 December 2024
Lint is the computer science term for a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs.[1] The term originates from a Unix utility that examined C language source code.[2] A program which performs this function is also known as a "linter".
History
[edit]Original author(s) | Stephen C. Johnson |
---|---|
Developer(s) | AT&T Bell Laboratories |
Initial release | July 26, 1978[2] |
Written in | C |
Operating system | Cross-platform |
Available in | English |
Type | Static program analysis tools |
License | Originally proprietary commercial software, now free software under a BSD-like license[3][4] |
Stephen C. Johnson, a computer scientist at Bell Labs, came up with the term "lint" in 1978 while debugging the yacc grammar he was writing for C and dealing with portability issues stemming from porting Unix to a 32-bit machine.[5][2] The term was borrowed from the word lint, the tiny bits of fiber and fluff shed by clothing, as the command he wrote would act like a lint trap in a clothes dryer, capturing waste fibers while leaving whole fabrics intact. In 1979, lint programming was used outside of Bell Labs for the first time, in the seventh version (V7) of Unix.
Over the years, different versions of lint have been developed for many C and C++ compilers, and while modern-day compilers have lint-like functions, lint-like tools have also advanced their capabilities. For example, Gimpel's PC-Lint, introduced in 1985 and used to analyze C++ source code, is still for sale.[5]
Overview
[edit]In his original 1978 paper Johnson stated his reasoning in creating a separate program to detect errors, distinct from that which it analyzed: "...the general notion of having two programs is a good one" [because they concentrate on different things, thereby allowing the programmer to] "concentrate at one stage of the programming process solely on the algorithms, data structures, and correctness of the program, and then later retrofit, with the aid of lint, the desirable properties of universality and portability".[2]
Successor linters
[edit]The analysis performed by lint-like tools can also be performed by an optimizing compiler, which aims to generate faster code. Even though modern compilers have evolved to include many of lint's historical functions, lint-like tools have also evolved to detect an even wider variety of suspicious constructs. These include "warnings about syntax errors, uses of undeclared variables, calls to deprecated functions, spacing and formatting conventions, misuse of scope, implicit fallthrough in switch statements, missing license headers, [and]...dangerous language features".[6]
Lint-like tools are especially useful for dynamically typed languages like JavaScript and Python. Because the interpreters of such languages typically do not enforce as many and as strict rules during execution, linter tools can also be used as simple debuggers for finding common errors (e.g. syntactic discrepancies) as well as hard-to-find errors such as heisenbugs (drawing attention to suspicious code as "possible errors").[7] Lint-like tools generally perform static analysis of source code.[8]
Lint-like tools have also been developed for other aspects of software development: enforcing grammar and style guides for given language source code.[citation needed] Some tools (such as ESLint) also allow rules to be auto-fixable: a rule definition can also come with the definition of a transform that makes the rule no longer not triggered. Rules about style are especially likely to come with an auto-fix. If the linter is run in "fix all" mode on a file that triggers only rules about formatting, the linter will act just like a formatter.
See also
[edit]References
[edit]- ^ "About SublimeLinter". The SublimeLinter Community, revision 1cecc79c. Archived from the original on 2023-06-06. Retrieved 2020-03-29.
- ^ a b c d Johnson, Stephen C. (25 October 1978). "Lint, a C Program Checker". Comp. Sci. Tech. Rep. Bell Labs: 78–1273. CiteSeerX 10.1.1.56.1841. Archived from the original on 2022-01-23.
- ^ "UNIX is free!". lemis.com. 2002-01-24.
- ^ Broderick, Bill (January 23, 2002). "Dear Unix enthusiasts" (PDF). Caldera International. Archived from the original (PDF) on February 19, 2009.
- ^ a b Morris, Richard (1 October 2009). "Stephen Curtis Johnson: Geek of the Week". Red Gate Software. Retrieved 19 January 2018.
- ^ "Arcanist User Guide: Lint". Phabricator. Retrieved 19 January 2018.
- ^ "ESLint - Customizable JavaScript linting tool (1)". theCodeCampus. 2015-06-09. Retrieved 2019-04-21.
- ^ Jones, Nigel (1 May 2002). "How to Use Lint for Static Code Analysis". Barr Group.
Further reading
[edit]- Darwin, Ian F. (1991). Checking C Programs with Lint: C Programming Utility (Revised ed.). United States: O'Reilly Media. ISBN 978-0937175309.
- "LINT(1)". NetBSD General Commands Manual. 2024-01-24.