Wartremover still reports warts in Play excluded file

I try to add Wartremover to my Play project, but it continues to report warts in the routes file, even if I exclude it. I am using Wartremover 0.14 and Play Framework 2.4.6.

Relevant part from my build.sbt file:

wartremoverErrors ++= Warts.all
wartremoverExcluded += crossTarget.value / "routes" / "main" / "router" / "Routes.scala"

(Please note that I have to do this differently than to offer answers to this question ).

Without a line, wartremoverExcludedWartremover reports 13 errors in the routes file. However, he still reports two: one about Wart.Varand one about Wart.ExplicitImplicitTypes. I can also exclude these warts, but using Warts.allBut(Wart.Var, Wart.ExplicitImplicitTypes), but I would prefer not to, because it excludes these warts from my entire code base, and not just the routes file.

Is there a way to make Wartremover stop reporting these warts in the route file without excluding these warts for each file?

+4
source share
2 answers

Try adding:

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"

Editing: More than a year has passed since I first wrote this answer. wartremoverExcludedhas been changed from SettingKeyto TaskKey, so you can simplify this:

wartremoverExcluded ++= routes.in(Compile).value

Or you can try this sbt plugin that I wrote to do this for you .

+6
source

This works for me:

wartremoverExcluded ++= Seq(
  baseDirectory.value / "target" / "scala-2.11" / "src_managed" / "main" / "routes_routing.scala",
  baseDirectory.value / "target" / "scala-2.11" / "src_managed" / "main" / "routes_reverseRouting.scala"
)

(actually I play 2.3, not sure if it is the same on 2.4.6)

0
source

Source: https://habr.com/ru/post/1624260/


All Articles