The context : a scala project has been started but for various reasons Maven was chosen instead of sbt. At first it does seem an odd choice. Why pick such a common Java tool and not the default Scala build tool? In practice, it can make sense for a Java-centric shop making a first step towards the Scala world. The next question is then : how can the quality of the Scala code be checked while still using Maven?
Scalastyle, the scala CheckStyle
Checkstyle is well known in the Java world. Scalastyle is similar, but for Scala. Both tools help teams converge on a shared coding standard with automated control.
Scalatest should be the first stop as it provides an integration with Maven, but also common IDEs : Intellij and Eclipse. Scala IDE, based on Eclipse, is also supported as a consequence.
At the end of the build, after the test, scalastyle output should be visible.
###4) Run in isolation, without all the previous Maven build lifecycle phases.
With a similar end results, but quicker.
WartRemover is “a flexible Scala code linting tool”. Its main usage is as a sbt plugin but luckily, it is still compatible with Maven.
###1) Configure Maven to automatically copy the depency by using the maven-dependency-plugin during the validate phase.
###2) Verify the configuration by running Maven.
The downloaded plugin (jar) should be visible from the logs.
###3) Configure the compilator with this plugin.
For more information about how to configure which rules should be actived, in error or warn, the WartRemover github should be consulted. Here, all safe checks will be displayed as warns. The build will not fail if the plugin is added and the code is warty.
###4) Compile the project.
And if the project is not pristine, a few warts should pop up.
##Linter, Scapegoat, others?
Linter and Scapegoat are two others well known tools in the scala community. I am open to any feedback about their usage with scala 2.10 and Maven.