Squid S2275 does not know about format string argument indexes

543 Views Asked by At

Ran across this in some old code that is being Sonarized. The method

private String dateToString(Calendar cal) {
    return String.format("%1$tm/%1$td/%1$tY", cal);
}

triggers SonarQube rule S2275, "Not enough arguments." It appears that SQ is simply counting the format specifiers in the format string and not taking their argument indexes into account. The above example is perfectly valid; it uses the single argument three times.

So the question is, how do I bring this to the developers' notice?

1

There are 1 best solutions below

0
On

There are various ways to get involved in SonarQube and you can report issues in SonarQube in the Goolge Group.

Unless there is a ticket already and there is one (unresolved) for this issue: https://jira.sonarsource.com/browse/SONARJAVA-1197