Create custom rule - especially for comment

I am asking question about how to write and apply a custom rule into my Python project. As i search on Rules documents of SonarCloud docs ( I find that we can find template to create Custom rule, but i can not find it for myself

Could you have me to create some rules? Or can you send me the list of rule that can be applied to code comments in Sonar cloud
Thank :slight_smile:


I believe that you’re looking for the rule named Track comments matching a regular expression: that’s in fact a rule template and rule templates are not available on SonarCloud.

There are a few python rules related to comments and all of them except that rule template are available on SonarCloud…

Hi, i find a way to adapt my problem: I create new quality profile and then add predefined rule to it.
However, i still want to ask if i want to create some new rule, etc:“Each functions must have comments”, how can i defind it by myself?

On SonarCloud, you cannot define custom rules. For rules which have parameters, you can customize the values of the parameters.

Maybe you would be interested by the rule named “Docstrings should be defined”. However, it would also check docstrings on classes and modules.

1 Like