I'm trying to add Wartremover to my Play project, but it keeps reporting warts on the routes file, even if I exclude it. I'm using Wartremover 0.14 and Play Framework 2.4.6.
The relevant part from my build.sbt:
wartremoverErrors ++= Warts.all
wartremoverExcluded += crossTarget.value / "routes" / "main" / "router" / "Routes.scala"
(Note that I have to do it differently than the answers in this question suggest.)
Without the wartremoverExcluded
line, Wartremover reports 13 errors in my routes file. With it, it still reports two: one about Wart.Var
and one about Wart.ExplicitImplicitTypes
. I can exclude these warts too, but using Warts.allBut(Wart.Var, Wart.ExplicitImplicitTypes)
, but I'd prefer not to, because that excludes these warts from my entire codebase, not just the routes file.
Is there a way to make Wartremover stop reporting these warts on the route file, without excluding these warts for every file?
Try adding these:
wartremoverExcluded += crossTarget.value / "routes" / "main" / "router" / "Routes.scala"
wartremoverExcluded += crossTarget.value / "routes" / "main" / "router" / "RoutesPrefix.scala"
wartremoverExcluded += crossTarget.value / "routes" / "main" / "controllers" / "ReverseRoutes.scala"
wartremoverExcluded += crossTarget.value / "routes" / "main" / "controllers" / "javascript" / "JavaScriptReverseRoutes.scala"
Edit: It's over a year since I first wrote this answer. wartremoverExcluded
has been changed from a SettingKey
to a TaskKey
, so you can simplify the above to:
wartremoverExcluded ++= routes.in(Compile).value
For sbt 1.4+:
wartremoverExcluded ++= (Compile / routes).value
Or you could try this sbt plugin I wrote to do it for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With