Should SonarScanner be more robust handling "line X out of range" of e.g. jacoco?


(Holger Mensch) #1


today our SonarScanner run failed once more because of JaCoCo reporting an error “line X out of range” (see exception stacktrace below). This means the whole execution failed because of 1 file not being correct.
Could the SonarScanner be more robust in handling that scenario without failing the complete run? (e.g. just logging an error)
Or is it rather the responsibility of the JaCoCo part?


INFO: ------------------------------------------------------------------------
INFO: Total time: 1:31:17.563s
INFO: Final Memory: 289M/7664M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Line 116 is out of range in the file projects/main/plugins/aquintos.queryresulttable/src/aquintos/queryresulttable/ (lines: 113)
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.UnitTestAnalyzer.analyzeFile(
at org.sonar.plugins.jacoco.UnitTestAnalyzer.readExecutionData(
at org.sonar.plugins.jacoco.UnitTestAnalyzer.analyse(
at org.sonar.plugins.jacoco.JaCoCoSensor.execute(
at org.sonar.scanner.sensor.SensorWrapper.analyse(
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(
at org.sonar.scanner.phases.SensorsExecutor.execute(
at org.sonar.scanner.phases.SensorsExecutor.execute(
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(
at org.sonar.core.platform.ComponentContainer.startComponents(
at org.sonar.core.platform.ComponentContainer.execute(
at org.sonar.scanner.scan.ProjectScanContainer.scan(
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(
at org.sonar.core.platform.ComponentContainer.startComponents(
at org.sonar.core.platform.ComponentContainer.execute(
at org.sonar.scanner.task.ScanTask.execute(
at org.sonar.scanner.task.TaskContainer.doAfterStart(
at org.sonar.core.platform.ComponentContainer.startComponents(
at org.sonar.core.platform.ComponentContainer.execute(
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(
at org.sonar.batch.bootstrapper.Batch.executeTask(
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(
at org.sonarsource.scanner.cli.Main.runAnalysis(
at org.sonarsource.scanner.cli.Main.execute(
at org.sonarsource.scanner.cli.Main.main(
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
ERROR: SonarQube scanner exited with non-zero code: 1

(Nicolas Bontoux) #2

Hi Holger,

Well what the error itself means is that the JaCoCo reports contains coverage data for a line that is not found in the corresponding source file. So I would more specifically put the responsibility on the overall Continuous Integration chain: at any point in time it’s important that the coverage reports present locally correspond precisely to the actual source files analyzed locally.

If any slightest mismatch (e.g. source files changed after coverage data was computed) then failing is the only viable strategy, otherwise you run the risk of having totally incorrect data reported and tracked by your team (in that respect, silent failure or incorrect data is worst than any failure at all).

java.lang.IllegalStateException: Line 588 is out of range in the file
(Holger Mensch) #3

Hi Nicolas,

Thanks for the answer. I think you are right.
Currently we cannot guarantee that the JaCoCo report corresponds precisely to the source files that are analyzed locally. We will work on that.

Greetings Holger

(Oliver Goroll) #4

Please forgive me, if this is a dumb question, but how would I disable JaCoCo reports? I had a look at the settings in the administration page, but there is no single setting.
The rules common-java:InsufficientLineCoverage and common-java:InsufficientBranchCoverage are disabled, yet the JaCoCoSensor is still active. I could exclude all files from coverage analysis or point sonar.jacoco.reportPaths to some non-existing path but this solution strikes me as not optimal.