Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wartremover still reports warts in excluded Play routes file

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?

like image 323
jqno Avatar asked Jan 14 '16 11:01

jqno


1 Answers

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.

like image 85
danielnixon Avatar answered Sep 19 '22 17:09

danielnixon