There's no reason not to use a linter

August 15, 2021

A linter is a program that anylizes your source code to detect common bugs or other areas for improvement.

Most modern languages come with a wide variety of linters and other static analysis tools available. Pick one. Or pick ten.

If you’re not already doing so, simply adding a linter as the first check in your CI or build pipeline is usually the simplest, cheapest single step you can do to improve code quality, as it can provide a sort of machine-operated code review for you.

While what’s available depends on each language, in general you can, and should, find linters to detect and warn about bugs such as:

  • SQL injections
  • Common memory leaks
  • Uninitialized or unused variables

Additionally, you may want to use linters to detect more stylistic problems that commonly lead to bugs or confusing code:

  • Shadowed variables
  • Use of conventional naming
  • Spell checking of comments or inline documentation
  • Unnecessary type conversions
  • Excessive indentation
  • Unnecessary or redundant conditionals

Related Content

Better code review

How can we encourage less superficial code reviews?

When is a pull request too big?

Smaller pull requests are faster to write and easier to review. Here are 4 tests to see if your PR might be too big.

The one code review method to rule them all

Find the method that works for you, and don't let anyone guilt you into thinking your way is "wrong".