public class AbbreviationAsWordInNameCheck extends Check
The Check validate abbreviations(consecutive capital letters) length in identifier name, it also allows to enforce camel case naming. Please read more at Google Style Guide to get to know how to avoid long abbreviations in names.
Option allowedAbbreviationLength
indicates on the allowed amount of capital
letters in abbreviations in the classes, interfaces,
variables and methods names. Default value is '3'.
Option allowedAbbreviations
- list of abbreviations that
must be skipped for checking. Abbreviations should be separated by comma,
no spaces are allowed.
Option ignoreFinal
allow to skip variables with final
modifier.
Default value is true
.
Option ignoreStatic
allow to skip variables with static
modifier.
Default value is true
.
Option ignoreOverriddenMethod
- Allows to
ignore methods tagged with @Override
annotation
(that usually mean inherited name). Default value is true
.
<module name="AbbreviationAsWordInName" />
To configure to check variables and classes identifiers, do not ignore variables with static modifier and allow no abbreviations (enforce camel case phrase) but allow XML and URL abbreviations.
<module name="AbbreviationAsWordInName"> <property name="tokens" value="VARIABLE_DEF,CLASS_DEF"/> <property name="ignoreStatic" value="false"/> <property name="allowedAbbreviationLength" value="1"/> <property name="allowedAbbreviations" value="XML,URL"/> </module>
Modifier and Type | Field and Description |
---|---|
static String |
MSG_KEY
Warning message key.
|
Constructor and Description |
---|
AbbreviationAsWordInNameCheck() |
Modifier and Type | Method and Description |
---|---|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
void |
setAllowedAbbreviationLength(int allowedAbbreviationLength)
Allowed abbreviation length in names.
|
void |
setAllowedAbbreviations(String allowedAbbreviations)
Set a list of abbreviations that must be skipped for checking.
|
void |
setIgnoreFinal(boolean ignoreFinal)
Sets ignore option for variables with 'final' modifier.
|
void |
setIgnoreOverriddenMethods(boolean ignoreOverriddenMethods)
Sets ignore option for methods with "@Override" annotation.
|
void |
setIgnoreStatic(boolean ignoreStatic)
Sets ignore option for variables with 'static' modifier.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLine, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public static final String MSG_KEY
public AbbreviationAsWordInNameCheck()
public void setIgnoreFinal(boolean ignoreFinal)
ignoreFinal
- Defines if ignore variables with 'final' modifier or not.public void setIgnoreStatic(boolean ignoreStatic)
ignoreStatic
- Defines if ignore variables with 'static' modifier or not.public void setIgnoreOverriddenMethods(boolean ignoreOverriddenMethods)
ignoreOverriddenMethods
- Defines if ignore methods with "@Override" annotation or not.public void setAllowedAbbreviationLength(int allowedAbbreviationLength)
allowedAbbreviationLength
- amount of allowed capital letters in abbreviation.public void setAllowedAbbreviations(String allowedAbbreviations)
allowedAbbreviations
- an string of abbreviations that must be skipped from checking,
each abbreviation separated by comma.public int[] getDefaultTokens()
Check
getDefaultTokens
in class Check
TokenTypes
public void visitToken(DetailAST ast)
Check
visitToken
in class Check
ast
- the token to processCopyright © 2001–2015. All rights reserved.