Sonarqube scan error with line out of range?

Ro. picture Ro. · Sep 28, 2016 · Viewed 13.5k times · Source

[07:43:57]W: [Step 1/1] ERROR: Error during SonarQube Scanner execution

[07:43:57]W: [Step 1/1] ERROR: Line 523 is out of range in the file src/main/java/com/company/package/File.java (lines: 522)

For some reason Sonarqube is reporting an error on line 523 but there is only 522 lines in the source file ?

I saw this on a previous file, but when I added a blank line to the end of it the problem went away, this file already has a blank line at the end of it.

Answer

Don picture Don · Jan 9, 2017

I had the same issue when using sonar maven plugin and jacoco test reports. mvn sonar:sonar relies on an existintig jacoco report, when the source code was changed (lines had been removed), but the test report wasn't updated this error occurred. Running mvn clean test sonar:sonar solved it.