Old code sometimes mixes with the new code when sonar determines what is new

Hi everyone!

I’m writing to you after I browsed issues declared in jira.sonarsource.com and couldn’t find anywhere an issue corresponding to what we are facing now, using the community edition v6.7.4 (LTS).

My issue concerns code coverage on the new source code, some old code sporadically mixes with the new code when sonar determines what is new. It takes old classes, totally untouched. This is a bother for I want to enforce our quality-gate rules on the new code only.

Could you please advise me what to do? Should I upgrade to v7 ? Should I install some extra plugin ?


Hi Gregory,

Could you please send us some screenshots to show us what do you think is not working well ?

Julien Lancelot

Here are the three captures, as you can see, the new code smell comes on an old code, whereas we have set only checking of new code. To us it seems sonar just picked a random class without change to create this code smell…

Please keep us posted.

Best regards,

First capture:

second capture:

third capture:

I’m still not sure to really understand the problem.

What is the date of the last commit of the file CancellationRequestReconciliationTask ?

Last git commit on CancellationRequestReconciliationTask is 25 Feb, 2016, so 2 years ago. That’s the problem. It’s an old class, with no recent changes, so sonar shouldn’t make that pop up in the new changes and new code smells.


I’m not sure what I’m supposed to be seeing in your third screenshot, but new issues can easily be raised on old code if there have been changes to your quality profile. For instance, if the rule behind the issue was just added then in 6.7.*, the issue will be new. Similarly, if the rule was already in the profile, but the threshold was changed recently, that would also cause a new issue.

BTW, we’ve done some work on issue backdating since 6.7, so you might not have the same experience in more recent versions.



There wasn’t any change in the quality profile, no change in the quality gate, no update in sonar whatsoever.
Again, it is ONLY a new git push triggering a new sonar analysis, this push does NOT contain ANY change whatsoever on the class sonar seems to believe is new…

However, thanks for this advice to upgrade to a newer version of sonar, we’re probably going to try.

Best regards,

Hi Gregory - have you had any luck working out how to avoid this ? We’re seeing similar issues where old classes are “pulled in” to the Sonar Gate analysis even though they are not being changed in the current PR

1 Like