tag should be precede with empty line.", - "8:
tag should be precede with empty line.", - "14:
tag should be precede with empty line.", - "23:
tag should be precede with empty line.", - "32:
tag should be precede with empty line.", - "32: Redundant
tag.", - "33:
tag should be precede with empty line.", - "34:
tag should be precede with empty line.", - "35:
tag should be precede with empty line.", - "39:
tag should be precede with empty line.", - "45: Redundant
tag.", - "50:
tag should be precede with empty line.", - "51:
tag should be precede with empty line.", - "61: Redundant
tag.", - "62: Empty line should be followed by
tag on the next line.", - "70:
tag should be precede with empty line.", - "75:
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);
}
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java
index 8f00e59c4..6a266eb53 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java
@@ -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: This guy is missing end of bold tag",
- "66:7: Extra HTML tag found: Extra tag shouldn't be here",
- "68:19: Unclosed HTML tag found: dummy.",
- "74: First sentence should end with a period.",
- "75:23: Unclosed HTML tag found: should fail",
- "81: First sentence should end with a period.",
- "82:31: Unclosed HTML tag found: should fail",
- "88: First sentence should end with a period.",
- "89:31: Extra HTML tag found: ",
- "90: Incomplete HTML tag found: * should fail <",
- "109:39: Extra HTML tag found: ",
- "186:8: Unclosed HTML tag found: ",
- "193: First sentence should end with a period.",
- "238: First sentence should end with a period.",
- "335:33: Extra HTML tag found:
dummy."),
+ "74: " + getCheckMessage(NO_PERIOD),
+ "75:23: " + getCheckMessage(UNCLOSED_HTML, "should fail"),
+ "81: " + getCheckMessage(NO_PERIOD),
+ "82:31: " + getCheckMessage(UNCLOSED_HTML, "should fail"),
+ "88: " + getCheckMessage(NO_PERIOD),
+ "89:31: " + getCheckMessage(EXTRA_HTML, ""),
+ "90: " + getCheckMessage(INCOMPLETE_TAG, " * should fail <"),
+ "109:39: " + getCheckMessage(EXTRA_HTML, ""),
+ "186:8: " + getCheckMessage(UNCLOSED_HTML, ""), + "193: " + getCheckMessage(NO_PERIOD), + "238: " + getCheckMessage(NO_PERIOD), + "335:33: " + getCheckMessage(EXTRA_HTML, ""), }; 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: This guy is missing end of bold tag", - "66:7: Extra HTML tag found: Extra tag shouldn't be here", - "68:19: Unclosed HTML tag found:dummy.", - "75:23: Unclosed HTML tag found: should fail", - "82:31: Unclosed HTML tag found: should fail", - "89:31: Extra HTML tag found:", - "90: Incomplete HTML tag found: * should fail <", - "109:39: Extra HTML tag found: ", - "186:8: Unclosed HTML tag found:", - "335:33: Extra HTML tag found: ", + "63:11: " + getCheckMessage(UNCLOSED_HTML, "This guy is missing end of bold tag"), + "66:7: " + getCheckMessage(EXTRA_HTML, "Extra tag shouldn't be here"), + "68:19: " + getCheckMessage(UNCLOSED_HTML, "dummy."), + "75:23: " + getCheckMessage(UNCLOSED_HTML, "should fail"), + "82:31: " + getCheckMessage(UNCLOSED_HTML, "should fail"), + "89:31: " + getCheckMessage(EXTRA_HTML, ""), + "90: " + getCheckMessage(INCOMPLETE_TAG, " * should fail <"), + "109:39: " + getCheckMessage(EXTRA_HTML, ""), + "186:8: " + getCheckMessage(UNCLOSED_HTML, ""), + "335:33: " + getCheckMessage(EXTRA_HTML, ""), }; 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: ", - "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: ", + "88: " + getCheckMessage(NO_PERIOD), + "89:31: " + getCheckMessage(EXTRA_HTML, ""), + "90: " + getCheckMessage(INCOMPLETE_TAG, " * should fail <"), + "205: " + getCheckMessage(EMPTY), + "230: " + getCheckMessage(EMPTY), + "238: " + getCheckMessage(NO_PERIOD), + "335:33: " + getCheckMessage(EXTRA_HTML, ""), }; 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: should fail", - "88: First sentence should end with a period.", - "89:31: Extra HTML tag found: ", - "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: ", + "74: " + getCheckMessage(NO_PERIOD), + "75:23: " + getCheckMessage(UNCLOSED_HTML, "should fail"), + "88: " + getCheckMessage(NO_PERIOD), + "89:31: " + getCheckMessage(EXTRA_HTML, ""), + "90: " + getCheckMessage(INCOMPLETE_TAG, " * should fail <"), + "205: " + getCheckMessage(EMPTY), + "211: " + getCheckMessage(EMPTY), + "230: " + getCheckMessage(EMPTY), + "238: " + getCheckMessage(NO_PERIOD), + "335:33: " + getCheckMessage(EXTRA_HTML, ""), }; 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: should fail", - "81: First sentence should end with a period.", - "82:31: Unclosed HTML tag found: should fail", - "88: First sentence should end with a period.", - "89:31: Extra HTML tag found: ", - "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: ", + "74: " + getCheckMessage(NO_PERIOD), + "75:23: " + getCheckMessage(UNCLOSED_HTML, "should fail"), + "81: " + getCheckMessage(NO_PERIOD), + "82:31: " + getCheckMessage(UNCLOSED_HTML, "should fail"), + "88: " + getCheckMessage(NO_PERIOD), + "89:31: " + getCheckMessage(EXTRA_HTML, ""), + "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, ""), }; 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: This guy is missing end of bold tag", - "66:7: Extra HTML tag found: Extra tag shouldn't be here", - "68:19: Unclosed HTML tag found:dummy.", - "81: First sentence should end with a period.", - "82:31: Unclosed HTML tag found: should fail", - "109:39: Extra HTML tag found: ", - "186:8: Unclosed HTML tag found:", - "193: First sentence should end with a period.", + "20: " + getCheckMessage(NO_PERIOD), + "53: " + getCheckMessage(NO_PERIOD), + "63:11: " + getCheckMessage(UNCLOSED_HTML, "This guy is missing end of bold tag"), + "66:7: " + getCheckMessage(EXTRA_HTML, "Extra tag shouldn't be here"), + "68:19: " + getCheckMessage(UNCLOSED_HTML, "dummy."), + "81: " + getCheckMessage(NO_PERIOD), + "82:31: " + getCheckMessage(UNCLOSED_HTML, "should fail"), + "109:39: " + getCheckMessage(EXTRA_HTML, ""), + "186:8: " + getCheckMessage(UNCLOSED_HTML, ""), + "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 diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java index b838e4f35..d7b887341 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java @@ -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); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java index ea8a13e12..199baa3fb 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java @@ -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 ''.", - "11: Type Javadoc comment is missing an @param tag.", + "7:4: " + getCheckMessage(UNUSED_TAG, "@param", " "), + "11: " + getCheckMessage(MISSING_TAG, "@param "), }; 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 ' '.", + "7:4: " + getCheckMessage(UNUSED_TAG, "@param", " "), }; 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"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java index fac2e3ccf..e05cd7071 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java @@ -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"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java index c7d9e8393..ca4ae6f98 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java @@ -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); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java index 05a2d5b3d..4cfc3b2d7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java @@ -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); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java index 12ddfab66..1c431529a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java @@ -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); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java index 88aff26a3..9bed0748b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java @@ -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); }