Exclude white space/line changes from new code detection

I’m using SonarQube 8.7, sonar-scanner-msbuild 5.1.0 and JetBrains dotCover 2020.2.4.

I’m running SonarQube on C# projects, some of these project don’t have any unit tests. I changed some source code formatting, e.g. source code comments, line spacings, tabs and white spaces.

SonarQube detects new code on these changes, this is as expected because I changed the code recently.

The SonarQube quality gate fails too because new code coverage is below 80%.

Is there any way to exclude changes with white spaces and white lines from new code detection?


Welcome to the community!

I believe you’re interested in this ticket:

SONAR-11283 - Quality Gate should not fail when too few lines to cover

Feel free to watch/vote.


Hi Ann,

Thank you for pointing me to the ticket. If I’m not mistaken this ticket is about setting a minimum amount lines of new code before evaluating the quality gate. Outlining source code (adding white spaces and / or line feeds) may take a lot of changed lines.

Do you think my use case will be covered with this ticket?

Thank you.


Here’s the relevant part for me:

Instead of considering the number of lines, conditions on coverage-related metrics should be ignored based a minimum number of new lines to cover.

I.e. ignore vertical whitespace.

Now if you change the indenting in the file, that will show up as changed code → lines of code marked new by your SCM. But otherwise, this is what you’re looking for, isn’t it?


Hi Ann,

I think my use case is different. You’ll find the scenario below:

  1. quality gate is passed
  2. I commit the next change. The commit contains more than 20 lines of changed code. For brevity I included only one statement:
  3. after building the Sonar Qube quality gate fails:

The offending statement in Sonar Qube (only one statement is shown):

How should I configure Sonar Qube so the quality gate doesn’t fail on changed white spaces?