With the “new code period” (or “leak period” as it was called in the past) set to “last version”, all changes included in the first analysis of the new version should be included in the “new code”.
That’s not what happened to me. “The new version” was 1.14 for me. Which included quite some changes. But Sonar showed 0 lines of new code.
I agree that the naming and some labels could be improved as sometimes it might look like the “new code” will include all changes done throughout the previous version (1.13 in your example).
That’s what I would expect, and from my point of view, this statement contradicts your previous paragraph.
I am not alone in this understanding. Here the quote from a tutorial, which shows up as the first link in google if you search for “previous_version”:
By using the previous_version setting, the New Code Period will be tracked from the previous version set with the sonar.projectVersion parameter.
Yeap, that’s exactly what I would expect. Here is the quote from your docs:
Previous Version – The New Code Period defaults to Previous version which shows any changes made in your project’s current version. This works well for projects with regular versions or releases.
Seems like this is closer to what you are trying to explain, but it is totally unexpected and still not clear to me. The docs do not help, there are not much info on how this feature works, which is annoying.
Here is our workflow, which I think is quite usual. We have a CI system set up, and it builds the software several times a day. Each build has its own build number. My first thought was that I upload each analysis with the version in the form major.minor.patch.build. This means each new analysis will have new projectVersion assigned. Are you trying to say I won’t be able to use previous_version setting in this case, since each new analysis will reset the baseline for comparison?
Now, I tried to upload several analyses under the same version. Essentially, I repeated the same steps I described originally, but did not change projectVersion. But this does not work either! I still see zero lines of new code!
Now I am really confused. I see this nice mark “New Code Period starts here” in the activity pane. I can clearlly see how Lines Of Code metric went up in the chart on the right. But there are still 0 lines of new code in Measures pane!
Anyway, I suspect that your test didn’t give the results you expected because you are analyzing versions in the past
How is this related, if I specify leak period as previous_version?
The problem here is that SonarQube gets the modification date of each line using git. In this case, since this is code modified years ago, no line will be marked as “new”.
I’d expect Sonar works the same way for both analyses I made. Both times I was analyzing code from git. I don’t get how this is related.
I assume that when I set the leak period in days, only in this case the “age” of code starts to matter. And the “birth date” of a line of code is the moment an analysis was uploaded to the server. Unless overridden by
projectDate setting. Is this correct? Or is it actually determined by the date in git?