Sonarqube - Excluding Through UI Does Not Work

Sonarqube information:
Version: 8.9
Executed from Azure DevOps pipeline steps

Hello,
After upgrading from the earlier LTS version to 8.9, I noticed that one of our projects had 20 new bugs. Looking into it, the issues all came from the area path “Website.Elevate/Tests/src/…” so I navigated to “Project Settings->GeneralSettings->Analysis Scope” and added the source file exclusions as follows:

However, the 20 bugs remained after I ran the build in AzureDevOps.

I then added the sonar.exclusions key to our “Prepare analysis on SQ” build step, which should be equivalent to using the UI, but this time it worked.


I am able to replicate this behavior on another one of our projects. I have a workaround of course, but I would like to be able to use the UI area for exclusions.

Thank you,

Hi Gracie,

It looks like your exclusion patterns are incomplete. For example, if you want to exclude all files under Tests at any level, like for example Tests/src/folder/Foo.cs, then the pattern would need to be Tests/**/*. You need the first ** to match any possible directories between the root and the files and then the final /* to match the files in any directories traversed.

Hi Jeff,
Thanks for the feedback!

I don’t think the glob pattern is the issue though since the same pattern worked in the Azure DevOps build step, but not the UI area. I also tested **/*Test*/** in a couple of glob pattern testers and it picked up the file that had the bug which would have looked like Website.Elevate/Tests/src/tryitout.cs.

Thanks,

Hi Gracie,

For your purposes, that expression would actually need to be **/*Test*/**/* to actually match files and not just directories beneath any directory with a name containing Test. I encourage you to try that literally rather than make an assumption based on a 3rd party glob expression tester.

Alrighty! I did the change and after a couple hiccups got it working. Thank you.

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