问题
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