Gradle plugin to apply WartRemover, the Scala linting tool.
It applies the WartRemover plugin with same settings to all ScalaCompile
tasks, so even the test code is checked.
"Keep your tests clean. Treat them as first-class citizens of the system." Robert C. Martin (Uncle Bob)
If you want to have different settings for tests then you can use the test
block as shown below.
If you don't use test
block then all the settings is applied to all the Scala code.
Please note that since
0.15.0
version at least Gradle 6.4 is required (because the plugin usesscalaCompilerPlugins
configuration).
The plugin is published to Gradle Plugins portal
plugins {
id 'cz.augi.gradle.wartremover' version '<putCurrentVersionHere>'
}
errorWarts.add(<String>)
orerrorWarts.addAll(Collection<String>)
(default is an emptySet<String>
):- Set of warts to use which throw an error when violated.
warningWarts.add(<String>)
orwarningWarts.addAll(Collection<String>)
(default is aSet<String>
with allwartremover:2.x
Unsafe warts):- Set of warts to use which throw a warning when violated.
excludedFiles.add(<String>)
orexcludedFiles.addAll(Collection<String>)
(default is an emptySet<String>
):- Set of files to be excluded from wartremover coverage.
classPaths.add(<String>)
orclassPaths.addAll(Collection<String>)
(default is an emptySet<String>
):- Set of files or directories to be added to the classpath if using custom warts.
scalaVersion = <String>
(defaultdetected
):- Scala version used to denote the wartremover artifact, e.g.
scalaVersion = 2.13.16
->wartremover_2.13.16
;scalaVersion = 2.13
->wartremover_2.13
. - Refer to the Maven Repository for corresponding artifact versions.
- Scala version used to denote the wartremover artifact, e.g.
wartremoverVersion = <String>
(default'2.4.21'
for Scala 2.11+,2.3.7
for Scala 2.10):- Version of the
org.wartremover
dependency. This plugin is compatible with2.x
by default, while3.x
may require manually adding the different Unsafe warts.
- Version of the
watremover {
errorWarts.add('Product')
warningWarts.add('Product')
excludedFiles.add('src/main/scala/me/project/Main.scala')
classPaths.add(new File("path/to/yourWarts").toURI().toURL().toString())
scalaVersion = '2.13.16'
wartremoverVersion = '2.4.21'
test {
errorWarts.add('Serializable') // default settings from the block above
warningWarts.add('Serializable') // default settings from the block above
excludedFiles.add('src/test/scala/me/project/Test.scala') // default settings from the block above
classPaths.add(new File("path/to/yourTestWarts").toURI().toURL().toString()) // default settings from the block above
}
}