Package com.qulice.checkstyle
Class NonStaticMethodCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.qulice.checkstyle.NonStaticMethodCheck
-
- All Implemented Interfaces:
Configurable
,Contextualizable
public final class NonStaticMethodCheck extends AbstractCheck
Checks that non static method must contain at least one reference tothis
.If your method doesn't need
this
than why it is notstatic
? The exception here is when method has@Override
annotation. There's no concept of inheritance and polymorphism for static methods even if they don't needthis
to perform the actual work. Another exception is when method isabstract
ornative
. Such methods don't have body so detection based onthis
doesn't make sense for them.- Since:
- 0.3
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Constructor Summary
Constructors Constructor Description NonStaticMethodCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]
getAcceptableTokens()
int[]
getDefaultTokens()
int[]
getRequiredTokens()
void
setExcludeFileNamePattern(String excl)
Exclude files matching given pattern.void
visitToken(DetailAST ast)
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
beginTree, clearMessages, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setClassLoader, setFileContents, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Method Detail
-
setExcludeFileNamePattern
public void setExcludeFileNamePattern(String excl)
Exclude files matching given pattern.- Parameters:
excl
- Regexp of classes to exclude.
-
getDefaultTokens
public int[] getDefaultTokens()
- Specified by:
getDefaultTokens
in classAbstractCheck
-
getAcceptableTokens
public int[] getAcceptableTokens()
- Specified by:
getAcceptableTokens
in classAbstractCheck
-
getRequiredTokens
public int[] getRequiredTokens()
- Specified by:
getRequiredTokens
in classAbstractCheck
-
visitToken
public void visitToken(DetailAST ast)
- Overrides:
visitToken
in classAbstractCheck
-
-