All new projects must now define their new code on SonarCloud to get a Quality Gate

Hello SonarCloud community,

From now on, all new projects have to define their new code to get a Quality Gate. The clean-as-you-code methodology is at the heart of SonarCloud and there is no one definition that can fit perfectly for all projects. So you will be prompted to select the definition that best fits your project right after having created it:

We fully revamped the configuration window for the new code definition to better convey what each option is about:

As a result of these changes, the Quality Gate will not be computed for the first analysis. The focus of our default Quality Gate is on new code only so that it cannot be computed without the definition of new code being available.

Of course, if you are already familiar with the concept you can set up a default value for the new code definition in your organization settings (Organization → Administration → New Code) that will be applied to all new projects.

The SonarCloud :sonarcloud: Team

1 Like

Hi @Martin_Bednorz,
I having some issues with this new change.
I don’t see the option to Set New Code definition on already existing projects.
I have set the organization New Code definition.
Any help would be appreciated.

1 Like

Hello @jcmuddle,

Welcome to the community!

Existing projects were automatically migrated to their previous setting. Before this change, the default value was set to the last 30 days, so I imagine that your existing projects were migrated to that value as well. You can navigate to the configuration page by selecting Administration --> New Code inside your project on SonarCloud.

@Martin_Bednorz but the problem is that in existing projects, they have the status “None” or “Not computed” in the quality portal, causing failures in the gate.

We have a parameter similar to “sonar.leak.period” to use the “Previous version” option. See the script below as I use it before the change.

# Set New Code Period

Write-Host “”

Write-Host “Set New Code Period”

$Date = “previous_version”

$NewCodePeriodPost = $SetKeyURL -f $BuildRepositoryNameURL, “sonar.leak.period”, $Date

Try {

  • $Post = Invoke-RestMethod -Method Post -Uri $NewCodePeriodPost -Headers $Headers*

  • Write-Host " sonar.leak.period: “$Date” done!"*

} catch { Write-Host " sonar.leak.period: “$Date” failed!"}

I didn’t find anything in the official documentation or in the community with the “” Previous version "parameter.

Can you help?