Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
marcusphi opened this issue Nov 8, 2017 · 6 comments
Open

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

marcusphi opened this issue Nov 8, 2017 · 6 comments

Comments

@marcusphi
Copy link

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
Copy link
Author

marcusphi commented Nov 8, 2017

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
Copy link
Author

marcusphi commented Nov 8, 2017

It is fixed in 0.27 of CodeNarc (CodeNarc/CodeNarc#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
Copy link
Author

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.

phsh added a commit to phsh/sonar-groovy that referenced this issue Nov 9, 2017
@pmayweg
Copy link
Owner

pmayweg commented Nov 9, 2017

I have a look into that

@froucher
Copy link

I just have the same issue...

@TobiX
Copy link

TobiX commented Jul 11, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants