The Java rule S1450 produces a false-positive here.
I hope, this reduced example is good enough.
private Map<X, Y> map = null; // FP
public void init()
this.map = loadMyMap();
public void doSomething()
Y y = map.get(x);
The rule marks the declaration line to tell me, that I should more the declaration to the sepcific methods. Obviously FP.
Make sure to read this post before raising a thread here:
Hey SonarSource Community!
False-positives happen, as do false-negatives, and we’re eager to fix them. We are thrilled when our users report issues so that we can make our products better.
What is a false-positive (FP)?
A false-positive is when an issue is raised unexpectedly on code that should not trigger an issue, or where the suggested action doesn’t make any sense for the code.
What is a false-negative (FN)?
A false-negative is when an issue should be raised on a piece of code, but isn…
Specifically, we’re missing what products you’re using and (if relevant) what versions.
C’mon, seriously? I have tagged the thread with the used products: Java, SonarCube and Lint. Ok, it is Qube 8.3, which we’re using, soon 9.4. And it is Lint 7.4.0. Do you need anything else?
Yes, thank you for the additional version details. This is very important for us to understand whether you encounter a bug in some version of the Java analyzer that might have already been fixed in a newer version.