I'm having some issues when trying to import Jacoco code coverage to SonarQube.
I am using SonarQube with Jacoco for importing test coverage results (https://docs.sonarqube.org/display/PLUG/Java+Unit+Tests+and+Coverage+Results+Import). Everything has worked well until i have forEach block in some method.
ERROR: Cannot import coverage information for file, coverage data is invalid.
java.lang.IllegalStateException: Line 29 is out of range in the file (lines: 28)
If I remove forEach file then test coverage is correctly generated, but with forEach I get 0% coverage.
This happens only when i integrate it with sonarqube, if i run jacoco locally it works perfectly.
We use SonarQube Scanner 3.3.0.1492, SonarQube server 7.5.0.
SonarQube itself does not calculate coverage. To include coverage results in your analysis, you must set up a third-party coverage tool and configure SonarQube to import the results produced by that tool. Below, you'll find guidelines and resources, as well as language- and tool-specific analysis parameters.
SonarQube has a broader approval, being mentioned in 163 company stacks & 271 developers stacks; compared to JaCoCo, which is listed in 5 company stacks and 11 developer stacks.
Search in Google by keywords sonarqube
kotlin
jacoco
and
is out of range in the file
reveals following page https://community.sonarsource.com/t/sonar-kotlin-coverage-fails-due-to-line-is-out-of-range-errors/3201/18 , which states that problem was fixed in JaCoCo version 0.8.3
And which contains link to page https://github.com/jacoco/jacoco/issues/763 , which in its turn contains quite expressive explanation of problem, including explanations of why it affects SonarQube.
So make sure that you use JaCoCo version 0.8.3
or even better latest, which is 0.8.7
as of 8 September 2021.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With