devAdvantage  devAdvantage

Rules

Rules are the elements of devAdvantage that have knowledge about identifying and fixing specific issues.  All rules are created from a base Rule Template which allow you to create rules configured for your specific needs.  Properties allow you to configure rules.  Some rules have only basic properties common to all rules, while others may have additional custom properties.  There can only be one rule with the same name in the knowledgebase, but rules can be referenced in many profiles. 

Object Oriented terminology can be useful in understanding the difference between rules and rule templates.  Rule templates are the classes or types, where rules are specific instances of those types.  Profiles can share references to the same rule.

Topics

Rule Properties- Rule properties can be accessed by either selecting the rule in the Knowledgebase explorer and modifying properties in the standard Visual Studio® .NET properties tab (see figure 1 below), or by selecting the rule, right-clicking for the context menu and selecting the Properties menu item (see figure 2 below).

Figure 1 - Visual Studio® .NET Rule Property Page

 

Figure 2 - devAdvantage Rule Property Page

 

Rule Name - This is the name you would like to call the rule.  By default it is the Template name.  When a rule has no specialized configuration to be done, the default name is the best choice.  If you are configuring different instances of a rule to have different properties, it makes sense to create special names for each case.

Rule Description - Description of the overall rule.  By default this is the template description

Rule Help URL - This is the URL used to provide an explanation of the rule or violation.  By default this is set to the standard documentation provided by devAdvantage, but can be redirected to custom documentation if it is appropriate for your organization and its standards.

Rule Template - This is the template used to create the rule.  The template name is read only once the rule is created.

Rule Profiles - This property shows the profiles that reference the rule.  Profiles can be added or removed from here - or done within the Knowledgebase explorer.

Custom Properties - If a rule has custom properties, more tabs will be present on the dialog box.  To see documentation for those properties, please refer to the Rule explanation.

Creating Rules- Rules can be created by going through the main devAdvantage menu or the Knowledgebase Explorer context menu.  Both approaches will bring up the Create Rules Wizard.  The wizard allows you to choose from the installed Rule Templates and create new instances of rules.  Because the default installation is configured with all the installed rules, creating rules is typically only necessary if you are building different configurations for the same rule template or you have deleted a rule.  If you want to add a rule to a profile, you can copy a rule from the All Rules profile to the profile you are interested in - in other words all profiles references rules that exist in the All Rules profile.  For more information on profiles, please see the Profiles topic. 

NOTE: It is possible to create multiple rules with the exact same configuration.  If these duplicate rules are used in the analysis of the same code, they will raise multiple violations on the same issue which may be confusing.  When automatically corrected, the first violation will be addressed and the remaining rules will find the code already changed and raise an error.  To avoid this don't create more than one rule that has the exact same configuration. 

Deleting and Disabling Rules - Every rule created exists in the All Rules profile and can be referenced by other profiles.  If you delete a rule from the All Rules profile you are deleting it from the knowledgebase and that it will be removed from all profiles that reference the rule.  You will be prompted to verify if you want to remove a rule permanently.  If you delete a rule from a profile other than the All Rules profile, it will remove the reference from that profile only.  To configure your projects and solutions to only use specific rules, please see the Profiles topic.

If you have deleted a rule inadvertently, you can re-create it from a template - see Creating Rules above.