Help on Formatting the Exclusion Pattern?

Hi all,
Version: 8.9 LTS

I have the following exclusion in sonar.global.exclusions:

*Test*/**/*

My expectation is that it would start excluding code smells from the following area below, but it does not?

Does anyone have any suggestions or should I post in the “bug” area?

Thanks,
Gracie.

Hi @GCDewski ,

You should use **/*Tests.cs instead. You can test the glob pattern with https://globster.xyz/ or Digital Ocean’s Glob Tool.

Thanks for the reply Joe,

Both of those glob testers say that my pattern should work for that path. I want all files, .cs or otherwise, under the folder “Website.blank.Tests” excluded.

OK, try this one: Website.blank.Tests/**/*Tests.cs

example: Glob Tool | DigitalOcean

That did not work either. Here’s a snippit from the “Run Code Analysis” Sonarqube build step log.

2021-06-28T19:25:01.8965255Z INFO: Indexing files of module 'Website.Blank.Tests'
2021-06-28T19:25:01.8966300Z INFO:   Base dir: C:\agent\_work\6\s\Website.Blank.Tests
2021-06-28T19:25:01.8967028Z INFO:   Test paths: Clients/Auth0ClientTests.cs, Clients/RosterClientTests.cs, ...
2021-06-28T19:25:01.8968792Z INFO:   Excluded sources: **/*jquery*, **/*modernizr*, **/AssemblyInfo.cs, **/*Tool*/**/*, *Tool*/**/*, **/bower_components/**/*, **/node_modules/**/*, **/typings/*.d.ts, **/InvalidXml.xml, **/karma.conf.js, **/*Test*/**/*, **/*Test*, *Test*/**/*, **/*Specs*/**/*, *Specs*/**/*, **/*Specs*, *test*/**/*, Website.Blank.Tests/**/*Tests.cs, **/Connected Services/**/*, **/testresults/**/*, **/SigWebTablet*, **/js/library/**, **/Migrations/**/*, **/js/bootstrap-datetimepicker.js
2021-06-28T19:25:01.8970653Z INFO:   Excluded sources for coverage: **/Startup.cs, **/Program.cs, **/MainForm.cs, **/Services/Started/StartedClients.cs
2021-06-28T19:25:01.8971523Z INFO:   Excluded sources for duplication: **/*Dialog.js, **/*Dialog.html

It acts like it is doing it, but it doesn’t seem to actually exclude the files on the UI side?

Hi @GCDewski ,

I think that code smell shown in the first picture is regarding a rule that runs against test files, so you need to exclude the file via sonar.test.exclusions=Website.blank.Tests/**/*Tests.cs.

That was it! Thank you!

1 Like

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