I’ve seen that there is a very strict rule key validation for rule keys in https://github.com/SonarSource/sonarqube/blob/dbed19dc8cf4cd6fc2a2112d0e07454b41c105ff/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/RuleCreator.java#L179
Is there a reason for that? We are using a plugin that provides templates for custom rules and the keys contain “-” (gcc compiler warning id’s) With this rule validation not permitting this character I cannot create new custom rules but need to always reinstall the plugin with the new rules in the deployed xml file.
I’m not sure anybody will be able to tell you why this exact validation was chosen (it was introduced in 2014).
I’m not sure I understand this. Is the key validation different for rules deployed via a pugin?
Deployed with the xml file, the rules are just copied in the database. So after installing the plugin, I find all the correct values in the rules table. It also works, if I manually change the DB entry via SQL.
The issue is only, if I want to create via GUI or API based on the template…
Ah. I understand better now.
I suppose the safest thing to do (on a fresh deployment) is to make sure the rule keys use a substitute for
- (such as
It’s interesting that we have different requirements for rules deployed via plugin than via custom rule. I’ll flag this for attention (but I don’t expect a short-term action)
Thanks for the feedback Please don’t improve in a way, that the existing XML files don’t work anymore
Many thanks for the feedback.
Upon investigation, we found that there are indeed inconsistencies when validating the rule key between using plugin API and creating a custom rule from a template.
The validation is correct for the latter, however, there is no validation when creating rules through the plugin API. Hence, a bug ticket has been created.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.