Known limitation in .NET: this property does not currently work while the "sonar.dotnet.key.generation.strategy" property is set to "safe". See SONARDOTNT-10.
Since version 3.5, you can also work the other way around by setting inclusions. Go to Settings > General Settings > Exclusions > Files and set the
sonar.test.inclusions properties to the list of files that should be analyzed. If you set an inclusion, then only the files or modules listed there will be included in the analysis.
See the Patterns section for more details on the syntax.
To do so, go to Settings > General Settings > Exclusions > Duplications and set the Duplication Exclusions property. See the Patterns section for more details on the syntax.
You can prevent some files from being taken into account for code coverage by unit tests and integration tests.
To do so, go to Settings > General Settings > Exclusions > Code Coverage and set the Coverage Exclusions property. See the Patterns section for more details on the syntax.
Paths can be defined either as either relative or absolute. Use relative paths whenever possible.are relative to the project base directory.
The following wildcards can be used in either kind of path:
|*||zero or more characters|
|**||zero or more directories|
|?||a single character|
Relative paths are based on the fully qualified name of the component (like the ones displayed in the red frames below):
# Exclude all classes ending by "Bean" # Matches org.sonar.api.MyBean.java, org.sonar.util.MyOtherBean.java, org.sonar.util.MyDTO.java, etc. sonar.exclusions=**/*Bean.java,**/*DTO.java # Exclude all classes in the "org.sonar" package # Matches org.sonar.MyClass.java, org.sonar.MyOtherClass.java # But does not match org.sonar.util.MyClassUtil.java sonar.exclusions=org/sonar/* # Exclude all COBOL programs in the "bank" directory and its sub-directories # Matches bank/ZTR00021.cbl, bank/data/CBR00354.cbl, bank/data/REM012345.cob sonar.exclusions=bank/**/* # Exclude all COBOL programs in the "bank" directory and its sub-directories whose extension is .cbl # Matches bank/ZTR00021.cbl, bank/data/CBR00354.cbl sonar.exclusions=bank/**/*.cbl
To define an absolute path, start the pattern with "file:"
# Exclude all the *.cs files included in /path_to_my_project/myProject/src/generated and its subdirectories sonar.exclusions=file:/path_to_my_project/myProject/src/generated/**/*.cs # Exclude all the java classes contained in a src/generated/java directory and its subdirectories sonar.exclusions=file:**/src/generated/java/**/*.java