# New code configuration

**URL:** <https://community.sonarsource.com/t/new-code-configuration/152871>\
**Category:** SonarQube Server / Community Build\
**Tags:** new-code\
**Created:** [November 21, 2025, 6:12pm UTC](https://community.sonarsource.com/t/new-code-configuration/152871 "2025-11-21T18:12:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel\_Amorosa](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/michel_amorosa/32/54146_2.png) [@Michel\_Amorosa](https://community.sonarsource.com/u/Michel_Amorosa)\
**Post date:** [November 21, 2025, 6:12pm UTC](https://community.sonarsource.com/t/new-code-configuration/152871/1 "2025-11-21T18:12:21Z")

</div>

Hi,

I cannot configure “New Code” as I wish, I need help.

I am using SonarQube Server: Developer Edition v2025.1.1 (104738). I don’t know how it is deployed.

What I am trying to achieve:

On a dev branch, I want to consider as “new code”, the difference with the branch master. If I push a new commit to this branch or if I amend this commit to fix something, I want the analysis to compare the code of my branch (all the commits on my branch) with _master_. My Quality Gate only have conditions on New Code.

How I configured Sonarqube:

The baseline chosen for new code in the settings is “Reference branch” and I chose the branch _master_. The first commit is always compared to master and it is ok. The next commits are always compared to the previous one and not the _master_.

What I have tried so far to achieve this:

I have tried to add new arguments in the `dotnet sonarscanner begin` command :

- `/d:sonar.branch.name=%MyBranchName%`
- `/d:sonar.newCode.referenceBranch=master`
- `/d:sonar.scm.forceReloadAll=true`

I have also tried the other baselines for new code (version and number of days) but even the first analysis did not recognize anything as new code.

Can sonarqube can be configured that way ?

Thank you for your time

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [November 24, 2025, 9:04am UTC](https://community.sonarsource.com/t/new-code-configuration/152871/2 "2025-11-24T09:04:10Z")

</div>

Hey there.

Configuring the “New Code Period” is all about setting a baseline, after which all changes are considered “New Code”. The **Reference Branch** New Code Period ensure that changes made before the first analysis (establishing the baseline) fall into the New Code Period, and does this by comparing the new branch to the reference branch.

> [@Michel\_Amorosa](#):
>
> The first commit is always compared to master and it is ok. The next commits are always compared to the previous one and not the _master_.

That sounds like it’s working as expected, although I’m not quite sure what you mean by the your last sentence. Are your new commits / amended commits not falling into the New Code Period? What are you expecting to see compared to what’s being shown? Some specific examples would help.

---

<div class="post-metadata">

**Author:** ![Michel\_Amorosa](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/michel_amorosa/32/54146_2.png) [@Michel\_Amorosa](https://community.sonarsource.com/u/Michel_Amorosa)\
**Post date:** [November 24, 2025, 4:11pm UTC](https://community.sonarsource.com/t/new-code-configuration/152871/3 "2025-11-24T16:11:18Z")

</div>

Hi,

Thank you for your reply.

Here’s a simple example:  
In the first commit of a branch, 314 code smells are introduced. In the _New Code_ section, I can see the exact number of code smells added.  
Then, in the second commit, I fix 2 of these code smells. In _New Code_, I now see “0 New Issues”.

I don’t know if this is expected behavior, but I was hoping to see the combined data from both commits in the _New Code_ tab — meaning that this branch introduced a total of 312 code smells.

In the analysis history, I can see that 2 code smells were fixed, but I can’t see how many were added in the first commit.

First analysis :

 ![first-analysis](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/d/3/d35a73b8c78a93dd25a6fce7ee0d14ca5b9a7b3c.png)

Second analysis :

 ![second-analysis](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/b/6/b65396323622293626a850472fd84f6688fd0ac0.png)

Expected second analysis :

 ![second-analysis-explain](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/f/9/f9fe15be4fa296b8ae4563270f222ffe33f1651d.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [November 25, 2025, 12:52pm UTC](https://community.sonarsource.com/t/new-code-configuration/152871/4 "2025-11-25T12:52:32Z")

</div>

Thanks. What you’re describing should be how it works.

> [@Michel\_Amorosa](#):
>
> ![second-analysis](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/b/6/b65396323622293626a850472fd84f6688fd0ac0.png)

It says here the analysis has warnings. What are those warnings (click **See details** ).

---

<div class="post-metadata">

**Author:** ![Michel\_Amorosa](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/michel_amorosa/32/54146_2.png) [@Michel\_Amorosa](https://community.sonarsource.com/u/Michel_Amorosa)\
**Post date:** [November 25, 2025, 1:58pm UTC](https://community.sonarsource.com/t/new-code-configuration/152871/5 "2025-11-25T13:58:44Z")

</div>

Hi,

thank you for your reply

Here are the warnings:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/9/a/9a9b13dc3c2bfbb5303bd0d6098f724ab6fc38c1.png)

Or maybe I’m using wrong commands in my pipeline ?

1. dotnet sonarscanner begin
2. donet test
3. dotnet sonarscanner end

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [November 25, 2025, 4:34pm UTC](https://community.sonarsource.com/t/new-code-configuration/152871/6 "2025-11-25T16:34:49Z")

</div>

I was kind of hoping it would be something about collecting blame data. 😃

I don’t think you need to worry about the commands you’re using. Analysis seems to happen correctly, it’s just that everything seems to fall out of the new code period on your next analysis.

I would like to see what these log lines look like both the first and second analysis (with `/d:sonar.verbose=true`). They’re towards the end.

```auto
17:30:53.060 INFO SCM revision ID '12313b6be2852ff5502412498dc24a694214124'
17:30:53.099 INFO SCM writing changed lines
17:30:53.102 INFO Merge base sha1: 7095143b6be2852ff5502a298dc24a6928f7e878
17:30:53.109 DEBUG SCM reported changed lines for 3files in the branch
17:30:53.109 INFO SCM writing changed lines (done) | time=10ms

```

Specifically I’ll be interested to see if the same `Merge base sha1` is detected for both runs.

---

<div class="post-metadata">

**Author:** ![Michel\_Amorosa](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/michel_amorosa/32/54146_2.png) [@Michel\_Amorosa](https://community.sonarsource.com/u/Michel_Amorosa)\
**Post date:** [November 28, 2025, 8:32am UTC](https://community.sonarsource.com/t/new-code-configuration/152871/7 "2025-11-28T08:32:56Z")

</div>

Hi,

I am not able to find these lines in the result.

I used this command line  
`dotnet sonarscanner begin /k:myProjectName/d:sonar.login=MySonarqueToken /d:sonar.host.url=MySonarUlr/d:sonar.cs.opencover.reportsPaths=./TestResults/**/*.xml /d:sonar.cs.vstest.reportsPaths=./TestResults//*.trx /d:sonar.sources=front/src /d:sonar.qualitygate.wait=true /d:sonar.verbose=true /d:sonar.scm.forceReloadAll=true /d:sonar.branch.name=MyBranchName /d:sonar.newCode.referenceBranch=master`

But I found this (the only reference to SCM) :

`INFO: SCM Publisher is disabled`

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [November 28, 2025, 8:35am UTC](https://community.sonarsource.com/t/new-code-configuration/152871/8 "2025-11-28T08:35:32Z")

</div>

> [@Michel\_Amorosa](#):
>
> `INFO: SCM Publisher is disabled`

Well that’s a very big hint.

In your server-side settings, is it possible `sonar.scm.disabled` is set to true? Global **Administration \> SCM \> Disable the SCM Sensor** (you can also find this at the project-level).

You can force it back on with `/d:sonar.scm.disabled=false`.

Without SCM data, SonarQube cannot reliably detect new code. You’re using, git, right? 🤞

---

<div class="post-metadata">

**Author:** ![Michel\_Amorosa](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/michel_amorosa/32/54146_2.png) [@Michel\_Amorosa](https://community.sonarsource.com/u/Michel_Amorosa)\
**Post date:** [November 28, 2025, 10:43am UTC](https://community.sonarsource.com/t/new-code-configuration/152871/9 "2025-11-28T10:43:53Z")

</div>

It now works perfectly 😁

Your assistance has been very helpful, thank you very much.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [December 5, 2025, 10:44am UTC](https://community.sonarsource.com/t/new-code-configuration/152871/10 "2025-12-05T10:44:30Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
