What’s the lint(er)?

Batikan Sosun
Loodos
3 min readAug 7, 2019

--

Above all, I’m very excited having first article on this platform. Please feel free to warn me and give recommendation if you see something wrong in the article.

I’m going to try to give you some details about the lint tools without going into deep. Here we go:

Credit: Getty Images

Lint or linter is a tool that analyzes your source code, reports wrong structures or bugs, warns for stylistic errors.

The term comes from a Unix utility that examined C language source code.

Let’s look at the history of linter.

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. The term “lint” was derived from the name of the undesirable bits of fiber and fluff found in sheep’s wool. In 1979, lint was used outside of Bell Labs for the first time in the seventh version (V7) of the Unix operating system.

Over the years, different versions of lint were 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, used to analyze C++ source code, is still being sold even though it was introduced in 1985.

The important question is why we should use linter. We are using because linter;

  • Increases the readability of your code.
  • Prevents structural errors.
  • Helps you to see bugs in advance.
  • Provides visual wealth.
  • Helps you create a coding standard.
  • Forces to maintain.
  • Prevents duplicated code rows
  • Shows unused code or code blocks

The analysis is performed by lint tool or triggered by compiler. Lint tools are more useful when working with interpreted languages. You can see simple errors (such as syntax errors) before program are executed.

Having barely working code is not good enough and expected approach. The code must meet the standard that we can read and understand later.

In general, lint tools perform static code analysis.

Now, I’ll list the popular lint tools of the most used languages below.

JAVA

  • Checkstyle — Force to coding standards and code documents creation(JavaDoc, etc)
  • Findbugs — Findbugs finds bugs, as in their name.

C/C++/Objective -C(C based language :) )

  • clang-format — Formats C/C++ code according to a coding style (Google, LLVM, Mozilla, Webkit, and Chromium available)
  • cppcheck —Cppcheck is a static analysis tool for C/C++ code. It provides a unique code analysis to detect bugs and focuses on detecting undefined behavior and dangerous coding constructs. The goal is to detect only real errors in the code (i.e. have very few false positives).
  • OCLint — Static analysis for C, C++, and Objective-C. Written in C++.

C#

SonarLint — A open-source linter that scope is too much. You can use for C# VB.Net C/C++ JavaScript. Access the highlighted issue in the editor. Overall issues show in error list.

PYHTON

  • flake8 — Runs PyFlakes, pycodestyle and other tools from only one CLI. Written in Python.
  • Pylint — Source code analyzer which looks for programming errors, helps to enforce a coding standard and sniffs for some code smells.

In the same time, a compiler can be a linter. For example; gcc-normal, gcc-strict, .NET Compiler Platform

JAVASCRIPT

  • ESLint — JavaScript syntax checker and formatter.
  • JSHint — Community-driven tool that detects errors and potential problems in JavaScript code.

SWIFT

Swift is Apple’s newest favorite language. It’s important point. Since 2014, Swift has evolved continuously to reach the current 5.0 version. Therefore, swift lint tools are very few.

  • SwiftLint — Tool to enforce Swift style and conventions, loosely based on GitHub’s Swift Style Guide.

Thanks for reading.

References:

--

--

Batikan Sosun
Loodos
Writer for

Tweeting tips and tricks about #swift #xcode #apple Twitter @batikansosun Weekly Swift Blogging