Finding and Activating / Deactivating Rules
Go to the profile's Coding rules tab. Because some languages have hundreds of coding rules available, the list of rules is headed with a search interface. The default search is always the active rules in the current profile:
The list of rules returned by the search engine is paginated, with 25 rules per page.
Coding rules can be activated or deactivated by, and their severity can be modified. Some rules have parameters which can also be modified:
Bulk change actions allow you to quickly activate or deactivate multiple rules:
Since version 3.6, to help you choose which coding rules to activate, each rule has a status:
- Beta: The coding rule has been recently implemented and we haven't gotten enough feedback from users yet, so there may be false positives or false negatives.
- Deprecated: The coding rule should no longer be used because a similar, but more powerful and accurate rule exists.
- Ready: The rule is ready to be used in production.
Rule Creation Date
Since version 3.6 each rule has a creation date to help you spot the new coding rules:
Multiple Activations of a Rule
Some coding rules, such as the XPath rule can be activated multiple times in the same quality profile with different parameter values.
If a rule can be activated multiple times, a Copy rule link is available:
Clicking on the Copy rule link displays a rule-specific form so you can define the new rule:
Once the new rule has been created, it can be managed like any other rule. Note that you will need to explicitly add your new rule to a profile; it will not automatically be added to the profile you created it from.
Extending Rule Description
- You can extend the description of a rule to give more details, add an internal description, etc. :
Extended rule descriptions are useful to let users know why a rule has been included in a profile (if there might be a question) or how your organization is using a particular rule. Your extension will be available to users as a normal part of the rule details:
Your extension will be added to the rule in every quality profile, not just the profile from which you edited the rule, and it will persist with the rule even if the rule is removed from every profile.
- You can add a rule comment, or administrator's note, in the context of a specific quality profile. Rule comments are useful for noting the reason of a rule was activated, set to a particular severity, etc. Rule comments are only visible in the Quality Profile administration interface, but they are visible to all users, even anonymous ones.
If you remove a rule from a profile, its notes will be erased because notes are profile-specific and exist only in the context of a rule's inclusion in a profile.
Since SonarQube 4.2, it is possible to add tags to coding rules to classify them:
You can then filter rules by tags.
Extending Coding Rules
Custom coding rules can be added. See Extending Coding Rules for detailed information and tutorials.