pmayweg / sonar-groovy

SonarQube plugin for Groovy
GNU Lesser General Public License v3.0
52 stars 65 forks source link

False positive 'Unused Variable' for @Field annotation #61

Open marcusphi opened 7 years ago

marcusphi commented 7 years ago

We get grvy:org.codenarc.rule.unused.UnusedVariableRule.fixed for (essentially) the following groovy script code:

import groovy.transform.Field
@Field private final String FOO = 'foo'

void f() {
    println FOO
}
marcusphi commented 7 years ago

I guess the problem is in CodeNarc. I'll look for/file a bug there as well. We are using plugin version 1.5. which means CodeNarc version 0.25.2.

marcusphi commented 7 years ago

It is fixed in 0.27 of CodeNarc (https://github.com/CodeNarc/CodeNarc/issues/182).

CodeNarc has actually gone 1.0. Seems like a good idea to upgrade that dependency and release a new version of this. But there are breaking changes there, so if it's complicated I would appreciate if you release a version that uses 0.27.

marcusphi commented 7 years ago

I've built a snapshot version where I just update the CodeNarc version in the poms to 0.27.0 and tested in my Sonar instance and it seems to work, so hopefully this is simple for you.

pmayweg commented 7 years ago

I have a look into that

froucher commented 6 years ago

I just have the same issue...

TobiX commented 5 years ago

Since this is fixed in newer versions of CodeNarc, this is fixed in release 1.6