We have a build system that generates jacoco report, that is later fed into sonar-scanner. We’re seeing following exception with classes which have auto-generated methods using lombok, though I can see that .class file has @Generated annotation.
INFO: Analysing /tmp/build/put/merge-request/server/build/jacoco/test.exec
WARN: The following class(es) did not match with execution data:
WARN: > 'com/org/bla/../ScheduledTaskResponse'
WARN: > 'com/org/bla/../ReservationWindow'
WARN: > 'com/org/bla/../MaintenanceWindow'
WARN: > 'com/org/bla/../WorkflowDefinition'
WARN: In order to have accurate coverage measures, the same class files must be used as at runtime for report generation.
...
...
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Line 32 is out of range in the file server/src/main/java/com/org/bla/../ScheduledTaskResponse.java (lines: 30)
at org.sonar.api.internal.google.common.base.Preconditions.checkState(Preconditions.java:197)
at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(DefaultCoverage.java:93)
at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.lineHits(DefaultCoverage.java:81)
...
ScheduledTaskResponse.java has 32 lines and ScheduledTaskResponse.class has 111 lines because of auto-generated code. I’m new to sonarqube, any hints are appreciated.
SonarQube 7.1 is past EOL. You need to upgrade at your earliest convenience and let us know if the problem persists after that. (A lot of improvements have been made since 7.1.) Your upgrade path is
Thank you! Because of some limitations we couldn’t upgrade to 7.9.4, but we’ve upgraded to 7.9.0.26994 and we’re still seeing the issue above. Rest of the metrics are same.
To re-iterate the issue, we have java classes with getter/setter methods being auto-generated by lombok and sonarqube throws out of range exception for those classes. We will be upgrading to 8.x in couple of weeks time, meanwhile any pointers will be helpful!
Congrats on your upgrade! If you feel it’s relevant, I think it might be interesting to understand (in a new thread) what prevented you from going all the way to 7.9.4.
Reviewing your latest answer as well as your OP (which TBH I didn’t read closely after 7.1.0…) it seems that you’re getting an ‘out of range’ error during the processing of a coverage report?
So to be really clear, you’re
generating code
writing unit tests for that generated code
expecting coverage on that generated code to be reflected in the SonarQube UI?
Hi Ann, appreciate your quick response! Good news we have identified the issue, it’s a bug in our build system that’s messing up jacoco report causing the sonar failure.
And about upgrade, we have an infra team who maintains external softwares for maintainability purposes, we can’t upgrade until it’s supported by their infra. Soon, we’ll be upgrading to 8.x.x.