SQ rule java:S4174 says local constants (local identifiers marked final, but not class constants) should follow the naming conventions for other constants.
Does this rule apply to any local identifier qualified final? Or just those where SQ can determine the value being assigned is a compile-time constant (such as an arithmetic expression consisting only of literals and class constants)?
The rule’s canonical counterexample is “final int local = 42” which should be “LOCAL” according to the rule. But what about something like “final int local = 42 + abc” where abc in an input parameter, for example? In that case, I’m just computing an intermediate subexpression which I want to use later in some other expressions. (Either I will use it several times, and don’t want to depend on the compiler’s CSE, or the subexpression has some sensible meaning in the context of my method, and it’s just more readable to use local or LOCAL in the other expressions rather than repeatedly saying “42 + abc”.) And I don’t want to reassign it, so for a safety check I add the final keyword.
In that example, is local considered a local constant by rule S4174? (I don’t think so, based on what I see in my reports, but I wanted to get confirmation.)