From 09a7ca60414ea04b64f45bb190eaa26c767086be Mon Sep 17 00:00:00 2001 From: ychulovskyy Date: Sat, 27 Dec 2014 22:49:55 +0100 Subject: [PATCH] Issue #537 refactoring: remove copy-paste of messages from UTests --- .../annotation/AnnotationLocationCheck.java | 16 +- .../annotation/AnnotationUseStyleCheck.java | 45 +- .../annotation/MissingDeprecatedCheck.java | 30 +- .../annotation/MissingOverrideCheck.java | 17 +- .../annotation/SuppressWarningsCheck.java | 9 +- .../checkstyle/BaseCheckTestSupport.java | 84 +- .../checks/UniquePropertiesCheckTest.java | 34 +- .../AnnotationLocationCheckTest.java | 41 +- .../annotation/AnnotationUseStyleTest.java | 88 +- .../annotation/MissingDeprecatedTest.java | 66 +- .../annotation/MissingOverrideCheckTest.java | 47 +- .../annotation/SuppressWarningsTest.java | 864 +++++++++--------- ...ableDeclarationUsageDistanceCheckTest.java | 12 - .../AbbreviationAsWordInNameCheckTest.java | 11 - .../checks/naming/TypeNameCheckTest.java | 49 +- 15 files changed, 731 insertions(+), 682 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheck.java index 8f10a1609..b829df522 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheck.java @@ -112,6 +112,18 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; */ public class AnnotationLocationCheck extends Check { + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_ANNOTATION_LOCATION_ALONE = "annotation.location.alone"; + + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_ANNOTATION_LOCATION = "annotation.location"; + /** * Some javadoc. */ @@ -191,10 +203,10 @@ public class AnnotationLocationCheck extends Check if (!isCorrectLocation(annotation, hasParameters)) { log(annotation.getLineNo(), - "annotation.location.alone", getAnnotationName(annotation)); + MSG_KEY_ANNOTATION_LOCATION_ALONE, getAnnotationName(annotation)); } else if (annotation.getColumnNo() != aCorrectLevel && !hasNodeBefore(annotation)) { - log(annotation.getLineNo(), "annotation.location", + log(annotation.getLineNo(), MSG_KEY_ANNOTATION_LOCATION, getAnnotationName(annotation), annotation.getColumnNo(), aCorrectLevel); } annotation = annotation.getNextSibling(); diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java index 753747929..4d54bf6fb 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheck.java @@ -125,6 +125,41 @@ public final class AnnotationUseStyleCheck extends Check private static final String ANNOTATION_ELEMENT_SINGLE_NAME = "value"; + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_ANNOTATION_INCORRECT_STYLE = + "annotation.incorrect.style"; + + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_ANNOTATION_PARENS_MISSING = + "annotation.parens.missing"; + + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_ANNOTATION_PARENS_PRESENT = + "annotation.parens.present"; + + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING = + "annotation.trailing.comma.missing"; + + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT = + "annotation.trailing.comma.present"; + //not extending AbstractOptionCheck because check //has more than one option type. @@ -260,7 +295,7 @@ public final class AnnotationUseStyleCheck extends Check if (valuePairCount == 0 && aAnnotation.branchContains(TokenTypes.EXPR)) { - this.log(aAnnotation.getLineNo(), "annotation.incorrect.style", + this.log(aAnnotation.getLineNo(), MSG_KEY_ANNOTATION_INCORRECT_STYLE, ElementStyle.EXPANDED); } } @@ -382,13 +417,13 @@ public final class AnnotationUseStyleCheck extends Check && (comma == null || comma.getType() != TokenTypes.COMMA)) { this.log(rCurly.getLineNo(), - rCurly.getColumnNo(), "annotation.trailing.comma.missing"); + rCurly.getColumnNo(), MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING); } else if (TrailingArrayComma.NEVER.equals(this.mComma) && comma != null && comma.getType() == TokenTypes.COMMA) { this.log(comma.getLineNo(), - comma.getColumnNo(), "annotation.trailing.comma.present"); + comma.getColumnNo(), MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT); } } @@ -412,7 +447,7 @@ public final class AnnotationUseStyleCheck extends Check if (ClosingParens.ALWAYS.equals(this.mParens) && !parenExists) { - this.log(aAST.getLineNo(), "annotation.parens.missing"); + this.log(aAST.getLineNo(), MSG_KEY_ANNOTATION_PARENS_MISSING); } else if (ClosingParens.NEVER.equals(this.mParens) && !aAST.branchContains(TokenTypes.EXPR) @@ -420,7 +455,7 @@ public final class AnnotationUseStyleCheck extends Check && !aAST.branchContains(TokenTypes.ANNOTATION_ARRAY_INIT) && parenExists) { - this.log(aAST.getLineNo(), "annotation.parens.present"); + this.log(aAST.getLineNo(), MSG_KEY_ANNOTATION_PARENS_PRESENT); } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheck.java index 9a4746eb3..ee8be2c4f 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheck.java @@ -96,6 +96,26 @@ public final class MissingDeprecatedCheck extends Check /** Multiline finished at next Javadoc * */ private static final String NEXT_TAG = "@"; + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_ANNOTATION_MISSING_DEPRECATED = + "annotation.missing.deprecated"; + + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_JAVADOC_DUPLICATE_TAG = + "javadoc.duplicateTag"; + + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_JAVADOC_MISSING = "javadoc.missing"; + /** {@inheritDoc} */ @Override public int[] getDefaultTokens() @@ -134,7 +154,7 @@ public final class MissingDeprecatedCheck extends Check final boolean containsJavadocTag = this.containsJavadocTag(javadoc); if (containsAnnotation ^ containsJavadocTag) { - this.log(aAST.getLineNo(), "annotation.missing.deprecated"); + this.log(aAST.getLineNo(), MSG_KEY_ANNOTATION_MISSING_DEPRECATED); } } @@ -168,7 +188,7 @@ public final class MissingDeprecatedCheck extends Check if (javadocNoargMatcher.find()) { if (found) { - this.log(currentLine, "javadoc.duplicateTag", + this.log(currentLine, MSG_KEY_JAVADOC_DUPLICATE_TAG, JavadocTagInfo.DEPRECATED.getText()); } found = true; @@ -193,15 +213,15 @@ public final class MissingDeprecatedCheck extends Check && !lFin.equals(MissingDeprecatedCheck.END_JAVADOC)) { if (found) { - this.log(currentLine, "javadoc.duplicateTag", + this.log(currentLine, MSG_KEY_JAVADOC_DUPLICATE_TAG, JavadocTagInfo.DEPRECATED.getText()); } found = true; } else { - this.log(currentLine, "javadoc.missing"); + this.log(currentLine, MSG_KEY_JAVADOC_MISSING); if (found) { - this.log(currentLine, "javadoc.duplicateTag", + this.log(currentLine, MSG_KEY_JAVADOC_DUPLICATE_TAG, JavadocTagInfo.DEPRECATED.getText()); } found = true; diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java index 4e72b42f4..2d3a4accb 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java @@ -86,6 +86,19 @@ public final class MissingOverrideCheck extends Check private static final Pattern MATCH_INHERITDOC = Utils.createPattern("\\{\\s*@(inheritDoc)\\s*\\}"); + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_TAG_NOT_VALID_ON = "tag.not.valid.on"; + + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_ANNOTATION_MISSING_OVERRIDE = + "annotation.missing.override"; + /** @see #setJavaFiveCompatibility(boolean) */ private boolean mJavaFiveCompatibility; @@ -142,7 +155,7 @@ public final class MissingOverrideCheck extends Check final boolean containsTag = this.containsJavadocTag(javadoc); if (containsTag && !JavadocTagInfo.INHERIT_DOC.isValidOn(aAST)) { - this.log(aAST.getLineNo(), "tag.not.valid.on", + this.log(aAST.getLineNo(), MSG_KEY_TAG_NOT_VALID_ON, JavadocTagInfo.INHERIT_DOC.getText()); return; } @@ -162,7 +175,7 @@ public final class MissingOverrideCheck extends Check && (!AnnotationUtility.containsAnnotation(aAST, OVERRIDE) && !AnnotationUtility.containsAnnotation(aAST, FQ_OVERRIDE))) { - this.log(aAST.getLineNo(), "annotation.missing.override"); + this.log(aAST.getLineNo(), MSG_KEY_ANNOTATION_MISSING_OVERRIDE); } } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java index ccc080d8c..a4d7c4f0c 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java @@ -96,6 +96,13 @@ public class SuppressWarningsCheck extends AbstractFormatCheck private static final String FQ_SUPPRESS_WARNINGS = "java.lang." + SUPPRESS_WARNINGS; + /** + * A key is pointing to the warning message text in "messages.properties" + * file. + */ + public static final String MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED = + "suppressed.warning.not.allowed"; + /** * Ctor that specifies the default for the format property * as specified in the class javadocs. @@ -216,7 +223,7 @@ public class SuppressWarningsCheck extends AbstractFormatCheck final Matcher matcher = this.getRegexp().matcher(aWarningText); if (matcher.matches()) { this.log(aLineNo, aColNum, - "suppressed.warning.not.allowed", aWarningText); + MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, aWarningText); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java b/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java index 75c99ac69..1f2e315f9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java @@ -1,5 +1,6 @@ package com.puppycrawl.tools.checkstyle; +import static java.text.MessageFormat.format; import static org.junit.Assert.assertEquals; import com.google.common.collect.Lists; @@ -18,38 +19,41 @@ import java.util.List; import java.util.Locale; import java.util.Properties; -public abstract class BaseCheckTestSupport -{ - /** a brief logger that only display info about errors */ +public abstract class BaseCheckTestSupport { + /** + * a brief logger that only display info about errors + */ protected static class BriefLogger - extends DefaultLogger - { - public BriefLogger(OutputStream out) - { + extends DefaultLogger { + public BriefLogger(OutputStream out) { super(out, true); } + @Override - public void auditStarted(AuditEvent evt) {} + public void auditStarted(AuditEvent evt) { + } + @Override - public void fileFinished(AuditEvent evt) {} + public void fileFinished(AuditEvent evt) { + } + @Override - public void fileStarted(AuditEvent evt) {} + public void fileStarted(AuditEvent evt) { + } } protected final ByteArrayOutputStream mBAOS = new ByteArrayOutputStream(); protected final PrintStream mStream = new PrintStream(mBAOS); protected final Properties mProps = new Properties(); - public static DefaultConfiguration createCheckConfig(Class aClazz) - { + public static DefaultConfiguration createCheckConfig(Class aClazz) { final DefaultConfiguration checkConfig = - new DefaultConfiguration(aClazz.getName()); + new DefaultConfiguration(aClazz.getName()); return checkConfig; } protected Checker createChecker(Configuration aCheckConfig) - throws Exception - { + throws Exception { final DefaultConfiguration dc = createCheckerConfig(aCheckConfig); final Checker c = new Checker(); // make sure the tests always run with english error messages @@ -63,10 +67,9 @@ public abstract class BaseCheckTestSupport return c; } - protected DefaultConfiguration createCheckerConfig(Configuration aConfig) - { + protected DefaultConfiguration createCheckerConfig(Configuration aConfig) { final DefaultConfiguration dc = - new DefaultConfiguration("configuration"); + new DefaultConfiguration("configuration"); final DefaultConfiguration twConf = createCheckConfig(TreeWalker.class); // make sure that the tests always run with this charset dc.addAttribute("charset", "iso-8859-1"); @@ -76,26 +79,22 @@ public abstract class BaseCheckTestSupport } protected static String getPath(String aFilename) - throws IOException - { + throws IOException { return new File("src/test/resources/com/puppycrawl/tools/checkstyle/" + aFilename).getCanonicalPath(); } - protected static String getSrcPath(String aFilename) throws IOException - { - + protected static String getSrcPath(String aFilename) throws IOException { + return new File("src/test/java/com/puppycrawl/tools/checkstyle/" + aFilename).getCanonicalPath(); } protected void verify(Configuration aConfig, String aFileName, String[] aExpected) - throws Exception - { + throws Exception { verify(createChecker(aConfig), aFileName, aFileName, aExpected); } protected void verify(Checker aC, String aFileName, String[] aExpected) - throws Exception - { + throws Exception { verify(aC, aFileName, aFileName, aExpected); } @@ -103,19 +102,17 @@ public abstract class BaseCheckTestSupport String aProcessedFilename, String aMessageFileName, String[] aExpected) - throws Exception - { + throws Exception { verify(aC, - new File[] {new File(aProcessedFilename)}, - aMessageFileName, aExpected); + new File[]{new File(aProcessedFilename)}, + aMessageFileName, aExpected); } protected void verify(Checker aC, File[] aProcessedFiles, String aMessageFileName, String[] aExpected) - throws Exception - { + throws Exception { mStream.flush(); final List theFiles = Lists.newArrayList(); Collections.addAll(theFiles, aProcessedFiles); @@ -123,10 +120,10 @@ public abstract class BaseCheckTestSupport // process each of the lines final ByteArrayInputStream bais = - new ByteArrayInputStream(mBAOS.toByteArray()); + new ByteArrayInputStream(mBAOS.toByteArray()); final LineNumberReader lnr = - new LineNumberReader(new InputStreamReader(bais)); - + new LineNumberReader(new InputStreamReader(bais)); + for (int i = 0; i < aExpected.length; i++) { final String expected = aMessageFileName + ":" + aExpected[i]; final String actual = lnr.readLine(); @@ -134,7 +131,7 @@ public abstract class BaseCheckTestSupport } assertEquals("unexpected output: " + lnr.readLine(), - aExpected.length, errs); + aExpected.length, errs); aC.destroy(); } @@ -142,19 +139,16 @@ public abstract class BaseCheckTestSupport * Gets the check message 'as is' from appropriate 'messages.properties' * file. * - * @param messageKey - * the key of message in 'messages.properties' file. + * @param messageKey the key of message in 'messages.properties' file. + * @param arguments the arguments of message in 'messages.properties' file. */ - public String getCheckMessage(String messageKey) - { + public String getCheckMessage(String messageKey, Object... arguments) { Properties pr = new Properties(); try { pr.load(getClass().getResourceAsStream("messages.properties")); - } - catch (IOException e) { + } catch (IOException e) { return null; } - return pr.getProperty(messageKey); + return format(pr.getProperty(messageKey), arguments); } - } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckTest.java index 0282987c6..e480123df 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckTest.java @@ -22,7 +22,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -36,15 +35,15 @@ import com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.api.LocalizedMessage; +import static com.puppycrawl.tools.checkstyle.checks.UniquePropertiesCheck.IO_EXCEPTION_KEY; +import static com.puppycrawl.tools.checkstyle.checks.UniquePropertiesCheck.MSG_KEY; + /** * JUnit tests for Unique Properties check. */ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport { - private String msg = getCheckMessage(UniquePropertiesCheck.MSG_KEY); - private String ioMsg = getCheckMessage(UniquePropertiesCheck.IO_EXCEPTION_KEY); - private DefaultConfiguration mCheckConfig; @Before @@ -63,12 +62,12 @@ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport { final String[] expected = { - buildMesssage(3, "general.exception", 2), - buildMesssage(5, "DefaultLogger.auditStarted", 2), - buildMesssage(11, "onlineManual", 3), - buildMesssage(22, "time stamp", 3), - buildMesssage(28, "Support Link ", 2), - buildMesssage(34, "failed", 2), + "3: " + getCheckMessage(MSG_KEY, "general.exception", 2), + "5: " + getCheckMessage(MSG_KEY, "DefaultLogger.auditStarted", 2), + "11: " + getCheckMessage(MSG_KEY, "onlineManual", 3), + "22: " + getCheckMessage(MSG_KEY, "time stamp", 3), + "28: " + getCheckMessage(MSG_KEY, "Support Link ", 2), + "34: " + getCheckMessage(MSG_KEY, "failed", 2), }; verify(mCheckConfig, getPath("InputUniquePropertiesCheck.properties"), expected); @@ -118,7 +117,7 @@ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport "unable.open.cause"); Assert.assertEquals("Message '" + message.getMessage() + "' is not valid", message.getMessage(), - buildIOMessage(fileName, getFileNotFoundDetail(file))); + getCheckMessage(IO_EXCEPTION_KEY, fileName, getFileNotFoundDetail(file))); } /** @@ -142,17 +141,4 @@ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport return ex.getLocalizedMessage(); } } - - private String buildMesssage(int lineNumber, String keyName, - int nOccurrences) - { - return lineNumber + ": " - + MessageFormat.format(msg, keyName, nOccurrences); - } - - private String buildIOMessage(String filename, String exceptionDetails) - { - return MessageFormat.format(ioMsg, filename, exceptionDetails); - } - } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.java index fd422d5fd..e2896b769 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.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.annotation.AnnotationLocationCheck.MSG_KEY_ANNOTATION_LOCATION_ALONE; +import static com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck.MSG_KEY_ANNOTATION_LOCATION; + public class AnnotationLocationCheckTest extends BaseCheckTestSupport { @Test @@ -40,25 +43,25 @@ public class AnnotationLocationCheckTest extends BaseCheckTestSupport { DefaultConfiguration checkConfig = createCheckConfig(AnnotationLocationCheck.class); final String[] expected = { - "6: Annotation 'MyAnnotation1' should be alone on line.", - "11: Annotation 'MyAnnotation1' should be alone on line.", - "17: Annotation 'MyAnnotation1' have incorrect indentation level 8, expected level should be 4.", - "25: Annotation 'MyAnnotation1' have incorrect indentation level 8, expected level should be 4.", - "29: Annotation 'MyAnnotation1' should be alone on line.", - "29: Annotation 'MyAnnotation2' should be alone on line.", - "32: Annotation 'MyAnnotation2' have incorrect indentation level 7, expected level should be 4.", - "36: Annotation 'MyAnnotation2' have incorrect indentation level 8, expected level should be 4.", - "37: Annotation 'MyAnnotation3' have incorrect indentation level 6, expected level should be 4.", - "38: Annotation 'MyAnnotation4' have incorrect indentation level 10, expected level should be 4.", - "41: Annotation 'MyAnnotation1' should be alone on line.", - "48: Annotation 'MyAnnotation1' have incorrect indentation level 12, expected level should be 8.", - "61: Annotation 'MyAnnotation2' have incorrect indentation level 12, expected level should be 8.", - "65: Annotation 'MyAnnotation2' have incorrect indentation level 12, expected level should be 8.", - "70: Annotation 'MyAnnotation2' have incorrect indentation level 7, expected level should be 4.", - "73: Annotation 'MyAnnotation1' should be alone on line.", - "85: Annotation 'MyAnnotation2' have incorrect indentation level 11, expected level should be 8.", - "88: Annotation 'MyAnnotation2' have incorrect indentation level 10, expected level should be 8.", - "98: Annotation 'MyAnnotation2' have incorrect indentation level 0, expected level should be 3.", + "6: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation1"), + "11: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation1"), + "17: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation1", 8, 4), + "25: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation1", 8, 4), + "29: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation1"), + "29: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation2"), + "32: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation2", 7, 4), + "36: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation2", 8, 4), + "37: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation3", 6, 4), + "38: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation4", 10, 4), + "41: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation1"), + "48: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation1", 12, 8), + "61: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation2", 12, 8), + "65: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation2", 12, 8), + "70: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation2", 7, 4), + "73: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation1"), + "85: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation2", 11, 8), + "88: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation2", 10, 8), + "98: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation2", 0, 3), }; verify(checkConfig, getPath("annotation/InputIncorrectAnnotationLocation.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleTest.java index f9dc36952..7fee6d8fb 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleTest.java @@ -23,6 +23,12 @@ import org.junit.Test; import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; +import static com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.MSG_KEY_ANNOTATION_INCORRECT_STYLE; +import static com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.MSG_KEY_ANNOTATION_PARENS_MISSING; +import static com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.MSG_KEY_ANNOTATION_PARENS_PRESENT; +import static com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING; +import static com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT; + public class AnnotationUseStyleTest extends BaseCheckTestSupport { /** @@ -37,9 +43,9 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport checkConfig.addAttribute("elementStyle", "ignore"); checkConfig.addAttribute("trailingArrayComma", "ignore"); final String[] expected = { - "3: Annotation must have closing parenthesis.", - "18: Annotation must have closing parenthesis.", - "23: Annotation must have closing parenthesis.", + "3: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_MISSING), + "18: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_MISSING), + "23: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_MISSING), }; verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected); @@ -57,9 +63,9 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport checkConfig.addAttribute("elementStyle", "ignore"); checkConfig.addAttribute("trailingArrayComma", "ignore"); final String[] expected = { - "13: Annotation cannot have closing parenthesis.", - "30: Annotation cannot have closing parenthesis.", - "33: Annotation cannot have closing parenthesis.", + "13: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_PRESENT), + "30: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_PRESENT), + "33: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_PRESENT), }; verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected); @@ -73,13 +79,13 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport checkConfig.addAttribute("elementStyle", "EXPANDED"); checkConfig.addAttribute("trailingArrayComma", "ignore"); final String[] expected = { - "5: Annotation style must be 'EXPANDED'.", - "12: Annotation style must be 'EXPANDED'.", - "20: Annotation style must be 'EXPANDED'.", - "26: Annotation style must be 'EXPANDED'.", - "39: Annotation style must be 'EXPANDED'.", - "41: Annotation style must be 'EXPANDED'.", - "58: Annotation style must be 'EXPANDED'.", + "5: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), + "12: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), + "20: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), + "26: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), + "39: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), + "41: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), + "58: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), }; verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected); @@ -93,8 +99,8 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport checkConfig.addAttribute("elementStyle", "COMPACT"); checkConfig.addAttribute("trailingArrayComma", "ignore"); final String[] expected = { - "43: Annotation style must be 'COMPACT'.", - "47: Annotation style must be 'COMPACT'.", + "43: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT"), + "47: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT"), }; verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected); @@ -108,11 +114,11 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport checkConfig.addAttribute("elementStyle", "COMPACT_NO_ARRAY"); checkConfig.addAttribute("trailingArrayComma", "ignore"); final String[] expected = { - "5: Annotation style must be 'COMPACT_NO_ARRAY'.", - "20: Annotation style must be 'COMPACT_NO_ARRAY'.", - "41: Annotation style must be 'COMPACT_NO_ARRAY'.", - "43: Annotation style must be 'COMPACT_NO_ARRAY'.", - "47: Annotation style must be 'COMPACT_NO_ARRAY'.", + "5: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), + "20: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), + "41: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), + "43: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), + "47: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), }; verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected); @@ -126,19 +132,19 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport checkConfig.addAttribute("elementStyle", "ignore"); checkConfig.addAttribute("trailingArrayComma", "ALWAYS"); final String[] expected = { - "3:20: Annotation array values must contain trailing comma.", - "6:30: Annotation array values must contain trailing comma.", - "10:40: Annotation array values must contain trailing comma.", - "13:44: Annotation array values must contain trailing comma.", - "16:54: Annotation array values must contain trailing comma.", - "24:37: Annotation array values must contain trailing comma.", - "24:65: Annotation array values must contain trailing comma.", - "26:21: Annotation array values must contain trailing comma.", - "26:30: Annotation array values must contain trailing comma.", - "29:39: Annotation array values must contain trailing comma.", - "29:49: Annotation array values must contain trailing comma.", - "32:21: Annotation array values must contain trailing comma.", - "32:56: Annotation array values must contain trailing comma.", + "3:20: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "6:30: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "10:40: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "13:44: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "16:54: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "24:37: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "24:65: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "26:21: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "26:30: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "29:39: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "29:49: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "32:21: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), + "32:56: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), }; verify(checkConfig, getPath("annotation" + File.separator + "AnnotationUseNoTrailingComma.java"), expected); @@ -165,14 +171,14 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport checkConfig.addAttribute("elementStyle", "ignore"); checkConfig.addAttribute("trailingArrayComma", "NEVER"); final String[] expected = { - "9:32: Annotation array values cannot contain trailing comma.", - "13:42: Annotation array values cannot contain trailing comma.", - "16:46: Annotation array values cannot contain trailing comma.", - "19:56: Annotation array values cannot contain trailing comma.", - "27:38: Annotation array values cannot contain trailing comma.", - "27:67: Annotation array values cannot contain trailing comma.", - "33:39: Annotation array values cannot contain trailing comma.", - "33:50: Annotation array values cannot contain trailing comma.", + "9:32: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), + "13:42: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), + "16:46: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), + "19:56: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), + "27:38: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), + "27:67: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), + "33:39: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), + "33:50: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), }; verify(checkConfig, getPath("annotation" + File.separator + "AnnotationUseWithTrailingComma.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedTest.java index b48b549fb..4568bf6b7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedTest.java @@ -25,6 +25,10 @@ import org.junit.Test; import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; +import static com.puppycrawl.tools.checkstyle.checks.annotation.MissingDeprecatedCheck.MSG_KEY_ANNOTATION_MISSING_DEPRECATED; +import static com.puppycrawl.tools.checkstyle.checks.annotation.MissingDeprecatedCheck.MSG_KEY_JAVADOC_DUPLICATE_TAG; +import static com.puppycrawl.tools.checkstyle.checks.annotation.MissingDeprecatedCheck.MSG_KEY_JAVADOC_MISSING; + public class MissingDeprecatedTest extends BaseCheckTestSupport { /** @@ -36,15 +40,15 @@ public class MissingDeprecatedTest extends BaseCheckTestSupport DefaultConfiguration checkConfig = createCheckConfig(MissingDeprecatedCheck.class); final String[] expected = { - "7: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "12: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "19: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "26: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "31: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "38: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "43: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "51: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "56: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", + "7: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "12: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "19: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "26: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "31: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "38: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "43: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "51: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "56: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), }; verify(checkConfig, getPath("annotation" + File.separator + "BadDeprecatedAnnotation.java"), expected); @@ -60,15 +64,15 @@ public class MissingDeprecatedTest extends BaseCheckTestSupport DefaultConfiguration checkConfig = createCheckConfig(MissingDeprecatedCheck.class); final String[] expected = { - "5: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "11: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "16: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "23: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "29: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "38: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "40: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "48: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "55: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", + "5: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "11: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "16: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "23: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "29: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "38: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "40: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "48: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "55: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), }; verify(checkConfig, getPath("annotation" + File.separator + "BadDeprecatedJavadoc.java"), expected); @@ -84,19 +88,19 @@ public class MissingDeprecatedTest extends BaseCheckTestSupport DefaultConfiguration checkConfig = createCheckConfig(MissingDeprecatedCheck.class); final String[] expected = { - "5: Duplicate @deprecated tag.", - "12: Duplicate @deprecated tag.", - "14: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "17: Missing a Javadoc comment.", - "19: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.", - "24: Missing a Javadoc comment.", - "32: Missing a Javadoc comment.", - "33: Duplicate @deprecated tag.", - "33: Missing a Javadoc comment.", - "42: Duplicate @deprecated tag.", - "42: Missing a Javadoc comment.", - "50: Missing a Javadoc comment.", - "51: Duplicate @deprecated tag.", + "5: " + getCheckMessage(MSG_KEY_JAVADOC_DUPLICATE_TAG, "@deprecated"), + "12: " + getCheckMessage(MSG_KEY_JAVADOC_DUPLICATE_TAG, "@deprecated"), + "14: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "17: " + getCheckMessage(MSG_KEY_JAVADOC_MISSING), + "19: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), + "24: " + getCheckMessage(MSG_KEY_JAVADOC_MISSING), + "32: " + getCheckMessage(MSG_KEY_JAVADOC_MISSING), + "33: " + getCheckMessage(MSG_KEY_JAVADOC_DUPLICATE_TAG, "@deprecated"), + "33: " + getCheckMessage(MSG_KEY_JAVADOC_MISSING), + "42: " + getCheckMessage(MSG_KEY_JAVADOC_DUPLICATE_TAG, "@deprecated"), + "42: " + getCheckMessage(MSG_KEY_JAVADOC_MISSING), + "50: " + getCheckMessage(MSG_KEY_JAVADOC_MISSING), + "51: " + getCheckMessage(MSG_KEY_JAVADOC_DUPLICATE_TAG, "@deprecated"), }; verify(checkConfig, getPath("annotation" + File.separator + "SpecialCaseDeprecated.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java index 921a01998..0a6236e34 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java @@ -25,6 +25,9 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import org.junit.Test; +import static com.puppycrawl.tools.checkstyle.checks.annotation.MissingOverrideCheck.MSG_KEY_ANNOTATION_MISSING_OVERRIDE; +import static com.puppycrawl.tools.checkstyle.checks.annotation.MissingOverrideCheck.MSG_KEY_TAG_NOT_VALID_ON; + public class MissingOverrideCheckTest extends BaseCheckTestSupport { /** @@ -39,10 +42,10 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport checkConfig.addAttribute("javaFiveCompatibility", "false"); final String[] expected = { - "8: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "30: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "41: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "50: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", + "8: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "30: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "41: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "50: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), }; verify(checkConfig, getPath("annotation" + File.separator + "BadOverrideFromObject.java"), expected); @@ -60,10 +63,10 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport checkConfig.addAttribute("javaFiveCompatibility", "true"); final String[] expected = { - "8: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "30: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "41: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "50: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", + "8: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "30: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "41: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "50: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), }; verify(checkConfig, getPath("annotation" + File.separator + "BadOverrideFromObject.java"), expected); @@ -79,13 +82,13 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport { DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class); final String[] expected = { - "10: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "26: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "34: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "40: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "47: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "53: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "63: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", + "10: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "26: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "34: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "40: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "47: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "53: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "63: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), }; verify(checkConfig, getPath("annotation" + File.separator + "BadOverrideFromOther.java"), expected); @@ -118,10 +121,10 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport { DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class); final String[] expected = { - "10: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "16: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "29: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", - "35: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.", + "10: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "16: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "29: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), + "35: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), }; verify(checkConfig, getPath("annotation" + File.separator + "BadAnnonOverride.java"), expected); @@ -152,10 +155,8 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport { DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class); final String[] expected = { - "8: The Javadoc {@inheritDoc} tag is not valid at this location.", - "15: The Javadoc {@inheritDoc} tag is not valid at this location.", - //this wont be flagged because this check only checks methods. - //"22: The Javadoc comment contains an {@inheritDoc} tag. The tag is not valid at this location.", + "8: " + getCheckMessage(MSG_KEY_TAG_NOT_VALID_ON, "{@inheritDoc}"), + "15: " + getCheckMessage(MSG_KEY_TAG_NOT_VALID_ON, "{@inheritDoc}"), }; verify(checkConfig, getPath("annotation" + File.separator + "NotOverride.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsTest.java index 6b8aa9180..4cbdcf68a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsTest.java @@ -23,6 +23,8 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import java.io.File; import org.junit.Test; +import static com.puppycrawl.tools.checkstyle.checks.annotation.SuppressWarningsCheck.MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED; + public class SuppressWarningsTest extends BaseCheckTestSupport { /** @@ -35,15 +37,15 @@ public class SuppressWarningsTest extends BaseCheckTestSupport DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class); final String[] expected = { - "8:23: The warning ' ' cannot be suppressed at this location.", - "11:27: The warning '' cannot be suppressed at this location.", - "53:27: The warning '' cannot be suppressed at this location.", - "64:47: The warning '' cannot be suppressed at this location.", - "67:37: The warning '' cannot be suppressed at this location.", - "72:46: The warning ' ' cannot be suppressed at this location.", - "77:60: The warning ' ' cannot be suppressed at this location.", - "82:93: The warning '' cannot be suppressed at this location.", - "82:106: The warning ' ' cannot be suppressed at this location.", + "8:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "11:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "53:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "64:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:37: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "72:46: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "77:60: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:93: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:106: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected); @@ -60,34 +62,34 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", ".*"); final String[] expected = { - "5:19: The warning 'unchecked' cannot be suppressed at this location.", - "8:23: The warning ' ' cannot be suppressed at this location.", - "11:27: The warning '' cannot be suppressed at this location.", - "17:23: The warning 'unused' cannot be suppressed at this location.", - "20:27: The warning 'unforgiven' cannot be suppressed at this location.", - "25:31: The warning 'unused' cannot be suppressed at this location.", - "29:35: The warning 'unchecked' cannot be suppressed at this location.", - "37:23: The warning 'abcun' cannot be suppressed at this location.", - "44:23: The warning 'abcun' cannot be suppressed at this location.", - "47:27: The warning 'unused' cannot be suppressed at this location.", - "53:27: The warning '' cannot be suppressed at this location.", - "56:27: The warning 'unchecked' cannot be suppressed at this location.", - "59:48: The warning 'unchecked' cannot be suppressed at this location.", - "64:33: The warning 'unchecked' cannot be suppressed at this location.", - "64:47: The warning '' cannot be suppressed at this location.", - "67:37: The warning '' cannot be suppressed at this location.", - "67:42: The warning 'unchecked' cannot be suppressed at this location.", - "72:46: The warning ' ' cannot be suppressed at this location.", - "72:54: The warning 'unused' cannot be suppressed at this location.", - "72:65: The warning 'unchecked' cannot be suppressed at this location.", - "77:37: The warning 'unchecked' cannot be suppressed at this location.", - "77:60: The warning ' ' cannot be suppressed at this location.", - "77:68: The warning 'unused' cannot be suppressed at this location.", - "82:47: The warning 'unchecked' cannot be suppressed at this location.", - "82:93: The warning '' cannot be suppressed at this location.", - "82:98: The warning 'foo' cannot be suppressed at this location.", - "82:106: The warning ' ' cannot be suppressed at this location.", - "82:115: The warning 'unused' cannot be suppressed at this location.", + "5:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "8:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "11:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "17:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "20:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unforgiven"), + "25:31: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:35: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "37:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "44:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "47:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "53:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "56:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:37: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:46: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:65: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:37: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:60: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "77:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:93: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:98: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:106: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:115: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected); @@ -104,16 +106,16 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "^unchecked$*"); final String[] expected = { - "5:19: The warning 'unchecked' cannot be suppressed at this location.", - "29:35: The warning 'unchecked' cannot be suppressed at this location.", - "56:27: The warning 'unchecked' cannot be suppressed at this location.", - "59:48: The warning 'unchecked' cannot be suppressed at this location.", + "5:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "29:35: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "56:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:33: The warning 'unchecked' cannot be suppressed at this location.", - "67:42: The warning 'unchecked' cannot be suppressed at this location.", - "72:65: The warning 'unchecked' cannot be suppressed at this location.", - "77:37: The warning 'unchecked' cannot be suppressed at this location.", - "82:47: The warning 'unchecked' cannot be suppressed at this location.", + "64:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "67:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:65: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:37: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected); @@ -131,13 +133,13 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("tokens", "CLASS_DEF,METHOD_DEF"); final String[] expected = { - "5:19: The warning 'unchecked' cannot be suppressed at this location.", - "29:35: The warning 'unchecked' cannot be suppressed at this location.", + "5:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "29:35: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:33: The warning 'unchecked' cannot be suppressed at this location.", - "72:65: The warning 'unchecked' cannot be suppressed at this location.", - "77:37: The warning 'unchecked' cannot be suppressed at this location.", - "82:47: The warning 'unchecked' cannot be suppressed at this location.", + "64:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:65: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:37: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected); @@ -154,25 +156,25 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", ".*un.*"); final String[] expected = { - "5:19: The warning 'unchecked' cannot be suppressed at this location.", - "17:23: The warning 'unused' cannot be suppressed at this location.", - "20:27: The warning 'unforgiven' cannot be suppressed at this location.", - "25:31: The warning 'unused' cannot be suppressed at this location.", - "29:35: The warning 'unchecked' cannot be suppressed at this location.", - "37:23: The warning 'abcun' cannot be suppressed at this location.", - "44:23: The warning 'abcun' cannot be suppressed at this location.", - "47:27: The warning 'unused' cannot be suppressed at this location.", - "56:27: The warning 'unchecked' cannot be suppressed at this location.", - "59:48: The warning 'unchecked' cannot be suppressed at this location.", + "5:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "17:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "20:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unforgiven"), + "25:31: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:35: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "37:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "44:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "47:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "56:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:33: The warning 'unchecked' cannot be suppressed at this location.", - "67:42: The warning 'unchecked' cannot be suppressed at this location.", - "72:54: The warning 'unused' cannot be suppressed at this location.", - "72:65: The warning 'unchecked' cannot be suppressed at this location.", - "77:37: The warning 'unchecked' cannot be suppressed at this location.", - "77:68: The warning 'unused' cannot be suppressed at this location.", - "82:47: The warning 'unchecked' cannot be suppressed at this location.", - "82:115: The warning 'unused' cannot be suppressed at this location.", + "64:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "67:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:65: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:37: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:115: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected); @@ -189,22 +191,22 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "^unchecked$*|^unused$"); final String[] expected = { - "5:19: The warning 'unchecked' cannot be suppressed at this location.", - "17:23: The warning 'unused' cannot be suppressed at this location.", - "25:31: The warning 'unused' cannot be suppressed at this location.", - "29:35: The warning 'unchecked' cannot be suppressed at this location.", - "47:27: The warning 'unused' cannot be suppressed at this location.", - "56:27: The warning 'unchecked' cannot be suppressed at this location.", - "59:48: The warning 'unchecked' cannot be suppressed at this location.", + "5:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "17:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "25:31: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:35: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "47:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "56:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:33: The warning 'unchecked' cannot be suppressed at this location.", - "67:42: The warning 'unchecked' cannot be suppressed at this location.", - "72:54: The warning 'unused' cannot be suppressed at this location.", - "72:65: The warning 'unchecked' cannot be suppressed at this location.", - "77:37: The warning 'unchecked' cannot be suppressed at this location.", - "77:68: The warning 'unused' cannot be suppressed at this location.", - "82:47: The warning 'unchecked' cannot be suppressed at this location.", - "82:115: The warning 'unused' cannot be suppressed at this location.", + "64:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "67:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:65: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:37: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:115: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected); @@ -221,34 +223,34 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "^unchecked$*|^unused$*|.*"); final String[] expected = { - "5:19: The warning 'unchecked' cannot be suppressed at this location.", - "8:23: The warning ' ' cannot be suppressed at this location.", - "11:27: The warning '' cannot be suppressed at this location.", - "17:23: The warning 'unused' cannot be suppressed at this location.", - "20:27: The warning 'unforgiven' cannot be suppressed at this location.", - "25:31: The warning 'unused' cannot be suppressed at this location.", - "29:35: The warning 'unchecked' cannot be suppressed at this location.", - "37:23: The warning 'abcun' cannot be suppressed at this location.", - "44:23: The warning 'abcun' cannot be suppressed at this location.", - "47:27: The warning 'unused' cannot be suppressed at this location.", - "53:27: The warning '' cannot be suppressed at this location.", - "56:27: The warning 'unchecked' cannot be suppressed at this location.", - "59:48: The warning 'unchecked' cannot be suppressed at this location.", - "64:33: The warning 'unchecked' cannot be suppressed at this location.", - "64:47: The warning '' cannot be suppressed at this location.", - "67:37: The warning '' cannot be suppressed at this location.", - "67:42: The warning 'unchecked' cannot be suppressed at this location.", - "72:46: The warning ' ' cannot be suppressed at this location.", - "72:54: The warning 'unused' cannot be suppressed at this location.", - "72:65: The warning 'unchecked' cannot be suppressed at this location.", - "77:37: The warning 'unchecked' cannot be suppressed at this location.", - "77:60: The warning ' ' cannot be suppressed at this location.", - "77:68: The warning 'unused' cannot be suppressed at this location.", - "82:47: The warning 'unchecked' cannot be suppressed at this location.", - "82:93: The warning '' cannot be suppressed at this location.", - "82:98: The warning 'foo' cannot be suppressed at this location.", - "82:106: The warning ' ' cannot be suppressed at this location.", - "82:115: The warning 'unused' cannot be suppressed at this location.", + "5:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "8:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "11:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "17:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "20:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unforgiven"), + "25:31: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:35: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "37:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "44:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "47:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "53:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "56:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:37: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:46: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:65: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:37: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:60: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "77:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:93: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:98: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:106: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:115: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected); @@ -264,22 +266,22 @@ public class SuppressWarningsTest extends BaseCheckTestSupport DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class); final String[] expected = { - "8:24: The warning ' ' cannot be suppressed at this location.", - "11:41: The warning '' cannot be suppressed at this location.", - "44:23: The warning '' cannot be suppressed at this location.", - "53:27: The warning '' cannot be suppressed at this location.", + "8:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "11:41: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "44:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "53:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), - "64:48: The warning '' cannot be suppressed at this location.", - "64:76: The warning '' cannot be suppressed at this location.", + "64:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "64:76: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), - "67:38: The warning '' cannot be suppressed at this location.", - "72:47: The warning ' ' cannot be suppressed at this location.", - "72:98: The warning ' ' cannot be suppressed at this location.", - "77:61: The warning ' ' cannot be suppressed at this location.", - "82:94: The warning '' cannot be suppressed at this location.", - "82:107: The warning ' ' cannot be suppressed at this location.", - "82:181: The warning '' cannot be suppressed at this location.", - "82:194: The warning ' ' cannot be suppressed at this location.", + "67:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "72:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:98: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "77:61: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:94: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:107: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:181: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:194: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected); @@ -296,53 +298,53 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", ".*"); final String[] expected = { - "5:20: The warning 'unchecked' cannot be suppressed at this location.", - "5:33: The warning 'unused' cannot be suppressed at this location.", - "8:24: The warning ' ' cannot be suppressed at this location.", - "11:28: The warning 'unchecked' cannot be suppressed at this location.", - "11:41: The warning '' cannot be suppressed at this location.", - "17:24: The warning 'unused' cannot be suppressed at this location.", - "20:28: The warning 'unforgiven' cannot be suppressed at this location.", - "20:42: The warning ' un' cannot be suppressed at this location.", - "25:32: The warning 'unused' cannot be suppressed at this location.", - "29:36: The warning 'unchecked' cannot be suppressed at this location.", - "37:24: The warning 'abcun' cannot be suppressed at this location.", - "44:23: The warning '' cannot be suppressed at this location.", - "47:28: The warning 'unused' cannot be suppressed at this location.", - "47:38: The warning 'bleh' cannot be suppressed at this location.", - "53:27: The warning '' cannot be suppressed at this location.", - "56:28: The warning 'unchecked' cannot be suppressed at this location.", - "59:49: The warning 'unchecked' cannot be suppressed at this location.", + "5:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "5:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "8:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "11:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "11:41: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "17:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "20:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unforgiven"), + "20:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " un"), + "25:32: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:36: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "37:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "44:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "47:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "47:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "bleh"), + "53:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "56:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:34: The warning 'unchecked' cannot be suppressed at this location.", - "64:48: The warning '' cannot be suppressed at this location.", - "64:62: The warning 'unchecked' cannot be suppressed at this location.", - "64:76: The warning '' cannot be suppressed at this location.", + "64:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "64:62: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:76: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), - "67:38: The warning '' cannot be suppressed at this location.", - "67:43: The warning 'unchecked' cannot be suppressed at this location.", + "67:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:43: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "72:47: The warning ' ' cannot be suppressed at this location.", - "72:55: The warning 'unused' cannot be suppressed at this location.", - "72:66: The warning 'unchecked' cannot be suppressed at this location.", - "72:98: The warning ' ' cannot be suppressed at this location.", - "72:106: The warning 'unused' cannot be suppressed at this location.", - "72:117: The warning 'unchecked' cannot be suppressed at this location.", + "72:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:55: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:66: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:98: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:106: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:117: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "77:38: The warning 'unchecked' cannot be suppressed at this location.", - "77:61: The warning ' ' cannot be suppressed at this location.", - "77:69: The warning 'unused' cannot be suppressed at this location.", + "77:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:61: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "77:69: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), - "82:48: The warning 'unchecked' cannot be suppressed at this location.", - "82:94: The warning '' cannot be suppressed at this location.", - "82:99: The warning 'foo' cannot be suppressed at this location.", - "82:107: The warning ' ' cannot be suppressed at this location.", - "82:115: The warning 'unused' cannot be suppressed at this location.", - "82:135: The warning 'unchecked' cannot be suppressed at this location.", - "82:181: The warning '' cannot be suppressed at this location.", - "82:186: The warning 'foo' cannot be suppressed at this location.", - "82:194: The warning ' ' cannot be suppressed at this location.", - "82:202: The warning 'unused' cannot be suppressed at this location.", + "82:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:94: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:99: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:107: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:115: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:135: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:181: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:186: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:194: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:202: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected); @@ -359,19 +361,19 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "^unchecked$*"); final String[] expected = { - "5:20: The warning 'unchecked' cannot be suppressed at this location.", - "11:28: The warning 'unchecked' cannot be suppressed at this location.", - "29:36: The warning 'unchecked' cannot be suppressed at this location.", - "56:28: The warning 'unchecked' cannot be suppressed at this location.", - "59:49: The warning 'unchecked' cannot be suppressed at this location.", - "64:34: The warning 'unchecked' cannot be suppressed at this location.", - "64:62: The warning 'unchecked' cannot be suppressed at this location.", - "67:43: The warning 'unchecked' cannot be suppressed at this location.", - "72:66: The warning 'unchecked' cannot be suppressed at this location.", - "72:117: The warning 'unchecked' cannot be suppressed at this location.", - "77:38: The warning 'unchecked' cannot be suppressed at this location.", - "82:48: The warning 'unchecked' cannot be suppressed at this location.", - "82:135: The warning 'unchecked' cannot be suppressed at this location.", + "5:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "11:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "29:36: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "56:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:62: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "67:43: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:66: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:117: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:135: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected); @@ -390,10 +392,10 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("tokens", "CLASS_DEF"); final String[] expected = { - "5:20: The warning 'unchecked' cannot be suppressed at this location.", + "5:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:34: The warning 'unchecked' cannot be suppressed at this location.", - "64:62: The warning 'unchecked' cannot be suppressed at this location.", + "64:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:62: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected); @@ -410,34 +412,34 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "un.*"); final String[] expected = { - "5:20: The warning 'unchecked' cannot be suppressed at this location.", - "5:33: The warning 'unused' cannot be suppressed at this location.", - "11:28: The warning 'unchecked' cannot be suppressed at this location.", - "17:24: The warning 'unused' cannot be suppressed at this location.", - "20:28: The warning 'unforgiven' cannot be suppressed at this location.", - "25:32: The warning 'unused' cannot be suppressed at this location.", - "29:36: The warning 'unchecked' cannot be suppressed at this location.", - "47:28: The warning 'unused' cannot be suppressed at this location.", - "56:28: The warning 'unchecked' cannot be suppressed at this location.", - "59:49: The warning 'unchecked' cannot be suppressed at this location.", + "5:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "5:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "11:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "17:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "20:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unforgiven"), + "25:32: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:36: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "47:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "56:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:34: The warning 'unchecked' cannot be suppressed at this location.", - "64:62: The warning 'unchecked' cannot be suppressed at this location.", + "64:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:62: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "67:43: The warning 'unchecked' cannot be suppressed at this location.", + "67:43: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "72:55: The warning 'unused' cannot be suppressed at this location.", - "72:66: The warning 'unchecked' cannot be suppressed at this location.", - "72:106: The warning 'unused' cannot be suppressed at this location.", - "72:117: The warning 'unchecked' cannot be suppressed at this location.", + "72:55: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:66: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:106: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:117: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "77:38: The warning 'unchecked' cannot be suppressed at this location.", - "77:69: The warning 'unused' cannot be suppressed at this location.", + "77:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:69: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), - "82:48: The warning 'unchecked' cannot be suppressed at this location.", - "82:115: The warning 'unused' cannot be suppressed at this location.", - "82:135: The warning 'unchecked' cannot be suppressed at this location.", - "82:202: The warning 'unused' cannot be suppressed at this location.", + "82:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:115: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:135: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:202: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected); @@ -454,28 +456,28 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "^unchecked$*|^unused$"); final String[] expected = { - "5:20: The warning 'unchecked' cannot be suppressed at this location.", - "5:33: The warning 'unused' cannot be suppressed at this location.", - "11:28: The warning 'unchecked' cannot be suppressed at this location.", - "17:24: The warning 'unused' cannot be suppressed at this location.", - "25:32: The warning 'unused' cannot be suppressed at this location.", - "29:36: The warning 'unchecked' cannot be suppressed at this location.", - "47:28: The warning 'unused' cannot be suppressed at this location.", - "56:28: The warning 'unchecked' cannot be suppressed at this location.", - "59:49: The warning 'unchecked' cannot be suppressed at this location.", - "64:34: The warning 'unchecked' cannot be suppressed at this location.", - "64:62: The warning 'unchecked' cannot be suppressed at this location.", - "67:43: The warning 'unchecked' cannot be suppressed at this location.", - "72:55: The warning 'unused' cannot be suppressed at this location.", - "72:66: The warning 'unchecked' cannot be suppressed at this location.", - "72:106: The warning 'unused' cannot be suppressed at this location.", - "72:117: The warning 'unchecked' cannot be suppressed at this location.", - "77:38: The warning 'unchecked' cannot be suppressed at this location.", - "77:69: The warning 'unused' cannot be suppressed at this location.", - "82:48: The warning 'unchecked' cannot be suppressed at this location.", - "82:115: The warning 'unused' cannot be suppressed at this location.", - "82:135: The warning 'unchecked' cannot be suppressed at this location.", - "82:202: The warning 'unused' cannot be suppressed at this location.", + "5:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "5:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "11:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "17:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "25:32: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:36: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "47:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "56:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:62: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "67:43: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:55: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:66: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:106: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:117: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:69: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:115: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:135: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:202: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected); @@ -492,53 +494,53 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "^unchecked$*|^unused$*|.*"); final String[] expected = { - "5:20: The warning 'unchecked' cannot be suppressed at this location.", - "5:33: The warning 'unused' cannot be suppressed at this location.", - "8:24: The warning ' ' cannot be suppressed at this location.", - "11:28: The warning 'unchecked' cannot be suppressed at this location.", - "11:41: The warning '' cannot be suppressed at this location.", - "17:24: The warning 'unused' cannot be suppressed at this location.", - "20:28: The warning 'unforgiven' cannot be suppressed at this location.", - "20:42: The warning ' un' cannot be suppressed at this location.", - "25:32: The warning 'unused' cannot be suppressed at this location.", - "29:36: The warning 'unchecked' cannot be suppressed at this location.", - "37:24: The warning 'abcun' cannot be suppressed at this location.", - "44:23: The warning '' cannot be suppressed at this location.", - "47:28: The warning 'unused' cannot be suppressed at this location.", - "47:38: The warning 'bleh' cannot be suppressed at this location.", - "53:27: The warning '' cannot be suppressed at this location.", - "56:28: The warning 'unchecked' cannot be suppressed at this location.", - "59:49: The warning 'unchecked' cannot be suppressed at this location.", + "5:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "5:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "8:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "11:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "11:41: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "17:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "20:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unforgiven"), + "20:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " un"), + "25:32: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:36: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "37:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "44:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "47:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "47:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "bleh"), + "53:27: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "56:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:34: The warning 'unchecked' cannot be suppressed at this location.", - "64:48: The warning '' cannot be suppressed at this location.", - "64:62: The warning 'unchecked' cannot be suppressed at this location.", - "64:76: The warning '' cannot be suppressed at this location.", + "64:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "64:62: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:76: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), - "67:38: The warning '' cannot be suppressed at this location.", - "67:43: The warning 'unchecked' cannot be suppressed at this location.", + "67:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:43: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "72:47: The warning ' ' cannot be suppressed at this location.", - "72:55: The warning 'unused' cannot be suppressed at this location.", - "72:66: The warning 'unchecked' cannot be suppressed at this location.", - "72:98: The warning ' ' cannot be suppressed at this location.", - "72:106: The warning 'unused' cannot be suppressed at this location.", - "72:117: The warning 'unchecked' cannot be suppressed at this location.", + "72:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:55: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:66: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:98: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:106: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:117: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "77:38: The warning 'unchecked' cannot be suppressed at this location.", - "77:61: The warning ' ' cannot be suppressed at this location.", - "77:69: The warning 'unused' cannot be suppressed at this location.", + "77:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:61: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "77:69: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), - "82:48: The warning 'unchecked' cannot be suppressed at this location.", - "82:94: The warning '' cannot be suppressed at this location.", - "82:99: The warning 'foo' cannot be suppressed at this location.", - "82:107: The warning ' ' cannot be suppressed at this location.", - "82:115: The warning 'unused' cannot be suppressed at this location.", - "82:135: The warning 'unchecked' cannot be suppressed at this location.", - "82:181: The warning '' cannot be suppressed at this location.", - "82:186: The warning 'foo' cannot be suppressed at this location.", - "82:194: The warning ' ' cannot be suppressed at this location.", - "82:202: The warning 'unused' cannot be suppressed at this location.", + "82:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:94: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:99: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:107: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:115: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:135: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:181: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:186: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:194: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:202: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected); @@ -554,20 +556,20 @@ public class SuppressWarningsTest extends BaseCheckTestSupport DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class); final String[] expected = { - "8:30: The warning ' ' cannot be suppressed at this location.", - "11:47: The warning '' cannot be suppressed at this location.", - "44:29: The warning '' cannot be suppressed at this location.", - "53:33: The warning '' cannot be suppressed at this location.", - "64:54: The warning '' cannot be suppressed at this location.", - "64:82: The warning '' cannot be suppressed at this location.", - "67:44: The warning '' cannot be suppressed at this location.", - "72:53: The warning ' ' cannot be suppressed at this location.", - "72:104: The warning ' ' cannot be suppressed at this location.", - "77:67: The warning ' ' cannot be suppressed at this location.", - "82:100: The warning '' cannot be suppressed at this location.", - "82:113: The warning ' ' cannot be suppressed at this location.", - "82:187: The warning '' cannot be suppressed at this location.", - "82:200: The warning ' ' cannot be suppressed at this location.", + "8:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "11:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "44:29: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "53:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "64:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "64:82: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "72:53: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:104: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "77:67: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:100: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:113: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:187: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:200: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected); @@ -584,49 +586,49 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", ".*"); final String[] expected = { - "5:26: The warning 'unchecked' cannot be suppressed at this location.", - "5:39: The warning 'unused' cannot be suppressed at this location.", - "8:30: The warning ' ' cannot be suppressed at this location.", - "11:34: The warning 'unchecked' cannot be suppressed at this location.", - "11:47: The warning '' cannot be suppressed at this location.", - "17:30: The warning 'unused' cannot be suppressed at this location.", - "20:34: The warning 'unforgiven' cannot be suppressed at this location.", - "20:48: The warning ' un' cannot be suppressed at this location.", - "25:38: The warning 'unused' cannot be suppressed at this location.", - "29:42: The warning 'unchecked' cannot be suppressed at this location.", - "37:30: The warning 'abcun' cannot be suppressed at this location.", - "44:29: The warning '' cannot be suppressed at this location.", - "47:34: The warning 'unused' cannot be suppressed at this location.", - "47:44: The warning 'bleh' cannot be suppressed at this location.", - "53:33: The warning '' cannot be suppressed at this location.", - "56:34: The warning 'unchecked' cannot be suppressed at this location.", - "59:55: The warning 'unchecked' cannot be suppressed at this location.", + "5:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "5:39: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "8:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "11:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "11:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "17:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "20:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unforgiven"), + "20:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " un"), + "25:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "37:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "44:29: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "47:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "47:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "bleh"), + "53:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "56:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:55: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:40: The warning 'unchecked' cannot be suppressed at this location.", - "64:54: The warning '' cannot be suppressed at this location.", - "64:68: The warning 'unchecked' cannot be suppressed at this location.", - "64:82: The warning '' cannot be suppressed at this location.", - "67:44: The warning '' cannot be suppressed at this location.", - "67:49: The warning 'unchecked' cannot be suppressed at this location.", - "72:53: The warning ' ' cannot be suppressed at this location.", - "72:61: The warning 'unused' cannot be suppressed at this location.", - "72:72: The warning 'unchecked' cannot be suppressed at this location.", - "72:104: The warning ' ' cannot be suppressed at this location.", - "72:112: The warning 'unused' cannot be suppressed at this location.", - "72:123: The warning 'unchecked' cannot be suppressed at this location.", - "77:44: The warning 'unchecked' cannot be suppressed at this location.", - "77:67: The warning ' ' cannot be suppressed at this location.", - "77:75: The warning 'unused' cannot be suppressed at this location.", - "82:54: The warning 'unchecked' cannot be suppressed at this location.", - "82:100: The warning '' cannot be suppressed at this location.", - "82:105: The warning 'foo' cannot be suppressed at this location.", - "82:113: The warning ' ' cannot be suppressed at this location.", - "82:121: The warning 'unused' cannot be suppressed at this location.", - "82:141: The warning 'unchecked' cannot be suppressed at this location.", - "82:187: The warning '' cannot be suppressed at this location.", - "82:192: The warning 'foo' cannot be suppressed at this location.", - "82:200: The warning ' ' cannot be suppressed at this location.", - "82:208: The warning 'unused' cannot be suppressed at this location.", + "64:40: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "64:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:82: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:53: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:61: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:72: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:104: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:112: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:123: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:67: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "77:75: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:100: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:105: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:113: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:121: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:141: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:187: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:192: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:200: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:208: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; @@ -644,20 +646,20 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "^unchecked$*"); final String[] expected = { - "5:26: The warning 'unchecked' cannot be suppressed at this location.", - "11:34: The warning 'unchecked' cannot be suppressed at this location.", - "29:42: The warning 'unchecked' cannot be suppressed at this location.", - "56:34: The warning 'unchecked' cannot be suppressed at this location.", - "59:55: The warning 'unchecked' cannot be suppressed at this location.", + "5:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "11:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "29:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "56:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:55: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:40: The warning 'unchecked' cannot be suppressed at this location.", - "64:68: The warning 'unchecked' cannot be suppressed at this location.", - "67:49: The warning 'unchecked' cannot be suppressed at this location.", - "72:72: The warning 'unchecked' cannot be suppressed at this location.", - "72:123: The warning 'unchecked' cannot be suppressed at this location.", - "77:44: The warning 'unchecked' cannot be suppressed at this location.", - "82:54: The warning 'unchecked' cannot be suppressed at this location.", - "82:141: The warning 'unchecked' cannot be suppressed at this location.", + "64:40: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "67:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:72: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:123: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:141: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected); @@ -675,10 +677,10 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("tokens", "CLASS_DEF"); final String[] expected = { - "5:26: The warning 'unchecked' cannot be suppressed at this location.", + "5:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:40: The warning 'unchecked' cannot be suppressed at this location.", - "64:68: The warning 'unchecked' cannot be suppressed at this location.", + "64:40: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected); @@ -695,30 +697,30 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "un.*"); final String[] expected = { - "5:26: The warning 'unchecked' cannot be suppressed at this location.", - "5:39: The warning 'unused' cannot be suppressed at this location.", - "11:34: The warning 'unchecked' cannot be suppressed at this location.", - "17:30: The warning 'unused' cannot be suppressed at this location.", - "20:34: The warning 'unforgiven' cannot be suppressed at this location.", - "25:38: The warning 'unused' cannot be suppressed at this location.", - "29:42: The warning 'unchecked' cannot be suppressed at this location.", - "47:34: The warning 'unused' cannot be suppressed at this location.", - "56:34: The warning 'unchecked' cannot be suppressed at this location.", - "59:55: The warning 'unchecked' cannot be suppressed at this location.", + "5:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "5:39: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "11:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "17:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "20:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unforgiven"), + "25:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "47:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "56:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:55: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:40: The warning 'unchecked' cannot be suppressed at this location.", - "64:68: The warning 'unchecked' cannot be suppressed at this location.", - "67:49: The warning 'unchecked' cannot be suppressed at this location.", - "72:61: The warning 'unused' cannot be suppressed at this location.", - "72:72: The warning 'unchecked' cannot be suppressed at this location.", - "72:112: The warning 'unused' cannot be suppressed at this location.", - "72:123: The warning 'unchecked' cannot be suppressed at this location.", - "77:44: The warning 'unchecked' cannot be suppressed at this location.", - "77:75: The warning 'unused' cannot be suppressed at this location.", - "82:54: The warning 'unchecked' cannot be suppressed at this location.", - "82:121: The warning 'unused' cannot be suppressed at this location.", - "82:141: The warning 'unchecked' cannot be suppressed at this location.", - "82:208: The warning 'unused' cannot be suppressed at this location.", + "64:40: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "67:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:61: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:72: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:112: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:123: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:75: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:121: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:141: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:208: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected); @@ -736,29 +738,29 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "^unchecked$*|^unused$"); final String[] expected = { - "5:26: The warning 'unchecked' cannot be suppressed at this location.", - "5:39: The warning 'unused' cannot be suppressed at this location.", - "11:34: The warning 'unchecked' cannot be suppressed at this location.", - "17:30: The warning 'unused' cannot be suppressed at this location.", - "25:38: The warning 'unused' cannot be suppressed at this location.", - "29:42: The warning 'unchecked' cannot be suppressed at this location.", - "47:34: The warning 'unused' cannot be suppressed at this location.", - "56:34: The warning 'unchecked' cannot be suppressed at this location.", - "59:55: The warning 'unchecked' cannot be suppressed at this location.", + "5:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "5:39: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "11:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "17:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "25:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "47:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "56:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:55: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:40: The warning 'unchecked' cannot be suppressed at this location.", - "64:68: The warning 'unchecked' cannot be suppressed at this location.", - "67:49: The warning 'unchecked' cannot be suppressed at this location.", - "72:61: The warning 'unused' cannot be suppressed at this location.", - "72:72: The warning 'unchecked' cannot be suppressed at this location.", - "72:112: The warning 'unused' cannot be suppressed at this location.", - "72:123: The warning 'unchecked' cannot be suppressed at this location.", - "77:44: The warning 'unchecked' cannot be suppressed at this location.", - "77:75: The warning 'unused' cannot be suppressed at this location.", - "82:54: The warning 'unchecked' cannot be suppressed at this location.", - "82:121: The warning 'unused' cannot be suppressed at this location.", - "82:141: The warning 'unchecked' cannot be suppressed at this location.", - "82:208: The warning 'unused' cannot be suppressed at this location.", + "64:40: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "67:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:61: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:72: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:112: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:123: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:75: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:121: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:141: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:208: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected); @@ -775,49 +777,49 @@ public class SuppressWarningsTest extends BaseCheckTestSupport checkConfig.addAttribute("format", "^unchecked$*|^unused$*|.*"); final String[] expected = { - "5:26: The warning 'unchecked' cannot be suppressed at this location.", - "5:39: The warning 'unused' cannot be suppressed at this location.", - "8:30: The warning ' ' cannot be suppressed at this location.", - "11:34: The warning 'unchecked' cannot be suppressed at this location.", - "11:47: The warning '' cannot be suppressed at this location.", - "17:30: The warning 'unused' cannot be suppressed at this location.", - "20:34: The warning 'unforgiven' cannot be suppressed at this location.", - "20:48: The warning ' un' cannot be suppressed at this location.", - "25:38: The warning 'unused' cannot be suppressed at this location.", - "29:42: The warning 'unchecked' cannot be suppressed at this location.", - "37:30: The warning 'abcun' cannot be suppressed at this location.", - "44:29: The warning '' cannot be suppressed at this location.", - "47:34: The warning 'unused' cannot be suppressed at this location.", - "47:44: The warning 'bleh' cannot be suppressed at this location.", - "53:33: The warning '' cannot be suppressed at this location.", - "56:34: The warning 'unchecked' cannot be suppressed at this location.", - "59:55: The warning 'unchecked' cannot be suppressed at this location.", + "5:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "5:39: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "8:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "11:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "11:47: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "17:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "20:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unforgiven"), + "20:48: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " un"), + "25:38: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "29:42: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "37:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "abcun"), + "44:29: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "47:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "47:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "bleh"), + "53:33: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "56:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "59:55: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), - "64:40: The warning 'unchecked' cannot be suppressed at this location.", - "64:54: The warning '' cannot be suppressed at this location.", - "64:68: The warning 'unchecked' cannot be suppressed at this location.", - "64:82: The warning '' cannot be suppressed at this location.", - "67:44: The warning '' cannot be suppressed at this location.", - "67:49: The warning 'unchecked' cannot be suppressed at this location.", - "72:53: The warning ' ' cannot be suppressed at this location.", - "72:61: The warning 'unused' cannot be suppressed at this location.", - "72:72: The warning 'unchecked' cannot be suppressed at this location.", - "72:104: The warning ' ' cannot be suppressed at this location.", - "72:112: The warning 'unused' cannot be suppressed at this location.", - "72:123: The warning 'unchecked' cannot be suppressed at this location.", - "77:44: The warning 'unchecked' cannot be suppressed at this location.", - "77:67: The warning ' ' cannot be suppressed at this location.", - "77:75: The warning 'unused' cannot be suppressed at this location.", - "82:54: The warning 'unchecked' cannot be suppressed at this location.", - "82:100: The warning '' cannot be suppressed at this location.", - "82:105: The warning 'foo' cannot be suppressed at this location.", - "82:113: The warning ' ' cannot be suppressed at this location.", - "82:121: The warning 'unused' cannot be suppressed at this location.", - "82:141: The warning 'unchecked' cannot be suppressed at this location.", - "82:187: The warning '' cannot be suppressed at this location.", - "82:192: The warning 'foo' cannot be suppressed at this location.", - "82:200: The warning ' ' cannot be suppressed at this location.", - "82:208: The warning 'unused' cannot be suppressed at this location.", + "64:40: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "64:68: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "64:82: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "67:49: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:53: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:61: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:72: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "72:104: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "72:112: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "72:123: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:44: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "77:67: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "77:75: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:54: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:100: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:105: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:113: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:121: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), + "82:141: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), + "82:187: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), + "82:192: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "foo"), + "82:200: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), + "82:208: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), }; verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java index a9db2bee0..a90dacdd3 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java @@ -21,8 +21,6 @@ package com.puppycrawl.tools.checkstyle.checks.coding; import static com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck.MSG_KEY; import static com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck.MSG_KEY_EXT; -import static java.text.MessageFormat.format; - import org.junit.Test; import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport; @@ -204,14 +202,4 @@ public class VariableDeclarationUsageDistanceCheckTest extends }; verify(checkConfig, getPath("coding/InputVariableDeclarationUsageDistanceCheck.java"), expected); } - - /** - * Gets the check message 'as is' from appropriate 'messages.properties' file. - * @param messageKey the key of message in 'messages.properties' file. - * @param arguments the arguments of message in 'messages.properties' file. - */ - public String getCheckMessage(String messageKey, Object ... arguments) - { - return format(getCheckMessage(messageKey), arguments); - } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java index 86949ada9..462c90fbf 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java @@ -19,7 +19,6 @@ package com.puppycrawl.tools.checkstyle.checks.naming; import static com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck.MSG_KEY; -import static java.text.MessageFormat.format; import org.junit.Test; @@ -314,14 +313,4 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport verify(checkConfig, getPath("naming/AbstractMultisetSetCountTester.java"), expected); } - - /** - * Gets the check message 'as is' from appropriate 'messages.properties' file. - * @param messageKey the key of message in 'messages.properties' file. - * @param arguments the arguments of message in 'messages.properties' file. - */ - public String getCheckMessage(String messageKey, Object ... arguments) - { - return format(getCheckMessage(messageKey), arguments); - } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java index e8fe1d238..7f9d06e36 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java @@ -20,7 +20,6 @@ package com.puppycrawl.tools.checkstyle.checks.naming; import java.io.File; import java.io.IOException; -import java.text.MessageFormat; import org.junit.Test; @@ -28,15 +27,13 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.api.TokenTypes; +import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN; +import static com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck.DEFAULT_PATTERN; + public class TypeNameCheckTest extends BaseCheckTestSupport { - /** - * Localized error message from @link {@link TypeNameCheck}. - */ - private final String msg = getCheckMessage(AbstractNameCheck.MSG_INVALID_PATTERN); - private final String inputFilename; public TypeNameCheckTest() throws IOException @@ -64,14 +61,14 @@ public class TypeNameCheckTest final DefaultConfiguration checkConfig = createCheckConfig(TypeNameCheck.class); final String[] expected = { - buildMesssage(3, 7, "inputHeaderClass", - TypeNameCheck.DEFAULT_PATTERN), - buildMesssage(5, 22, "inputHeaderInterface", - TypeNameCheck.DEFAULT_PATTERN), - buildMesssage(7, 17, "inputHeaderEnum", - TypeNameCheck.DEFAULT_PATTERN), - buildMesssage(9, 23, "inputHeaderAnnotation", - TypeNameCheck.DEFAULT_PATTERN), + "3:7: " + getCheckMessage(MSG_INVALID_PATTERN, + "inputHeaderClass", DEFAULT_PATTERN), + "5:22: " + getCheckMessage(MSG_INVALID_PATTERN, + "inputHeaderInterface", DEFAULT_PATTERN), + "7:17: " + getCheckMessage(MSG_INVALID_PATTERN, + "inputHeaderEnum", DEFAULT_PATTERN), + "9:23: " + getCheckMessage(MSG_INVALID_PATTERN, + "inputHeaderAnnotation", DEFAULT_PATTERN), }; verify(checkConfig, inputFilename, expected); } @@ -84,8 +81,8 @@ public class TypeNameCheckTest createCheckConfig(TypeNameCheck.class); checkConfig.addAttribute("tokens", TokenTypes.getTokenName(TokenTypes.CLASS_DEF)); final String[] expected = { - buildMesssage(3, 7, "inputHeaderClass", - TypeNameCheck.DEFAULT_PATTERN), + "3:7: " + getCheckMessage(MSG_INVALID_PATTERN, + "inputHeaderClass", DEFAULT_PATTERN), }; verify(checkConfig, inputFilename, expected); } @@ -98,8 +95,8 @@ public class TypeNameCheckTest createCheckConfig(TypeNameCheck.class); checkConfig.addAttribute("tokens", TokenTypes.getTokenName(TokenTypes.INTERFACE_DEF)); final String[] expected = { - buildMesssage(5, 22, "inputHeaderInterface", - TypeNameCheck.DEFAULT_PATTERN), + "5:22: " + getCheckMessage(MSG_INVALID_PATTERN, + "inputHeaderInterface", DEFAULT_PATTERN), }; verify(checkConfig, inputFilename, expected); } @@ -112,8 +109,8 @@ public class TypeNameCheckTest createCheckConfig(TypeNameCheck.class); checkConfig.addAttribute("tokens", TokenTypes.getTokenName(TokenTypes.ENUM_DEF)); final String[] expected = { - buildMesssage(7, 17, "inputHeaderEnum", - TypeNameCheck.DEFAULT_PATTERN), + "7:17: " + getCheckMessage(MSG_INVALID_PATTERN, + "inputHeaderEnum", DEFAULT_PATTERN), }; verify(checkConfig, inputFilename, expected); } @@ -126,17 +123,9 @@ public class TypeNameCheckTest createCheckConfig(TypeNameCheck.class); checkConfig.addAttribute("tokens", TokenTypes.getTokenName(TokenTypes.ANNOTATION_DEF)); final String[] expected = { - buildMesssage(9, 23, "inputHeaderAnnotation", - TypeNameCheck.DEFAULT_PATTERN), + "9:23: " + getCheckMessage(MSG_INVALID_PATTERN, + "inputHeaderAnnotation", DEFAULT_PATTERN), }; verify(checkConfig, inputFilename, expected); } - - private String buildMesssage(int lineNumber, int colNumber, String name, - String pattern) - { - return lineNumber + ":" + colNumber + ": " - + MessageFormat.format(msg, name, pattern); - } - }