Validation of parameter of type REGULAR_EXPRESSION not working

Hi,

It looks like a validation is expected for parameters of type REGULAR_EXPRESSION.

 @RuleProperty(
    key = "regex",
    description = "My description",
    type = "REGULAR_EXPRESSION",
    defaultValue = ".+"
  )

But, it does not seem to work…

Thank you

Regards

Nicolas

Hey there.

What doesn’t seem to work? More details (screenshots, logs, error messages), please :slight_smile:

Hi Colin,

When I activate a rule with parameter of type REGULAR_EXPRESSION, I would expect an error message when saving the following because it is not a valid regular expression. But I don’t get any error message.

Validation works for instance for parameters of type INTEGER:

Thank you

Regards

Nicolas

Thanks for clarifying. Indeed, it would be cool if rule parameters checked the validity of RegEx patterns, but that’s not the case today.

It probably wouldn’t be too difficult since we already check for valid patterns when RegEx is set for server settings.

I’ll pass this on as a good idea!

Thanks Colin. There might be some issue in the code of sonar-plugin-api because code for validation seems to be already there: sonar-plugin-api/plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java at master · SonarSource/sonar-plugin-api · GitHub