Coverage exclusion not working

(Alex Denton) #1

I’m trying to add two coverage exclusion rules and they work independently but not together. The first is intended to filter all files that end in “ControllerDocumentation.cs” and the second is intended to filter all files that fall under folders that start with “MyProject.Tests”. The config looks like:

sonar.coverage.exclusions="**/*ControllerDocumentation.cs, **/MyProject.Tests*/**/*"

Any advice?

(Fabrice Bellingard) #2

Hi Alex, and sorry for the late reply,

did you manage to fix your problem? Looking quickly at your setting, this should be working fine.

(Alex Denton) #3

What fixed it for me was using the web client for the configuration. However, I’d really like to be able to handle it as a part of my CI scripts so it could be version controlled. Would be happy to work with you to get that figured out.

(Fabrice Bellingard) #4

How do you configure this property in your CI scripts? This must definitely be possible to achieve what you want Alex.

(Alex Denton) #5

We’re using command line configuration. The only thing that’s special is we’re using Azure Pipelines. I haven’t tried running the console runner myself manually. The reason I don’t think Azure Pipelines is the issue is because if I just do one or the other pattern it works fine. I’m inferring that Azure Pipelines is transparently passing those values in but that may not be true.

The yaml definitions look something like:

  - task: SonarSource.sonarcloud.some-guid
    displayName: 'Prepare analysis on SonarCloud'
      SonarCloud: 'the_project'
      organization: the organization
      projectKey: theProjectKey
      projectName: TheProjectName
      extraProperties: |
        sonar.coverage.exclusions="**/*ControllerDocumentation.cs, **/MyProject.Tests*/**/*"
(Fabrice Bellingard) #6

So if I understand well, the following works:


And this works too:


But not when you combine both, it that right?

(Alex Denton) #7

Sorry for the delay response.

Yes. That’s it exactly. If I put them into 1 comma-delimited string then neither of them work.