How to exclude a directory from the code analysis?

余生长醉 提交于 2019-12-07 14:50:08

问题


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

回答1:


That's the correct place to set it up. Please try simply /Migrations/** or /MyProject/Migrations/**. When you go to one of the issues you want to get rid of, you'll see what your "regex" path should start with.

And one more tip: To see result, you have to rebuild the project, run sonar again. And again, until you get it right.




回答2:


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.



来源:https://stackoverflow.com/questions/30667507/how-to-exclude-a-directory-from-the-code-analysis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!