scalastyle / scalastyle-sbt-plugin

scalastyle-sbt-plugin
Apache License 2.0
139 stars 52 forks source link

NullChecker with 'error' level makes scalastyle crash #23

Closed eugene-sy closed 7 years ago

eugene-sy commented 10 years ago

I have a play project with multiple modules. Each module is configured to run scalastyle. It works well when NullChecker is set to warning level.

<check level="warning" class="org.scalastyle.scalariform.NullChecker" enabled="true"></check>

If it is set to error level:

<check level="error" class="org.scalastyle.scalariform.NullChecker" enabled="true"></check>

I receive an error on checking with this stacktrace:

java.lang.RuntimeException: exists error
at scala.sys.package$.error(package.scala:27)
at scala.Predef$.error(Predef.scala:142)
at org.scalastyle.sbt.Tasks$.onHasErrors$1(Plugin.scala:99)
at org.scalastyle.sbt.Tasks$.doScalastyle(Plugin.scala:106)
at org.scalastyle.sbt.ScalastylePlugin$$anonfun$4$$anonfun$apply$1.apply(Plugin.scala:63)
at org.scalastyle.sbt.ScalastylePlugin$$anonfun$4$$anonfun$apply$1.apply(Plugin.scala:63)
at scala.Function6$$anonfun$tupled$1.apply(Function6.scala:35)
at scala.Function6$$anonfun$tupled$1.apply(Function6.scala:34)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
at sbt.std.Transform$$anon$4.work(System.scala:64)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:244)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (common/*:scalastyle) exists error

Our environment: Oracle JDK 1.7 or 1.8 SBT 0.13.0 Scala 2.10.3 or 2.10.4 Scalastyle sbt plugin 0.4.0

matthewfarwell commented 10 years ago

Yes, this is the point of the error level. I agree it is a bit untidy, but we want it to fail.

eugene-sy commented 10 years ago

Hmm, and we don't have any way to mark this check as ones with higher priority, do we? The worst side of this issue for me - it makes CI builds failed as one of its step is failed with error and statistics of this build is not collected as I don't have XML file with check results.

matthewfarwell commented 10 years ago

OK, are you saying that we should produce the file and then fail the build? The point of the error level is to fail the build. Otherwise it is just a warning

eugene-sy commented 10 years ago

I think scalastyle should produce report with all errors and warnings. Then it can fail.

NullChecker is the only checker that makes build fail with error level.

snorberhuis commented 10 years ago

I get a similar error when I use IfBraceChecker at error level. As a first time user of scalastyle and having experience with other style checkers, I was not sure if I made a configuration error or if this was default behavior.

I agree with Axblade that a nice report containing the errors and warnings and afterwards a fail that isn't an exception is a nicer solution.

matthewfarwell commented 7 years ago

This has been fixed (at least at 0.9.0). If there are still problems, please raise a new issue.