I am writing a custom java rule: “The logger with lower level than expected must be judged if it is enabled”. However, since the expected logger level is defined in a yml file, not in the java class itself, I need to obtain the expected logger level first before scanning and parsing java files.
I come up with 2 ideas:
read and parse the yml file in the plugin to find the expected level, in sonar way or using other packages.
use a customized analyze parameter to tell the plugin which level is expected.
I wonder if it is possible to implement these ideas. If not, how can I write this rule?
I guess if I add a RuleProperty annotation to a variable, then I can change its value via the settings of frontend website? Or if I specify the “key”, I can access it using analyze parameter like -Dsonar.mykey=something?