SonarQube new code not working as expected


I have a SonarQube 10.4 instance running and I setup my first projects. They are all legacy projects and for ‘New Code’ I chose ‘Previous Version’.

My first analysis I tagged with version BESELINE. Then from that point all analysis are tagged as CURRENT. This way I have a clear separation from what issues are legacy and what are new, so we can focus on fixing the new ones.

This worked for the first few analysis. But after my last analysis, SonarQube is considering issues that were already there as new issues. This is the example of one of the projects:

As you can see, the first analysis is the BASELINE version (done at Feb 14th), and everything above that tis New Code. I did another analysis on Feb 15th, and no new issues where found. Then I ran a new analysis today on Feb 21th and a lot of new issues appeared.

I went to the issues tab to see where they came from since there shouldn’t have much new commits and filtered by ‘Issues in new code’ only:


I looked at a few of them, and all of them were there in the BASELINE analysis, since they were commited several years ago:

The script to run the analysis didn’t change since the first analysis. The project’s Quality Profile also didn’t change.

I can see this exact same behavior across all my projects.

Does anyone have an idea of what could be the cause of this?

Hey there.

The number of issues appears to jump by a lot – are you sure the same scope of code is being analyzed between the two analyses? For example, you can check the Lines of Code metric on the Activity page , or compare the analysis logs of your baseline analysis and future analyses.

When new code is introduced after the baseline analysis (an exclusion removed, for example, or a clean build after an incremental build)… whether or not the SCM considers it as “new”, SonarQube will