Does CodeNarc work with Groovy traits?

299 Views Asked by At

I have a Gradle project with Groovy sources and I use CodeNarc for code quality checking.

For the first time I wanted to use Groovy trait and it seems that even an empty one causes CodeNarc to fail badly:

Error from [org.codenarc.rule.formatting.BracesForClassRule]
processing source file
[C:/some/path/project/src/main/groovy/AnyTrait.groovy]
java.lang.NullPointerException
at org.codenarc.util.AstUtil.findFirstNonAnnotationLine(AstUtil.java:1085)
at org.codenarc.util.AstUtil$findFirstNonAnnotationLine$39.call(Unknown Source) ...

Where AnyTrait.groovy has only trait AnyTrait { } inside (traits with more content fail as badly as the empty one).

  • Gradle 2.3
  • Groovy 2.4.3
  • CodeNarc 2.3

With Gradle 2.4 it fails the same way, just stacktrace is hidden. If I disable the BracesForClass rule than it fails the same way on SpaceAfterOpeningBrace rule.

Is it a bug or a feature not yet implemented?

I raised issue on CodeNarc's GitHub

1

There are 1 best solutions below

1
On

According to the CodeNarc GitHub, this should be fixed.