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:
globals
module
main
function
report
- item specifies the identifier type. It can be one of the following:
constant
type
type.record.member
variable
variable.record.member
cursor
function
report
parameter
prepare
- The
identifier
mandatory keyword indicates that the rule is an identifier naming convention rule.
Options
The options available for identifier naming convention rules are:
.enabled
specifies whether a rule is enabled. Valid values aretrue
orfalse
..severity
specifies 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..prefix
checks for the existence of a constant string (without quotes)..characters
checks 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).
.excludedCharacters
checks for specific characters in the identifier root (the identifier without its prefix). Provide the list of characters to exclude, without quotes..lettercase
checks 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.