Sonar 5.3 does not show me "Coverage on new code" stats with 2 analysis in the same day

988 views
Skip to first unread message

fester...@gmail.com

unread,
Feb 19, 2016, 8:48:48 AM2/19/16
to SonarQube
Hi all,
I am having a strange problem. I have a jenkins job that launches 2 sonar analysis on 1 branch. 
The first analysis is launched on the starting commit of the branch and the second is launched on the last commit. My idea is to get the "new code" tests coverage as the first commit is my base and everything after this is new code and sonar should show me the new code coverage, but it does not ...

It's configured to show new code coverage "since previous version". I also tried to manually give versions to the 2 analysis with sonar.projectVersion, but I still don't get the new code coverage percent.

On other hand when I have some branch that I am working on and it is analysed more than one time in 2-3 days, the new code coverage is shown ...

Any ideas? Thanks in advance!

nicolas...@sonarsource.com

unread,
Feb 22, 2016, 4:31:20 AM2/22/16
to SonarQube, fester...@gmail.com
Hello,

You are most likely observing this behaviour because Coverage on new code currently identifies new code based on the date of the previous analysis (and not the commit date of the code previously analyzed), see SONAR-7085 for more details.

For your scenario to work (i.e. accurately identifying new code between first and last commit of the branch): you have to force a past date for the analysis of the old code (commit date of this first commit on the branch), using -Dsonar.projectDate. Good article on this right here: Sonar Time Machine : replaying the past .

Hope that helps, best regards,
Nicolas

fester...@gmail.com

unread,
Feb 22, 2016, 4:51:34 AM2/22/16
to SonarQube, fester...@gmail.com
Thanks for the reply! Yes it seems this is the issue. I am now setting custom dates for the 2 analysis and it works fine. 

I am still having some issues like when there are no tests on the new code, sonar shows me a dash for the new code coverage metric instead of 0%.
Also I keep getting the JVM crash on PMD analysis in jenkins every 2-3 builds which is very annoying, but those are other topics :) 

G. Ann Campbell

unread,
Feb 22, 2016, 9:48:06 AM2/22/16
to SonarQube, fester...@gmail.com
We've replaced most valuable PMD rules in the Java plugin. Perhaps the answer is to simply update your profile. 


:-)
Ann


On Monday, 22 February 2016 04:51:34 UTC-5:

fester...@gmail.com

unread,
Feb 23, 2016, 1:31:06 AM2/23/16
to SonarQube, fester...@gmail.com
I'll definitely try it! Thanks!
Reply all
Reply to author
Forward
0 new messages