Hello,
We’re using SonarQube Server v2025.1 (102418)
and seeing this false positive in java:S2259
rule.
To make it easy to reproduce, I’m copying the code below.
public enum Status {
SUCCESS("green"),
FAILED("red"),
PENDING("yellow");
private final String color;
Status(String color) {
this.color = color;
}
public String getColor() {
return color;
}
}
public class StatusMapper {
public String getColor(@CheckForNull Status status) {
if (Status.SUCCESS == status || status == null) {
return Status.SUCCESS.getColor(); <<<<<<< FP here
}
return status.getColor();
}
}
Please let me know what you think.
Thanks.