Sonarqube scan error with line out of range?
Solution 1:
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.
Solution 2:
I tried gradle clean build
and it worked for me
Solution 3:
Same damn issue happens in python code as well. I got it resolved adding a blank line at the end of the file.
Solution 4:
For me it was because I had exactly the same class (for example com.test.MyClass
) name and package name in two different sub modules (maven), MyClass
in first module is larger i.e. 120 lines of code. MyClass
in second module is shorter, then the exception was thrown since JaCoCo though the report was for that.
Solution was to rename one of the classes or move it into a different package.
i.e. :
com.test.MyClass
and
com.test.MyClassB
OR:
com.test.MyClass
and
com.test.foo.MyClass