[Java] Wrong argument count complaint for String.format in squid:S2275 when using argument indexes

346 views
Skip to first unread message

oliver...@mindsatwork.com.br

unread,
Oct 9, 2015, 2:21:52 PM10/9/15
to SonarQube
Rule: Printf-style format strings should not lead to unexpected behavior at runtime (squid:S2275)

Version: Sonar 5.1.2, Java 3.4 plugin (Yes, I know there is already the 3.6 update but I didn't find anything about this rule in the release notes)

Steps to reproduce:
Analyze following code with the rule enabled:
String.format("%1$s %1$s", 1);

Says "Not enough arguments".

Michael Gumowski

unread,
Oct 12, 2015, 4:33:51 AM10/12/15
to oliver...@mindsatwork.com.br, SonarQube
Hey Oliver,

Thank you for your feedback! There is indeed a problem with the implementation of the rules. 
I created the following JIRA ticket to handle the issue: https://jira.sonarsource.com/browse/SONARJAVA-1334

Cheers,

Michael GUMOWSKI | SonarSource
Software Developer @ Language Team
http://sonarsource.com

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/5d192d43-e279-4f6f-8532-3272b92d8669%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

oliver...@mindsatwork.com.br

unread,
Oct 13, 2015, 2:21:32 PM10/13/15
to SonarQube, oliver...@mindsatwork.com.br
Thanks!

Any idea what the fix version will be?

Nicolas Peru

unread,
Oct 14, 2015, 3:08:48 AM10/14/15
to oliver...@mindsatwork.com.br, SonarQube
The ticket https://jira.sonarsource.com/browse/SONARJAVA-1197 has been scheduled for 3.7 

So if everything goes according to plan this should be released within the next two weeks. 

Cheers,

Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


oliver...@mindsatwork.com.br

unread,
Oct 14, 2015, 10:55:45 AM10/14/15
to SonarQube, oliver...@mindsatwork.com.br
Thanks!
Reply all
Reply to author
Forward
0 new messages