Checks for Naming Conventions |
![]() |
Each of these naming modules validates identifiers for particular code elements. Valid identifiers for a naming module are specified by its format property. The value of format is a regular expression for valid identifiers. This is an example of a configuration of the MemberName module to ensure that member identifiers begin with 'm', followed by an upper case letter, and then letters and digits:
<module name="MemberName"> <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/> </module>
All naming modules belong to package com.puppycrawl.tools.checkstyle.checks and are submodules of TreeWalker.
module | validates identifiers for | default value of format |
---|---|---|
ConstantName | constants (static, final fields) | ^[A-Z](_?[A-Z0-9]+)*$ |
LocalFinalVariableName | local, final variables | ^[a-z][a-zA-Z0-9]*$ |
LocalVariableName | local, non-final variables | ^[a-z][a-zA-Z0-9]*$ |
MemberName | non-static fields | ^[a-z][a-zA-Z0-9]*$ |
MethodName | methods | ^[a-z][a-zA-Z0-9]*$ |
PackageName | packages | ^[a-z]+(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$ |
ParameterName | parameters | ^[a-z][a-zA-Z0-9]*$ |
StaticVariableName | static, non-final fields | ^[a-z][a-zA-Z0-9]*$ |
TypeName | classes and interfaces | ^[A-Z][a-zA-Z0-9]*$ |
<module name="PackageName"> <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/> </module>
<module name="TypeName"> <property name="format" value="^I_[a-zA-Z0-9]*$"/> <property name="tokens" value="INTERFACE_DEF"/> </module>
Copyright © 2002-2003 Oliver Burn. All rights Reserved.