SonarQube: Coverage on New Code never calculated
Solution 1
The key requirement to obtain new_code -related information/metrics is to leverage SonarQube SCM integration. And to benefit from that you have to install a compatible SCM Plugin applicable to your project (e.g. Git Plugin, SVN Plugin etc.).
Solution 2
Adding this sonar.java.binaries=classes directory, most likely target/classes helped me in fixing this issue. No JaCoCo analysis of project coverage can be done since there is no class files
Solution 3
"Coverage on New Code" is only displayed if you are using/activating SCM support (SVN, Git, ...).
sonar.scm.disabled=false
MisterStrickland
Updated on June 21, 2022Comments
-
MisterStrickland almost 2 years
I have set up SonarQube, Maven and Cobertura to upload unit test coverage at every build run. I want to use the differential views to get coverage for the delta (new code only).
The coverage itself is successfully uploaded, and I can see the delta in lines of code. However, I can't get the "Coverage on new Code" to work.
I tried different values for the leak period, including
previous_analysis
andprevious_version
(changing the version from 1.0 to 1.1 in the new analysis). I also used-Dsonar.projectDate
to simulate a past date of analysis but still no luck.Any thoughts?
-
MisterStrickland over 7 yearsThat's what I have in mind, but I wanted to create a minimum viable product "manually" first. So you're saying I can't use the
new_code
by manually uploading from the command-line? -
Nicolas B. over 7 yearsI don't understand your question. All I'm saying is that you should install the Git Plugin (or else depending on the SCM you're using) and verify that SCM integration is enabled in your project settings. That's because New Code is detected based on SCM blame information.
-
MisterStrickland over 7 yearsI installed the Jazz RTC plug-in and the results I'm seeing in SonarQube are the very same - I can see the new lines of code, but no new coverage :(
-
MisterStrickland over 7 yearsInterestingly, it's working with Git. I will accept your answer and send a separate question just for jazz. Thanks @Nicolas
-
bsky about 7 yearsI have added
sonar-scm-git-plugin-1.2.jar
tosonarqube-6.2/extensions/plugins/
since I'm using Git for scm. However, nothing changed. Is that enough? -
sao about 4 yearsplease consider adding relevant info from your link to the space provided in the answer.
-
Weijing Jay Lin over 2 yearsWhat is it? What's that for, why we should disable it?