有什么方法可以在单个文件上运行声纳分析?

Val*_*ath 5 java sonarqube

我的项目太大了,在整个项目上运行 Sonar 需要大量的时间和内存。所以我想知道是否有任何方法可以在单个 java 文件上运行声纳。

Kru*_*mmy 5

您也可以直接使用包含或排除(或两者),而不是安装此插件。

在执行的 pom.xml 中,您可以编写pathToInclude(在属性部分中),并且在控制台中,您必须添加一个带有-Dsonar.inclusions=pathToInclude的属性

-Dsonar.inclusions=file:/path_to_my_project/MyProject.java
//only the file above will be analyzed

-Dsonar.exclusions=file:/path_to_my_project_root/another_directory/**/*
//all subfolders and files within "another_directory" are exclued / ignored. 

-Dsonar.inclusions=file:/path_to_my_project/another_directory/MyProject.java
-Dsonar.exclusions=file:/path_to_my_project/another_directory/**/*
//all subfolders and files within "another_directory" are exclued / ignored EXCEPT MyProject.java.
Run Code Online (Sandbox Code Playgroud)