Refactored UTs, javadoc package, issue #537

This commit is contained in:
alexkravin 2015-02-20 17:01:02 +04:00
parent d8f8de2b53
commit cee4f35194
26 changed files with 921 additions and 676 deletions

View File

@ -57,12 +57,12 @@ public abstract class AbstractJavadocCheck extends Check
/**
* Error message key for common javadoc errors.
*/
private static final String PARSE_ERROR_MESSAGE_KEY = "javadoc.parse.error";
public static final String PARSE_ERROR_MESSAGE_KEY = "javadoc.parse.error";
/**
* Unrecognized error from antlr parser
* Unrecognized error from antlr parser.
*/
private static final String UNRECOGNIZED_ANTLR_ERROR_MESSAGE_KEY =
public static final String UNRECOGNIZED_ANTLR_ERROR_MESSAGE_KEY =
"javadoc.unrecognized.antlr.error";
/**

View File

@ -63,6 +63,12 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class AtclauseOrderCheck extends AbstractJavadocCheck
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_KEY = "at.clause.order";
/**
* Default order of atclauses.
*/
@ -151,7 +157,7 @@ public class AtclauseOrderCheck extends AbstractJavadocCheck
if (tagOrder.contains(tagText)
&& indexOrderOfCurrentTag < indexOrderOfPreviousTag)
{
log(node.getLineNumber(), "at.clause.order", tagOrder.toString());
log(node.getLineNumber(), MSG_KEY, tagOrder.toString());
}
indexOrderOfPreviousTag = indexOrderOfCurrentTag;
}

View File

@ -54,6 +54,55 @@ import java.util.regex.Pattern;
@SuppressWarnings("deprecation")
public class JavadocMethodCheck extends AbstractTypeAwareCheck
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_JAVADOC_MISSING = "javadoc.missing";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_CLASS_INFO = "javadoc.classInfo";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_UNUSED_TAG_GENERAL = "javadoc.unusedTagGeneral";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_INVALID_INHERIT_DOC = "javadoc.invalidInheritDoc";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_UNUSED_TAG = "javadoc.unusedTag";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_EXCPECTED_TAG = "javadoc.expectedTag";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_RETURN_EXPECTED = "javadoc.return.expected";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_DUPLICATE_TAG = "javadoc.duplicateTag";
/** compiled regexp to match Javadoc tags that take an argument * */
private static final Pattern MATCH_JAVADOC_ARG =
Utils.createPattern("@(throws|exception|param)\\s+(\\S+)\\s+\\S*");
@ -330,7 +379,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
if (cmt == null) {
if (!isMissingJavadocAllowed(ast)) {
log(ast, "javadoc.missing");
log(ast, MSG_JAVADOC_MISSING);
}
}
else {
@ -386,7 +435,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
protected final void logLoadError(Token ident)
{
logLoadErrorImpl(ident.getLineNo(), ident.getColumnNo(),
"javadoc.classInfo",
MSG_CLASS_INFO,
JavadocTagInfo.THROWS.getText(), ident.getText());
}
@ -480,7 +529,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
while (it.hasNext()) {
final JavadocTag jt = it.next();
if (!jt.isSeeOrInheritDocTag()) {
log(jt.getLineNo(), "javadoc.unusedTagGeneral");
log(jt.getLineNo(), MSG_UNUSED_TAG_GENERAL);
}
}
}
@ -505,7 +554,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
// Invalid if private, a constructor, or a static method
if (!JavadocTagInfo.INHERIT_DOC.isValidOn(ast)) {
log(ast, "javadoc.invalidInheritDoc");
log(ast, MSG_INVALID_INHERIT_DOC);
}
return true;
@ -745,7 +794,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
// Handle extra JavadocTag
if (!found) {
log(tag.getLineNo(), tag.getColumnNo(), "javadoc.unusedTag",
log(tag.getLineNo(), tag.getColumnNo(), MSG_UNUSED_TAG,
"@param", tag.getArg1());
}
}
@ -754,12 +803,12 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
// the user has chosen to suppress these problems
if (!allowMissingParamTags && reportExpectedTags) {
for (DetailAST param : params) {
log(param, "javadoc.expectedTag",
log(param, MSG_EXCPECTED_TAG,
JavadocTagInfo.PARAM.getText(), param.getText());
}
for (DetailAST typeParam : typeParams) {
log(typeParam, "javadoc.expectedTag",
log(typeParam, MSG_EXCPECTED_TAG,
JavadocTagInfo.PARAM.getText(),
"<" + typeParam.findFirstToken(TokenTypes.IDENT).getText()
+ ">");
@ -808,7 +857,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
if (jt.isReturnTag()) {
if (found) {
log(jt.getLineNo(), jt.getColumnNo(),
"javadoc.duplicateTag",
MSG_DUPLICATE_TAG,
JavadocTagInfo.RETURN.getText());
}
found = true;
@ -819,7 +868,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
// Handle there being no @return tags :- unless
// the user has chosen to suppress these problems
if (!found && !allowMissingReturnTag && reportExpectedTags) {
log(lineNo, "javadoc.return.expected");
log(lineNo, MSG_RETURN_EXPECTED);
}
}
@ -893,7 +942,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
if (reqd && validateThrows) {
log(tag.getLineNo(), tag.getColumnNo(),
"javadoc.unusedTag",
MSG_UNUSED_TAG,
JavadocTagInfo.THROWS.getText(), tag.getArg1());
}
@ -907,7 +956,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
if (!ei.isFound()) {
final Token fi = ei.getName();
log(fi.getLineNo(), fi.getColumnNo(),
"javadoc.expectedTag",
MSG_EXCPECTED_TAG,
JavadocTagInfo.THROWS.getText(), fi.getText());
}
}

View File

@ -31,6 +31,19 @@ import java.util.Set;
*/
public class JavadocPackageCheck extends AbstractFileSetCheck
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_LEGACY_PACKAGE_HTML = "javadoc.legacyPackageHtml";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_PACKAGE_INFO = "javadoc.packageInfo";
/** Indicates if allow legacy "package.html" file to be used. */
private boolean allowLegacy;
/** The directories checked. */
@ -69,11 +82,11 @@ public class JavadocPackageCheck extends AbstractFileSetCheck
if (packageInfo.exists()) {
if (packageHtml.exists()) {
log(0, "javadoc.legacyPackageHtml");
log(0, MSG_LEGACY_PACKAGE_HTML);
}
}
else if (!allowLegacy || !packageHtml.exists()) {
log(0, "javadoc.packageInfo");
log(0, MSG_PACKAGE_INFO);
}
}

View File

@ -43,6 +43,24 @@ import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes;
public class JavadocParagraphCheck extends AbstractJavadocCheck
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_TAG_AFTER = "javadoc.paragraph.tag.after";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_LINE_BEFORE = "javadoc.paragraph.line.before";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_REDUNDANT_PARAGRAPH = "javadoc.paragraph.redundant.paragraph";
@Override
public int[] getDefaultJavadocTokens()
{
@ -76,7 +94,7 @@ public class JavadocParagraphCheck extends AbstractJavadocCheck
&& nearestToken.getType() == JavadocTokenTypes.TEXT
&& nearestToken.getChildren().length > 1)
{
log(newline.getLineNumber(), "javadoc.paragraph.tag.after");
log(newline.getLineNumber(), MSG_TAG_AFTER);
}
}
@ -88,10 +106,10 @@ public class JavadocParagraphCheck extends AbstractJavadocCheck
{
final DetailNode newLine = getNearestEmptyLine(tag);
if (isFirstParagraph(tag)) {
log(tag.getLineNumber(), "javadoc.paragraph.redundant.paragraph");
log(tag.getLineNumber(), MSG_REDUNDANT_PARAGRAPH);
}
else if (newLine == null || tag.getLineNumber() - newLine.getLineNumber() != 1) {
log(tag.getLineNumber(), "javadoc.paragraph.line.before");
log(tag.getLineNumber(), MSG_LINE_BEFORE);
}
}

View File

@ -44,11 +44,24 @@ import java.util.regex.Pattern;
public class JavadocStyleCheck
extends Check
{
/** Message property key for the Unclosed HTML message. */
private static final String UNCLOSED_HTML = "javadoc.unclosedhtml";
public static final String JAVADOC_MISSING = "javadoc.missing";
/** Message property key for the Unclosed HTML message. */
public static final String EMPTY = "javadoc.empty";
/** Message property key for the Unclosed HTML message. */
public static final String NO_PERIOD = "javadoc.noperiod";
/** Message property key for the Unclosed HTML message. */
public static final String INCOMPLETE_TAG = "javadoc.incompleteTag";
/** Message property key for the Unclosed HTML message. */
public static final String UNCLOSED_HTML = "javadoc.unclosedhtml";
/** Message property key for the Extra HTML message. */
private static final String EXTRA_HTML = "javadoc.extrahtml";
public static final String EXTRA_HTML = "javadoc.extrahtml";
/** HTML tags that do not require a close tag. */
private static final Set<String> SINGLE_TAGS = ImmutableSortedSet.of(
@ -198,7 +211,7 @@ public class JavadocStyleCheck
made sense to make another csheck just to ensure that the
package-info.java file actually contains package Javadocs.*/
if (getFileContents().inPackageInfo()) {
log(ast.getLineNo(), "javadoc.missing");
log(ast.getLineNo(), JAVADOC_MISSING);
}
return;
}
@ -235,7 +248,7 @@ public class JavadocStyleCheck
&& !("{@inheritDoc}".equals(commentText)
&& JavadocTagInfo.INHERIT_DOC.isValidOn(ast)))
{
log(comment.getStartLineNo(), "javadoc.noperiod");
log(comment.getStartLineNo(), NO_PERIOD);
}
}
@ -249,7 +262,7 @@ public class JavadocStyleCheck
final String commentText = getCommentText(comment.getText());
if (commentText.length() == 0) {
log(comment.getStartLineNo(), "javadoc.empty");
log(comment.getStartLineNo(), EMPTY);
}
}
@ -358,7 +371,7 @@ public class JavadocStyleCheck
final HtmlTag tag = parser.nextTag();
if (tag.isIncompleteTag()) {
log(tag.getLineno(), "javadoc.incompleteTag",
log(tag.getLineno(), INCOMPLETE_TAG,
text[tag.getLineno() - lineno]);
return;
}

View File

@ -43,6 +43,12 @@ import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes;
public class JavadocTagContinuationIndentationCheck extends AbstractJavadocCheck
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_KEY = "tag.continuation.indent";
/** Default tag continuation indentation */
private static final int DEFAULT_INDENTATION = 4;
@ -83,7 +89,7 @@ public class JavadocTagContinuationIndentationCheck extends AbstractJavadocCheck
if (whitespace.getType() == JavadocTokenTypes.WS
&& whitespace.getText().length() - 1 < offset)
{
log(textNode.getLineNumber(), "tag.continuation.indent", offset);
log(textNode.getLineNumber(), MSG_KEY, offset);
}
}
}

View File

@ -43,6 +43,43 @@ import org.apache.commons.beanutils.ConversionException;
public class JavadocTypeCheck
extends Check
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String JAVADOC_MISSING = "javadoc.missing";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String UNKNOWN_TAG = "javadoc.unknownTag";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String TAG_FORMAT = "type.tagFormat";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MISSING_TAG = "type.missingTag";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String UNUSED_TAG = "javadoc.unusedTag";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String UNUSED_TAG_GENERAL = "javadoc.unusedTagGeneral";
/** the scope to check for */
private Scope scope = Scope.PRIVATE;
/** the visibility scope where Javadoc comments shouldn't be checked **/
@ -166,7 +203,7 @@ public class JavadocTypeCheck
final int lineNo = ast.getLineNo();
final TextBlock cmt = contents.getJavadocBefore(lineNo);
if (cmt == null) {
log(lineNo, "javadoc.missing");
log(lineNo, JAVADOC_MISSING);
}
else if (ScopeUtils.isOuterMostType(ast)) {
// don't check author/version for inner classes
@ -225,7 +262,7 @@ public class JavadocTypeCheck
JavadocUtils.JavadocTagType.BLOCK);
if (!allowUnknownTags) {
for (final InvalidJavadocTag tag : tags.getInvalidTags()) {
log(tag.getLine(), tag.getCol(), "javadoc.unknownTag",
log(tag.getLine(), tag.getCol(), UNKNOWN_TAG,
tag.getName());
}
}
@ -253,12 +290,12 @@ public class JavadocTypeCheck
if (tag.getTagName().equals(tagName)) {
tagCount++;
if (!formatPattern.matcher(tag.getArg1()).find()) {
log(lineNo, "type.tagFormat", "@" + tagName, format);
log(lineNo, TAG_FORMAT, "@" + tagName, format);
}
}
}
if (tagCount == 0) {
log(lineNo, "type.missingTag", "@" + tagName);
log(lineNo, MISSING_TAG, "@" + tagName);
}
}
@ -283,7 +320,7 @@ public class JavadocTypeCheck
}
}
if (!found) {
log(lineNo, "type.missingTag",
log(lineNo, MISSING_TAG,
JavadocTagInfo.PARAM.getText() + " <" + typeParamName + ">");
}
}
@ -311,19 +348,19 @@ public class JavadocTypeCheck
typeParamName = matcher.group(1).trim();
if (!typeParamNames.contains(typeParamName)) {
log(tag.getLineNo(), tag.getColumnNo(),
"javadoc.unusedTag",
UNUSED_TAG,
JavadocTagInfo.PARAM.getText(),
"<" + typeParamName + ">");
}
}
else {
log(tag.getLineNo(), tag.getColumnNo(),
"javadoc.unusedTagGeneral");
UNUSED_TAG_GENERAL);
}
}
else {
log(tag.getLineNo(), tag.getColumnNo(),
"javadoc.unusedTagGeneral");
UNUSED_TAG_GENERAL);
}
}
}

View File

@ -37,6 +37,13 @@ import java.util.regex.Pattern;
public class JavadocVariableCheck
extends Check
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String JAVADOC_MISSING = "javadoc.missing";
/** the scope to check */
private Scope scope = Scope.PRIVATE;
@ -118,7 +125,7 @@ public class JavadocVariableCheck
contents.getJavadocBefore(ast.getLineNo());
if (cmt == null) {
log(ast, "javadoc.missing");
log(ast, JAVADOC_MISSING);
}
}
}

View File

@ -45,6 +45,12 @@ import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes;
public class NonEmptyAtclauseDescriptionCheck extends AbstractJavadocCheck
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_KEY = "non.empty.atclause";
@Override
public int[] getDefaultJavadocTokens()
{
@ -60,7 +66,7 @@ public class NonEmptyAtclauseDescriptionCheck extends AbstractJavadocCheck
public void visitJavadocToken(DetailNode ast)
{
if (isEmptyTag(ast.getParent())) {
log(ast.getLineNumber(), "non.empty.atclause", ast.getText());
log(ast.getLineNumber(), MSG_KEY, ast.getText());
}
}

View File

@ -39,6 +39,12 @@ import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes;
public class SingleLineJavadocCheck extends AbstractJavadocCheck
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_KEY = "singleline.javadoc";
@Override
public int[] getDefaultJavadocTokens()
{

View File

@ -59,6 +59,18 @@ import com.puppycrawl.tools.checkstyle.api.Utils;
public class SummaryJavadocCheck extends AbstractJavadocCheck
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String SUMMARY_FIRST_SENTENCE = "summary.first.sentence";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String SUMMARY_JAVADOC = "summary.javaDoc";
/**
* Regular expression for forbidden summary fragments.
*/
@ -101,12 +113,12 @@ public class SummaryJavadocCheck extends AbstractJavadocCheck
String firstSentence = getFirstSentence(ast);
final int endOfSentence = firstSentence.lastIndexOf(period);
if (endOfSentence == -1) {
log(ast.getLineNumber(), "summary.first.sentence");
log(ast.getLineNumber(), SUMMARY_FIRST_SENTENCE);
}
else {
firstSentence = firstSentence.substring(0, endOfSentence);
if (containsForbiddenFragment(firstSentence)) {
log(ast.getLineNumber(), "summary.javaDoc");
log(ast.getLineNumber(), SUMMARY_JAVADOC);
}
}
}

View File

@ -67,6 +67,25 @@ import org.apache.commons.beanutils.ConversionException;
public class WriteTagCheck
extends Check
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MISSING_TAG = "type.missingTag";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WRITE_TAG = "javadoc.writeTag";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String TAG_FORMAT = "type.tagFormat";
/** compiled regexp to match tag **/
private Pattern tagRE;
/** compiled regexp to match tag content **/
@ -157,7 +176,7 @@ public class WriteTagCheck
final TextBlock cmt =
contents.getJavadocBefore(lineNo);
if (cmt == null) {
log(lineNo, "type.missingTag", tag);
log(lineNo, MISSING_TAG, tag);
}
else {
checkTag(lineNo, cmt.getText(), tag, tagRE, tagFormatRE,
@ -195,7 +214,7 @@ public class WriteTagCheck
final int contentStart = matcher.start(1);
final String content = s.substring(contentStart);
if ((formatRE != null) && !formatRE.matcher(content).find()) {
log(lineNo + i - comment.length, "type.tagFormat", tag,
log(lineNo + i - comment.length, TAG_FORMAT, tag,
format);
}
else {
@ -205,7 +224,7 @@ public class WriteTagCheck
}
}
if (tagCount == 0) {
log(lineNo, "type.missingTag", tag);
log(lineNo, MISSING_TAG, tag);
}
}
@ -225,7 +244,7 @@ public class WriteTagCheck
final String originalSeverity = getSeverity();
setSeverity(tagSeverityLevel.getName());
log(line, "javadoc.writeTag", tag, tagValue);
log(line, WRITE_TAG, tag, tagValue);
setSeverity(originalSeverity);
}

View File

@ -23,6 +23,8 @@ import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck.PARSE_ERROR_MESSAGE_KEY;
public class AbstractJavadocCheckTest extends BaseCheckTestSupport
{
public static class TempCheck extends AbstractJavadocCheck
@ -41,9 +43,9 @@ public class AbstractJavadocCheckTest extends BaseCheckTestSupport
{
final DefaultConfiguration checkConfig = createCheckConfig(TempCheck.class);
final String[] expected = {
"3: Javadoc comment at column 52 has parse error. Details: no viable "
"3: " + getCheckMessage(PARSE_ERROR_MESSAGE_KEY, 52, "no viable "
+ "alternative at input '<ul><li>a' {@link EntityEntry} (by way of {@link #;' "
+ "while parsing HTML_TAG",
+ "while parsing HTML_TAG"),
};
verify(checkConfig, getPath("javadoc/InputTestNumberFomatException.java"), expected);
}

View File

@ -22,6 +22,8 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck.MSG_KEY;
public class AtclauseOrderCheckTest extends BaseCheckTestSupport
{
@ -37,46 +39,46 @@ public class AtclauseOrderCheckTest extends BaseCheckTestSupport
@Test
public void testIncorrect() throws Exception
{
final String tagOrder = "'[@author, @version, @param, @return, @throws, @exception, @see,"
+ " @since, @serial, @serialField, @serialData, @deprecated]'.";
final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see,"
+ " @since, @serial, @serialField, @serialData, @deprecated]";
DefaultConfiguration checkConfig = createCheckConfig(AtclauseOrderCheck.class);
final String[] expected = {
"9: At-clauses have to appear in the order " + tagOrder,
"11: At-clauses have to appear in the order " + tagOrder,
"12: At-clauses have to appear in the order " + tagOrder,
"40: At-clauses have to appear in the order " + tagOrder,
"50: At-clauses have to appear in the order " + tagOrder,
"51: At-clauses have to appear in the order " + tagOrder,
"62: At-clauses have to appear in the order " + tagOrder,
"69: At-clauses have to appear in the order " + tagOrder,
"86: At-clauses have to appear in the order " + tagOrder,
"87: At-clauses have to appear in the order " + tagOrder,
"99: At-clauses have to appear in the order " + tagOrder,
"101: At-clauses have to appear in the order " + tagOrder,
"115: At-clauses have to appear in the order " + tagOrder,
"123: At-clauses have to appear in the order " + tagOrder,
"134: At-clauses have to appear in the order " + tagOrder,
"135: At-clauses have to appear in the order " + tagOrder,
"145: At-clauses have to appear in the order " + tagOrder,
"153: At-clauses have to appear in the order " + tagOrder,
"161: At-clauses have to appear in the order " + tagOrder,
"172: At-clauses have to appear in the order " + tagOrder,
"183: At-clauses have to appear in the order " + tagOrder,
"185: At-clauses have to appear in the order " + tagOrder,
"199: At-clauses have to appear in the order " + tagOrder,
"202: At-clauses have to appear in the order " + tagOrder,
"213: At-clauses have to appear in the order " + tagOrder,
"223: At-clauses have to appear in the order " + tagOrder,
"230: At-clauses have to appear in the order " + tagOrder,
"237: At-clauses have to appear in the order " + tagOrder,
"247: At-clauses have to appear in the order " + tagOrder,
"248: At-clauses have to appear in the order " + tagOrder,
"259: At-clauses have to appear in the order " + tagOrder,
"261: At-clauses have to appear in the order " + tagOrder,
"275: At-clauses have to appear in the order " + tagOrder,
"277: At-clauses have to appear in the order " + tagOrder,
"278: At-clauses have to appear in the order " + tagOrder,
"288: At-clauses have to appear in the order " + tagOrder,
"9: " + getCheckMessage(MSG_KEY, tagOrder),
"11: " + getCheckMessage(MSG_KEY, tagOrder),
"12: " + getCheckMessage(MSG_KEY, tagOrder),
"40: " + getCheckMessage(MSG_KEY, tagOrder),
"50: " + getCheckMessage(MSG_KEY, tagOrder),
"51: " + getCheckMessage(MSG_KEY, tagOrder),
"62: " + getCheckMessage(MSG_KEY, tagOrder),
"69: " + getCheckMessage(MSG_KEY, tagOrder),
"86: " + getCheckMessage(MSG_KEY, tagOrder),
"87: " + getCheckMessage(MSG_KEY, tagOrder),
"99: " + getCheckMessage(MSG_KEY, tagOrder),
"101: " + getCheckMessage(MSG_KEY, tagOrder),
"115: " + getCheckMessage(MSG_KEY, tagOrder),
"123: " + getCheckMessage(MSG_KEY, tagOrder),
"134: " + getCheckMessage(MSG_KEY, tagOrder),
"135: " + getCheckMessage(MSG_KEY, tagOrder),
"145: " + getCheckMessage(MSG_KEY, tagOrder),
"153: " + getCheckMessage(MSG_KEY, tagOrder),
"161: " + getCheckMessage(MSG_KEY, tagOrder),
"172: " + getCheckMessage(MSG_KEY, tagOrder),
"183: " + getCheckMessage(MSG_KEY, tagOrder),
"185: " + getCheckMessage(MSG_KEY, tagOrder),
"199: " + getCheckMessage(MSG_KEY, tagOrder),
"202: " + getCheckMessage(MSG_KEY, tagOrder),
"213: " + getCheckMessage(MSG_KEY, tagOrder),
"223: " + getCheckMessage(MSG_KEY, tagOrder),
"230: " + getCheckMessage(MSG_KEY, tagOrder),
"237: " + getCheckMessage(MSG_KEY, tagOrder),
"247: " + getCheckMessage(MSG_KEY, tagOrder),
"248: " + getCheckMessage(MSG_KEY, tagOrder),
"259: " + getCheckMessage(MSG_KEY, tagOrder),
"261: " + getCheckMessage(MSG_KEY, tagOrder),
"275: " + getCheckMessage(MSG_KEY, tagOrder),
"277: " + getCheckMessage(MSG_KEY, tagOrder),
"278: " + getCheckMessage(MSG_KEY, tagOrder),
"288: " + getCheckMessage(MSG_KEY, tagOrder),
};
verify(checkConfig, getPath("javadoc/InputIncorrectAtClauseOrderCheck.java"), expected);
}
@ -84,16 +86,16 @@ public class AtclauseOrderCheckTest extends BaseCheckTestSupport
@Test
public void testIncorrectCustom() throws Exception
{
final String tagOrder = "'[@author, @version, @param, @return, @throws, @exception, @see,"
+ " @since, @serial, @serialField, @serialData, @deprecated]'.";
final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see,"
+ " @since, @serial, @serialField, @serialData, @deprecated]";
DefaultConfiguration checkConfig = createCheckConfig(AtclauseOrderCheck.class);
checkConfig.addAttribute("target", "CLASS_DEF");
final String[] expected = {
"9: At-clauses have to appear in the order " + tagOrder,
"11: At-clauses have to appear in the order " + tagOrder,
"12: At-clauses have to appear in the order " + tagOrder,
"115: At-clauses have to appear in the order " + tagOrder,
"9: " + getCheckMessage(MSG_KEY, tagOrder),
"11: " + getCheckMessage(MSG_KEY, tagOrder),
"12: " + getCheckMessage(MSG_KEY, tagOrder),
"115: " + getCheckMessage(MSG_KEY, tagOrder),
};
verify(checkConfig, getPath("javadoc/InputIncorrectAtClauseOrderCheck.java"), expected);
}

View File

@ -18,12 +18,22 @@
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.javadoc;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_DUPLICATE_TAG;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_EXCPECTED_TAG;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_INVALID_INHERIT_DOC;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_JAVADOC_MISSING;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_RETURN_EXPECTED;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_UNUSED_TAG;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_UNUSED_TAG_GENERAL;
import java.io.File;
import org.junit.Before;
import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.Scope;
import java.io.File;
import org.junit.Before;
import org.junit.Test;
public class JavadocMethodCheckTest extends BaseCheckTestSupport
{
@ -43,7 +53,7 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
config.addAttribute("allowedAnnotations", "MyAnnotation, Override");
config.addAttribute("minLineCount", "2");
final String[] expected = {
"46:1: Missing a Javadoc comment.",
"46:1: " + getCheckMessage(MSG_JAVADOC_MISSING),
};
verify(config, getPath("javadoc/ExtendAnnotation.java"), expected);
}
@ -55,7 +65,7 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
config.addAttribute("allowedAnnotations", "MyAnnotation, Override");
config.addAttribute("minLineCount", "2");
final String[] expected = {
"57:5: Missing a Javadoc comment.",
"57:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
};
verify(config, getPath("javadoc/InputJavadocMethodCheck_SmallMethods.java"), expected);
}
@ -64,35 +74,35 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
public void testTags() throws Exception
{
final String[] expected = {
"14:5: Missing a Javadoc comment.",
"18:9: Unused @param tag for 'unused'.",
"24: Expected an @return tag.",
"33: Expected an @return tag.",
"40:16: Expected @throws tag for 'Exception'.",
"49:16: Expected @throws tag for 'Exception'.",
"53:9: Unused @throws tag for 'WrongException'.",
"55:16: Expected @throws tag for 'Exception'.",
"55:27: Expected @throws tag for 'NullPointerException'.",
"60:22: Expected @param tag for 'aOne'.",
"68:22: Expected @param tag for 'aOne'.",
"72:9: Unused @param tag for 'WrongParam'.",
"73:23: Expected @param tag for 'aOne'.",
"73:33: Expected @param tag for 'aTwo'.",
"78:8: Unused @param tag for 'Unneeded'.",
"79: Unused Javadoc tag.",
"87:8: Duplicate @return tag.",
"109:23: Expected @param tag for 'aOne'.",
"109:55: Expected @param tag for 'aFour'.",
"109:66: Expected @param tag for 'aFive'.",
"178:8: Unused @throws tag for 'ThreadDeath'.",
"179:8: Unused @throws tag for 'ArrayStoreException'.",
"236:8: Unused @throws tag for 'java.io.FileNotFoundException'.",
"254:8: Unused @throws tag for 'java.io.FileNotFoundException'.",
"256:28: Expected @throws tag for 'IOException'.",
"262:8: Unused @param tag for 'aParam'.",
"320:9: Missing a Javadoc comment.",
"329:5: Missing a Javadoc comment.",
"333: Unused Javadoc tag.",
"14:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"18:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unused"),
"24: " + getCheckMessage(MSG_RETURN_EXPECTED),
"33: " + getCheckMessage(MSG_RETURN_EXPECTED),
"40:16: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "Exception"),
"49:16: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "Exception"),
"53:9: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "WrongException"),
"55:16: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "Exception"),
"55:27: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "NullPointerException"),
"60:22: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"68:22: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"72:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "WrongParam"),
"73:23: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"73:33: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aTwo"),
"78:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "Unneeded"),
"79: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
"87:8: " + getCheckMessage(MSG_DUPLICATE_TAG, "@return"),
"109:23: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"109:55: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aFour"),
"109:66: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aFive"),
"178:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "ThreadDeath"),
"179:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "ArrayStoreException"),
"236:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "java.io.FileNotFoundException"),
"254:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "java.io.FileNotFoundException"),
"256:28: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "IOException"),
"262:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "aParam"),
"320:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"329:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"333: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
};
verify(checkConfig, getSrcPath("checks/javadoc/InputTags.java"), expected);
@ -103,32 +113,32 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
{
checkConfig.addAttribute("allowUndeclaredRTE", "true");
final String[] expected = {
"14:5: Missing a Javadoc comment.",
"18:9: Unused @param tag for 'unused'.",
"24: Expected an @return tag.",
"33: Expected an @return tag.",
"40:16: Expected @throws tag for 'Exception'.",
"49:16: Expected @throws tag for 'Exception'.",
"55:16: Expected @throws tag for 'Exception'.",
"55:27: Expected @throws tag for 'NullPointerException'.",
"60:22: Expected @param tag for 'aOne'.",
"68:22: Expected @param tag for 'aOne'.",
"72:9: Unused @param tag for 'WrongParam'.",
"73:23: Expected @param tag for 'aOne'.",
"73:33: Expected @param tag for 'aTwo'.",
"78:8: Unused @param tag for 'Unneeded'.",
"79: Unused Javadoc tag.",
"87:8: Duplicate @return tag.",
"109:23: Expected @param tag for 'aOne'.",
"109:55: Expected @param tag for 'aFour'.",
"109:66: Expected @param tag for 'aFive'.",
"236:8: Unused @throws tag for 'java.io.FileNotFoundException'.",
"254:8: Unused @throws tag for 'java.io.FileNotFoundException'.",
"256:28: Expected @throws tag for 'IOException'.",
"262:8: Unused @param tag for 'aParam'.",
"320:9: Missing a Javadoc comment.",
"329:5: Missing a Javadoc comment.",
"333: Unused Javadoc tag.", };
"14:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"18:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unused"),
"24: " + getCheckMessage(MSG_RETURN_EXPECTED),
"33: " + getCheckMessage(MSG_RETURN_EXPECTED),
"40:16: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "Exception"),
"49:16: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "Exception"),
"55:16: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "Exception"),
"55:27: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "NullPointerException"),
"60:22: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"68:22: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"72:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "WrongParam"),
"73:23: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"73:33: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aTwo"),
"78:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "Unneeded"),
"79: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
"87:8: " + getCheckMessage(MSG_DUPLICATE_TAG, "@return"),
"109:23: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"109:55: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aFour"),
"109:66: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aFive"),
"236:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "java.io.FileNotFoundException"),
"254:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "java.io.FileNotFoundException"),
"256:28: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "IOException"),
"262:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "aParam"),
"320:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"329:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"333: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), };
verify(checkConfig, getSrcPath("checks/javadoc/InputTags.java"), expected);
}
@ -136,19 +146,19 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
public void testStrictJavadoc() throws Exception
{
final String[] expected = {
"12:9: Missing a Javadoc comment.",
"18:13: Missing a Javadoc comment.",
"25:13: Missing a Javadoc comment.",
"38:9: Missing a Javadoc comment.",
"49:5: Missing a Javadoc comment.",
"54:5: Missing a Javadoc comment.",
"59:5: Missing a Javadoc comment.",
"64:5: Missing a Javadoc comment.",
"69:5: Missing a Javadoc comment.",
"74:5: Missing a Javadoc comment.",
"79:5: Missing a Javadoc comment.",
"84:5: Missing a Javadoc comment.",
"94:32: Expected @param tag for 'aA'.",
"12:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"18:13: " + getCheckMessage(MSG_JAVADOC_MISSING),
"25:13: " + getCheckMessage(MSG_JAVADOC_MISSING),
"38:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"49:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"54:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"59:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"64:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"69:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"74:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"79:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"84:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"94:32: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aA"),
};
verify(checkConfig, getPath("InputPublicOnly.java"), expected);
}
@ -167,10 +177,10 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
{
checkConfig.addAttribute("scope", Scope.PROTECTED.getName());
final String[] expected = {
"59:5: Missing a Javadoc comment.",
"64:5: Missing a Javadoc comment.",
"79:5: Missing a Javadoc comment.",
"84:5: Missing a Javadoc comment.",
"59:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"64:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"79:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"84:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputPublicOnly.java"), expected);
}
@ -180,8 +190,8 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
{
checkConfig.addAttribute("scope", Scope.PUBLIC.getName());
final String[] expected = {
"43:9: Missing a Javadoc comment.",
"44:9: Missing a Javadoc comment.",
"43:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"44:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
}
@ -199,9 +209,9 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
{
checkConfig.addAttribute("scope", Scope.ANONINNER.getName());
final String[] expected = {
"26:9: Missing a Javadoc comment.",
"39:17: Missing a Javadoc comment.",
"53:17: Missing a Javadoc comment.", };
"26:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"39:17: " + getCheckMessage(MSG_JAVADOC_MISSING),
"53:17: " + getCheckMessage(MSG_JAVADOC_MISSING), };
verify(checkConfig, getPath("InputScopeAnonInner.java"), expected);
}
@ -218,32 +228,32 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
{
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
final String[] expected = {
"14:5: Missing a Javadoc comment.",
"18:9: Unused @param tag for 'unused'.",
"24: Expected an @return tag.",
"33: Expected an @return tag.",
"40:16: Expected @throws tag for 'Exception'.",
"49:16: Expected @throws tag for 'Exception'.",
"55:16: Expected @throws tag for 'Exception'.",
"55:27: Expected @throws tag for 'NullPointerException'.",
"60:22: Expected @param tag for 'aOne'.",
"68:22: Expected @param tag for 'aOne'.",
"72:9: Unused @param tag for 'WrongParam'.",
"73:23: Expected @param tag for 'aOne'.",
"73:33: Expected @param tag for 'aTwo'.",
"78:8: Unused @param tag for 'Unneeded'.",
"79: Unused Javadoc tag.",
"87:8: Duplicate @return tag.",
"109:23: Expected @param tag for 'aOne'.",
"109:55: Expected @param tag for 'aFour'.",
"109:66: Expected @param tag for 'aFive'.",
"178:8: Unused @throws tag for 'ThreadDeath'.",
"179:8: Unused @throws tag for 'ArrayStoreException'.",
"256:28: Expected @throws tag for 'IOException'.",
"262:8: Unused @param tag for 'aParam'.",
"320:9: Missing a Javadoc comment.",
"329:5: Missing a Javadoc comment.",
"333: Unused Javadoc tag.", };
"14:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"18:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unused"),
"24: " + getCheckMessage(MSG_RETURN_EXPECTED),
"33: " + getCheckMessage(MSG_RETURN_EXPECTED),
"40:16: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "Exception"),
"49:16: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "Exception"),
"55:16: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "Exception"),
"55:27: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "NullPointerException"),
"60:22: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"68:22: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"72:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "WrongParam"),
"73:23: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"73:33: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aTwo"),
"78:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "Unneeded"),
"79: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
"87:8: " + getCheckMessage(MSG_DUPLICATE_TAG, "@return"),
"109:23: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aOne"),
"109:55: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aFour"),
"109:66: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "aFive"),
"178:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "ThreadDeath"),
"179:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "ArrayStoreException"),
"256:28: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "IOException"),
"262:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "aParam"),
"320:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"329:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"333: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), };
verify(checkConfig, getSrcPath("checks/javadoc/InputTags.java"), expected);
}
@ -251,42 +261,42 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
public void testScopes() throws Exception
{
final String[] expected = {
"10:5: Missing a Javadoc comment.",
"11:5: Missing a Javadoc comment.",
"12:5: Missing a Javadoc comment.",
"13:5: Missing a Javadoc comment.",
"21:9: Missing a Javadoc comment.",
"22:9: Missing a Javadoc comment.",
"23:9: Missing a Javadoc comment.",
"24:9: Missing a Javadoc comment.",
"33:9: Missing a Javadoc comment.",
"34:9: Missing a Javadoc comment.",
"35:9: Missing a Javadoc comment.",
"36:9: Missing a Javadoc comment.",
"45:9: Missing a Javadoc comment.",
"46:9: Missing a Javadoc comment.",
"47:9: Missing a Javadoc comment.",
"48:9: Missing a Javadoc comment.",
"58:5: Missing a Javadoc comment.",
"59:5: Missing a Javadoc comment.",
"60:5: Missing a Javadoc comment.",
"61:5: Missing a Javadoc comment.",
"69:9: Missing a Javadoc comment.",
"70:9: Missing a Javadoc comment.",
"71:9: Missing a Javadoc comment.",
"72:9: Missing a Javadoc comment.",
"81:9: Missing a Javadoc comment.",
"82:9: Missing a Javadoc comment.",
"83:9: Missing a Javadoc comment.",
"84:9: Missing a Javadoc comment.",
"93:9: Missing a Javadoc comment.",
"94:9: Missing a Javadoc comment.",
"95:9: Missing a Javadoc comment.",
"96:9: Missing a Javadoc comment.",
"105:9: Missing a Javadoc comment.",
"106:9: Missing a Javadoc comment.",
"107:9: Missing a Javadoc comment.",
"108:9: Missing a Javadoc comment.", };
"10:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"11:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"12:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"13:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"21:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"22:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"23:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"24:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"33:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"34:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"35:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"36:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"45:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"46:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"47:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"48:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"58:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"59:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"60:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"61:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"69:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"70:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"71:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"72:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"81:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"82:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"83:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"84:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"93:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"94:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"95:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"96:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"105:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"106:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"107:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"108:9: " + getCheckMessage(MSG_JAVADOC_MISSING), };
verify(checkConfig, getPath("javadoc" + File.separator
+ "InputNoJavadoc.java"), expected);
}
@ -296,10 +306,10 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
{
checkConfig.addAttribute("scope", Scope.PROTECTED.getName());
final String[] expected = {
"10:5: Missing a Javadoc comment.",
"11:5: Missing a Javadoc comment.",
"21:9: Missing a Javadoc comment.",
"22:9: Missing a Javadoc comment.", };
"10:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"11:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"21:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"22:9: " + getCheckMessage(MSG_JAVADOC_MISSING), };
verify(checkConfig, getPath("javadoc" + File.separator
+ "InputNoJavadoc.java"), expected);
}
@ -310,38 +320,38 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("scope", Scope.PRIVATE.getName());
checkConfig.addAttribute("excludeScope", Scope.PROTECTED.getName());
final String[] expected = {
"12:5: Missing a Javadoc comment.",
"13:5: Missing a Javadoc comment.",
"23:9: Missing a Javadoc comment.",
"24:9: Missing a Javadoc comment.",
"33:9: Missing a Javadoc comment.",
"34:9: Missing a Javadoc comment.",
"35:9: Missing a Javadoc comment.",
"36:9: Missing a Javadoc comment.",
"45:9: Missing a Javadoc comment.",
"46:9: Missing a Javadoc comment.",
"47:9: Missing a Javadoc comment.",
"48:9: Missing a Javadoc comment.",
"58:5: Missing a Javadoc comment.",
"59:5: Missing a Javadoc comment.",
"60:5: Missing a Javadoc comment.",
"61:5: Missing a Javadoc comment.",
"69:9: Missing a Javadoc comment.",
"70:9: Missing a Javadoc comment.",
"71:9: Missing a Javadoc comment.",
"72:9: Missing a Javadoc comment.",
"81:9: Missing a Javadoc comment.",
"82:9: Missing a Javadoc comment.",
"83:9: Missing a Javadoc comment.",
"84:9: Missing a Javadoc comment.",
"93:9: Missing a Javadoc comment.",
"94:9: Missing a Javadoc comment.",
"95:9: Missing a Javadoc comment.",
"96:9: Missing a Javadoc comment.",
"105:9: Missing a Javadoc comment.",
"106:9: Missing a Javadoc comment.",
"107:9: Missing a Javadoc comment.",
"108:9: Missing a Javadoc comment.", };
"12:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"13:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"23:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"24:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"33:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"34:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"35:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"36:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"45:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"46:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"47:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"48:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"58:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"59:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"60:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"61:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"69:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"70:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"71:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"72:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"81:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"82:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"83:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"84:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"93:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"94:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"95:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"96:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"105:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"106:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"107:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"108:9: " + getCheckMessage(MSG_JAVADOC_MISSING), };
verify(checkConfig, getPath("javadoc" + File.separator
+ "InputNoJavadoc.java"), expected);
}
@ -359,16 +369,16 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
public void testSetterGetterOff() throws Exception
{
final String[] expected = {
"7:5: Missing a Javadoc comment.",
"12:5: Missing a Javadoc comment.",
"17:5: Missing a Javadoc comment.",
"22:5: Missing a Javadoc comment.",
"28:5: Missing a Javadoc comment.",
"32:5: Missing a Javadoc comment.",
"37:5: Missing a Javadoc comment.",
"43:5: Missing a Javadoc comment.",
"48:5: Missing a Javadoc comment.",
"53:5: Missing a Javadoc comment.", };
"7:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"12:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"17:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"22:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"28:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"32:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"37:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"43:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"48:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"53:5: " + getCheckMessage(MSG_JAVADOC_MISSING), };
verify(checkConfig, getPath("javadoc" + File.separator
+ "InputSetterGetter.java"), expected);
}
@ -378,13 +388,13 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
{
checkConfig.addAttribute("allowMissingPropertyJavadoc", "true");
final String[] expected = {
"17:5: Missing a Javadoc comment.",
"22:5: Missing a Javadoc comment.",
"28:5: Missing a Javadoc comment.",
"32:5: Missing a Javadoc comment.",
"37:5: Missing a Javadoc comment.",
"43:5: Missing a Javadoc comment.",
"53:5: Missing a Javadoc comment.", };
"17:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"22:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"28:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"32:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"37:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"43:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
"53:5: " + getCheckMessage(MSG_JAVADOC_MISSING), };
verify(checkConfig, getPath("javadoc" + File.separator
+ "InputSetterGetter.java"), expected);
}
@ -393,8 +403,8 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
public void testTypeParamsTags() throws Exception
{
final String[] expected = {
"26:8: Unused @param tag for '<BB>'.",
"28:13: Expected @param tag for '<Z>'.", };
"26:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<BB>"),
"28:13: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "<Z>"), };
verify(checkConfig, getPath("InputTypeParamsTags.java"), expected);
}
@ -427,11 +437,11 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
checkConfig.addAttribute("allowUndeclaredRTE", "true");
final String[] expected = {
"17:34: Expected @throws tag for 'RE'.",
"33:13: Expected @param tag for '<NPE>'.",
"40:12: Unused @throws tag for 'E'.",
"43:38: Expected @throws tag for 'RuntimeException'.",
"44:13: Expected @throws tag for 'java.lang.RuntimeException'.",
"17:34: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "RE"),
"33:13: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "<NPE>"),
"40:12: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "E"),
"43:38: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "RuntimeException"),
"44:13: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "java.lang.RuntimeException"),
};
verify(checkConfig, getPath("javadoc/TestGenerics.java"), expected);
}
@ -441,11 +451,11 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
{
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
final String[] expected = {
"17:34: Expected @throws tag for 'RE'.",
"33:13: Expected @param tag for '<NPE>'.",
"40:12: Unused @throws tag for 'E'.",
"43:38: Expected @throws tag for 'RuntimeException'.",
"44:13: Expected @throws tag for 'java.lang.RuntimeException'.",
"17:34: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "RE"),
"33:13: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "<NPE>"),
"40:12: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "E"),
"43:38: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "RuntimeException"),
"44:13: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "java.lang.RuntimeException"),
};
verify(checkConfig, getPath("javadoc/TestGenerics.java"), expected);
}
@ -454,12 +464,12 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
public void test_generics_3() throws Exception
{
final String[] expected = {
"8:8: Unused @throws tag for 'RE'.",
"17:34: Expected @throws tag for 'RE'.",
"33:13: Expected @param tag for '<NPE>'.",
"40:12: Unused @throws tag for 'E'.",
"43:38: Expected @throws tag for 'RuntimeException'.",
"44:13: Expected @throws tag for 'java.lang.RuntimeException'.",
"8:8: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "RE"),
"17:34: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "RE"),
"33:13: " + getCheckMessage(MSG_EXCPECTED_TAG, "@param", "<NPE>"),
"40:12: " + getCheckMessage(MSG_UNUSED_TAG, "@throws", "E"),
"43:38: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "RuntimeException"),
"44:13: " + getCheckMessage(MSG_EXCPECTED_TAG, "@throws", "java.lang.RuntimeException"),
};
verify(checkConfig, getPath("javadoc/TestGenerics.java"), expected);
}
@ -477,12 +487,12 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport
public void testInheritDoc() throws Exception
{
final String[] expected = {
"6:5: Invalid use of the {@inheritDoc} tag.",
"11:5: Invalid use of the {@inheritDoc} tag.",
"31:5: Invalid use of the {@inheritDoc} tag.",
"36:5: Invalid use of the {@inheritDoc} tag.",
"41:5: Invalid use of the {@inheritDoc} tag.",
"46:5: Invalid use of the {@inheritDoc} tag.",
"6:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
"11:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
"31:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
"36:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
"41:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
"46:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
};
verify(checkConfig, getPath("javadoc/InputInheritDoc.java"), expected);
}

View File

@ -23,6 +23,8 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.Configuration;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck.MSG_LEGACY_PACKAGE_HTML;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck.MSG_PACKAGE_INFO;
public class JavadocPackageCheckTest
extends BaseCheckTestSupport
@ -41,7 +43,7 @@ public class JavadocPackageCheckTest
{
final Configuration checkConfig = createCheckConfig(JavadocPackageCheck.class);
final String[] expected = {
"0: Missing package-info.java file.",
"0: " + getCheckMessage(MSG_PACKAGE_INFO),
};
verify(
createChecker(checkConfig),
@ -55,7 +57,7 @@ public class JavadocPackageCheckTest
{
final Configuration checkConfig = createCheckConfig(JavadocPackageCheck.class);
final String[] expected = {
"0: Legacy package.html file should be removed.",
"0: " + getCheckMessage(MSG_LEGACY_PACKAGE_HTML),
};
verify(createChecker(checkConfig),
getPath("javadoc/bothfiles/Ignored.java"),

View File

@ -23,8 +23,13 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck.MSG_LINE_BEFORE;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck.MSG_REDUNDANT_PARAGRAPH;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck.MSG_TAG_AFTER;
public class JavadocParagraphCheckTest extends BaseCheckTestSupport
{
private DefaultConfiguration checkConfig;
@Before
@ -45,23 +50,23 @@ public class JavadocParagraphCheckTest extends BaseCheckTestSupport
public void testIncorrect() throws Exception
{
final String[] expected = {
"7: <p> tag should be precede with empty line.",
"8: <p> tag should be precede with empty line.",
"14: <p> tag should be precede with empty line.",
"23: <p> tag should be precede with empty line.",
"32: <p> tag should be precede with empty line.",
"32: Redundant <p> tag.",
"33: <p> tag should be precede with empty line.",
"34: <p> tag should be precede with empty line.",
"35: <p> tag should be precede with empty line.",
"39: <p> tag should be precede with empty line.",
"45: Redundant <p> tag.",
"50: <p> tag should be precede with empty line.",
"51: <p> tag should be precede with empty line.",
"61: Redundant <p> tag.",
"62: Empty line should be followed by <p> tag on the next line.",
"70: <p> tag should be precede with empty line.",
"75: <p> tag should be precede with empty line.",
"7: " + getCheckMessage(MSG_LINE_BEFORE),
"8: " + getCheckMessage(MSG_LINE_BEFORE),
"14: " + getCheckMessage(MSG_LINE_BEFORE),
"23: " + getCheckMessage(MSG_LINE_BEFORE),
"32: " + getCheckMessage(MSG_LINE_BEFORE),
"32: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"33: " + getCheckMessage(MSG_LINE_BEFORE),
"34: " + getCheckMessage(MSG_LINE_BEFORE),
"35: " + getCheckMessage(MSG_LINE_BEFORE),
"39: " + getCheckMessage(MSG_LINE_BEFORE),
"45: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"50: " + getCheckMessage(MSG_LINE_BEFORE),
"51: " + getCheckMessage(MSG_LINE_BEFORE),
"61: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"62: " + getCheckMessage(MSG_TAG_AFTER),
"70: " + getCheckMessage(MSG_LINE_BEFORE),
"75: " + getCheckMessage(MSG_LINE_BEFORE),
};
verify(checkConfig, getPath("javadoc/InputIncorrectJavaDocParagraphCheck.java"), expected);
}

View File

@ -25,6 +25,12 @@ import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.EXTRA_HTML;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.UNCLOSED_HTML;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.INCOMPLETE_TAG;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.NO_PERIOD;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.EMPTY;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.JAVADOC_MISSING;
public class JavadocStyleCheckTest
extends BaseCheckTestSupport
@ -37,23 +43,23 @@ public class JavadocStyleCheckTest
createCheckConfig(JavadocStyleCheck.class);
final String[] expected =
{
"20: First sentence should end with a period.",
"53: First sentence should end with a period.",
"63:11: Unclosed HTML tag found: <b>This guy is missing end of bold tag",
"66:7: Extra HTML tag found: </td>Extra tag shouldn't be here",
"68:19: Unclosed HTML tag found: <code>dummy.",
"74: First sentence should end with a period.",
"75:23: Unclosed HTML tag found: <b>should fail",
"81: First sentence should end with a period.",
"82:31: Unclosed HTML tag found: <b>should fail",
"88: First sentence should end with a period.",
"89:31: Extra HTML tag found: </code>",
"90: Incomplete HTML tag found: * should fail <",
"109:39: Extra HTML tag found: </img>",
"186:8: Unclosed HTML tag found: <blockquote>",
"193: First sentence should end with a period.",
"238: First sentence should end with a period.",
"335:33: Extra HTML tag found: </string>",
"20: " + getCheckMessage(NO_PERIOD),
"53: " + getCheckMessage(NO_PERIOD),
"63:11: " + getCheckMessage(UNCLOSED_HTML, "<b>This guy is missing end of bold tag"),
"66:7: " + getCheckMessage(EXTRA_HTML, "</td>Extra tag shouldn't be here"),
"68:19: " + getCheckMessage(UNCLOSED_HTML, "<code>dummy."),
"74: " + getCheckMessage(NO_PERIOD),
"75:23: " + getCheckMessage(UNCLOSED_HTML, "<b>should fail"),
"81: " + getCheckMessage(NO_PERIOD),
"82:31: " + getCheckMessage(UNCLOSED_HTML, "<b>should fail"),
"88: " + getCheckMessage(NO_PERIOD),
"89:31: " + getCheckMessage(EXTRA_HTML, "</code>"),
"90: " + getCheckMessage(INCOMPLETE_TAG, " * should fail <"),
"109:39: " + getCheckMessage(EXTRA_HTML, "</img>"),
"186:8: " + getCheckMessage(UNCLOSED_HTML, "<blockquote>"),
"193: " + getCheckMessage(NO_PERIOD),
"238: " + getCheckMessage(NO_PERIOD),
"335:33: " + getCheckMessage(EXTRA_HTML, "</string>"),
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -68,13 +74,13 @@ public class JavadocStyleCheckTest
checkConfig.addAttribute("checkHtml", "false");
final String[] expected =
{
"20: First sentence should end with a period.",
"53: First sentence should end with a period.",
"74: First sentence should end with a period.",
"81: First sentence should end with a period.",
"88: First sentence should end with a period.",
"193: First sentence should end with a period.",
"238: First sentence should end with a period.",
"20: " + getCheckMessage(NO_PERIOD),
"53: " + getCheckMessage(NO_PERIOD),
"74: " + getCheckMessage(NO_PERIOD),
"81: " + getCheckMessage(NO_PERIOD),
"88: " + getCheckMessage(NO_PERIOD),
"193: " + getCheckMessage(NO_PERIOD),
"238: " + getCheckMessage(NO_PERIOD),
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -91,15 +97,15 @@ public class JavadocStyleCheckTest
"([.][ \t\n\r\f<])|([.]$)");
final String[] expected =
{
"20: First sentence should end with a period.",
"32: First sentence should end with a period.",
"39: First sentence should end with a period.",
"53: First sentence should end with a period.",
"74: First sentence should end with a period.",
"81: First sentence should end with a period.",
"88: First sentence should end with a period.",
"193: First sentence should end with a period.",
"238: First sentence should end with a period.",
"20: " + getCheckMessage(NO_PERIOD),
"32: " + getCheckMessage(NO_PERIOD),
"39: " + getCheckMessage(NO_PERIOD),
"53: " + getCheckMessage(NO_PERIOD),
"74: " + getCheckMessage(NO_PERIOD),
"81: " + getCheckMessage(NO_PERIOD),
"88: " + getCheckMessage(NO_PERIOD),
"193: " + getCheckMessage(NO_PERIOD),
"238: " + getCheckMessage(NO_PERIOD),
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -113,16 +119,16 @@ public class JavadocStyleCheckTest
checkConfig.addAttribute("checkHtml", "true");
final String[] expected =
{
"63:11: Unclosed HTML tag found: <b>This guy is missing end of bold tag",
"66:7: Extra HTML tag found: </td>Extra tag shouldn't be here",
"68:19: Unclosed HTML tag found: <code>dummy.",
"75:23: Unclosed HTML tag found: <b>should fail",
"82:31: Unclosed HTML tag found: <b>should fail",
"89:31: Extra HTML tag found: </code>",
"90: Incomplete HTML tag found: * should fail <",
"109:39: Extra HTML tag found: </img>",
"186:8: Unclosed HTML tag found: <blockquote>",
"335:33: Extra HTML tag found: </string>",
"63:11: " + getCheckMessage(UNCLOSED_HTML, "<b>This guy is missing end of bold tag"),
"66:7: " + getCheckMessage(EXTRA_HTML, "</td>Extra tag shouldn't be here"),
"68:19: " + getCheckMessage(UNCLOSED_HTML, "<code>dummy."),
"75:23: " + getCheckMessage(UNCLOSED_HTML, "<b>should fail"),
"82:31: " + getCheckMessage(UNCLOSED_HTML, "<b>should fail"),
"89:31: " + getCheckMessage(EXTRA_HTML, "</code>"),
"90: " + getCheckMessage(INCOMPLETE_TAG, " * should fail <"),
"109:39: " + getCheckMessage(EXTRA_HTML, "</img>"),
"186:8: " + getCheckMessage(UNCLOSED_HTML, "<blockquote>"),
"335:33: " + getCheckMessage(EXTRA_HTML, "</string>"),
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -153,13 +159,13 @@ public class JavadocStyleCheckTest
checkConfig.addAttribute("scope", "public");
final String[] expected =
{
"88: First sentence should end with a period.",
"89:31: Extra HTML tag found: </code>",
"90: Incomplete HTML tag found: * should fail <",
"205: Javadoc has empty description section.",
"230: Javadoc has empty description section.",
"238: First sentence should end with a period.",
"335:33: Extra HTML tag found: </string>",
"88: " + getCheckMessage(NO_PERIOD),
"89:31: " + getCheckMessage(EXTRA_HTML, "</code>"),
"90: " + getCheckMessage(INCOMPLETE_TAG, " * should fail <"),
"205: " + getCheckMessage(EMPTY),
"230: " + getCheckMessage(EMPTY),
"238: " + getCheckMessage(NO_PERIOD),
"335:33: " + getCheckMessage(EXTRA_HTML, "</string>"),
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -177,16 +183,16 @@ public class JavadocStyleCheckTest
checkConfig.addAttribute("scope", "protected");
final String[] expected =
{
"74: First sentence should end with a period.",
"75:23: Unclosed HTML tag found: <b>should fail",
"88: First sentence should end with a period.",
"89:31: Extra HTML tag found: </code>",
"90: Incomplete HTML tag found: * should fail <",
"205: Javadoc has empty description section.",
"211: Javadoc has empty description section.",
"230: Javadoc has empty description section.",
"238: First sentence should end with a period.",
"335:33: Extra HTML tag found: </string>",
"74: " + getCheckMessage(NO_PERIOD),
"75:23: " + getCheckMessage(UNCLOSED_HTML, "<b>should fail"),
"88: " + getCheckMessage(NO_PERIOD),
"89:31: " + getCheckMessage(EXTRA_HTML, "</code>"),
"90: " + getCheckMessage(INCOMPLETE_TAG, " * should fail <"),
"205: " + getCheckMessage(EMPTY),
"211: " + getCheckMessage(EMPTY),
"230: " + getCheckMessage(EMPTY),
"238: " + getCheckMessage(NO_PERIOD),
"335:33: " + getCheckMessage(EXTRA_HTML, "</string>"),
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -204,19 +210,19 @@ public class JavadocStyleCheckTest
checkConfig.addAttribute("scope", "package");
final String[] expected =
{
"74: First sentence should end with a period.",
"75:23: Unclosed HTML tag found: <b>should fail",
"81: First sentence should end with a period.",
"82:31: Unclosed HTML tag found: <b>should fail",
"88: First sentence should end with a period.",
"89:31: Extra HTML tag found: </code>",
"90: Incomplete HTML tag found: * should fail <",
"205: Javadoc has empty description section.",
"211: Javadoc has empty description section.",
"218: Javadoc has empty description section.",
"230: Javadoc has empty description section.",
"238: First sentence should end with a period.",
"335:33: Extra HTML tag found: </string>",
"74: " + getCheckMessage(NO_PERIOD),
"75:23: " + getCheckMessage(UNCLOSED_HTML, "<b>should fail"),
"81: " + getCheckMessage(NO_PERIOD),
"82:31: " + getCheckMessage(UNCLOSED_HTML, "<b>should fail"),
"88: " + getCheckMessage(NO_PERIOD),
"89:31: " + getCheckMessage(EXTRA_HTML, "</code>"),
"90: " + getCheckMessage(INCOMPLETE_TAG, " * should fail <"),
"205: " + getCheckMessage(EMPTY),
"211: " + getCheckMessage(EMPTY),
"218: " + getCheckMessage(EMPTY),
"230: " + getCheckMessage(EMPTY),
"238: " + getCheckMessage(NO_PERIOD),
"335:33: " + getCheckMessage(EXTRA_HTML, "</string>"),
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -231,11 +237,11 @@ public class JavadocStyleCheckTest
checkConfig.addAttribute("checkEmptyJavadoc", "true");
final String[] expected =
{
"205: Javadoc has empty description section.",
"211: Javadoc has empty description section.",
"218: Javadoc has empty description section.",
"225: Javadoc has empty description section.",
"230: Javadoc has empty description section.",
"205: " + getCheckMessage(EMPTY),
"211: " + getCheckMessage(EMPTY),
"218: " + getCheckMessage(EMPTY),
"225: " + getCheckMessage(EMPTY),
"230: " + getCheckMessage(EMPTY),
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -251,16 +257,16 @@ public class JavadocStyleCheckTest
checkConfig.addAttribute("excludeScope", "protected");
final String[] expected =
{
"20: First sentence should end with a period.",
"53: First sentence should end with a period.",
"63:11: Unclosed HTML tag found: <b>This guy is missing end of bold tag",
"66:7: Extra HTML tag found: </td>Extra tag shouldn't be here",
"68:19: Unclosed HTML tag found: <code>dummy.",
"81: First sentence should end with a period.",
"82:31: Unclosed HTML tag found: <b>should fail",
"109:39: Extra HTML tag found: </img>",
"186:8: Unclosed HTML tag found: <blockquote>",
"193: First sentence should end with a period.",
"20: " + getCheckMessage(NO_PERIOD),
"53: " + getCheckMessage(NO_PERIOD),
"63:11: " + getCheckMessage(UNCLOSED_HTML, "<b>This guy is missing end of bold tag"),
"66:7: " + getCheckMessage(EXTRA_HTML, "</td>Extra tag shouldn't be here"),
"68:19: " + getCheckMessage(UNCLOSED_HTML, "<code>dummy."),
"81: " + getCheckMessage(NO_PERIOD),
"82:31: " + getCheckMessage(UNCLOSED_HTML, "<b>should fail"),
"109:39: " + getCheckMessage(EXTRA_HTML, "</img>"),
"186:8: " + getCheckMessage(UNCLOSED_HTML, "<blockquote>"),
"193: " + getCheckMessage(NO_PERIOD),
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -273,7 +279,7 @@ public class JavadocStyleCheckTest
createCheckConfig(JavadocStyleCheck.class);
final String[] expected =
{
"1: First sentence should end with a period.",
"1: " + getCheckMessage(NO_PERIOD),
};
String basePath = "javadoc" + File.separator
@ -291,7 +297,7 @@ public class JavadocStyleCheckTest
createCheckConfig(JavadocStyleCheck.class);
final String[] expected =
{
"1: First sentence should end with a period.",
"1: " + getCheckMessage(NO_PERIOD),
};
String basePath = "javadoc" + File.separator
@ -325,7 +331,7 @@ public class JavadocStyleCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(JavadocStyleCheck.class);
final String[] expected = {
"1: Missing a Javadoc comment.",
"1: " + getCheckMessage(JAVADOC_MISSING),
};
String basePath = "javadoc" + File.separator

View File

@ -23,6 +23,9 @@ import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTagContinuationIndentationCheck
.MSG_KEY;
public class JavadocTagContinuationIndentationCheckTest
extends BaseCheckTestSupport
{
@ -42,18 +45,18 @@ public class JavadocTagContinuationIndentationCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(JavadocTagContinuationIndentationCheck.class);
final String[] expected = {
"47: Line continuation have incorrect indentation level, expected level should be 4.",
"109: Line continuation have incorrect indentation level, expected level should be 4.",
"112: Line continuation have incorrect indentation level, expected level should be 4.",
"203: Line continuation have incorrect indentation level, expected level should be 4.",
"206: Line continuation have incorrect indentation level, expected level should be 4.",
"221: Line continuation have incorrect indentation level, expected level should be 4.",
"223: Line continuation have incorrect indentation level, expected level should be 4.",
"285: Line continuation have incorrect indentation level, expected level should be 4.",
"288: Line continuation have incorrect indentation level, expected level should be 4.",
"290: Line continuation have incorrect indentation level, expected level should be 4.",
"310: Line continuation have incorrect indentation level, expected level should be 4.",
"322: Line continuation have incorrect indentation level, expected level should be 4.",
"47: " + getCheckMessage(MSG_KEY, 4),
"109: " + getCheckMessage(MSG_KEY, 4),
"112: " + getCheckMessage(MSG_KEY, 4),
"203: " + getCheckMessage(MSG_KEY, 4),
"206: " + getCheckMessage(MSG_KEY, 4),
"221: " + getCheckMessage(MSG_KEY, 4),
"223: " + getCheckMessage(MSG_KEY, 4),
"285: " + getCheckMessage(MSG_KEY, 4),
"288: " + getCheckMessage(MSG_KEY, 4),
"290: " + getCheckMessage(MSG_KEY, 4),
"310: " + getCheckMessage(MSG_KEY, 4),
"322: " + getCheckMessage(MSG_KEY, 4),
};
verify(checkConfig, getPath("javadoc/InputJavaDocTagContinuationIndentation.java"), expected);
}

View File

@ -18,11 +18,19 @@
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.javadoc;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.JAVADOC_MISSING;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.MISSING_TAG;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.TAG_FORMAT;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.UNKNOWN_TAG;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.UNUSED_TAG;
import java.io.File;
import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.Scope;
import java.io.File;
import org.junit.Test;
/**
* @author Oliver.Burn
@ -41,9 +49,9 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
final String[] expected =
{
"8: Missing a Javadoc comment.",
"302: Missing a Javadoc comment.",
"327: Missing a Javadoc comment.",
"8: " + getCheckMessage(JAVADOC_MISSING),
"302: " + getCheckMessage(JAVADOC_MISSING),
"327: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getSrcPath("checks/javadoc/InputTags.java"), expected);
}
@ -55,9 +63,9 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
final String[] expected =
{
"14: Missing a Javadoc comment.",
"21: Missing a Javadoc comment.",
"27: Missing a Javadoc comment.",
"14: " + getCheckMessage(JAVADOC_MISSING),
"21: " + getCheckMessage(JAVADOC_MISSING),
"27: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputInner.java"), expected);
}
@ -69,10 +77,10 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
final String[] expected =
{
"7: Missing a Javadoc comment.",
"9: Missing a Javadoc comment.",
"14: Missing a Javadoc comment.",
"34: Missing a Javadoc comment.",
"7: " + getCheckMessage(JAVADOC_MISSING),
"9: " + getCheckMessage(JAVADOC_MISSING),
"14: " + getCheckMessage(JAVADOC_MISSING),
"34: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputPublicOnly.java"), expected);
}
@ -85,7 +93,7 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("scope", Scope.PROTECTED.getName());
final String[] expected =
{
"7: Missing a Javadoc comment.",
"7: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputPublicOnly.java"), expected);
}
@ -98,8 +106,8 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("scope", Scope.PUBLIC.getName());
final String[] expected =
{
"7: Missing a Javadoc comment.",
"38: Missing a Javadoc comment.",
"7: " + getCheckMessage(JAVADOC_MISSING),
"38: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
}
@ -112,10 +120,10 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("scope", Scope.PROTECTED.getName());
final String[] expected =
{
"7: Missing a Javadoc comment.",
"29: Missing a Javadoc comment.",
"38: Missing a Javadoc comment.",
"65: Missing a Javadoc comment.",
"7: " + getCheckMessage(JAVADOC_MISSING),
"29: " + getCheckMessage(JAVADOC_MISSING),
"38: " + getCheckMessage(JAVADOC_MISSING),
"65: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
}
@ -130,9 +138,9 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
Scope.getInstance("package").getName());
final String[] expected =
{
"18: Missing a Javadoc comment.",
"20: Missing a Javadoc comment.",
"22: Missing a Javadoc comment.",
"18: " + getCheckMessage(JAVADOC_MISSING),
"20: " + getCheckMessage(JAVADOC_MISSING),
"22: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputScopeInnerClasses.java"), expected);
}
@ -147,7 +155,7 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
Scope.getInstance("public").getName());
final String[] expected =
{
"18: Missing a Javadoc comment.",
"18: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputScopeInnerClasses.java"), expected);
}
@ -160,7 +168,7 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("authorFormat", "\\S");
final String[] expected =
{
"13: Type Javadoc comment is missing an @author tag.",
"13: " + getCheckMessage(MISSING_TAG, "@author"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -173,9 +181,9 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
checkConfig.addAttribute("authorFormat", "0*");
final String[] expected = {
"22: Type Javadoc comment is missing an @author tag.",
"58: Type Javadoc comment is missing an @author tag.",
"94: Type Javadoc comment is missing an @author tag.",
"22: " + getCheckMessage(MISSING_TAG, "@author"),
"58: " + getCheckMessage(MISSING_TAG, "@author"),
"94: " + getCheckMessage(MISSING_TAG, "@author"),
};
verify(checkConfig, getPath("InputJavadoc.java"), expected);
}
@ -188,15 +196,15 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
checkConfig.addAttribute("authorFormat", "ABC");
final String[] expected = {
"13: Type Javadoc tag @author must match pattern 'ABC'.",
"22: Type Javadoc comment is missing an @author tag.",
"31: Type Javadoc tag @author must match pattern 'ABC'.",
"49: Type Javadoc tag @author must match pattern 'ABC'.",
"58: Type Javadoc comment is missing an @author tag.",
"67: Type Javadoc tag @author must match pattern 'ABC'.",
"85: Type Javadoc tag @author must match pattern 'ABC'.",
"94: Type Javadoc comment is missing an @author tag.",
"103: Type Javadoc tag @author must match pattern 'ABC'.",
"13: " + getCheckMessage(TAG_FORMAT, "@author", "ABC"),
"22: " + getCheckMessage(MISSING_TAG, "@author"),
"31: " + getCheckMessage(TAG_FORMAT, "@author", "ABC"),
"49: " + getCheckMessage(TAG_FORMAT, "@author", "ABC"),
"58: " + getCheckMessage(MISSING_TAG, "@author"),
"67: " + getCheckMessage(TAG_FORMAT, "@author", "ABC"),
"85: " + getCheckMessage(TAG_FORMAT, "@author", "ABC"),
"94: " + getCheckMessage(MISSING_TAG, "@author"),
"103: " + getCheckMessage(TAG_FORMAT, "@author", "ABC"),
};
verify(checkConfig, getPath("InputJavadoc.java"), expected);
}
@ -209,7 +217,7 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
checkConfig.addAttribute("versionFormat", "\\S");
final String[] expected = {
"13: Type Javadoc comment is missing an @version tag.",
"13: " + getCheckMessage(MISSING_TAG, "@version"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -222,9 +230,9 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
checkConfig.addAttribute("versionFormat", "^\\p{Digit}+\\.\\p{Digit}+$");
final String[] expected = {
"22: Type Javadoc comment is missing an @version tag.",
"58: Type Javadoc comment is missing an @version tag.",
"94: Type Javadoc comment is missing an @version tag.",
"22: " + getCheckMessage(MISSING_TAG, "@version"),
"58: " + getCheckMessage(MISSING_TAG, "@version"),
"94: " + getCheckMessage(MISSING_TAG, "@version"),
};
verify(checkConfig, getPath("InputJavadoc.java"), expected);
}
@ -237,18 +245,18 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
checkConfig.addAttribute("versionFormat", "\\$Revision.*\\$");
final String[] expected = {
"13: Type Javadoc tag @version must match pattern '\\$Revision.*\\$'.",
"22: Type Javadoc comment is missing an @version tag.",
"31: Type Javadoc tag @version must match pattern '\\$Revision.*\\$'.",
"40: Type Javadoc tag @version must match pattern '\\$Revision.*\\$'.",
"49: Type Javadoc tag @version must match pattern '\\$Revision.*\\$'.",
"58: Type Javadoc comment is missing an @version tag.",
"67: Type Javadoc tag @version must match pattern '\\$Revision.*\\$'.",
"76: Type Javadoc tag @version must match pattern '\\$Revision.*\\$'.",
"85: Type Javadoc tag @version must match pattern '\\$Revision.*\\$'.",
"94: Type Javadoc comment is missing an @version tag.",
"103: Type Javadoc tag @version must match pattern '\\$Revision.*\\$'.",
"112: Type Javadoc tag @version must match pattern '\\$Revision.*\\$'.",
"13: " + getCheckMessage(TAG_FORMAT, "@version", "\\$Revision.*\\$"),
"22: " + getCheckMessage(MISSING_TAG, "@version"),
"31: " + getCheckMessage(TAG_FORMAT, "@version", "\\$Revision.*\\$"),
"40: " + getCheckMessage(TAG_FORMAT, "@version", "\\$Revision.*\\$"),
"49: " + getCheckMessage(TAG_FORMAT, "@version", "\\$Revision.*\\$"),
"58: " + getCheckMessage(MISSING_TAG, "@version"),
"67: " + getCheckMessage(TAG_FORMAT, "@version", "\\$Revision.*\\$"),
"76: " + getCheckMessage(TAG_FORMAT, "@version", "\\$Revision.*\\$"),
"85: " + getCheckMessage(TAG_FORMAT, "@version", "\\$Revision.*\\$"),
"94: " + getCheckMessage(MISSING_TAG, "@version"),
"103: " + getCheckMessage(TAG_FORMAT, "@version", "\\$Revision.*\\$"),
"112: " + getCheckMessage(TAG_FORMAT, "@version", "\\$Revision.*\\$"),
};
verify(checkConfig, getPath("InputJavadoc.java"), expected);
}
@ -259,16 +267,16 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
final DefaultConfiguration checkConfig =
createCheckConfig(JavadocTypeCheck.class);
final String[] expected = {
"3: Missing a Javadoc comment.",
"15: Missing a Javadoc comment.",
"27: Missing a Javadoc comment.",
"39: Missing a Javadoc comment.",
"52: Missing a Javadoc comment.",
"63: Missing a Javadoc comment.",
"75: Missing a Javadoc comment.",
"87: Missing a Javadoc comment.",
"99: Missing a Javadoc comment.",
"111: Missing a Javadoc comment.",
"3: " + getCheckMessage(JAVADOC_MISSING),
"15: " + getCheckMessage(JAVADOC_MISSING),
"27: " + getCheckMessage(JAVADOC_MISSING),
"39: " + getCheckMessage(JAVADOC_MISSING),
"52: " + getCheckMessage(JAVADOC_MISSING),
"63: " + getCheckMessage(JAVADOC_MISSING),
"75: " + getCheckMessage(JAVADOC_MISSING),
"87: " + getCheckMessage(JAVADOC_MISSING),
"99: " + getCheckMessage(JAVADOC_MISSING),
"111: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig,
getPath("javadoc" + File.separator + "InputNoJavadoc.java"),
@ -282,8 +290,8 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
checkConfig.addAttribute("scope", Scope.PROTECTED.getName());
final String[] expected = {
"3: Missing a Javadoc comment.",
"15: Missing a Javadoc comment.",
"3: " + getCheckMessage(JAVADOC_MISSING),
"15: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig,
getPath("javadoc" + File.separator + "InputNoJavadoc.java"),
@ -298,14 +306,14 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("scope", Scope.PRIVATE.getName());
checkConfig.addAttribute("excludeScope", Scope.PROTECTED.getName());
final String[] expected = {
"27: Missing a Javadoc comment.",
"39: Missing a Javadoc comment.",
"52: Missing a Javadoc comment.",
"63: Missing a Javadoc comment.",
"75: Missing a Javadoc comment.",
"87: Missing a Javadoc comment.",
"99: Missing a Javadoc comment.",
"111: Missing a Javadoc comment.",
"27: " + getCheckMessage(JAVADOC_MISSING),
"39: " + getCheckMessage(JAVADOC_MISSING),
"52: " + getCheckMessage(JAVADOC_MISSING),
"63: " + getCheckMessage(JAVADOC_MISSING),
"75: " + getCheckMessage(JAVADOC_MISSING),
"87: " + getCheckMessage(JAVADOC_MISSING),
"99: " + getCheckMessage(JAVADOC_MISSING),
"111: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig,
getPath("javadoc" + File.separator + "InputNoJavadoc.java"),
@ -318,8 +326,8 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
final DefaultConfiguration checkConfig =
createCheckConfig(JavadocTypeCheck.class);
final String[] expected = {
"7:4: Unused @param tag for '<D123>'.",
"11: Type Javadoc comment is missing an @param <C456> tag.",
"7:4: " + getCheckMessage(UNUSED_TAG, "@param", "<D123>"),
"11: " + getCheckMessage(MISSING_TAG, "@param <C456>"),
};
verify(checkConfig, getPath("InputTypeParamsTags.java"), expected);
}
@ -330,7 +338,7 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
createCheckConfig(JavadocTypeCheck.class);
checkConfig.addAttribute("allowMissingParamTags", "true");
final String[] expected = {
"7:4: Unused @param tag for '<D123>'.",
"7:4: " + getCheckMessage(UNUSED_TAG, "@param", "<D123>"),
};
verify(checkConfig, getPath("InputTypeParamsTags.java"), expected);
}
@ -341,7 +349,7 @@ public class JavadocTypeCheckTest extends BaseCheckTestSupport
final DefaultConfiguration checkConfig =
createCheckConfig(JavadocTypeCheck.class);
final String[] expected = {
"5:4: Unknown tag 'mytag'.",
"5:4: " + getCheckMessage(UNKNOWN_TAG, "mytag"),
};
verify(checkConfig,
getPath("javadoc" + File.separator + "InputBadTag.java"),

View File

@ -24,6 +24,8 @@ import com.puppycrawl.tools.checkstyle.api.Scope;
import java.io.File;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck.JAVADOC_MISSING;
public class JavadocVariableCheckTest
extends BaseCheckTestSupport
{
@ -34,10 +36,10 @@ public class JavadocVariableCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(JavadocVariableCheck.class);
final String[] expected = {
"11:5: Missing a Javadoc comment.",
"304:5: Missing a Javadoc comment.",
"311:5: Missing a Javadoc comment.",
"330:5: Missing a Javadoc comment.",
"11:5: " + getCheckMessage(JAVADOC_MISSING),
"304:5: " + getCheckMessage(JAVADOC_MISSING),
"311:5: " + getCheckMessage(JAVADOC_MISSING),
"330:5: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getSrcPath("checks/javadoc/InputTags.java"), expected);
}
@ -49,9 +51,9 @@ public class JavadocVariableCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(JavadocVariableCheck.class);
final String[] expected = {
"17:9: Missing a Javadoc comment.",
"24:9: Missing a Javadoc comment.",
"30:13: Missing a Javadoc comment.",
"17:9: " + getCheckMessage(JAVADOC_MISSING),
"24:9: " + getCheckMessage(JAVADOC_MISSING),
"30:13: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputInner.java"), expected);
}
@ -75,13 +77,13 @@ public class JavadocVariableCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(JavadocVariableCheck.class);
final String[] expected = {
"11:9: Missing a Javadoc comment.",
"16:13: Missing a Javadoc comment.",
"36:9: Missing a Javadoc comment.",
"43:5: Missing a Javadoc comment.",
"44:5: Missing a Javadoc comment.",
"45:5: Missing a Javadoc comment.",
"46:5: Missing a Javadoc comment.",
"11:9: " + getCheckMessage(JAVADOC_MISSING),
"16:13: " + getCheckMessage(JAVADOC_MISSING),
"36:9: " + getCheckMessage(JAVADOC_MISSING),
"43:5: " + getCheckMessage(JAVADOC_MISSING),
"44:5: " + getCheckMessage(JAVADOC_MISSING),
"45:5: " + getCheckMessage(JAVADOC_MISSING),
"46:5: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputPublicOnly.java"), expected);
}
@ -93,7 +95,7 @@ public class JavadocVariableCheckTest
createCheckConfig(JavadocVariableCheck.class);
checkConfig.addAttribute("scope", Scope.PUBLIC.getName());
final String[] expected = {
"46:5: Missing a Javadoc comment.",
"46:5: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputPublicOnly.java"), expected);
}
@ -104,43 +106,43 @@ public class JavadocVariableCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(JavadocVariableCheck.class);
final String[] expected = {
"5:5: Missing a Javadoc comment.",
"6:5: Missing a Javadoc comment.",
"7:5: Missing a Javadoc comment.",
"8:5: Missing a Javadoc comment.",
"16:9: Missing a Javadoc comment.",
"17:9: Missing a Javadoc comment.",
"18:9: Missing a Javadoc comment.",
"19:9: Missing a Javadoc comment.",
"28:9: Missing a Javadoc comment.",
"29:9: Missing a Javadoc comment.",
"30:9: Missing a Javadoc comment.",
"31:9: Missing a Javadoc comment.",
"40:9: Missing a Javadoc comment.",
"41:9: Missing a Javadoc comment.",
"42:9: Missing a Javadoc comment.",
"43:9: Missing a Javadoc comment.",
"53:5: Missing a Javadoc comment.",
"54:5: Missing a Javadoc comment.",
"55:5: Missing a Javadoc comment.",
"56:5: Missing a Javadoc comment.",
"64:9: Missing a Javadoc comment.",
"65:9: Missing a Javadoc comment.",
"66:9: Missing a Javadoc comment.",
"67:9: Missing a Javadoc comment.",
"76:9: Missing a Javadoc comment.",
"77:9: Missing a Javadoc comment.",
"78:9: Missing a Javadoc comment.",
"79:9: Missing a Javadoc comment.",
"88:9: Missing a Javadoc comment.",
"89:9: Missing a Javadoc comment.",
"90:9: Missing a Javadoc comment.",
"91:9: Missing a Javadoc comment.",
"100:9: Missing a Javadoc comment.",
"101:9: Missing a Javadoc comment.",
"102:9: Missing a Javadoc comment.",
"103:9: Missing a Javadoc comment.",
"113:9: Missing a Javadoc comment.",
"5:5: " + getCheckMessage(JAVADOC_MISSING),
"6:5: " + getCheckMessage(JAVADOC_MISSING),
"7:5: " + getCheckMessage(JAVADOC_MISSING),
"8:5: " + getCheckMessage(JAVADOC_MISSING),
"16:9: " + getCheckMessage(JAVADOC_MISSING),
"17:9: " + getCheckMessage(JAVADOC_MISSING),
"18:9: " + getCheckMessage(JAVADOC_MISSING),
"19:9: " + getCheckMessage(JAVADOC_MISSING),
"28:9: " + getCheckMessage(JAVADOC_MISSING),
"29:9: " + getCheckMessage(JAVADOC_MISSING),
"30:9: " + getCheckMessage(JAVADOC_MISSING),
"31:9: " + getCheckMessage(JAVADOC_MISSING),
"40:9: " + getCheckMessage(JAVADOC_MISSING),
"41:9: " + getCheckMessage(JAVADOC_MISSING),
"42:9: " + getCheckMessage(JAVADOC_MISSING),
"43:9: " + getCheckMessage(JAVADOC_MISSING),
"53:5: " + getCheckMessage(JAVADOC_MISSING),
"54:5: " + getCheckMessage(JAVADOC_MISSING),
"55:5: " + getCheckMessage(JAVADOC_MISSING),
"56:5: " + getCheckMessage(JAVADOC_MISSING),
"64:9: " + getCheckMessage(JAVADOC_MISSING),
"65:9: " + getCheckMessage(JAVADOC_MISSING),
"66:9: " + getCheckMessage(JAVADOC_MISSING),
"67:9: " + getCheckMessage(JAVADOC_MISSING),
"76:9: " + getCheckMessage(JAVADOC_MISSING),
"77:9: " + getCheckMessage(JAVADOC_MISSING),
"78:9: " + getCheckMessage(JAVADOC_MISSING),
"79:9: " + getCheckMessage(JAVADOC_MISSING),
"88:9: " + getCheckMessage(JAVADOC_MISSING),
"89:9: " + getCheckMessage(JAVADOC_MISSING),
"90:9: " + getCheckMessage(JAVADOC_MISSING),
"91:9: " + getCheckMessage(JAVADOC_MISSING),
"100:9: " + getCheckMessage(JAVADOC_MISSING),
"101:9: " + getCheckMessage(JAVADOC_MISSING),
"102:9: " + getCheckMessage(JAVADOC_MISSING),
"103:9: " + getCheckMessage(JAVADOC_MISSING),
"113:9: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig,
getPath("javadoc" + File.separator + "InputNoJavadoc.java"),
@ -154,10 +156,10 @@ public class JavadocVariableCheckTest
createCheckConfig(JavadocVariableCheck.class);
checkConfig.addAttribute("scope", Scope.PROTECTED.getName());
final String[] expected = {
"5:5: Missing a Javadoc comment.",
"6:5: Missing a Javadoc comment.",
"16:9: Missing a Javadoc comment.",
"17:9: Missing a Javadoc comment.",
"5:5: " + getCheckMessage(JAVADOC_MISSING),
"6:5: " + getCheckMessage(JAVADOC_MISSING),
"16:9: " + getCheckMessage(JAVADOC_MISSING),
"17:9: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig,
getPath("javadoc" + File.separator + "InputNoJavadoc.java"),
@ -172,39 +174,39 @@ public class JavadocVariableCheckTest
checkConfig.addAttribute("scope", Scope.PRIVATE.getName());
checkConfig.addAttribute("excludeScope", Scope.PROTECTED.getName());
final String[] expected = {
"7:5: Missing a Javadoc comment.",
"8:5: Missing a Javadoc comment.",
"18:9: Missing a Javadoc comment.",
"19:9: Missing a Javadoc comment.",
"28:9: Missing a Javadoc comment.",
"29:9: Missing a Javadoc comment.",
"30:9: Missing a Javadoc comment.",
"31:9: Missing a Javadoc comment.",
"40:9: Missing a Javadoc comment.",
"41:9: Missing a Javadoc comment.",
"42:9: Missing a Javadoc comment.",
"43:9: Missing a Javadoc comment.",
"53:5: Missing a Javadoc comment.",
"54:5: Missing a Javadoc comment.",
"55:5: Missing a Javadoc comment.",
"56:5: Missing a Javadoc comment.",
"64:9: Missing a Javadoc comment.",
"65:9: Missing a Javadoc comment.",
"66:9: Missing a Javadoc comment.",
"67:9: Missing a Javadoc comment.",
"76:9: Missing a Javadoc comment.",
"77:9: Missing a Javadoc comment.",
"78:9: Missing a Javadoc comment.",
"79:9: Missing a Javadoc comment.",
"88:9: Missing a Javadoc comment.",
"89:9: Missing a Javadoc comment.",
"90:9: Missing a Javadoc comment.",
"91:9: Missing a Javadoc comment.",
"100:9: Missing a Javadoc comment.",
"101:9: Missing a Javadoc comment.",
"102:9: Missing a Javadoc comment.",
"103:9: Missing a Javadoc comment.",
"113:9: Missing a Javadoc comment.",
"7:5: " + getCheckMessage(JAVADOC_MISSING),
"8:5: " + getCheckMessage(JAVADOC_MISSING),
"18:9: " + getCheckMessage(JAVADOC_MISSING),
"19:9: " + getCheckMessage(JAVADOC_MISSING),
"28:9: " + getCheckMessage(JAVADOC_MISSING),
"29:9: " + getCheckMessage(JAVADOC_MISSING),
"30:9: " + getCheckMessage(JAVADOC_MISSING),
"31:9: " + getCheckMessage(JAVADOC_MISSING),
"40:9: " + getCheckMessage(JAVADOC_MISSING),
"41:9: " + getCheckMessage(JAVADOC_MISSING),
"42:9: " + getCheckMessage(JAVADOC_MISSING),
"43:9: " + getCheckMessage(JAVADOC_MISSING),
"53:5: " + getCheckMessage(JAVADOC_MISSING),
"54:5: " + getCheckMessage(JAVADOC_MISSING),
"55:5: " + getCheckMessage(JAVADOC_MISSING),
"56:5: " + getCheckMessage(JAVADOC_MISSING),
"64:9: " + getCheckMessage(JAVADOC_MISSING),
"65:9: " + getCheckMessage(JAVADOC_MISSING),
"66:9: " + getCheckMessage(JAVADOC_MISSING),
"67:9: " + getCheckMessage(JAVADOC_MISSING),
"76:9: " + getCheckMessage(JAVADOC_MISSING),
"77:9: " + getCheckMessage(JAVADOC_MISSING),
"78:9: " + getCheckMessage(JAVADOC_MISSING),
"79:9: " + getCheckMessage(JAVADOC_MISSING),
"88:9: " + getCheckMessage(JAVADOC_MISSING),
"89:9: " + getCheckMessage(JAVADOC_MISSING),
"90:9: " + getCheckMessage(JAVADOC_MISSING),
"91:9: " + getCheckMessage(JAVADOC_MISSING),
"100:9: " + getCheckMessage(JAVADOC_MISSING),
"101:9: " + getCheckMessage(JAVADOC_MISSING),
"102:9: " + getCheckMessage(JAVADOC_MISSING),
"103:9: " + getCheckMessage(JAVADOC_MISSING),
"113:9: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig,
getPath("javadoc" + File.separator + "InputNoJavadoc.java"),
@ -219,42 +221,42 @@ public class JavadocVariableCheckTest
createCheckConfig(JavadocVariableCheck.class);
checkConfig.addAttribute("ignoreNamePattern", "log|logger");
final String[] expected = {
"5:5: Missing a Javadoc comment.",
"6:5: Missing a Javadoc comment.",
"7:5: Missing a Javadoc comment.",
"8:5: Missing a Javadoc comment.",
"16:9: Missing a Javadoc comment.",
"17:9: Missing a Javadoc comment.",
"18:9: Missing a Javadoc comment.",
"19:9: Missing a Javadoc comment.",
"28:9: Missing a Javadoc comment.",
"29:9: Missing a Javadoc comment.",
"30:9: Missing a Javadoc comment.",
"31:9: Missing a Javadoc comment.",
"40:9: Missing a Javadoc comment.",
"41:9: Missing a Javadoc comment.",
"42:9: Missing a Javadoc comment.",
"43:9: Missing a Javadoc comment.",
"53:5: Missing a Javadoc comment.",
"54:5: Missing a Javadoc comment.",
"55:5: Missing a Javadoc comment.",
"56:5: Missing a Javadoc comment.",
"64:9: Missing a Javadoc comment.",
"65:9: Missing a Javadoc comment.",
"66:9: Missing a Javadoc comment.",
"67:9: Missing a Javadoc comment.",
"76:9: Missing a Javadoc comment.",
"77:9: Missing a Javadoc comment.",
"78:9: Missing a Javadoc comment.",
"79:9: Missing a Javadoc comment.",
"88:9: Missing a Javadoc comment.",
"89:9: Missing a Javadoc comment.",
"90:9: Missing a Javadoc comment.",
"91:9: Missing a Javadoc comment.",
"100:9: Missing a Javadoc comment.",
"101:9: Missing a Javadoc comment.",
"102:9: Missing a Javadoc comment.",
"103:9: Missing a Javadoc comment.",
"5:5: " + getCheckMessage(JAVADOC_MISSING),
"6:5: " + getCheckMessage(JAVADOC_MISSING),
"7:5: " + getCheckMessage(JAVADOC_MISSING),
"8:5: " + getCheckMessage(JAVADOC_MISSING),
"16:9: " + getCheckMessage(JAVADOC_MISSING),
"17:9: " + getCheckMessage(JAVADOC_MISSING),
"18:9: " + getCheckMessage(JAVADOC_MISSING),
"19:9: " + getCheckMessage(JAVADOC_MISSING),
"28:9: " + getCheckMessage(JAVADOC_MISSING),
"29:9: " + getCheckMessage(JAVADOC_MISSING),
"30:9: " + getCheckMessage(JAVADOC_MISSING),
"31:9: " + getCheckMessage(JAVADOC_MISSING),
"40:9: " + getCheckMessage(JAVADOC_MISSING),
"41:9: " + getCheckMessage(JAVADOC_MISSING),
"42:9: " + getCheckMessage(JAVADOC_MISSING),
"43:9: " + getCheckMessage(JAVADOC_MISSING),
"53:5: " + getCheckMessage(JAVADOC_MISSING),
"54:5: " + getCheckMessage(JAVADOC_MISSING),
"55:5: " + getCheckMessage(JAVADOC_MISSING),
"56:5: " + getCheckMessage(JAVADOC_MISSING),
"64:9: " + getCheckMessage(JAVADOC_MISSING),
"65:9: " + getCheckMessage(JAVADOC_MISSING),
"66:9: " + getCheckMessage(JAVADOC_MISSING),
"67:9: " + getCheckMessage(JAVADOC_MISSING),
"76:9: " + getCheckMessage(JAVADOC_MISSING),
"77:9: " + getCheckMessage(JAVADOC_MISSING),
"78:9: " + getCheckMessage(JAVADOC_MISSING),
"79:9: " + getCheckMessage(JAVADOC_MISSING),
"88:9: " + getCheckMessage(JAVADOC_MISSING),
"89:9: " + getCheckMessage(JAVADOC_MISSING),
"90:9: " + getCheckMessage(JAVADOC_MISSING),
"91:9: " + getCheckMessage(JAVADOC_MISSING),
"100:9: " + getCheckMessage(JAVADOC_MISSING),
"101:9: " + getCheckMessage(JAVADOC_MISSING),
"102:9: " + getCheckMessage(JAVADOC_MISSING),
"103:9: " + getCheckMessage(JAVADOC_MISSING),
};
verify(checkConfig,
getPath("javadoc" + File.separator + "InputNoJavadoc.java"),

View File

@ -23,6 +23,9 @@ import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheck
.MSG_KEY;
public class NonEmptyAtclauseDescriptionCheckTest
extends BaseCheckTestSupport
{
@ -34,28 +37,28 @@ public class NonEmptyAtclauseDescriptionCheckTest
createCheckConfig(NonEmptyAtclauseDescriptionCheck.class);
final String[] expected = {
//this is a case with description that is sequences of spaces
"26: At-clause should have a non-empty description.",
"26: " + getCheckMessage(MSG_KEY),
//this is a case with description that is sequences of spaces
"27: At-clause should have a non-empty description.",
"27: " + getCheckMessage(MSG_KEY),
//this is a case with description that is sequences of spaces
"28: At-clause should have a non-empty description.",
"28: " + getCheckMessage(MSG_KEY),
//this is a case with description that is sequences of spaces
"37: At-clause should have a non-empty description.",
"37: " + getCheckMessage(MSG_KEY),
//this is a case with description that is sequences of spaces
"38: At-clause should have a non-empty description.",
"38: " + getCheckMessage(MSG_KEY),
//this is a case with description that is sequences of spaces
"39: At-clause should have a non-empty description.",
"75: At-clause should have a non-empty description.",
"76: At-clause should have a non-empty description.",
"77: At-clause should have a non-empty description.",
"78: At-clause should have a non-empty description.",
"79: At-clause should have a non-empty description.",
"80: At-clause should have a non-empty description.",
"89: At-clause should have a non-empty description.",
"90: At-clause should have a non-empty description.",
"91: At-clause should have a non-empty description.",
"92: At-clause should have a non-empty description.",
"93: At-clause should have a non-empty description.",
"39: " + getCheckMessage(MSG_KEY),
"75: " + getCheckMessage(MSG_KEY),
"76: " + getCheckMessage(MSG_KEY),
"77: " + getCheckMessage(MSG_KEY),
"78: " + getCheckMessage(MSG_KEY),
"79: " + getCheckMessage(MSG_KEY),
"80: " + getCheckMessage(MSG_KEY),
"89: " + getCheckMessage(MSG_KEY),
"90: " + getCheckMessage(MSG_KEY),
"91: " + getCheckMessage(MSG_KEY),
"92: " + getCheckMessage(MSG_KEY),
"93: " + getCheckMessage(MSG_KEY),
};
verify(checkConfig, getPath("javadoc/InputNonEmptyAtclauseDescriptionCheck.java"), expected);
}

View File

@ -23,6 +23,8 @@ import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.SingleLineJavadocCheck.MSG_KEY;
public class SingleLineJavadocCheckTest extends BaseCheckTestSupport
{
@Test
@ -31,8 +33,8 @@ public class SingleLineJavadocCheckTest extends BaseCheckTestSupport
final DefaultConfiguration checkConfig =
createCheckConfig(SingleLineJavadocCheck.class);
final String[] expected = {
"4: Single-line Javadoc comment should be multi-line.",
"12: Single-line Javadoc comment should be multi-line.",
"4: " + getCheckMessage(MSG_KEY),
"12: " + getCheckMessage(MSG_KEY),
};
verify(checkConfig, getPath("javadoc/InputSingleLineJavadocCheck.java"), expected);
}

View File

@ -23,6 +23,10 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck
.SUMMARY_FIRST_SENTENCE;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck.SUMMARY_JAVADOC;
public class SummaryJavadocCheckTest extends BaseCheckTestSupport
{
private DefaultConfiguration checkConfig;
@ -50,13 +54,13 @@ public class SummaryJavadocCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("forbiddenSummaryFragments",
"^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )");
final String[] expected = {
"14: First sentence should be present.",
"37: First sentence should be present.",
"47: Forbidden summary fragment.",
"58: Forbidden summary fragment.",
"69: First sentence should be present.",
"83: Forbidden summary fragment.",
"103: First sentence should be present.",
"14: " + getCheckMessage(SUMMARY_FIRST_SENTENCE),
"37: " + getCheckMessage(SUMMARY_FIRST_SENTENCE),
"47: " + getCheckMessage(SUMMARY_JAVADOC),
"58: " + getCheckMessage(SUMMARY_JAVADOC),
"69: " + getCheckMessage(SUMMARY_FIRST_SENTENCE),
"83: " + getCheckMessage(SUMMARY_JAVADOC),
"103: " + getCheckMessage(SUMMARY_FIRST_SENTENCE),
};
verify(checkConfig, getPath("javadoc/InputIncorrectSummaryJavaDocCheck.java"), expected);
}
@ -66,8 +70,8 @@ public class SummaryJavadocCheckTest extends BaseCheckTestSupport
{
checkConfig.addAttribute("period", "_");
final String[] expected = {
"5: First sentence should be present.",
"10: First sentence should be present.",
"5: " + getCheckMessage(SUMMARY_FIRST_SENTENCE),
"10: " + getCheckMessage(SUMMARY_FIRST_SENTENCE),
};
verify(checkConfig, getPath("javadoc/InputSummaryJavadocCheckPeriod.java"), expected);

View File

@ -33,6 +33,10 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck.MISSING_TAG;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck.TAG_FORMAT;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck.WRITE_TAG;
/**
* @author Daniel Grenner
*/
@ -62,7 +66,7 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("tagFormat", "\\S");
final String[] expected =
{
"10: @author=Daniel Grenner",
"10: " + getCheckMessage(WRITE_TAG, "@author", "Daniel Grenner"),
};
verify(checkConfig, getPath("InputWriteTag.java"), expected);
}
@ -73,7 +77,7 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("tag", "@author");
final String[] expected =
{
"10: @author=Daniel Grenner",
"10: " + getCheckMessage(WRITE_TAG, "@author", "Daniel Grenner"),
};
verify(checkConfig, getPath("InputWriteTag.java"), expected);
}
@ -86,7 +90,7 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("tagSeverity", "warning");
final String[] expected =
{
"11: warning: @incomplete=This class needs more code...",
"11: " + getCheckMessage(WRITE_TAG, "warning: @incomplete", "This class needs more code..."),
};
verify(checkConfig, getPath("InputWriteTag.java"), expected);
}
@ -97,8 +101,8 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("tag", "@doubletag");
checkConfig.addAttribute("tagFormat", "\\S");
final String[] expected = {
"12: @doubletag=first text",
"13: @doubletag=second text",
"12: " + getCheckMessage(WRITE_TAG, "@doubletag", "first text"),
"13: " + getCheckMessage(WRITE_TAG, "@doubletag", "second text"),
};
verify(checkConfig, getPath("InputWriteTag.java"), expected);
}
@ -109,7 +113,7 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("tag", "@emptytag");
checkConfig.addAttribute("tagFormat", "");
final String[] expected = {
"14: @emptytag=",
"14: " + getCheckMessage(WRITE_TAG, "@emptytag", ""),
};
verify(checkConfig, getPath("InputWriteTag.java"), expected);
}
@ -121,7 +125,7 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("tag", "@missingtag");
final String[] expected =
{
"16: Type Javadoc comment is missing an @missingtag tag.",
"16: " + getCheckMessage(MISSING_TAG, "@missingtag"),
};
verify(checkConfig, getPath("InputWriteTag.java"), expected);
}
@ -135,8 +139,8 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
"INTERFACE_DEF, CLASS_DEF, METHOD_DEF, CTOR_DEF");
checkConfig.addAttribute("severity", "ignore");
final String[] expected = {
"19: @todo=Add a constructor comment",
"30: @todo=Add a comment",
"19: " + getCheckMessage(WRITE_TAG, "@todo", "Add a constructor comment"),
"30: " + getCheckMessage(WRITE_TAG, "@todo", "Add a comment"),
};
verify(checkConfig, getPath("InputWriteTag.java"), expected);
}
@ -149,7 +153,7 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("severity", "ignore");
final String[] expected =
{
"10: @author=Daniel Grenner",
"10: " + getCheckMessage(WRITE_TAG, "@author", "Daniel Grenner"),
};
verify(checkConfig, getPath("InputWriteTag.java"), expected);
}
@ -184,7 +188,7 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
checkConfig.addAttribute("tag", "@author");
checkConfig.addAttribute("tagFormat", "ABC");
final String[] expected = {
"10: Type Javadoc tag @author must match pattern 'ABC'.",
"10: " + getCheckMessage(TAG_FORMAT, "@author", "ABC"),
};
verify(checkConfig, getPath("InputWriteTag.java"), expected);
}
@ -200,10 +204,10 @@ public class WriteTagCheckTest extends BaseCheckTestSupport
"ANNOTATION_DEF, ENUM_DEF, ANNOTATION_FIELD_DEF, ENUM_CONSTANT_DEF");
final String[] expected =
{
"9: @incomplete=This enum needs more code...",
"13: @incomplete=This enum constant needs more code...",
"19: @incomplete=This annotation needs more code...",
"23: @incomplete=This annotation field needs more code...",
"9: " + getCheckMessage(WRITE_TAG, "@incomplete", "This enum needs more code..."),
"13: " + getCheckMessage(WRITE_TAG, "@incomplete", "This enum constant needs more code..."),
"19: " + getCheckMessage(WRITE_TAG, "@incomplete", "This annotation needs more code..."),
"23: " + getCheckMessage(WRITE_TAG, "@incomplete", "This annotation field needs more code..."),
};
verify(checkConfig, getPath("InputWriteTag2.java"), expected);
}