About new code
With the Clean as You Code approach, focus is set on new code. New code is code that you've recently added or modified. Different options can be used to define new code on a project, or at the organization level. The new code definition tells SonarQube Cloud which part of the code is considered new during analysis.
Focus on new code
SonarQube Cloud differentiates the analysis results on new code from overall code (overall code includes new and old code). To ensure you focus your efforts on new code, SonarQube Cloud highlights the status of new code in the UI.

Likewise, the built-in quality gate Sonar Way defines conditions applying to new code only.

New code definition options
SonarQube Cloud supports the following options for new code definition: Previous version, Number of days, Specific version, and Specific date.
SonarQube Cloud calculates a new code period with a start and end date. All the code that falls between the date of your last analysis and the start date is considered new code. The way the start date is calculated depends on the applying new code definition option (for information about the issue date calculation, see Issue management solution overview).
Previous version
Any code that has changed since the most recent version increment of the project is considered new code.
With this option, the new code period's start date is the date of the first analysis performed for the current project version.
Number of days
Any code that has changed in the last X days is considered new code.
With this option, the new code period's start date is the current date minus X days.
For example, setting the Number of days to 30 creates a new code period beginning 30 days before the current date. If no action is taken on a new code issue after 30 days, this issue becomes part of the overall code. The default value is 30 days, 7 or 14 days are other common values. The maximum possible value is 90 days.
Specific version
Any code that has changed since a specific, defined version of the project is considered new code.
This option gives you more control over your new code than the Number of days option. For example, for a project that follows a continuous delivery model, it allows you to mark the start of a new cycle, where a number of days would not be accurate enough.
With this option, the new code period's start date is the date of the first analysis performed for the specific project version.
Specific date
Any code that has changed since a specific, defined date is considered new code.
With this option, the new code period's start date is the specific date.
Recommended option depending on project type
Depending on the type of project you're working on, the best option to use will vary. Here are general use cases for various types of projects:

Configuration levels
The new code definition can be set at the organization and project levels with the following restriction:
- Only the Previous version and Number of days options can be set at the organization level.
The following applies:
- The new code option defined at the organization level (if any) is applied by default to all new projects.
- The project-level definition has precedence over the organization-level definition.
- By default, no organization-level new code definition is set.

Related pages
Was this page helpful?