Class IllegalCatchExtendedCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.github.sevntu.checkstyle.checks.coding.IllegalCatchExtendedCheck
-
- All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable
,com.puppycrawl.tools.checkstyle.api.Contextualizable
public final class IllegalCatchExtendedCheck extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
Catching java.lang.Exception, java.lang.Error or java.lang.RuntimeException is almost never acceptable.- Since:
- 1.8.0
- Author:
- Simon Harris
-
-
Constructor Summary
Constructors Constructor Description IllegalCatchExtendedCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]
getAcceptableTokens()
int[]
getDefaultTokens()
int[]
getRequiredTokens()
com.puppycrawl.tools.checkstyle.api.DetailAST
getThrowAST(com.puppycrawl.tools.checkstyle.api.DetailAST parentAST)
Looking for the keyword "throw" among current (aParentAST) node childs.protected boolean
isIllegalClassName(String ident)
Checks if given class is illegal.void
setAllowRethrow(boolean value)
Enable(false) | Disable(true) warnings for "catch" blocks containing rethrowing an exception.void
setAllowThrow(boolean value)
Enable(false) | Disable(true) warnings for "catch" blocks containing throwing an exception.void
setIllegalClassNames(String... classNames)
Set the list of illegal classes.void
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST detailAST)
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
beginTree, clearViolations, destroy, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
-
-
-
Field Detail
-
MSG_KEY
public static final String MSG_KEY
Warning message key.- See Also:
- Constant Field Values
-
-
Method Detail
-
setIllegalClassNames
public void setIllegalClassNames(String... classNames)
Set the list of illegal classes.- Parameters:
classNames
- array of illegal exception classes
-
setAllowThrow
public void setAllowThrow(boolean value)
Enable(false) | Disable(true) warnings for "catch" blocks containing throwing an exception.- Parameters:
value
- Disable warning for throwing
-
setAllowRethrow
public void setAllowRethrow(boolean value)
Enable(false) | Disable(true) warnings for "catch" blocks containing rethrowing an exception.- Parameters:
value
- Disable warnings for rethrowing
-
getDefaultTokens
public int[] getDefaultTokens()
- Specified by:
getDefaultTokens
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
getAcceptableTokens
public int[] getAcceptableTokens()
- Specified by:
getAcceptableTokens
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
getRequiredTokens
public int[] getRequiredTokens()
- Specified by:
getRequiredTokens
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
visitToken
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST detailAST)
- Overrides:
visitToken
in classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
getThrowAST
public com.puppycrawl.tools.checkstyle.api.DetailAST getThrowAST(com.puppycrawl.tools.checkstyle.api.DetailAST parentAST)
Looking for the keyword "throw" among current (aParentAST) node childs.- Parameters:
parentAST
- - the current parent node.- Returns:
- null if the "throw" keyword was not found or the LITERAL_THROW DetailAST otherwise
-
isIllegalClassName
protected boolean isIllegalClassName(String ident)
Checks if given class is illegal.- Parameters:
ident
- ident to check.- Returns:
- true if given ident is illegal.
-
-