Maven Plugin org.sonarsource.scanner.maven:sonar-maven-plugin:22.214.171.1245
Sonarqube Developer Edition Version 9.2.1
I have a multi-module build. I’m producing an aggregate Jacoco report and setting sonar scanner to use that report.
One of the modules is only tested from tests in another module. The Jacoco aggregate report I created correctly has coverage shown for this. The sonar scanner when logged looks like it is using the report.
[INFO] 11:51:24.340 Sensor JaCoCo XML Report Importer [jacoco] [INFO] 11:51:24.340 Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list. [DEBUG] 11:51:24.340 Reading report '[...]/jacoco-aggregate/target/site/jacoco-aggregate/jacoco.xml' [INFO] 11:51:24.382 Sensor JaCoCo XML Report Importer [jacoco] (done) | time=42ms
For what it’s worth the path to the report is configured using sonar.coverage.jacoco.xmlReportPaths
When I view the Code coverage on SonarQube it shows 0% coverage for methods that are reporting >0% in the Jacoco xml report.
For example in the jacoco.xml one example method looks like
<method name="findUsersByFirstName" desc="(Ljava/lang/String;)[returnType];" line="280"> <counter type="INSTRUCTION" missed="28" covered="63"/> <counter type="BRANCH" missed="2" covered="2"/> <counter type="LINE" missed="8" covered="15"/> <counter type="COMPLEXITY" missed="2" covered="1"/> <counter type="METHOD" missed="0" covered="1"/> </method>
On SonarQube the entire class this method is in is showing 0.0% coverage.
Even though the Jacoco report is submitted, it is as if it is not used. Or that it is not able to reconcile the report with the code. I’m fairly certain the report is just not used, as even when I configure it to a missing location.
[INFO] 12:13:20.351 No report imported, no coverage information will be imported by JaCoCo XML Report Importer
The coverage on SonarQube is the regardless of whether or not a Jacoco report is submitted. Although maybe this is because if the report isn’t submitted SonarQube is relying on an old report? SonarQube is only showing coverage where the tests for a module are in the same module.
Could anyone recommend some likely causes of this issue? Is there any logs available on the server side I could look for that might explain why the code coverage on SonarQube is not like the report the scanner submitted?