So lets say I develop my own custom check for SonarQube.
I want to be able to include custom settings just for this one check.
Lets say I create a setting where I can enter regex to exclude specific classes from my custom rule.
This setting is the implemented within my custom rule so that I can use those set values inside my plugin.
Hello @Antoine
thank you very much for your help.
This is exactly what I need.
I cannot figure out how to access the values of those Params within my code.
Would you mind giving me an example or link me to some doc?
The repo sonar-custom-rules-examples will help you I think, in particular MyJavaRulesDefinition.java. No params are created there, but once you have the NewRule object setup, I guess (yeah, not really a Java expert!) you can call createParam​("my-param-id") and setup the returned NewParam object.
I understood that part. This only explains how to set up a parameter, not how to access the values of it later on.
Basically how do I access the values I entered within SonarQube from within my sourcecode?
I solved it myself with @RuleProperty.
Just add this to an attribute of your Rule or Class and Sonar takes care of initializing this attribute with the value set inside sonarqube.
Sadly this very usefull annotation is not documented anywhere within the docs