Is it possible to get some customized parameters in Custom rule?

Following This tutorial, I can write my custom rule checker.

For now, I can only get the key of project via context.getProject().key() .

The key is defined from scanner command line such as -Dsonar.projectKey=keyOfProject

Is It possible I can defined more customized parameters in the same way and received them in my custom rule?

If not, May be this is a new useful API worthy of implementation?

Hey there.

What’s the ultimate goal – how would you use this when developing rules?

Most customised parameters would be defined for the rule and then adjusted as part of a Quality Profile.

In my case, I want to pass an unique ID to the rule, although the rule is already defined in a specific Quality Profile. But I need this unique ID for applying different checks in the same rule.

Is is possible for me to do that?

In this case, we’d probably suggest creating different rules (the behavior of how the check is applied should be defined mostly by what rules are active in a quality profile, not by analysis parameter).

There are some exceptions you could try and model after if you’re really certain this makes sense, like how we adjust rules based on the sonar.java.version analysis parameter.

Thanks Colin. That helps a lot.