[java] RSPEC-2275: should detect constant string

Hi, I think rule RSPEC-2275 should recognize final constant string, not only the literal. Please refer to the minimized sample below.

This is a false negative. fs is a bad format string, but SonarQube cannot detect it. Hence, I think we should let this rule consider this kind of constant. Besides, this false negative can lead to runtime crash and could cause serious consequence.

Thanks for your kind consideration.

public void func() {
    final String fs = "Not enough arguments %d and %d";  
    String s = String.format(fs, 1);  // should report a warning here, because of wrong format string

Used Version:

  • sonarqube-
  • sonar-scanner-