Is it possible to configure settings related to a single custom check

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.

Is there anything possible like that?

Hello @LeslieM98,

Yes it is, our Java API has it: org.sonar.api.server.rule.RulesDefinition.NewRule#createParam​(java.lang.String paramKey)

Have you tried?

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?

@LeslieM98

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.

Cheers

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