Jump to content

Lint (software)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Hohum (talk | contribs) at 00:38, 4 September 2022 (Fortran). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Lint
Original author(s)Stephen C. Johnson
Developer(s)AT&T Bell Laboratories
Initial releaseJuly 26, 1978; 46 years ago (1978-07-26)[1]
Written inC
Operating systemCross-platform
Available inEnglish
TypeStatic program analysis tools
LicenseOriginally proprietary commercial software, now free software under a BSD-like license[2][3]

Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs.[4] The term originates from a Unix utility that examined C language source code.[1]

History

Stephen C. Johnson, a computer scientist at Bell Labs, came up with 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][1] The term "lint" was derived from lint, the name for the tiny bits of fiber and fluff shed by clothing, as the command should act like the lint trap in a clothes dryer, detecting small errors to great effect. In 1979, lint 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

The analysis performed by lint-like tools can also be performed by an optimizing compiler, which aims to generate faster code. In his original 1978 paper, Johnson addressed this issue, concluding that "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".[1]

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 compilers of such languages typically do not enforce as many and as strict rules prior to 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 language, including grammar and style guides.[citation needed]

Specialization

Fortran

Fortran compilers using space-squeezing techniques[a] (e.g. IBM 1130) made it impossible for the compiler to see the problem with lines like:

         .... DO 120 J=1<U>.</U>256   ...  120 CONTINUE
which is why programs like Lint for Fortran[9] can be helpful.[10][11]

See also

Notes

  1. ^ Software: reads the source statements into memory, discards comment lines, removes spaces except in text literals, concatenates continuation lines

References

  1. ^ 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.
  2. ^ "UNIX is free!". lemis.com. 2002-01-24.
  3. ^ Broderick, Bill (January 23, 2002). "Dear Unix enthusiasts" (PDF). Caldera International. Archived from the original (PDF) on February 19, 2009.
  4. ^ "About SublimeLinter". The SublimeLinter Community, revision 1cecc79c. Retrieved 2020-03-29.
  5. ^ a b Morris, Richard (1 October 2009). "Stephen Curtis Johnson: Geek of the Week". Red Gate Software. Retrieved 19 January 2018.
  6. ^ "Arcanist User Guide: Lint". Phabricator. Retrieved 19 January 2018.
  7. ^ "ESLint - Customizable JavaScript linting tool (1)". theCodeCampus. 2015-06-09. Retrieved 2019-04-21.
  8. ^ Jones, Nigel (1 May 2002). "How to Use Lint for Static Code Analysis". Barr Group.
  9. ^ Lint for Fortran: Denis W. Haskin (May 2, 1988). "Shaking down your FORTRAN programs". Digital Review. pp. 41–47. similar to DEC's Source Code Analyzer, .. comes into play much earlier .. before users compile their programs
  10. ^ "COMP-FORTRAN-90 Archives". Fortran90-lint, for Fortran 90 program analysis, also other tools, from http://www.cleanscape.net/stdprod/ftp/ftpflint.html {{cite web}}: External link in |quote= (help)
  11. ^ "Chapter 2. Basic Debugger Usage". There is a public domain version of lint for FORTRAN 77 called ftnchek

Further reading