Yalami
Yalami

Reputation: 63

how to use custom java rule on sonar?

i'm using sonar for a lot of customer projects, many customer need to have custom rules, I have always created rules for java with xpath, but now xpath are removed for java classes.

I'm using sonarQube ver. 4.5.1 and java plugin Ver. 2.9.1

In the documentation of sonar : http://docs.sonarqube.org/display/DEV/Custom+Rules+for+Java

I see that custom rules for java requires at least version 3.1 for plugin java, and changes made between ver. 3.0 and 3.1, that need to rewrite some classes.

I need to know how I can use the custom rule for java code with my actual configuration, and if I create custom rule now, will I rewrite some class of custom rule for any upgrade of java plugin??

Upvotes: 0

Views: 903

Answers (2)

Yalami
Yalami

Reputation: 63

Finally i found how to generate a custom java rule plugin,

I created a project template that he can generate the custom java rule

i posted the project on git, everyone can use it, the link of the project is : https://github.com/cecef/sonar-CustomRule-plugin

Regards, Youssef

Upvotes: 0

benzonico
benzonico

Reputation: 10833

If you write custom rules for java plugin version 2.9.1, yes you will encounter breaking changes when upgrading to a more recent version of the plugin in this case (which I can't recommend you enough).

We (java plugin developers) try to keep breaking changes of the API to a minimum but since version 2.9.1 it has happen.

Looking at the example in the doc for 3.1 might get you started to write custom rules but things will be different and you will have to figure things out.

Upvotes: 2

Related Questions