Folder/file exclusions not working as expected


I am running Sonarqube Community Edition Version 9.9 (build 65466) on a virtual machine to analyze my local code. It is a .NET 5 solution,and I am using the Sonar Scanner for .NET to run the analysis. It works fine mostly, but I’m having trouble excluding some library code which is part of the workspace.

The directory structure is as follows:

	-> Source Code
	-> Libs
		-> XYZ
			-> Proj1
			-> Proj2
			-> Proj10

I want to exclude the Libs folder completely and I’m using the exclusion pattern Libs/XYZ/**. This mostly works, however, some random folders in some projects still continue to be included. I’ve tried various exclusion patterns (listed below), but none of them seem to work. Please help.



Exclusions need to target files. Most of your patterns target directories. Specifically, ** excludes 0-n directories.

Try this:


Additionally, take a look at the paths SonarQube has for these unwanted files, and use those as a guide to setting your exclusions. TBH, I think it gets a little confusing when you’re in a multi-module/project context which is why I find it helpful to check the UI to get the paths as analysis sees them.


Thanks, I’d tried these patterns but they were giving me the same results. Turns out they were being treated as test code, so adding the patterns to test exclusions seems to have done the trick.

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