how to use the 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 :

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??

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.