public class MagicNumberCheck extends Check
Checks for magic numbers.
An example of how to configure the check to ignore numbers 0, 1, 1.5, 2:
<module name="MagicNumber"> <property name="ignoreNumbers" value="0, 1, 1.5, 2"/> <property name="ignoreHashCodeMethod" value="true"/> </module>
Constructor and Description |
---|
MagicNumberCheck() |
Modifier and Type | Method and Description |
---|---|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
void |
setIgnoreAnnotation(boolean ignoreAnnotation)
Set whether to ignore Annotations.
|
void |
setIgnoreHashCodeMethod(boolean ignoreHashCodeMethod)
Set whether to ignore hashCode methods.
|
void |
setIgnoreNumbers(double[] list)
Sets the numbers to ignore in the check.
|
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 MagicNumberCheck()
public int[] getDefaultTokens()
Check
getDefaultTokens
in class Check
TokenTypes
public void visitToken(DetailAST ast)
Check
visitToken
in class Check
ast
- the token to processpublic void setIgnoreNumbers(double[] list)
list
- list of numbers to ignore.public void setIgnoreHashCodeMethod(boolean ignoreHashCodeMethod)
ignoreHashCodeMethod
- decide whether to ignore
hash code methodspublic void setIgnoreAnnotation(boolean ignoreAnnotation)
ignoreAnnotation
- decide whether to ignore annotationsCopyright © 2001–2015. All rights reserved.