public class RequireEmptyLineBeforeBlockTagGroupCheck extends AbstractJavadocCheck
Checks that one blank line before the block tag if it is present in Javadoc.
violateExecutionOnNonTightHtml - Control when to print violations
if the Javadoc being examined by this check violates the tight html rules defined at
Tight-HTML Rules.
Type is boolean.
Default value is false.
To configure the check:
<module name="RequireEmptyLineBeforeBlockTagGroup"/>
By default, the check will report a violation if there is no blank line before the block tag, like in the example below.
/**
* testMethod's javadoc.
* @return something (violation)
*/
public boolean testMethod() {
return false;
}
Valid javadoc should have a blank line separating the parameters, return, throw, or other tags like in the example below.
/**
* testMethod's javadoc.
*
* @param firstParam
* @return something
*/
public boolean testMethod(int firstParam) {
return false;
}
Parent is com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
javadoc.missed.html.close
javadoc.parse.rule.error
javadoc.tag.line.before
javadoc.wrong.singleton.html.tag
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MSG_JAVADOC_TAG_LINE_BEFORE
The key in "messages.properties" for the message that describes a tag in javadoc
requiring an empty line before it.
|
private static java.util.List<java.lang.Integer> |
ONLY_TAG_VARIATION_1
Case when space separates the tag and the asterisk like in the below example.
|
private static java.util.List<java.lang.Integer> |
ONLY_TAG_VARIATION_2
Case when no space separates the tag and the asterisk like in the below example.
|
MSG_JAVADOC_MISSED_HTML_CLOSE, MSG_JAVADOC_PARSE_RULE_ERROR, MSG_JAVADOC_WRONG_SINGLETON_TAG| Constructor and Description |
|---|
RequireEmptyLineBeforeBlockTagGroupCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getDefaultJavadocTokens()
Returns only javadoc tags so visitJavadocToken only receives javadoc tags.
|
int[] |
getRequiredJavadocTokens()
The javadoc tokens that this check must be registered for.
|
private static boolean |
hasInsufficientConsecutiveNewlines(DetailNode tagNode)
Returns true when there are not enough empty lines before the provided tagNode.
|
private static boolean |
isAnotherTagBefore(DetailNode tagNode)
Returns true when there is a javadoc tag before the provided tagNode.
|
private static boolean |
isOnlyTagInWholeJavadoc(DetailNode tagNode)
Returns true when there are is only whitespace and asterisks before the provided tagNode.
|
void |
visitJavadocToken(DetailNode tagNode)
Logs when there is no empty line before the tag.
|
acceptJavadocWithNonTightHtml, beginJavadocTree, beginTree, destroy, finishJavadocTree, finishTree, getAcceptableJavadocTokens, getAcceptableTokens, getBlockCommentAst, getDefaultTokens, getRequiredTokens, init, isCommentNodesRequired, leaveJavadocToken, setJavadocTokens, setViolateExecutionOnNonTightHtml, visitTokenclearViolations, getFileContents, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic static final java.lang.String MSG_JAVADOC_TAG_LINE_BEFORE
private static final java.util.List<java.lang.Integer> ONLY_TAG_VARIATION_1
/** * @param noSpace there is no space here
private static final java.util.List<java.lang.Integer> ONLY_TAG_VARIATION_2
/** *@param noSpace there is no space here
public RequireEmptyLineBeforeBlockTagGroupCheck()
public int[] getDefaultJavadocTokens()
getDefaultJavadocTokens in class AbstractJavadocCheckJavadocTokenTypespublic int[] getRequiredJavadocTokens()
AbstractJavadocCheckgetRequiredJavadocTokens in class AbstractJavadocCheckJavadocTokenTypespublic void visitJavadocToken(DetailNode tagNode)
visitJavadocToken in class AbstractJavadocChecktagNode - the at tag node to check for an empty space before it.private static boolean isAnotherTagBefore(DetailNode tagNode)
tagNode - the javadoc tag node, to look for more tags before it.private static boolean isOnlyTagInWholeJavadoc(DetailNode tagNode)
JAVADOC[3x0] |--NEWLINE[3x0] : [\n] |--LEADING_ASTERISK[4x0] : [ *] |--WS[4x2] : [ ] |--JAVADOC_TAG[4x3] : [@param T The bar.\n ]Or it can also look like:
JAVADOC[3x0] |--NEWLINE[3x0] : [\n] |--LEADING_ASTERISK[4x0] : [ *] |--JAVADOC_TAG[4x3] : [@param T The bar.\n ]We do not include the variation
/**@param noSpace there is no space herewhich results in the tree
JAVADOC[3x0] |--JAVADOC_TAG[4x3] : [@param noSpace there is no space here\n ]because this one is invalid. We must recommend placing a blank line to separate @param from the first javadoc asterisks.
tagNode - the at tag node to check if there is nothing before it.private static boolean hasInsufficientConsecutiveNewlines(DetailNode tagNode)
Iterates through the previous siblings of the tagNode looking for empty lines until there are no more siblings or it hits something other than asterisk, whitespace or newline. If it finds at least one empty line, return true. Return false otherwise.
tagNode - the tagNode to check if there are sufficient empty lines before it.Copyright © 2001-2022. All Rights Reserved.