public class SummaryJavadocCheck extends AbstractJavadocCheck
Checks that Javadoc summary sentence does not contain phrases that are not recommended to use. By default Check validate that first sentence is not empty:
<module name="SummaryJavadocCheck"/>
To ensure that summary do not contain phrase like "This method returns", use following config:
<module name="SummaryJavadocCheck"> <property name="forbiddenSummaryFragments" value="^This method returns.*"/> </module>
To specify period symbol at the end of first javadoc sentence - use following config:
<module name="SummaryJavadocCheck"> <property name="period" value="period"/> </module>
Modifier and Type | Field and Description |
---|---|
private java.util.regex.Pattern |
forbiddenSummaryFragments
Regular expression for forbidden summary fragments.
|
private static java.util.regex.Pattern |
JAVADOC_MULTILINE_TO_SINGLELINE_PATTERN
This regexp is used to convert multiline javadoc to single line without stars.
|
static java.lang.String |
MSG_SUMMARY_FIRST_SENTENCE
A key is pointing to the warning message text in "messages.properties"
file.
|
static java.lang.String |
MSG_SUMMARY_JAVADOC
A key is pointing to the warning message text in "messages.properties"
file.
|
private java.lang.String |
period
Period symbol at the end of first javadoc sentence.
|
private static java.lang.String |
PERIOD
Period literal.
|
private static java.util.Set<java.lang.Integer> |
SKIP_TOKENS
Stores allowed values in document for inherit doc literal.
|
MSG_JAVADOC_MISSED_HTML_CLOSE, MSG_JAVADOC_PARSE_RULE_ERROR, MSG_JAVADOC_WRONG_SINGLETON_TAG, MSG_KEY_PARSE_ERROR, MSG_KEY_UNRECOGNIZED_ANTLR_ERROR
Constructor and Description |
---|
SummaryJavadocCheck() |
Modifier and Type | Method and Description |
---|---|
private boolean |
containsForbiddenFragment(java.lang.String firstSentence)
Tests if first sentence contains forbidden summary fragment.
|
int[] |
getDefaultJavadocTokens()
Returns the default javadoc token types a check is interested in.
|
private static java.lang.String |
getFirstSentence(DetailNode ast)
Finds and returns first sentence.
|
int[] |
getRequiredJavadocTokens()
The javadoc tokens that this check must be registered for.
|
private static boolean |
isOnlyInheritDoc(DetailNode ast)
Finds if inheritDoc is placed properly in java doc.
|
void |
setForbiddenSummaryFragments(java.util.regex.Pattern pattern)
Sets custom value of regular expression for forbidden summary fragments.
|
void |
setPeriod(java.lang.String period)
Sets value of period symbol at the end of first javadoc sentence.
|
void |
visitJavadocToken(DetailNode ast)
Called to process a Javadoc token.
|
beginJavadocTree, beginTree, finishJavadocTree, finishTree, getAcceptableJavadocTokens, getAcceptableTokens, getBlockCommentAst, getDefaultTokens, getRequiredTokens, init, isCommentNodesRequired, leaveJavadocToken, setJavadocTokens, visitToken
destroy, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public static final java.lang.String MSG_SUMMARY_FIRST_SENTENCE
public static final java.lang.String MSG_SUMMARY_JAVADOC
private static final java.util.regex.Pattern JAVADOC_MULTILINE_TO_SINGLELINE_PATTERN
private static final java.lang.String PERIOD
private static final java.util.Set<java.lang.Integer> SKIP_TOKENS
private java.util.regex.Pattern forbiddenSummaryFragments
private java.lang.String period
public void setForbiddenSummaryFragments(java.util.regex.Pattern pattern)
pattern
- a pattern.public void setPeriod(java.lang.String period)
period
- period's value.public int[] getDefaultJavadocTokens()
AbstractJavadocCheck
getDefaultJavadocTokens
in class AbstractJavadocCheck
JavadocTokenTypes
public int[] getRequiredJavadocTokens()
AbstractJavadocCheck
getRequiredJavadocTokens
in class AbstractJavadocCheck
JavadocTokenTypes
public void visitJavadocToken(DetailNode ast)
AbstractJavadocCheck
visitJavadocToken
in class AbstractJavadocCheck
ast
- the token to processprivate static boolean isOnlyInheritDoc(DetailNode ast)
ast
- Javadoc root node.private static java.lang.String getFirstSentence(DetailNode ast)
ast
- Javadoc root node.private boolean containsForbiddenFragment(java.lang.String firstSentence)
firstSentence
- String with first sentence.