Hi,
Thanks for the logs.
I have a few general observations:
First,
[e[1;34mINFOe[m] 2 languages detected in 19 preprocessed files
…
INFO: 4 languages detected in 28 preprocessed files
Your two analyses have different initial scopes. I say ‘initial’ because the scope for the PR is subsequently narrowed to only those files changed in the PR.
Your Maven analysis uses sonar-maven-plugin:3.9.1.2184, which is one version behind. The latest version includes
MSONAR-190 - Default sources to “src/main” instead of “src/main/java”
which may be helpful in this regard. However, you seem to be letting sonar.sources
default to .
in the SonarScanner CLI analysis, so it may still end up with some additional scope.
Second, this parameter, which you pass to the 2nd analysis, does nothing:
-Dsonar.java.coveragePlugin=jacoco
Similarly,
-Dsonar.jacoco.reportPaths=target/site/jacoco/jacoco.xml
is also a noop
, as noted in your log:
WARN: Property 'sonar.jacoco.reportPaths' is no longer supported. Use JaCoCo's xml report and sonar-jacoco plugin.
Now the good news is that the location of your coverage report is automatically checked:
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=78ms
So it seems that your coverage report is read.
Which brings me back to your original post, where you complain that coverage is “coming to zero”. But actually, the screenshot you provided shows it as -
. The distinction is significant. A 0% coverage means there was coverage to measure and it came to 0%. A -
coverage means there was no measurement. The question is “Why?”. You passed in a coverage report and the log says it was read.
So let’s come back to what I said earlier:
the scope for the PR is subsequently narrowed to only those files changed in the PR.
If no code files were changed in the PR, then it’s quite legitimate to have 0 issues and -
for coverage and duplications.
So, what files were changed?
And with all that said, I’m still not understanding why you’re doing two analyses. Is the end goal to have branch analysis or PR analysis?
If it’s PR analysis that you’re truly after, then run the one, Maven analysis (i.e. use the scanner that aligns with your build technology) and pass in your PR parameters on the command line. (The fact that you need to pass them manually is another topic, related to how you’re doing your checkout, I believe.)
Ann