|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Sonar plugin for custom violationsHi all, I'm writing a plugin to report custom violations (Class A may not access class B, to report layering problems in the project). The code for analyzing the project has already been written, and it generates a simple report in XML (which class, line number, ...) Now I'm trying to write a plugin to parse the XML and add the violations to Sonar. But before parsing the XML, I'm trying to just add a hard-coded violation to see if this works. I can add measures without any problem (based on the HelloWorld, but with INT instead of string, so I get a tendency as well). But the violations don't seem to show anywhere in the timeline or violations drilldown. So, my question(s) : - if the report is already generated (ant build), I suppose I don't need a MavenPluginHandler ? - Can I do something like this in my Sensor ? : <---> ... Rule testRule = new Rule(HelloPlugin.PLUGIN_KEY, "violation_key", "Test violation !", Iso9126RulesCategories.MAINTAINABILITY, RulePriority.BLOCKER); Violation violation = new Violation(repository.getRule(), new JavaFile("some.package.SomeClass")); Violation.setLineId(20); Context.saveViolation(violation); ... <---> I got the feeling I'm missing something stupid here, as this does't work. The documentation doesn't seem to mention anything about the RulesRepository (which I already tried without success), or any plugin development besides the HelloWorld in fact. Thanks in advance, Geert --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
RE: Sonar plugin for custom violationsI will post this in the dev list, sorry for the cross post. Geert -----Original Message----- From: Geert Van Damme [mailto:GVanDamme@...] Sent: maandag 2 november 2009 16:17 To: user@... Subject: [sonar-user] Sonar plugin for custom violations Hi all, I'm writing a plugin to report custom violations (Class A may not access class B, to report layering problems in the project). The code for analyzing the project has already been written, and it generates a simple report in XML (which class, line number, ...) Now I'm trying to write a plugin to parse the XML and add the violations to Sonar. But before parsing the XML, I'm trying to just add a hard-coded violation to see if this works. I can add measures without any problem (based on the HelloWorld, but with INT instead of string, so I get a tendency as well). But the violations don't seem to show anywhere in the timeline or violations drilldown. So, my question(s) : - if the report is already generated (ant build), I suppose I don't need a MavenPluginHandler ? - Can I do something like this in my Sensor ? : <---> ... Rule testRule = new Rule(HelloPlugin.PLUGIN_KEY, "violation_key", "Test violation !", Iso9126RulesCategories.MAINTAINABILITY, RulePriority.BLOCKER); Violation violation = new Violation(repository.getRule(), new JavaFile("some.package.SomeClass")); Violation.setLineId(20); Context.saveViolation(violation); ... <---> I got the feeling I'm missing something stupid here, as this does't work. The documentation doesn't seem to mention anything about the RulesRepository (which I already tried without success), or any plugin development besides the HelloWorld in fact. Thanks in advance, Geert --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
AW: Sonar plugin for custom violationsTrue... but anyway please have a look at this former thread, because this could be done nicely by integrating macker:
http://old.nabble.com/Is-there-a-way-to-create-a-rule-to-encourage-discourage-the-use-of-a-class---to25488273.html#a25488273 Harald -----Ursprüngliche Nachricht----- Von: Geert Van Damme [mailto:GVanDamme@...] Gesendet: Montag, 2. November 2009 16:24 An: user@... Betreff: [sonar-user] RE: Sonar plugin for custom violations I will post this in the dev list, sorry for the cross post. Geert -----Original Message----- From: Geert Van Damme [mailto:GVanDamme@...] Sent: maandag 2 november 2009 16:17 To: user@... Subject: [sonar-user] Sonar plugin for custom violations Hi all, I'm writing a plugin to report custom violations (Class A may not access class B, to report layering problems in the project). The code for analyzing the project has already been written, and it generates a simple report in XML (which class, line number, ...) Now I'm trying to write a plugin to parse the XML and add the violations to Sonar. But before parsing the XML, I'm trying to just add a hard-coded violation to see if this works. I can add measures without any problem (based on the HelloWorld, but with INT instead of string, so I get a tendency as well). But the violations don't seem to show anywhere in the timeline or violations drilldown. So, my question(s) : - if the report is already generated (ant build), I suppose I don't need a MavenPluginHandler ? - Can I do something like this in my Sensor ? : <---> ... Rule testRule = new Rule(HelloPlugin.PLUGIN_KEY, "violation_key", "Test violation !", Iso9126RulesCategories.MAINTAINABILITY, RulePriority.BLOCKER); Violation violation = new Violation(repository.getRule(), new JavaFile("some.package.SomeClass")); Violation.setLineId(20); Context.saveViolation(violation); ... <---> I got the feeling I'm missing something stupid here, as this does't work. The documentation doesn't seem to mention anything about the RulesRepository (which I already tried without success), or any plugin development besides the HelloWorld in fact. Thanks in advance, Geert --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
RE: Sonar plugin for custom violationsThanks for the link. The layering violations is just one violation, we will need to add some more later. And besides, it's interesting just to write a plugin in Sonar ;-) I have reposted on the dev list. Geert -----Original Message----- From: Goettlicher Harald (AA-DGP/ESI2) [mailto:Harald.Goettlicher@...] Sent: maandag 2 november 2009 16:37 To: user@... Subject: [sonar-user] AW: Sonar plugin for custom violations True... but anyway please have a look at this former thread, because this could be done nicely by integrating macker: http://old.nabble.com/Is-there-a-way-to-create-a-rule-to-encourage-discourage-the-use-of-a-class---to25488273.html#a25488273 Harald -----Ursprüngliche Nachricht----- Von: Geert Van Damme [mailto:GVanDamme@...] Gesendet: Montag, 2. November 2009 16:24 An: user@... Betreff: [sonar-user] RE: Sonar plugin for custom violations I will post this in the dev list, sorry for the cross post. Geert -----Original Message----- From: Geert Van Damme [mailto:GVanDamme@...] Sent: maandag 2 november 2009 16:17 To: user@... Subject: [sonar-user] Sonar plugin for custom violations Hi all, I'm writing a plugin to report custom violations (Class A may not access class B, to report layering problems in the project). The code for analyzing the project has already been written, and it generates a simple report in XML (which class, line number, ...) Now I'm trying to write a plugin to parse the XML and add the violations to Sonar. But before parsing the XML, I'm trying to just add a hard-coded violation to see if this works. I can add measures without any problem (based on the HelloWorld, but with INT instead of string, so I get a tendency as well). But the violations don't seem to show anywhere in the timeline or violations drilldown. So, my question(s) : - if the report is already generated (ant build), I suppose I don't need a MavenPluginHandler ? - Can I do something like this in my Sensor ? : <---> ... Rule testRule = new Rule(HelloPlugin.PLUGIN_KEY, "violation_key", "Test violation !", Iso9126RulesCategories.MAINTAINABILITY, RulePriority.BLOCKER); Violation violation = new Violation(repository.getRule(), new JavaFile("some.package.SomeClass")); Violation.setLineId(20); Context.saveViolation(violation); ... <---> I got the feeling I'm missing something stupid here, as this does't work. The documentation doesn't seem to mention anything about the RulesRepository (which I already tried without success), or any plugin development besides the HelloWorld in fact. Thanks in advance, Geert --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email Geert Van Damme Java Developer Consultant E-mail : GVanDamme@... Tel : +32 Fax : +32 Isabel NV/S.A. Keizerinlaan 13-15 Boulevard de l'Impératrice 1000 Brussels - Belgium RPR Bruxelles / RPM Brussel: BE 0455 530 509 http://www.isabel.eu/ http://www.zoomit.eu/ Zoomit is a Registered Trademark of Isabel NV/S.A. Disclaimer : http://www.isabel.eu/gps/en/disclaimer/mailing.php --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Sonar plugin for custom violationsHi Geert,
What you missed is to declare the rule(s) in a repository with the RulesRepository extension point. You can have a look at the Taglist plugin which embeds a simple rules repository : http://svn.codehaus.org/sonar-plugins/trunk/taglist/src/main/java/org/sonar/plugins/taglist/ Hope it helps, Freddy On Mon, Nov 2, 2009 at 4:17 PM, Geert Van Damme <GVanDamme@...> wrote:
|
|
|
RE: Sonar plugin for custom violationsHi Freddy,
I already tried using the RulesRepository, but no success.
I will start from the taglist example as this resembles what I need to
do.
I was wondering if I would need a MavenPluginHandler ? What
exactly does it do ? (I'm new to Sonar and Maven, so forgive me). I'm guessing I
would need one if the code analyzer would run during the sonar analyzing. But as
the analyzer is run during our ant build, I don't think I need a
MavenPluginHandler (the report is already present in the project). Is this
correct ?
Thanks again,
Geert
From: Freddy Mallet [mailto:freddy.mallet@...] Sent: maandag 2 november 2009 19:56 To: user@...; dev@... Subject: Re: [sonar-user] Sonar plugin for custom violations What you missed is to declare the rule(s) in a repository with the RulesRepository extension point. You can have a look at the Taglist plugin which embeds a simple rules repository : http://svn.codehaus.org/sonar-plugins/trunk/taglist/src/main/java/org/sonar/plugins/taglist/ Hope it helps, Freddy On Mon, Nov 2, 2009 at 4:17 PM, Geert Van Damme <GVanDamme@...> wrote:
Geert Van Damme
Java Developer Consultant
E-mail : GVanDamme@...
Tel : +32
Fax : +32 Isabel NV/S.A.
Keizerinlaan 13-15 Boulevard de l'Impératrice 1000 Brussels - Belgium
RPR Bruxelles / RPM Brussel: BE 0455 530 509 Zoomit is a Registered Trademark of Isabel NV/S.A. Disclaimer : www.isabel.eu/gps/en/disclaimer/mailing.php |
|
|
Re: Sonar plugin for custom violationsHello Geert,
A MavenPluginHandler is used in a plugin when you want to handle a maven plugin. For a example, if you create a Sonar Taglist Plugin, you can embed the Maven Taglist Plugin in it to avoid rewriting the whole thing and then you can use a MavenPluginHandler to configure and execute the maven plugin. Olivier On Tue, Nov 3, 2009 at 10:17 AM, Geert Van Damme <GVanDamme@...> wrote:
|
|
|
RE: Sonar plugin for custom violationsHey Freddy,
I finally got it working. Here's a round-up of the things I
did wrong, just for future reference :
- Create a RulesRepository (and add as extension in the
plugin). I guess at startup, Sonar will query this repository and add the new
rules to be used (rules definitions, not actual violations). So, creating a 'new
Rule(...)' in the Sensor only does not work.
- In the Sensor, a lot of classes can be automatically
injected in the constructor (just one line of documentation about this ?). This
way, I inject the RulesManager, from which I can get a certain rule to create a
violation (rulesManager.getPluginRule(...))
- I forgot to activate the rules in the Sonar profile
configuration screen (pretty trivial but easy to forget).
Knowing all this, it's actually pretty easy
:-)
Thanks again for the help !
Geert
From: Freddy Mallet [mailto:freddy.mallet@...] Sent: maandag 2 november 2009 19:56 To: user@...; dev@... Subject: Re: [sonar-user] Sonar plugin for custom violations What you missed is to declare the rule(s) in a repository with the RulesRepository extension point. You can have a look at the Taglist plugin which embeds a simple rules repository : http://svn.codehaus.org/sonar-plugins/trunk/taglist/src/main/java/org/sonar/plugins/taglist/ Hope it helps, Freddy On Mon, Nov 2, 2009 at 4:17 PM, Geert Van Damme <GVanDamme@...> wrote:
Geert Van Damme
Java Developer Consultant
E-mail : GVanDamme@...
Tel : +32
Fax : +32 Isabel NV/S.A.
Keizerinlaan 13-15 Boulevard de l'Impératrice 1000 Brussels - Belgium
RPR Bruxelles / RPM Brussel: BE 0455 530 509 Zoomit is a Registered Trademark of Isabel NV/S.A. Disclaimer : www.isabel.eu/gps/en/disclaimer/mailing.php |
| Free embeddable forum powered by Nabble | Forum Help |