Identifier naming convention rules
The identifier naming convention rules check that your identifier naming conventions are being followed.
The ruleId
The ruleId is
context.item.identifier, where:- context specifies the scope of the rule. It can be one of the following:
globalsmodulemainfunctionreport
- item specifies the identifier type. It can be one of the following:
constanttypetype.record.membervariablevariable.record.membercursorfunctionreportparameterprepare
- The
identifiermandatory keyword indicates that the rule is an identifier naming convention rule.
Options
The options available for identifier naming convention rules are:
.enabledspecifies whether a rule is enabled. Valid values aretrueorfalse..severityspecifies the severity level. Valid values areerror,info, orwarning(default).Warning: If the severity is set toerror, the compilation will fail if the rule is broken..prefixchecks for the existence of a constant string (without quotes)..characterschecks for character type of the identifier root (the identifier without its prefix). Valid values are:- alphabetic - All alphabetic characters.
- numeric - All numeric characters.
- alphanumeric - All alphanumeric (alphabetic + numeric) characters.
- all - All characters (alphanumeric + nonalphanumeric).
.excludedCharacterschecks for specific characters in the identifier root (the identifier without its prefix). Provide the list of characters to exclude, without quotes..lettercasechecks for case of the identifier root (the identifier without its prefix). Valid values are:- lowerCase (e.g.,
myvariablename) - upperCase (e.g.,
MYVARIABLENAME) - lowerCamelCase (e.g.,
myVariableName) - upperCamelCase (e.g.,
MyVariableName)
- lowerCase (e.g.,
Example
To check that all identifiers (regardless of scope) are alphanumeric and use lowercase names, specify:
identifier.enabled = true
identifier.characters = alphanumeric
identifier.lettercase = lowerCase
To override the general identifier rule and to specify that all identifiers in the
MAIN module use uppercase and start with "M_",
specify:main.identifier.enabled = true
main.identifier.lettercase = upperCase
main.identifier.prefix = M_To override the context identifier rule and to specify that all variable identifiers in the
MAIN module use lowerCamelCase and start with "V_",
specify:main.variable.identifier.enabled = true
main.variable.identifier.lettercase = lowerCamelCase
main.variable.identifier.prefix = V_To further specify that the variable name in the MAIN module cannot include a hyphen (-), the
letter o in lowercase (o), the letter o in uppercase (O), or the dollar sign ($), add the
rule:
main.variable.identifier.excludedCharacters = -oO$Additional examples are provided in the default.gslint file.