Class JavadocTypeCheck
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.JavadocTypeCheck
- All Implemented Interfaces:
Configurable,Contextualizable
Checks the Javadoc comments for type definitions. By default, does
not check for author or version tags. The scope to verify is specified using the
Scope
class and defaults to Scope.PRIVATE. To verify another scope, set property
scope to one of the Scope constants. To define the format for an author
tag or a version tag, set property authorFormat or versionFormat respectively to a
pattern.
Does not perform checks for author and version tags for inner classes, as they should be redundant because of outer class.
Does not perform checks for type definitions that do not have any Javadoc comments.
Error messages about type parameters and record components for which no param tags are present
can be suppressed by defining property allowMissingParamTags.
- Since:
- 3.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionSpecify annotations that allow skipping validation at all.private booleanControl whether to ignore violations when a class has type parameters but does not have matching param tags in the Javadoc.private booleanControl whether to ignore violations when a Javadoc tag is not recognised.private static final StringAuthor tag literal.private PatternSpecify the pattern for@authortag.private booleanWhether an@authortag was found in the current Javadoc tree.private static final StringClose angle bracket literal.private DetailASTJava AST node whose attached Javadoc is currently being processed.private ScopeSpecify the visibility scope where Javadoc comments are not checked.private final Map<DetailNode, String> Javadoc param tag names, mapped by their corresponding Javadoc node.static final StringA key is pointing to the warning message text in "messages.properties" file.static final StringA key is pointing to the warning message text in "messages.properties" file.static final StringA key is pointing to the warning message text in "messages.properties" file.static final StringA key is pointing to the warning message text in "messages.properties" file.static final StringA key is pointing to the warning message text in "messages.properties" file.static final StringA key is pointing to the warning message text in "messages.properties" file.private static final StringOpen angle bracket literal.private ScopeSpecify the visibility scope where Javadoc comments are checked.private static final StringVersion tag literal.private PatternSpecify the pattern for@versiontag.private booleanWhether a@versiontag was found in the current Javadoc tree.Fields inherited from class com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
MSG_JAVADOC_PARSE_RULE_ERROR, MSG_KEY_UNCLOSED_HTML_TAG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeginJavadocTree(DetailNode rootAst) Called before the starting to process a tree.private voidChecks collected Javadoc param tags against the current AST node.private voidcheckTagFormat(DetailNode ast, String tagName, Pattern format) Checks a Javadoc tag description against the expected format.private voidChecks an unknown Javadoc tag.private voidcollectParam(DetailNode ast) Collects a param tag.voidfinishJavadocTree(DetailNode rootAst) Called after finished processing a tree.int[]The configurable token set.int[]Returns the default javadoc token types a check is interested in.int[]Returns the default token a check is interested in.Collects the record component names in a record definition.int[]The javadoc tokens that this check must be registered for.int[]The tokens that this check must be registered for.voidsetAllowedAnnotations(String... userAnnotations) Setter to specify annotations that allow skipping validation at all.voidsetAllowMissingParamTags(boolean flag) Setter to control whether to ignore violations when a class has type parameters but does not have matching param tags in the Javadoc.voidsetAllowUnknownTags(boolean flag) Setter to control whether to ignore violations when a Javadoc tag is not recognised.voidsetAuthorFormat(Pattern pattern) Setter to specify the pattern for@authortag.voidsetExcludeScope(Scope excludeScope) Setter to specify the visibility scope where Javadoc comments are not checked.voidSetter to specify the visibility scope where Javadoc comments are checked.voidsetVersionFormat(Pattern pattern) Setter to specify the pattern for@versiontag.voidsetViolateExecutionOnNonTightHtml(boolean shouldReportViolation) Setter to control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules.private booleanshouldCheck(DetailAST ast) Whether we should check this node.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, beginTree, destroy, getAcceptableJavadocTokens, getBlockCommentAst, init, isCommentNodesRequired, leaveJavadocToken, log, setJavadocTokensMethods 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_UNKNOWN_TAG
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
MSG_TAG_FORMAT
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
MSG_MISSING_TAG
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
MSG_MISSING_TAG_WITH_QUOTES
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
MSG_UNUSED_TAG
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
MSG_UNUSED_TAG_GENERAL
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
OPEN_ANGLE_BRACKET
Open angle bracket literal.- See Also:
-
CLOSE_ANGLE_BRACKET
Close angle bracket literal.- See Also:
-
AUTHOR_TAG_NAME
Author tag literal.- See Also:
-
VERSION_TAG_NAME
Version tag literal.- See Also:
-
javadocTags
Javadoc param tag names, mapped by their corresponding Javadoc node. -
scope
Specify the visibility scope where Javadoc comments are checked. -
excludeScope
Specify the visibility scope where Javadoc comments are not checked. -
authorFormat
Specify the pattern for@authortag. -
versionFormat
Specify the pattern for@versiontag. -
allowMissingParamTags
Control whether to ignore violations when a class has type parameters but does not have matching param tags in the Javadoc. -
allowUnknownTags
Control whether to ignore violations when a Javadoc tag is not recognised. -
allowedAnnotations
Specify annotations that allow skipping validation at all. Only short names are allowed, e.g.Generated. -
currentAst
Java AST node whose attached Javadoc is currently being processed. -
authorTagIsPresent
Whether an@authortag was found in the current Javadoc tree. -
versionTagIsPresent
Whether a@versiontag was found in the current Javadoc tree.
-
-
Constructor Details
-
JavadocTypeCheck
public JavadocTypeCheck()Creates a newJavadocTypeCheckinstance.
-
-
Method Details
-
setScope
Setter to specify the visibility scope where Javadoc comments are checked.- Parameters:
scope- a scope.- Since:
- 3.0
-
setExcludeScope
Setter to specify the visibility scope where Javadoc comments are not checked.- Parameters:
excludeScope- a scope.- Since:
- 3.4
-
setAuthorFormat
Setter to specify the pattern for@authortag.- Parameters:
pattern- a pattern.- Since:
- 3.0
-
setVersionFormat
Setter to specify the pattern for@versiontag.- Parameters:
pattern- a pattern.- Since:
- 3.0
-
setAllowMissingParamTags
Setter to control whether to ignore violations when a class has type parameters but does not have matching param tags in the Javadoc.- Parameters:
flag- aBooleanvalue- Since:
- 4.0
-
setAllowUnknownTags
Setter to control whether to ignore violations when a Javadoc tag is not recognised.- Parameters:
flag- aBooleanvalue- Since:
- 5.1
-
setAllowedAnnotations
Setter to specify annotations that allow skipping validation at all. Only short names are allowed, e.g.Generated.- Parameters:
userAnnotations- user's value.- Since:
- 8.15
-
setViolateExecutionOnNonTightHtml
Setter to control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules.- Overrides:
setViolateExecutionOnNonTightHtmlin classAbstractJavadocCheck- Parameters:
shouldReportViolation- value to which the field shall be set to- Since:
- 8.3
-
beginJavadocTree
Description copied from class:AbstractJavadocCheckCalled before the starting to process a tree.- Overrides:
beginJavadocTreein classAbstractJavadocCheck- Parameters:
rootAst- the root of the tree
-
finishJavadocTree
Description copied from class:AbstractJavadocCheckCalled after finished processing a tree.- Overrides:
finishJavadocTreein classAbstractJavadocCheck- Parameters:
rootAst- the root of the tree
-
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:
-
visitJavadocToken
Description copied from class:AbstractJavadocCheckCalled to process a Javadoc token.- Specified by:
visitJavadocTokenin classAbstractJavadocCheck- Parameters:
ast- the token to process
-
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:
-
getAcceptableTokens
Description copied from class:AbstractCheckThe configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.- Overrides:
getAcceptableTokensin classAbstractJavadocCheck- Returns:
- the token set this check is designed for.
- 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:
-
visitToken
Description copied from class:AbstractCheckCalled to process a token.- Overrides:
visitTokenin classAbstractJavadocCheck- Parameters:
ast- the token to process
-
shouldCheck
Whether we should check this node.- Parameters:
ast- a given node.- Returns:
- whether we should check a given node.
-
collectParam
Collects a param tag.- Parameters:
ast- the param tag node
-
checkUnknownTag
Checks an unknown Javadoc tag.- Parameters:
ast- the unknown tag node
-
checkTagFormat
Checks a Javadoc tag description against the expected format.- Parameters:
ast- the Javadoc tag nodetagName- the tag nameformat- expected format for the tag description
-
checkCollectedParamTags
Checks collected Javadoc param tags against the current AST node. -
getRecordComponentNames
Collects the record component names in a record definition.- Parameters:
node- the possible record definition AST- Returns:
- the record component names in this record definition
-