VS VB6 VBA
The sub-section of the section of the tab allows you create the nomenclature rules to be checked when the Review Quality feature is executed with this review selected:
The nomenclature rules can use control tags and type tags that are defined in the Control Tags Options and Type Tags Options.
To create a new nomenclature rule you use the following window:
In this window you enter the following properties:
- (optional): an identifier for the nomenclature rule.
- : a brief text describing what the nomenclature rule checks.
- : the item whose name is going to be reviewed. It can be any item, project, file, form, any control, any code element, class, field, etc.
- : you can review the name of an item in several ways.
- The name must use a convention of prefixes, suffixes and a specific case (Pascal, Camel, all upper case, all lower case). For example, you can define a rule to check that control names start with a custom control tag.
- The name must meet a condition with an operator and a value or a set of values. For example, you can define a rule to check that interface names start with "I". The condition is defined using a Condition editor.
- The name length must meet a condition with an operator and a numeric value. For example, you can define a rule to check that variables have more than one letter, to avoid names like i or j. The condition is defined using a Condition editor.
- (optional): you can define conditions (using a When condition editor) for the review to be executed. You can set that all, any or none of the conditions must be met.
- : the explanation tab has the field to describe in great detail what the review does and the field to explain to the developer how to rename the item to meet the review.
Suppose that you want to create a nomenclature rule like this:
"When a module variable is global, it must be prefixed by "g_" followed by a prefix for its type (such as "i" for Integer, "b" for Boolean, "s" for String, etc.) and its name must use Pascal case"
Public g_sConnectionString As String ' Correct
Public g_ConnectionString As String ' Incorrect: missing "s" prefix for String type
Public sConnectionString As String ' Incorrect: missing "g_" prefix for Public scope
Public g_sconnectionString As String ' Incorrect: Camel case instead of Pascal case
Public ConnectionString As String ' Incorrect: missing prefixes
You would create that nomenclature rule as follows:
- Go to the Type Tags Options, and define the type tags for the desired types, such such as "i" for Integer, "b" for Boolean, "s" for String, etc.
- Back in the Nomenclature Rules Review Options page, create a new nomenclature rule with these steps:
- Click the button "New".
- In the field "Description", type "Public module fields must start with the prefix g_, followed by the prefix for its type and must use Pascal case"
- In the field "Item to review", select the value "Module Field".
- In the field "Prefix 1", type the hardcoded value "g_" (without the quotes).
- In the field "Prefix 2", click the "Insert >" button, click the "Predefined Variable..." menu item and select in the list the predefined variable "Type Tag". The field "Prefix 2" will be filled with the value "$P[TYPE_TAG]".
- In the list "Case" select "Pascal".
- In the tab "When to review" create a condition with these steps:
- Click the button "New".
- In the list with the object that must meet the condition, select the value "Module Field".
- In the list "Property Name" select the value "Access".
- In the list "Operator" select the value "One of Selected Values".
- In the list "Value", check the value "Public"
The following sample code would produce a nomenclature rule violation for each public variable in the module:
Quality Review Options
When Condition Editor