Class IllegalMethodCallCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.thomasjensen.checkstyle.addons.checks.AbstractAddonsCheck
-
- com.thomasjensen.checkstyle.addons.checks.AbstractMethodCallCheck
-
- com.thomasjensen.checkstyle.addons.checks.coding.IllegalMethodCallCheck
-
- All Implemented Interfaces:
Configurable
,Contextualizable
public class IllegalMethodCallCheck extends AbstractMethodCallCheck
Flags calls to methods with certain names. Occurrences are flagged based on the name alone; the type of the object to which the method belongs is not taken into account.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Constructor Summary
Constructors Constructor Description IllegalMethodCallCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
isCheckActive()
Determines if the check is configured to do anything at all.protected boolean
isRelevantCall(String pQualifier, String pMethodName)
Filter method which determines if the given method call is considered relevant.void
setExcludedQualifiers(String... pExcludedQualifiers)
Setter.void
setIllegalMethodNames(String... pIllegalMethodNames)
Setter.protected void
visitMethodCall(String pMethodName, DetailAST pMethodCallAst)
Visitor method called when a relevant method call is encountered.-
Methods inherited from class com.thomasjensen.checkstyle.addons.checks.AbstractMethodCallCheck
beginTree, getCurrentMethodName, getRelevantTokens, leaveToken, visitToken
-
Methods inherited from class com.thomasjensen.checkstyle.addons.checks.AbstractAddonsCheck
finishTree, finishTree, getAcceptableTokens, getApiFixer, getClassDeclarationPosition, getCurrentBinaryName, getCurrentSimpleName, getDefaultTokens, getMyPackage, getRequiredTokens, leaveKnownType, leaveToken, visitKnownType, visitToken
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
clearViolations, destroy, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, log, log, log, 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
-
isCheckActive
protected boolean isCheckActive()
Description copied from class:AbstractMethodCallCheck
Determines if the check is configured to do anything at all.- Specified by:
isCheckActive
in classAbstractMethodCallCheck
- Returns:
true
if processing should be performed
-
isRelevantCall
protected boolean isRelevantCall(@Nullable String pQualifier, @Nonnull String pMethodName)
Description copied from class:AbstractMethodCallCheck
Filter method which determines if the given method call is considered relevant.- Specified by:
isRelevantCall
in classAbstractMethodCallCheck
- Parameters:
pQualifier
- the qualifier of the method call (for a call likeFoo.Bar.call()
, the qualifier isFoo.Bar
)pMethodName
- the simple name of the called method- Returns:
- indication of whether the call is relevant (
true
) or not (false
)
-
visitMethodCall
protected void visitMethodCall(@Nonnull String pMethodName, @Nonnull DetailAST pMethodCallAst)
Description copied from class:AbstractMethodCallCheck
Visitor method called when a relevant method call is encountered. This method is called in addition to the other visitor methods.- Specified by:
visitMethodCall
in classAbstractMethodCallCheck
- Parameters:
pMethodName
- the simple name of the called methodpMethodCallAst
- AST of the call, useful for logging issues ( this is a METHOD_DEF, CTOR_CALL, or a SUPER_CTOR_CALL token)
-
setIllegalMethodNames
public void setIllegalMethodNames(String... pIllegalMethodNames)
Setter.- Parameters:
pIllegalMethodNames
- the list of method names to flag
-
setExcludedQualifiers
public void setExcludedQualifiers(String... pExcludedQualifiers)
Setter.- Parameters:
pExcludedQualifiers
- the list of excluded contexts
-
-