Quantcast

How do I get Sonar Eclipse plugin to exclude when analyzing locally?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How do I get Sonar Eclipse plugin to exclude when analyzing locally?

tofudisan
This post was updated on .
I've tried searching for this but I've only come up with answers for what appears to be configuring the web server install of Sonar?

I just got Sonar Integration for Eclipse 2.3.0.20111209-1529 installed.  I've been able to get it to scan locally and had good success with cleaning up some best practice issues.

However some of the code is 3rd party libraries and they are throwing large numbers of critical and major violations.  I'm not in charge of those libraries so I'd like to exclude them when running a local analysis.  How do I do that?

I will call the project "BOB" for this example.  My desire is to exclude local scans for everything from /BOB/src/main/java/com/ including all files in all of the sub directories within the folder on down.

So this leads to a couple questions:
1.  Is the syntax "exclusions=/BOB/src/main/java/com/**.java" correct?
2.  Where do I put this entry?  I tried creating a sonar-project.properties file and putting it in the root folder of the project but that doesn't work.  The local analysis still reports violations in the folders/packages I want to ignore at the local scan level.

Edit: I should mention that the Sonar server is a central server and not local.  I don't have permissions to configure the server settings.  Could that be causing a conflict with the properties file for local scans?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How do I get Sonar Eclipse plugin to exclude when analyzing locally?

Freddy Mallet
Hello,

However some of the code is 3rd party libraries and they are throwing large
numbers of critical and major violations.  I'm not in charge of those
libraries so I'd like to exclude them when running a local analysis.  How do
I do that?

Currently the only way to exclude some java source files from the (local or remote) analysis is to use the "sonar.exclusions" property which can be defined through the Sonar UI in the project Exclusions page.

I will call the project "BOB" for this example.  My desire is to exclude
local scans for everything from /BOB/src/main/java/com/ including all files
in all of the sub directories within the folder on down.

But this exclusion mechanism only works at package level. There is an open ticket to extend this mechanism in order to support exclusion of source code directories, see http://jira.codehaus.org/browse/SONAR-2760. So in your case, your java source files to be excluded must be in some dedicated packages.

So this leads to a couple questions:
1.  Is the syntax "exclusions=/BOB/src/main/java/com/**.java" correct?

No according to what I said : sonar.exclusions=**/packageToBeExcluded/**.java
 
2.  Where do I put this entry?  I tried creating a sonar-project.properties
file and putting it in the root folder of the project but that doesn't work.
The local analysis still reports violations in the folders/packages I want
to ignore at the local scan level.

The best place is in the Sonar UI.

Kind regards,
Freddy
 

--
View this message in context: http://sonar.15.n6.nabble.com/How-do-I-get-Sonar-Eclipse-plugin-to-exclude-when-analyzing-locally-tp5000436.html
Sent from the Sonar user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How do I get Sonar Eclipse plugin to exclude when analyzing locally?

tofudisan
Thanks Freddy!

I should have been clearer.  Yes all the code I want to exclude are in dedicated packages.

So the package for the example reference above would be in the Bob project as com.java.  For a specific example we use the Gomez web service to get some data and classes.  I want to exclude their code that is in the com.gomez.* packages.

Since I don't have a local server running, and can't alter the central server's exclusion settings, it sounds like I'm stuck with the local analysis reading the settings from the central server.

Bummer.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How do I get Sonar Eclipse plugin to exclude when analyzing locally?

Freddy Mallet
Hello,

See my comments below :

So the package for the example reference above would be in the Bob project
as com.java.  For a specific example we use the Gomez web service to get
some data and classes.  I want to exclude their code that is in the
com.gomez.* packages.

Since I don't have a local server running, and can't alter the central
server's exclusion settings, it sounds like I'm stuck with the local
analysis reading the settings from the central server.

Yes and no because by default the Sonar Eclipse plugin (The violation view) only displays the violations contained in the current selected resources and this could be a package, a project or a file. So using the Sonar Eclipse plugin remains valuable to reimburse the technical debt on the source files you're working on. 

Kind regards,
Freddy

Bummer.

--
View this message in context: http://sonar.15.n6.nabble.com/How-do-I-get-Sonar-Eclipse-plugin-to-exclude-when-analyzing-locally-tp5000436p5000500.html
Sent from the Sonar user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How do I get Sonar Eclipse plugin to exclude when analyzing locally?

tofudisan
Freddy Mallet wrote
...
Yes and no because by default the Sonar Eclipse plugin (The violation view)
only displays the violations contained in the current selected resources
and this could be a package, a project or a file. So using the Sonar
Eclipse plugin remains valuable to reimburse the technical debt on the
source files you're working on.
...
Very true!  I do click through the packages to find the major & critical issues I need to tackle.  Was just hoping I could exclude on the local scans to speed the scan up and also trim the list when I click on the violations tab for the project itself.

Still Sonar is definitely a great tool.  I've learned quite a bit about Java just by fixing the major and critical issues that have been found so far.
Loading...