SonarQube: Coverage on New Code never calculated

11,126

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

Share:
11,126
MisterStrickland
Author by

MisterStrickland

Updated on June 21, 2022

Comments

  • MisterStrickland
    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 and previous_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?

    enter image description here

  • MisterStrickland
    MisterStrickland over 7 years
    That'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.
    Nicolas B. over 7 years
    I 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
    MisterStrickland over 7 years
    I 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
    MisterStrickland over 7 years
    Interestingly, it's working with Git. I will accept your answer and send a separate question just for jazz. Thanks @Nicolas
  • bsky
    bsky about 7 years
    I have added sonar-scm-git-plugin-1.2.jar to sonarqube-6.2/extensions/plugins/ since I'm using Git for scm. However, nothing changed. Is that enough?
  • sao
    sao about 4 years
    please consider adding relevant info from your link to the space provided in the answer.
  • Weijing Jay Lin
    Weijing Jay Lin over 2 years
    What is it? What's that for, why we should disable it?