Project Settings -> Analysis Scope -> Coverage Exclusions is not working

Hi, can someone help me?

Sonar version: SonarQube version 9.3.0.51899

Project Language: c# (.netcore)

I´m trying to configure coverage exclusions on Project Settings → Analysis Scope.
When configured with only one pattern, sonar works fine.
When configured with more then one patter, sonar ignore all patern, even the one that works alone.

Example:

1: This configuration works fine:

Pattern used: **/NotFeature/*

Logs:

INFO:   Base dir: C:\Users\lampa\source\repos\TesteSonarCoverage\TesteSonarCoverage
INFO:   Source paths: Feature/HelloWorld.cs, NotFeature/JustClass.cs, Program.cs
INFO:   Excluded sources for coverage: **/NotFeature/*

2: This configuration don´t work:

Pattern used: **/NotFeature/*, **/Program.cs

Logs:

INFO:   Base dir: C:\Users\lampa\source\repos\TesteSonarCoverage\TesteSonarCoverageTests
INFO:   Test paths: Feature/HelloWorldTests.cs, UnitTest1.cs, TestResults/3f660b67-...
INFO:   Excluded sources for coverage: **/NotFeature/*, **/Program.cs

3: When excluded coverage options is used on “sonarscaner begin command”, everthing works as expected:

/d:sonar.coverage.exclusions="**/NotFeature/*, **/Program.cs"

Logs:

INFO:   Base dir: C:\Users\lampa\source\repos\TesteSonarCoverage\TesteSonarCoverage
INFO:   Source paths: Feature/HelloWorld.cs, NotFeature/JustClass.cs, Program.cs
INFO:   Excluded sources for coverage: **/NotFeature/*, **/Program.cs

I pushed the project on git repository

fernandolamp/sonarcoverage: Temporary project to demonstrage a sonar bug (github.com)

What i´m doing wrong?

HI @fernandolamp,

Welcome to the community! :smiley:

If you’re configuring exclusions in the SonarQube UI, you need to put one exclusion per line rather than using comma separators:

Then hit Save and you should be good to go!

Regards,

Cameron.

1 Like

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