Can't get Code Coverage exclusions to work with Azure DevOps &

  • ALM used: GitHub
  • CI system used: Azure DevOps
  • Languages of the repository: Ruby

I have been spending days to get code coverage exclusions to work since it’s including my specs and database migrations.

First I added the following in my pipeline:

- task: SonarCloudPrepare@1
SonarCloud: 'SonarCloud'
organization: '********'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: '********'
cliProjectName: '********'
#cliSources: '.'
extraProperties: |

But in the log it showed:

INFO: Indexing files...
INFO: Project configuration:
INFO: Excluded sources: **/*.erb
INFO: Excluded sources for coverage: db/migrate/**/*,spec/**/*,app/assets/**/*
INFO: Load project repositories
INFO: Load project repositories (done) | time=1265ms
INFO: 3654 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings

Also when I add these folders in Administration > General Settings > Analysis scope > Coverage exclusions, code coverage is still including my specs and migrations.

Help would be very much appreciated


This log means that the directory should be excluded from coverage, as expected.

How do you know that you’re coverage is still included? How do you see it in the UI?

If you go to the code tab and navigate to a excluded directory, you should see a - under coverage like this: