Class JavadocNoErrorInThrowsTagCheck
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.AbstractCheck
com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocNoErrorInThrowsTagCheck
- All Implemented Interfaces:
Configurable,Contextualizable
Checks that
Error types are not documented in @throws or
@exception Javadoc tags.
Per the documentation comments style guide, errors generally should not be
documented because they are unpredictable. This check reports documented
throwable names whose simple name ends with Error, unless the same
Error type is explicitly thrown with throw new in the documented
method or constructor.
- Since:
- 14.1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA key is pointing to the warning message text in "messages.properties" file.Type names explicitly thrown in the current documented construct.Fields inherited from class com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
MSG_JAVADOC_PARSE_RULE_ERROR, MSG_KEY_UNCLOSED_HTML_TAG -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newJavadocNoErrorInThrowsTagCheckinstance. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcollectThrownErrorType(DetailAST throwAst) Collects type name from athrow newstatement.private voidCollects type names explicitly thrown bythrow newin a construct.int[]Returns the default javadoc token types a check is interested in.int[]Returns the default token a check is interested in.int[]The javadoc tokens that this check must be registered for.final int[]The tokens that this check must be registered for.private static StringgetSimpleName(String className) Gets simple class name.private static StringgetTagName(DetailNode ast) Gets the Javadoc tag name from a throws or exception block tag.private static booleanisErrorType(String className) Checks whether class name is an Error type name.private booleanisExplicitlyThrown(String className) Checks whether Error type is explicitly thrown in current documented construct.private static booleanisInIgnoreBlock(DetailAST constructAst, DetailAST throwAst) Checks if a 'throw' usage is contained within a block that should be ignored.voidCalled to process a Javadoc token.voidvisitToken(DetailAST ast) Called to process a token.Methods inherited from class com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
acceptJavadocWithNonTightHtml, beginJavadocTree, beginTree, destroy, finishJavadocTree, getAcceptableJavadocTokens, getAcceptableTokens, getBlockCommentAst, init, isCommentNodesRequired, leaveJavadocToken, log, setJavadocTokens, setViolateExecutionOnNonTightHtmlMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
clearViolations, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityMethods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
-
Field Details
-
MSG_KEY
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
thrownTypeNames
Type names explicitly thrown in the current documented construct.
-
-
Constructor Details
-
JavadocNoErrorInThrowsTagCheck
public JavadocNoErrorInThrowsTagCheck()Creates a newJavadocNoErrorInThrowsTagCheckinstance.
-
-
Method Details
-
getDefaultTokens
Description copied from class:AbstractCheckReturns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.- Overrides:
getDefaultTokensin classAbstractJavadocCheck- Returns:
- the default tokens
- See Also:
-
getRequiredTokens
Description copied from class:AbstractCheckThe tokens that this check must be registered for.- Overrides:
getRequiredTokensin classAbstractJavadocCheck- Returns:
- the token set this must be registered for.
- See Also:
-
getDefaultJavadocTokens
Description copied from class:AbstractJavadocCheckReturns the default javadoc token types a check is interested in.- Specified by:
getDefaultJavadocTokensin classAbstractJavadocCheck- Returns:
- the default javadoc token types
- See Also:
-
getRequiredJavadocTokens
Description copied from class:AbstractJavadocCheckThe javadoc tokens that this check must be registered for.- Overrides:
getRequiredJavadocTokensin classAbstractJavadocCheck- Returns:
- the javadoc token set this must be registered for.
- See Also:
-
visitToken
Description copied from class:AbstractCheckCalled to process a token.- Overrides:
visitTokenin classAbstractJavadocCheck- Parameters:
ast- the token to process
-
visitJavadocToken
Description copied from class:AbstractJavadocCheckCalled to process a Javadoc token.- Specified by:
visitJavadocTokenin classAbstractJavadocCheck- Parameters:
ast- the token to process
-
collectThrownErrorTypes
Collects type names explicitly thrown bythrow newin a construct.- Parameters:
ast- documented construct
-
collectThrownErrorType
Collects type name from athrow newstatement.- Parameters:
throwAst- throw statement
-
isInIgnoreBlock
Checks if a 'throw' usage is contained within a block that should be ignored. Such blocks consist of try (with catch) blocks, local classes, anonymous classes, and lambda expressions. Note that a try block without catch is not considered.- Parameters:
constructAst- DetailAST node representing the documented constructthrowAst- DetailAST node representing the 'throw' literal- Returns:
- true if throwAst is inside a block that should be ignored
-
isErrorType
Checks whether class name is an Error type name.- Parameters:
className- class name- Returns:
- true if class name is an Error type name
-
isExplicitlyThrown
Checks whether Error type is explicitly thrown in current documented construct.- Parameters:
className- class name- Returns:
- true if Error type is explicitly thrown in current documented construct
-
getSimpleName
Gets simple class name.- Parameters:
className- class name- Returns:
- simple class name
-
getTagName
Gets the Javadoc tag name from a throws or exception block tag.- Parameters:
ast- throws or exception block tag- Returns:
- tag name with leading at sign
-