Why do you believe it’s a false-negative?
When I set non-capital letters to name of my/non-primitive type constant (marked as static final) the Sonar does not report an issue for Constant names should comply with a naming convention. If I use primitive or basic type for constant the issue is reported (for types int, String etc.)
Are you using
SonarQube Server - Enterprise Edition v9.9.7 (build 96285)
SonarQube for IDE - which IDE/version - IntelliJ IDEA 2023.3.2 (Ultimate Edition), SonarLint 10.12.0.79769
in connected mode with SonarQube Server - Yes
How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
// The issue is not reported by Sonar
static final ResourceBundle resources = ResourceBundle.INSTANCE;
// The issue is reported by Sonar
public static final String stringConstant = "example";
public static final int intConstant = 6;
The rule applies only to primitive types (for example, int), boxed primitives (Integer), and Strings. In such cases, the reference is immutable, its target is immutable as well, and methods do not have side effects.
Other objects can generally be mutated, or calls to them can have side effects, so we do not enforce CONST_CASE. For example:
public static final logger = getLogger(...);
public static final List<Integer> myList = new ArrayList<>();
//…
// calls can have side-effects
logger.info("message")
// objects can be mutated
myList.add(28);
I filed a ticket to improve the rule’s documentation. In the future, we may want to consider expanding the rule to also cover immutable value classes (for example, ImmutableList).