Understanding linting and code style
Scala is a type-safe language. By type safety, we mean Scala enforces type checks at compile time and thus enables programmers to catch and fix type errors early. A Scala program that compiles is guaranteed to run without any type errors.
Though type safety enforced by Scala is of immense help, there are still cases where a program will compile but has inherent flaws that the type checker will not call out. This is where linting tools come into play. They highlight potential bugs by analyzing the source code. Please note that there is no clear delineation between a linter and a static code analysis tool and they can be used to complement each other.
We will look at WartRemover, which is a Scala linting tool, next.
Linting code with WartRemover
There are several linting tools available to use. In this section, we are going to look at WartRemover and some of its predefined checks. We need to first add WartRemover to Plugins.sbt
. Here is...