|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectorg.codenarc.rule.AbstractRule
org.codenarc.rule.AbstractAstVisitorRule
org.codenarc.rule.naming.PropertyNameRule
class PropertyNameRule extends AbstractAstVisitorRule
Rule that verifies that the name of each property matches a regular expression. By default it checks that
property names (other than static final
) start with a lowercase letter and contains only letters
or numbers. By default, static final
property names start with an uppercase letter and contain
only uppercase letters, numbers and underscores.
FieldNameRule
.
The regex
property specifies the default regular expression to validate a property name.
It is required and cannot be null or empty. It defaults to '[a-z][a-zA-Z0-9]*'.
The finalRegex
property specifies the regular expression to validate final
property names. It is optional and defaults to null, so that final
properties that are
non-static
will be validated using regex
.
The staticRegex
property specifies the regular expression to validate static
property names. It is optional and defaults to null, so that static
properties that are
non-final
will be validated using regex
.
The staticFinalRegex
property specifies the regular expression to validate static final
property names. It is optional but defaults to '[A-Z][A-Z0-9_]*'.
The order of precedence for the regular expression properties is: staticFinalRegex
,
finalRegex
, staticRegex
and finally regex
. In other words, the first
regex in that list matching the modifiers for the property is the one that is applied for the property
name validation.
The ignorePropertyNames
property optionally specifies one or more
(comma-separated) property names that should be ignored (i.e., that should not cause a
rule violation). The name(s) may optionally include wildcard characters ('*' or '?').
Property Summary | |
---|---|
Class |
astVisitorClass
|
String |
finalRegex
|
String |
ignorePropertyNames
|
String |
name
|
int |
priority
|
String |
regex
|
String |
staticFinalRegex
|
String |
staticRegex
|
Constructor Summary | |
PropertyNameRule()
|
Method Summary | |
---|---|
void
|
validate()
|
Methods inherited from class AbstractAstVisitorRule | |
---|---|
shouldApplyThisRuleTo |
Property Detail |
---|
Class astVisitorClass
String finalRegex
String ignorePropertyNames
String name
int priority
String regex
String staticFinalRegex
String staticRegex
Constructor Detail |
---|
PropertyNameRule()
Method Detail |
---|
void validate()
Groovy Documentation