Report issues on line numbers that are out of range in the file and throwing errors

Sonar is reporting issues on line numbers that are out of range in the file, and it’s generating the following errors.

For example, below mentioned file has 140 lines, but sonar reporting issues at 142 line.

Could you please assist us with this?

[ERROR] Cannot import coverage information for file 'r4e-report/src/main/java/com/reputation/report/utils/', coverage data is invalid. Error: {}
java.lang.IllegalStateException: Line 142 is out of range in the file r4e-report/src/main/java/com/reputation/report/utils/ (lines: 141)
	at org.sonar.api.utils.Preconditions.checkState(
	at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(
	at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.lineHits(
	at org.sonar.plugins.jacoco.ReportImporter.importCoverage(
	at org.sonar.plugins.jacoco.JacocoSensor.importReport(

Hey there.

What version of SonarQube are you using? This information is requested in the template post.

Hi Colin,

Thanks for looking into this issue.

We are using the SonarCloud, not the SonarQube.

Thanks & Regards,

Okay. :slight_smile: You put the thread in the SonarQube category. I’ve moved it.

The error you’re receiving indicates that there are lines referenced in the coverage report that don’t exist in the source file. You can check (manually) the JaCoCo report XML file and, if it’s indeed referencing a line of a file that doesn’t exist, you’ll have to fix that issue by the source (either by generating a new coverage report, which you should be doing on every build before SonarQube analysis, or filing an issue with JaCoCo).