Selectively escalate warnings to errors: -Xfatal-warnings
with a whitelist.
Add the following to the project/plugin.sbt
:
addSbtPlugin("net.team2xh" % "sbt-lethal-warnings" % "[Version in badge above]")
In build.sbt
, configure which warnings need to be escalated to errors:
import sbt.LethalWarnings._
lethalWarnings := Seq(/* Desired warnings */)
Key | Matching warning |
---|---|
NonExhaustivePatternMatch |
Missing cases in pattern match blocks |
UniversalEquality |
Comparing objects of different types |
MatchOnErased |
Type erasure in pattern matches |
To lethalize all warnings supported by the plugin, use the following setting:
lethalWarnings := allWarnings
Tests are using scripted SBT and scripted-scalatest to run a nested SBT instance compiling the project located at src/sbt-test/sbt-lethal-warnings/test-warnings/
. To execute the test suite, run the following from the root of the project:
sbt scripted