- SonarQube Community Build v25.10.0.114319
- Java Code
- Rule S2259 Null pointers should not be dereferenced
S2259 reports an issue for the the following Java code:
package org.example;
import edu.umd.cs.findbugs.annotations.Nullable;
public class S2259BooleanNullability {
boolean test(@Nullable Boolean value) {
return value != null && value;
}
}
It reports ‘A “NullPointerException” could be thrown; “value” is nullable here.’ for the right-hand side of the expression, even though it has been checked before with value != null.
I’ve attached the above source as minimal maven project.
test.zip (1.9 KB)
Best
Andreas