2
votes

Using SonarQube 5.2 - just the "click and go" distribution downloaded yesterday and running under Windows. Nothing fancy.

After upgrading the "Java" rules package from the bundled 3.6 version to 3.7.1, the sonar runner then fails during analysis.

There's a long stacktrace that is revealed when running with '-e' option however there is no detail on where in the file it failed (line-number, method) or which rule failed.

I have pared down the stack-trace to what I believe are the useful bits:

ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
...
Caused by: org.sonar.squidbridge.api.AnalysisException: SonarQube is unable to analyze file : 'C:\Users\robert.rusk\Documents\cvs\ip_probe\src\com\robert\splat\MyClass.java'
...
Caused by: java.lang.IndexOutOfBoundsException: index (1) must be less than size (1)
...
        at org.sonar.java.checks.PrintfCheck.verifyParameters(PrintfCheck.java:173)
        at org.sonar.java.checks.PrintfCheck.onMethodInvocationFound(PrintfCheck.java:112)
...
2

2 Answers

3
votes

You are encoutering the following issue : https://jira.sonarsource.com/browse/SONARJAVA-1369 It happens when you have a parameter with %< during the printf check (rule squid:S2275).

Issue has been fixed (few minutes ago for the record ;) ) and should be part of next release bound to happen within the next few days.

2
votes

After some investigation I now believe the error occurs because String.format is called without enough parameters (should be 2), and when I comment out this line the analysis then runs without any problems.

splatDateStr = String.format("%tFT%<tRZ", splatDate);

I guess this is the PrintfCheck that is referred to in the stack-trace.