Groovy Documentation

org.codenarc.rule.naming
Class VariableNameRule

java.lang.Object
  org.codenarc.rule.AbstractRule
      org.codenarc.rule.AbstractAstVisitorRule
          org.codenarc.rule.naming.VariableNameRule

class VariableNameRule
extends AbstractAstVisitorRule

Rule that verifies that the name of each variable matches a regular expression. By default it checks that non-final variable names start with a lowercase letter and contains only letters or numbers. By default, final variable names start with an uppercase letter and contain only uppercase letters, numbers and underscores.

The regex property specifies the default regular expression to validate a variable 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 variable names. It is optional but defaults to '[A-Z][A-Z0-9_]*'. If not set, then regex is used to validate final variables.

The ignoreVariableNames property optionally specifies one or more (comma-separated) variable names that should be ignored (i.e., that should not cause a rule violation). The name(s) may optionally include wildcard characters ('*' or '?').

author:
Chris Mair
version:
$Revision: 219 $ - $Date: 2009-09-07 21:48:47 -0400 (Mon, 07 Sep 2009) $


Property Summary
Class astVisitorClass

String finalRegex

String ignoreVariableNames

String name

int priority

String regex

 
Constructor Summary
VariableNameRule()

 
Method Summary
 
Methods inherited from class AbstractAstVisitorRule
shouldApplyThisRuleTo
 
Methods inherited from class AbstractRule
applyTo, createViolation, createViolation, createViolationForImport, createViolationForImport, getImportsSortedByLineNumber, getName, getPriority, packageNameForImport, setName, setPriority, sourceLineAndNumberForImport, sourceLineAndNumberForImport
 

Property Detail

astVisitorClass

Class astVisitorClass


finalRegex

String finalRegex


ignoreVariableNames

String ignoreVariableNames


name

String name


priority

int priority


regex

String regex


 
Constructor Detail

VariableNameRule

VariableNameRule()


 

Groovy Documentation