Can Sonar plugin exclusions be configured for local analysis without a local server?

末鹿安然 提交于 2020-01-05 04:48:48

问题


We have a central Sonar server for scanning and reporting on all the code within the organization. We also have the Sonar plugin for Eclipse (RTC) so that we can run local analysis as we edit code.

The problem I've got is that I need to set exclusions on 3rd party libraries so they don't get parsed when running a local analysis. I've seen how to set exclusions on the server but I don't have permissions to alter the server setup (and don't see the need to do this for a local analysis). I also don't have a local Sonar server running on my dev computer so I can't point the plugin to a server other than our central instance.

So the question is how do I set exclusions specifically for my local analysis without a local sonar server (e.g. localhost:9000)? Do I need to create a properties file, set an XML file, etc? If so then where do I put it so that the plugin picks up the exclusions? I tried setting a properties file in the root of the project folder with the syntax:

exclusions=/[projectRootFolder]/src/main/java/com/**/*.java

But the code in that folder structure still gets parsed.


回答1:


The Sonar Eclipse plugin is designed to centralise the configuration of the source code analysis tools you are running.

A question one must ask is why do you want to run a different analysis locally? Normally users want to execute the same analysis on the files in the local Eclipse workspace, before committing them into the shared code stream.

Finally, assuming you are using Maven it is possible to configure PMD, Checkstyle and Findbugs to run using their standard Maven plugins. In order to sync with Sonar you could download each tool's XML configuration. The following is an example of the "Sonar way with Findbugs" profile from Nemo:

  • http://nemo.sonarsource.org/profiles/permalinks/12


来源:https://stackoverflow.com/questions/11266854/can-sonar-plugin-exclusions-be-configured-for-local-analysis-without-a-local-ser

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