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.naming and are submodules of TreeWalker.
module | validates identifiers for | default value of format |
---|---|---|
AbstractClassName | abstract classes | ^Abstract.*$|^.*Factory$ |
ConstantName | constants (static, final fields) | ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$ |
LocalFinalVariableName | local, final variables | ^[a-z][a-zA-Z0-9]*$ |
LocalVariableName | local, non-final variables, including catch parameters | ^[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="LocalVariableName"> <property name="format" value="^e[a-zA-Z0-9]*$"/> <property name="tokens" value="PARAMETER_DEF"/> </module>
<module name="TypeName"> <property name="format" value="^I_[a-zA-Z0-9]*$"/> <property name="tokens" value="INTERFACE_DEF"/> </module>
name | description | type | default value |
---|---|---|---|
applyToPublic | Controls whether to apply the check to public member. | Boolean | true |
applyToProtected | Controls whether to apply the check to protected member. | Boolean | true |
applyToPackage | Controls whether to apply the check to package-private member. | Boolean | true |
applyToPrivate | Controls whether to apply the check to pribvate member. | Boolean | true |
Copyright © 2002-2003 Oliver Burn. All rights Reserved.