2

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

Zoltan Toth
  • 46,981
  • 12
  • 120
  • 134
topr
  • 4,482
  • 3
  • 28
  • 35
  • 1
    I have seen this issue as well, but have not tried to track it down yet - sounds like a bug in CodeNarc. Maybe it's not quite ready for Groovy 2.4 yet. :-) – cjstehno May 20 '15 at 19:48
  • Yep, probsbly it is not ready yet. Thanks for info. – topr May 20 '15 at 23:17

1 Answers1

1

According to the CodeNarc GitHub, this should be fixed.

cdeszaq
  • 30,869
  • 25
  • 117
  • 173
  • I believe it is. I raised the issue in CodeNarc's GitHub and it got addressed: https://github.com/CodeNarc/CodeNarc/issues/93. Not sure has it been released yet, need to double check. – topr Aug 17 '15 at 14:38