New Code Period for master

Hi community,


  • SonarQube Enterprise 8.9, Java project, quality gate

The scenario

What we have

  • A quality gate with some conditions on new code plus this particularly: lines > 1000
  • A project with new code configuration set to: Previous version
  • A master branch which we use to release new versions of the app.
  • Feature branches which we merge into master when feature finished.

What we try to achieve:

The metric lines > 1000 prevents us to merge big pull requests (all good with this).
When we have big PRs we split them into smaller PRs in order to improve code reviews.
Merging each of those smaller PRs does not mean we release a new version of the app to production.
The new version is released from master when all those small pull requests are merged and the fully functional feature is in place.

After we merge some of those small PRs the quality gate starts to fail in master branch stating (correctly) that
the condition lines > 1000 is broken.
This is something we don’t want. We want to control when to release the new version into test environments and afterwards into production.

What we tried so far

New Code Period for master

  • Previous version: already does not work. Lines of code accumulate from all small PRs making the gate to fail.
  • Number of days: Lowered to 1. This might work but is ficticious since you might still need to wait a day to push more changes.
  • Specific analysis: also does not work. We 'd need to change this for every single merge into master.
  • Reference branch: Does not work. There is no reference branch for master.

Thanks in advance!

1 Like

Hey there.

Unforunately, Sonar can’t meet your need here right now, as the New Code Period will apply the same to your master branch as your pull requests.

I’ve moved your post to Product Manager for a Day since you have expressed the need – maybe other users have the same need, or our PMs will chime in!


Hi, I found this question when looking at the same issue on my side.
In our company we have specific version management and this breaks SonarQube scans as he thinks all code is new after version change.
Would be nice to have possibiility to have incremental code scans → when you change version on master it would not block all code on condition “no more than 2000 lines of code”. :rocket:

Welcome to the community @Piotr!

I’d be interested to understand how your version management interferes with the detection of the new code. Can you please elaborate?
You may want to look at the various options that SonarQube offers for the New Code definition?


Hi @Ramiro,

Thanks for sharing your need.
I’d prefer to not directly jump to a solution based on the New Code definition. I feel that you’re trying to use the Quality Gate as a way to enforce a practice in your team, and I don’t think this criteria relates to the quality of your code per see. Have you considered other ways to enforce this practice?