New code set to "Previous version" without setting sonar.projectversion property?

SQ 8.9 Developer
This question is a continuation with my difficulty understanding best practices with New Code (Advice needed on defining new code period) . Can someone tell me what SQ does when you leave New code detection set to the default of “Previous Version” but you don’t supply a sonar.projectversion property setting? What does it do in that case? This is with using the MSBuild scanner.

Hi,

If you don’t supply a value for sonar.projectVersion a default value is used (‘Not provided’ IIRC). And that value will continue to be used for each subsequent analysis until you do provide a value.

So if you’re using previous_version as your New Code Period setting the result is that version never changes. TBH, I can’t remember whether this results in all code being in the New Code Period or none of it. Have you tested?

 
Ann

I suspect this situation is very common and not fully realized by new users. Previous Version is the default setting. Yet sonar.ProjectVersion is an optional parameter. That’s going to result in this scenario being the default configuration for anyone who has not studied every detail of SQ functionality.

To your question, it appears that it results in all code being the new code period. This is confirmed because the date of the new code period appears on the New Code tab, which corresponds to when each project was onboarded.
In my case I guess this works, as we are using PR decoration as our primary code quality gating, so all I need from the “new code” analysis is confirmation that no bugs are making it into the develop branch (our main branch in SQ). This Previous Version + no sonar.projectVersion combination does that, and seems about equivalent to setting the New Code setting to Reference Branch = Develop. Completely different way that achieves the same outcome apparently.

Hi,

Fair point. I’ll pass it on internally.

 
Thx,
Ann