New Code Definition is working wrong


We were using Sonarqube Enterprise Edition and it’s version is 9.2 and we upgraded it to 9.3 yesterday. So we always use latest version for Enterprise Edition.

I think Sonarqube New Code definition is working wrong. I will try to tell you with our example.

You can see what our project’s New Code definition is.

I think Sonarqube should calculate difference code from the previous version. But it did not do that.

P.S. We scan our repository’s develop branch on Sonarqube every night as scheduled. So the previous version is yesterday’s scan.

We work with feature branches in our repository. Basically, we create new feature branch from develop, then we develop our features in the feature branch. Sometimes it takes one or more weeks. We did a lot of commits in this duration. After we finish developing, we merge the feature branch to develop. And that night, Sonarqube scan develop branch again. I think the merged feature branch’s codes is all new code. But Sonarqube only considers commits made that day(last day). Previous commits’ codes are not shown in New Code reports.

I hope I was able to explain my problem.


Hey there.

It sounds like you might be passing a brand new version to sonar.projectVersion on each analysis, which would reset the New Code Period on your develop branch with every scan. Ideally, when using the Previous Version New Code Period the version should only be updated when there has actually been a version cut (a milestone, a new release, etc.)

You can check this in the Activity tab of your project.


Yes, We set version with pipeline build id every scan as you can see below image. I think you said set a static variable to it?

I will try to set a static value in this night scan.

Hi @Colin ,
I tried your suggestion. And I fixed the Sonarqube Project’s version nubmer. After that, the New Code definition shows as “Started 5 days ago”. As you can see the below image. It means it takes 5 days period.


But I tried to tell before. I want to see all merged branches, commits to develop in new code report for every day. Is there any other suggestions?


Hi! I have the same problem. Did you solve it?