Determination of new code on master is different to branch

SonarQube Developer Edition Version 8.0
org.sonarsource.scanner.maven : sonar-maven-plugin : 3.7.0.1746

Some code changes during a recent release involved moving some java classes (and their respective test classes) from one package to another. The contents of these classes didn’t change apart from the package name at the top.
The sonar analysis on the release branch was treating these classes as new code. These classes were well covered (>80%) so they helped the release branch achieve the quality gate of 80% coverage on new code.
However when this branch was merged to master the analysis was done differently. These classes were now not counted as new code and so the test coverage on the (remaining) new code dropped.

Aside from the question of which analysis was correct, our main concern is why the code was treated in two different ways on the two branches.

Are you able to shed any light on why this might have happened?

Hi,

Welcome to the community!

This is going to be down to what the New Code Period is set to on your main versus release branch. Even before you dig into the settings, the top of the yellow column on each homepage should give you an indication.

 
HTH,
Ann

Hi Ann,
Thanks for the reply.
On master it’s analysed against the previous version and on the release branch it was being compared to the “next” branch with the “target.branch” parameter.
The next branch has been identical to master for a long time and we’ve been preparing to drop it which we’re going to do now, along with the target.branch parameter so that everything is compared to the previous version.
Perhaps part of this set-up caused the issue?
Thanks
John

Hi John,

The setup and/or expectations. That’s not actually what the sonar.branch.target parameter does. It’s more about synching issue states IIRC.

 
HTH,
Ann