Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a directory from the code analysis?

There have been some questions about this, but none of them solves my problem.

I use SonarQube to do code analysis on one of my projects, which contain a Migrations directory. I would like to exclude all the source files in that directory from the code analysis.

In the projects Configuration->Settings->Exclusions->Files->Source Files Exclusions I added "**/Migrations/.", but in the analysis results I still get issues in code files in that directory.
The directory structure of my project looks like this: \MyProject\Migrations\SourceFile.cs

What am I doing wrong? Am I entering the wildcard in the wrong place, or my wildcard is wrong?

In the logs I can see

13:06:23.460 INFO  - Copy-paste detection exclusions:
13:06:23.476 **/Migrations/*.*

but then I can also see

13:06:12.076 INFO  - Inspecting <MyProject>\Migrations\SourceFile.cs
like image 517
Mark Vincze Avatar asked Sep 18 '25 10:09

Mark Vincze


1 Answers

I had to use a different setting.

Instead of Configuration->Settings->Exclusions->Files->Source Files Exclusions I had to use Configuration->Settings->Exclusions->Issues->Ignore Issues on Multiple Criteria.

In this setting, I had to set the RULE KEY PATTERN to *, and I had to set the path wildcard in the FILE PATH PATTERN, **/Migrations/. works perfectly.

like image 114
Mark Vincze Avatar answered Sep 21 '25 07:09

Mark Vincze