Rule java:S4174 checks local constants for conformance with a naming convention based on a regex.
From my experiments, it seems to work on integer and string literals. However, it doesn’t apply to the concatenation of two string literals, or on imported constants.
It would be nice to have this apply to any identifier qualified ‘final’ and initialized to something fixed at compile time. For instance, in
final String theComm = ", "; final String theComm1 = ", " + "ABC"; final String theComm2 = BATCH_NAME; final String theComm3 = theComm + ", "; final String theCommaPlus = theComm + theComm1;
only the first line gets flagged. Here, BATCH_NAME is a string constant imported from a package. So all of these strings are constant and not dependent on any runtime information.