diff options
53 files changed, 388 insertions, 196 deletions
diff --git a/config/suppressions.xml b/config/suppressions.xml index e42b316b9..5748d0cfd 100644 --- a/config/suppressions.xml +++ b/config/suppressions.xml @@ -52,7 +52,9 @@ <!-- suppressions to remove over time --> <suppress checks="FinalLocalVariable" files=".*[\\/]src[\\/]test[\\/]"/> - <suppress checks="LineLength" files=".*[\\/]src[\\/]test[\\/]"/> + + <!-- Suppressions for long import statics --> + <suppress checks="LineLength" files=".*[\\/]src[\\/]test[\\/]" lines="22-29"/> <!-- Turn off all checks for Generated and Test code. Fixes issues with using diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/AllChecksTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/AllChecksTest.java index 348d5d01c..0a8fc4afd 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/AllChecksTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/AllChecksTest.java @@ -67,7 +67,8 @@ public class AllChecksTest extends BaseCheckTestSupport { if (Check.class.isAssignableFrom(check)) { // Checks which have Check as a parent. if (check.equals(ImportControlCheck.class)) { - // ImportControlCheck must have the import control configuration file to avoid violation. + // ImportControlCheck must have the import control configuration file to avoid + // violation. checkConfig.addAttribute("file", getPath("import-control_complete.xml")); } checker = createChecker(checkConfig); @@ -152,7 +153,8 @@ public class AllChecksTest extends BaseCheckTestSupport { public void testAllChecksAreReferencedInConfigFile() throws Exception { final String configFilePath = "config/checkstyle_checks.xml"; final Set<Class<?>> checksFromClassPath = getCheckstyleChecks(); - final Set<String> checksReferencedInConfig = getCheckStyleChecksReferencedInConfig(configFilePath); + final Set<String> checksReferencedInConfig = + getCheckStyleChecksReferencedInConfig(configFilePath); final Set<String> checksNames = getSimpleNames(checksFromClassPath); for (String check : checksNames) { @@ -295,7 +297,8 @@ public class AllChecksTest extends BaseCheckTestSupport { * Gets a set of names of checkstyle's checks which are referenced in checkstyle_checks.xml. * @param configFilePath file path of checkstyle_checks.xml. * @return names of checkstyle's checks which are referenced in checkstyle_checks.xml. - * @throws ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested. + * @throws ParserConfigurationException if a DocumentBuilder cannot be created which satisfies + * the configuration requested. * @throws IOException if any IO errors occur. * @throws SAXException if any parse errors occur. */ @@ -316,7 +319,8 @@ public class AllChecksTest extends BaseCheckTestSupport { final Document document = builder.parse(new File(configFilePath)); // optional, but recommended - // FYI: http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work + // FYI: http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java- + // how-does-it-work document.getDocumentElement().normalize(); final NodeList nodeList = document.getElementsByTagName("module"); @@ -341,7 +345,8 @@ public class AllChecksTest extends BaseCheckTestSupport { * Gets names of checkstyle's modules which are documented in xdocs. * @param xdocsDirectoryPath xdocs directory path. * @return a set of checkstyle's modules which have xdoc documentation. - * @throws ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested. + * @throws ParserConfigurationException if a DocumentBuilder cannot be created which satisfies + * the configuration requested. * @throws IOException if any IO errors occur. * @throws SAXException if any parse errors occur. */ @@ -366,7 +371,8 @@ public class AllChecksTest extends BaseCheckTestSupport { final Document document = builder.parse(path.toFile()); // optional, but recommended - // FYI: http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work + // FYI: http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with- + // java-how-does-it-work document.getDocumentElement().normalize(); final NodeList nodeList = document.getElementsByTagName("section"); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java b/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java index f7c2127ca..8234c47a1 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/BaseCheckTestSupport.java @@ -97,15 +97,18 @@ public class BaseCheckTestSupport { } protected String getPath(String filename) throws IOException { - return new File("src/test/resources/com/puppycrawl/tools/checkstyle/" + filename).getCanonicalPath(); + return new File("src/test/resources/com/puppycrawl/tools/checkstyle/" + filename) + .getCanonicalPath(); } protected String getUriString(String filename) { - return new File("src/test/resources/com/puppycrawl/tools/checkstyle/" + filename).toURI().toString(); + return new File("src/test/resources/com/puppycrawl/tools/checkstyle/" + filename).toURI() + .toString(); } protected String getSrcPath(String filename) throws IOException { - return new File("src/test/java/com/puppycrawl/tools/checkstyle/" + filename).getCanonicalPath(); + return new File("src/test/java/com/puppycrawl/tools/checkstyle/" + filename) + .getCanonicalPath(); } protected String getNonCompilablePath(String filename) throws IOException { @@ -158,17 +161,22 @@ public class BaseCheckTestSupport { final int errs = checker.process(theFiles); final Map<String, List<String>> actualViolations = getActualViolations(errs); - final Map<String, List<String>> realExpectedViolations = Maps.filterValues(expectedViolations, new Predicate<List<String>>() { - @Override - public boolean apply(List<String> input) { - return !input.isEmpty(); - } - }); - final MapDifference<String, List<String>> violationDifferences = Maps.difference(realExpectedViolations, actualViolations); + final Map<String, List<String>> realExpectedViolations = + Maps.filterValues(expectedViolations, new Predicate<List<String>>() { + @Override + public boolean apply(List<String> input) { + return !input.isEmpty(); + } + }); + final MapDifference<String, List<String>> violationDifferences = + Maps.difference(realExpectedViolations, actualViolations); - final Map<String, List<String>> missingViolations = violationDifferences.entriesOnlyOnLeft(); - final Map<String, List<String>> unexpectedViolations = violationDifferences.entriesOnlyOnRight(); - final Map<String, ValueDifference<List<String>>> differingViolations = violationDifferences.entriesDiffering(); + final Map<String, List<String>> missingViolations = + violationDifferences.entriesOnlyOnLeft(); + final Map<String, List<String>> unexpectedViolations = + violationDifferences.entriesOnlyOnRight(); + final Map<String, ValueDifference<List<String>>> differingViolations = + violationDifferences.entriesDiffering(); final StringBuilder message = new StringBuilder(); if (!missingViolations.isEmpty()) { @@ -212,7 +220,8 @@ public class BaseCheckTestSupport { final String actualViolationFileName = actualViolation[0]; final String actualViolationMessage = actualViolation[1]; - List<String> actualViolationsPerFile = actualViolations.get(actualViolationFileName); + List<String> actualViolationsPerFile = + actualViolations.get(actualViolationFileName); if (actualViolationsPerFile == null) { actualViolationsPerFile = new ArrayList<>(); actualViolations.put(actualViolationFileName, actualViolationsPerFile); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java index 63ca583a6..612d28a27 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java @@ -107,22 +107,26 @@ public class CheckerTest { // Let's try fire some events checker.fireAuditStarted(); assertTrue("Checker.fireAuditStarted() doesn't call listener", aa2.wasCalled()); - assertFalse("Checker.fireAuditStarted() does call removed listener", auditAdapter.wasCalled()); + assertFalse("Checker.fireAuditStarted() does call removed listener", + auditAdapter.wasCalled()); aa2.resetListener(); checker.fireAuditFinished(); assertTrue("Checker.fireAuditFinished() doesn't call listener", aa2.wasCalled()); - assertFalse("Checker.fireAuditFinished() does call removed listener", auditAdapter.wasCalled()); + assertFalse("Checker.fireAuditFinished() does call removed listener", + auditAdapter.wasCalled()); aa2.resetListener(); checker.fireFileStarted("Some File Name"); assertTrue("Checker.fireFileStarted() doesn't call listener", aa2.wasCalled()); - assertFalse("Checker.fireFileStarted() does call removed listener", auditAdapter.wasCalled()); + assertFalse("Checker.fireFileStarted() does call removed listener", + auditAdapter.wasCalled()); aa2.resetListener(); checker.fireFileFinished("Some File Name"); assertTrue("Checker.fireFileFinished() doesn't call listener", aa2.wasCalled()); - assertFalse("Checker.fireFileFinished() does call removed listener", auditAdapter.wasCalled()); + assertFalse("Checker.fireFileFinished() does call removed listener", + auditAdapter.wasCalled()); aa2.resetListener(); final SortedSet<LocalizedMessage> messages = Sets.newTreeSet(); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/CommitValidationTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/CommitValidationTest.java index 2cdac81b6..f8b452641 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/CommitValidationTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/CommitValidationTest.java @@ -129,7 +129,8 @@ public class CommitValidationTest { * if commit message has a single line we have to make sure that the only * newline character found is in the end of commit message. */ - boolean isFoundNewLineCharacterAtTheEndOfMessage = matcher.end() == commitMessage.length(); + boolean isFoundNewLineCharacterAtTheEndOfMessage = + matcher.end() == commitMessage.length(); assertTrue(getInvalidCommitMessageFormattingError(commitId, commitMessage), isFoundNewLineCharacterAtTheEndOfMessage); } @@ -203,11 +204,14 @@ public class CommitValidationTest { return currentCommit.getParentCount() > 1; } - private static List<RevCommit> getCommitsByCounter(Iterator<RevCommit> previousCommitsIterator) { - return Lists.newArrayList(Iterators.limit(previousCommitsIterator, PREVIOUS_COMMITS_TO_CHECK_COUNT)); + private static List<RevCommit> getCommitsByCounter( + Iterator<RevCommit> previousCommitsIterator) { + return Lists.newArrayList(Iterators.limit(previousCommitsIterator, + PREVIOUS_COMMITS_TO_CHECK_COUNT)); } - private static List<RevCommit> getCommitsByLastCommitAuthor(Iterator<RevCommit> previousCommitsIterator) { + private static List<RevCommit> getCommitsByLastCommitAuthor( + Iterator<RevCommit> previousCommitsIterator) { List<RevCommit> commits = new LinkedList<>(); if (previousCommitsIterator.hasNext()) { @@ -216,7 +220,8 @@ public class CommitValidationTest { commits.add(lastCommit); boolean wasLastCheckedCommitAuthorSameAsLastCommit = true; - while (previousCommitsIterator.hasNext() && wasLastCheckedCommitAuthorSameAsLastCommit) { + while (previousCommitsIterator.hasNext() + && wasLastCheckedCommitAuthorSameAsLastCommit) { RevCommit currentCommit = previousCommitsIterator.next(); String currentCommitAuthor = currentCommit.getAuthorIdent().getName(); if (currentCommitAuthor.equals(lastCommitAuthor)) { @@ -240,7 +245,8 @@ public class CommitValidationTest { + " 2) It contains only one line"; } - private static String getInvalidCommitMessageFormattingError(String commitId, String commitMessage) { + private static String getInvalidCommitMessageFormattingError(String commitId, + String commitMessage) { return "Commit " + commitId + " message: \"" + commitMessage + "\" is invalid\n" + getRulesForCommitMessageFormatting(); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java index c30edb7ee..2aa70e505 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java @@ -67,7 +67,8 @@ public class ConfigurationLoaderTest { props.setProperty("checkstyle.basedir", "basedir"); // load config that's only found in the classpath - final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration( + final DefaultConfiguration config = + (DefaultConfiguration) ConfigurationLoader.loadConfiguration( getConfigPath("checkstyle_checks.xml"), new PropertiesExpander(props)); //verify the root, and property substitution diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java index ee8338389..708576aab 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java @@ -192,7 +192,8 @@ public class MainTest { + " com.puppycrawl.tools.checkstyle.filters.NonExistingClass," + " com.puppycrawl.tools.checkstyle.NonExistingClass." + " Please recheck that class name is specified as canonical name or read" - + " how to configure short name usage http://checkstyle.sourceforge.net/config.html#Packages." + + " how to configure short name usage" + + " http://checkstyle.sourceforge.net/config.html#Packages." + " Please also recheck that provided ClassLoader to Checker is configured correctly."; final String expectedExceptionMessage = String.format(Locale.ROOT, "cannot initialize module TreeWalker - %1$s%n" @@ -274,9 +275,11 @@ public class MainTest { String expectedPath = getFilePath("InputMain.java"); assertEquals(String.format(Locale.ROOT, "Starting audit...%n" + "%1$s:3:14: " - + "warning: Name 'InputMain' must match pattern '^[a-z0-9]*$'.%n" + + "warning: Name 'InputMain' must match pattern" + + " '^[a-z0-9]*$'.%n" + "%1$s:5:7: " - + "warning: Name 'InputMainInner' must match pattern '^[a-z0-9]*$'.%n" + + "warning: Name 'InputMainInner' must match pattern" + + " '^[a-z0-9]*$'.%n" + "Audit done.%n", expectedPath), systemOut.getLog()); assertEquals("", systemErr.getLog()); @@ -431,10 +434,12 @@ public class MainTest { @Override public void checkAssertion() { assertTrue(systemOut.getLog().startsWith(String.format(Locale.ROOT, - "unable to parse configuration stream - Content is not allowed in prolog.:7:1%n" + "unable to parse configuration stream" + + " - Content is not allowed in prolog.:7:1%n" + "Cause: org.xml.sax.SAXParseException; systemId: file:"))); assertTrue(systemOut.getLog().endsWith(String.format(Locale.ROOT, - "com/puppycrawl/tools/checkstyle/config-Incorrect.xml; lineNumber: 7; columnNumber: 1; " + "com/puppycrawl/tools/checkstyle/config-Incorrect.xml;" + + " lineNumber: 7; columnNumber: 1; " + "Content is not allowed in prolog.%n" + "Checkstyle ends with 1 errors.%n"))); assertEquals("", systemErr.getLog()); @@ -470,7 +475,8 @@ public class MainTest { // We do separate validation for message as in Windows // disk drive letter appear in message, // so we skip that drive letter for compatibility issues - assertTrue(e.getCause().getMessage().startsWith("Unable to load properties from file '")); + assertTrue(e.getCause().getMessage() + .startsWith("Unable to load properties from file '")); assertTrue(e.getCause().getMessage().endsWith(":invalid'.")); } } @@ -521,7 +527,8 @@ public class MainTest { String expectedPath = getFilePath("checks/metrics") + File.separator; StringBuilder sb = new StringBuilder(); sb.append("Starting audit...").append(System.getProperty("line.separator")); - String format = "%s.java:%s: warning: File length is %s lines (max allowed is 170)."; + String format = "%s.java:%s: warning: File length is %s lines " + + "(max allowed is 170)."; for (String[] outputValue : outputValues) { String line = String.format(Locale.ROOT, format, expectedPath + outputValue[0], outputValue[1], diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/PackageNamesLoaderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/PackageNamesLoaderTest.java index 906fc6563..4a6d5a582 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/PackageNamesLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/PackageNamesLoaderTest.java @@ -94,7 +94,8 @@ public class PackageNamesLoaderTest { @SuppressWarnings("unchecked") public void testPackagesWithDots() throws Exception { - Constructor<PackageNamesLoader> constructor = PackageNamesLoader.class.getDeclaredConstructor(); + Constructor<PackageNamesLoader> constructor = + PackageNamesLoader.class.getDeclaredConstructor(); constructor.setAccessible(true); PackageNamesLoader loader = constructor.newInstance(); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/XDocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/XDocsPagesTest.java index efab736cd..ff452d17c 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/XDocsPagesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/XDocsPagesTest.java @@ -96,7 +96,8 @@ public class XDocsPagesTest { final String availableChecks = Files.toString(AVAILABLE_CHECKS_FILE, UTF_8); for (File file : Files.fileTreeTraverser().preOrderTraversal(JAVA_SOURCES_DIRECTORY)) { final String fileName = file.getName(); - if (fileName.matches(CHECK_FILE_NAME) && !CHECKS_ON_PAGE_IGNORE_LIST.contains(fileName)) { + if (fileName.matches(CHECK_FILE_NAME) + && !CHECKS_ON_PAGE_IGNORE_LIST.contains(fileName)) { final String checkName = fileName.replace(CHECK_SUFFIX, ""); if (!isPresent(availableChecks, checkName)) { Assert.fail(checkName + " is not correctly listed on Available Checks page" diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/XMLLoggerTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/XMLLoggerTest.java index 2e38ba8a2..80f612bc0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/XMLLoggerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/XMLLoggerTest.java @@ -158,7 +158,8 @@ public class XMLLoggerTest { logger.addError(ev); logger.auditFinished(null); final String[] expectedLines = { - "<error line=\"1\" column=\"1\" severity=\"error\" message=\"key\" source=\"com.puppycrawl.tools.checkstyle.XMLLoggerTest\"/>", + "<error line=\"1\" column=\"1\" severity=\"error\" message=\"key\"" + + " source=\"com.puppycrawl.tools.checkstyle.XMLLoggerTest\"/>", }; verifyLines(expectedLines); } @@ -175,7 +176,8 @@ public class XMLLoggerTest { logger.addError(ev); logger.auditFinished(null); final String[] expectedLines = { - "<error line=\"1\" severity=\"error\" message=\"key\" source=\"com.puppycrawl.tools.checkstyle.XMLLoggerTest\"/>", + "<error line=\"1\" severity=\"error\" message=\"key\"" + + " source=\"com.puppycrawl.tools.checkstyle.XMLLoggerTest\"/>", }; verifyLines(expectedLines); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java index 5390be926..fedcb145f 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java @@ -175,7 +175,8 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("limitedTokens", "STRING_LITERAL"); checkConfig.addAttribute("maximumNumber", "0"); checkConfig.addAttribute("maximumDepth", "1"); - checkConfig.addAttribute("maximumMessage", "Literal Strings should be compared using equals(), not ''==''."); + checkConfig.addAttribute("maximumMessage", + "Literal Strings should be compared using equals(), not ''==''."); final String[] expected = { "7:18: Literal Strings should be compared using equals(), not '=='.", 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 ce4ee82af..af8c57ea7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckTest.java @@ -130,11 +130,13 @@ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport { @Test public void testWrongKeyTypeInProperties() throws Exception { Class<?> uniquePropertiesClass = Class - .forName("com.puppycrawl.tools.checkstyle.checks.UniquePropertiesCheck$UniqueProperties"); + .forName("com.puppycrawl.tools.checkstyle.checks." + + "UniquePropertiesCheck$UniqueProperties"); Constructor<?> constructor = uniquePropertiesClass.getDeclaredConstructor(); constructor.setAccessible(true); Object uniqueProperties = constructor.newInstance(); - Method method = uniqueProperties.getClass().getDeclaredMethod("put", Object.class, Object.class); + Method method = uniqueProperties.getClass().getDeclaredMethod("put", Object.class, + Object.class); Object result = method.invoke(uniqueProperties, 1, "value"); Map<Object, Object> table = new HashMap<>(); Object expected = table.put(1, "value"); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java index 047cfa2a4..3fedd564b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java @@ -157,7 +157,8 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport { @Test public void testNPE() throws Exception { checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString()); - checkConfig.addAttribute("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"); + checkConfig.addAttribute("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, " + + "LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; verify(checkConfig, getPath("InputRightCurlyEmptyAbstractMethod.java"), expected); } @@ -165,9 +166,9 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport { @Test public void testWithAnnotations() throws Exception { checkConfig.addAttribute("option", RightCurlyOption.ALONE.toString()); - checkConfig.addAttribute("tokens", "LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, " - + "LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, " - + "STATIC_INIT, INSTANCE_INIT"); + checkConfig.addAttribute("tokens", "LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, " + + "LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, " + + "LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"); final String[] expected = { "8:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77), "11:65: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 65), @@ -228,9 +229,9 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport { @Test public void testAloneOrSingleLine() throws Exception { checkConfig.addAttribute("option", RightCurlyOption.ALONE_OR_SINGLELINE.toString()); - checkConfig.addAttribute("tokens", "LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, " - + "LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, " - + "STATIC_INIT, INSTANCE_INIT"); + checkConfig.addAttribute("tokens", "LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, " + + "LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, " + + "LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"); final String[] expected = { "60:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26), "69:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java index 2beabd4aa..fb61bdb4d 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java @@ -119,7 +119,8 @@ public class FinalLocalVariableCheckTest "8:20: " + "Variable 'a' should be declared final.", "15:13: " + "Variable 'x' should be declared final.", }; - verify(checkConfig, getPath("InputFinalLocalVariableEnhancedForLoopVariable.java"), expected); + verify(checkConfig, getPath("InputFinalLocalVariableEnhancedForLoopVariable.java"), + expected); } @Test @@ -130,7 +131,8 @@ public class FinalLocalVariableCheckTest final String[] expected = { "15:13: " + "Variable 'x' should be declared final.", }; - verify(checkConfig, getPath("InputFinalLocalVariableEnhancedForLoopVariable.java"), expected); + verify(checkConfig, getPath("InputFinalLocalVariableEnhancedForLoopVariable.java"), + expected); } @Test @@ -140,7 +142,8 @@ public class FinalLocalVariableCheckTest createCheckConfig(FinalLocalVariableCheck.class); checkConfig.addAttribute("tokens", "PARAMETER_DEF,VARIABLE_DEF"); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getNonCompilablePath("InputFinalLocalVariableNameLambda.java"), expected); + verify(checkConfig, getNonCompilablePath("InputFinalLocalVariableNameLambda.java"), + expected); } @Test diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java index ae8b6b5be..056eb6517 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java @@ -64,7 +64,8 @@ public class IllegalInstantiationCheckTest "19:21: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), "24:21: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), "31:16: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), - "38:21: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.coding.InputModifier"), + "38:21: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.coding.InputModifier"), "41:18: " + getCheckMessage(MSG_KEY, "java.io.File"), "44:21: " + getCheckMessage(MSG_KEY, "java.awt.Color"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java index 8e51bd250..4860d23bf 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java @@ -92,7 +92,7 @@ public class IllegalThrowsCheckTest extends BaseCheckTestSupport { public void testIllegalClassNamesWithIgnoreMethodNames() throws Exception { DefaultConfiguration checkConfig = createCheckConfig(IllegalThrowsCheck.class); checkConfig.addAttribute("illegalClassNames", - "java.lang.Error, java.lang.Exception, NullPointerException, Throwable"); + "java.lang.Error, java.lang.Exception, NullPointerException, Throwable"); checkConfig.addAttribute("ignoredMethodNames", "methodTwo"); String[] expected = { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java index f97fbdf90..5ffc637c3 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java @@ -84,7 +84,8 @@ public class IllegalTypeCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("validateAbstractClassNames", "true"); String[] expected = { "6:13: " + getCheckMessage(MSG_KEY, "AbstractClass"), - "9:13: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass"), + "9:13: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass"), "16:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), }; @@ -109,7 +110,8 @@ public class IllegalTypeCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("legalAbstractClassNames", "AbstractClass"); String[] expected = { - "9:13: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass"), + "9:13: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass"), "16:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), "17:13: " + getCheckMessage(MSG_KEY, "TreeSet"), }; @@ -132,7 +134,8 @@ public class IllegalTypeCheckTest extends BaseCheckTestSupport { @Test public void testSameFileNameGeneral() throws Exception { - checkConfig.addAttribute("illegalClassNames", "List, InputGregorianCalendar, java.io.File, ArrayList"); + checkConfig.addAttribute("illegalClassNames", + "List, InputGregorianCalendar, java.io.File, ArrayList"); String[] expected = { "10:5: " + getCheckMessage(MSG_KEY, "InputGregorianCalendar"), "16:23: " + getCheckMessage(MSG_KEY, "InputGregorianCalendar"), @@ -175,10 +178,14 @@ public class IllegalTypeCheckTest extends BaseCheckTestSupport { + " LITERAL_STATIC"); String[] expected = { "6:13: " + getCheckMessage(MSG_KEY, "AbstractClass"), - "9:13: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalTypeMemberModifiers.AbstractClass"), + "9:13: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.coding." + + "InputIllegalTypeMemberModifiers.AbstractClass"), "16:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), "17:13: " + getCheckMessage(MSG_KEY, "TreeSet"), - "23:15: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalTypeMemberModifiers.AbstractClass"), + "23:15: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.coding." + + "InputIllegalTypeMemberModifiers.AbstractClass"), "25:25: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), "33:15: " + getCheckMessage(MSG_KEY, "AbstractClass"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java index 4c1ff2630..13372de62 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java @@ -76,7 +76,8 @@ public class InnerAssignmentCheckTest final DefaultConfiguration checkConfig = createCheckConfig(InnerAssignmentCheck.class); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getNonCompilablePath("InputInnerAssignmentLambdaExpressions.java"), expected); + verify(checkConfig, getNonCompilablePath("InputInnerAssignmentLambdaExpressions.java"), + expected); } @Test diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java index ab6169ab9..98c2048f1 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java @@ -65,7 +65,8 @@ public class ModifiedControlVariableCheckTest checkConfig.addAttribute("skipEnhancedForLoopVariable", "true"); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("InputModifiedControlVariableEnhancedForLoopVariable.java"), expected); + verify(checkConfig, getPath("InputModifiedControlVariableEnhancedForLoopVariable.java"), + expected); } @Test @@ -76,7 +77,8 @@ public class ModifiedControlVariableCheckTest final String[] expected = { "9:18: " + getCheckMessage(MSG_KEY, "line"), }; - verify(checkConfig, getPath("InputModifiedControlVariableEnhancedForLoopVariable.java"), expected); + verify(checkConfig, getPath("InputModifiedControlVariableEnhancedForLoopVariable.java"), + expected); } @Test diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java index 0764c59b2..65c4b2160 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java @@ -105,7 +105,8 @@ public class UnnecessaryParenthesesCheckTest extends BaseCheckTestSupport { @Test public void test15Extensions() throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(UnnecessaryParenthesesCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(UnnecessaryParenthesesCheck.class); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; verify(checkConfig, getPath("Input15Extensions.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 aefe1b333..e03aeb5d1 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 @@ -41,7 +41,8 @@ public class VariableDeclarationUsageDistanceCheckTest extends @Test public void testGeneralLogic() throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(VariableDeclarationUsageDistanceCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(VariableDeclarationUsageDistanceCheck.class); checkConfig.addAttribute("allowedDistance", "1"); checkConfig.addAttribute("ignoreVariablePattern", ""); checkConfig.addAttribute("validateBetweenScopes", "true"); @@ -85,7 +86,8 @@ public class VariableDeclarationUsageDistanceCheckTest extends @Test public void testDistance() throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(VariableDeclarationUsageDistanceCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(VariableDeclarationUsageDistanceCheck.class); checkConfig.addAttribute("allowedDistance", "3"); checkConfig.addAttribute("ignoreVariablePattern", ""); checkConfig.addAttribute("validateBetweenScopes", "true"); @@ -105,7 +107,8 @@ public class VariableDeclarationUsageDistanceCheckTest extends @Test public void testVariableRegExp() throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(VariableDeclarationUsageDistanceCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(VariableDeclarationUsageDistanceCheck.class); checkConfig.addAttribute("allowedDistance", "1"); checkConfig.addAttribute("ignoreVariablePattern", "a|b|c|d|block|dist|t|m"); @@ -143,7 +146,8 @@ public class VariableDeclarationUsageDistanceCheckTest extends @Test public void testValidateBetweenScopesOption() throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(VariableDeclarationUsageDistanceCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(VariableDeclarationUsageDistanceCheck.class); checkConfig.addAttribute("allowedDistance", "1"); checkConfig.addAttribute("ignoreVariablePattern", ""); checkConfig.addAttribute("validateBetweenScopes", "false"); @@ -166,17 +170,22 @@ public class VariableDeclarationUsageDistanceCheckTest extends "471: " + getCheckMessage(MSG_KEY, "l1", 3, 1), "471: " + getCheckMessage(MSG_KEY, "l2", 2, 1), "479: " + getCheckMessage(MSG_KEY, "myOption", 7, 1), - "491: Distance between variable 'myOption' declaration and its first usage is 6, but allowed 1.", - "505: Distance between variable 'files' declaration and its first usage is 2, but allowed 1.", - "540: Distance between variable 'id' declaration and its first usage is 2, but allowed 1.", - "542: Distance between variable 'parentId' declaration and its first usage is 4, but allowed 1.", + "491: Distance between variable 'myOption' declaration and its first usage is 6," + + " but allowed 1.", + "505: Distance between variable 'files' declaration and its first usage is 2," + + " but allowed 1.", + "540: Distance between variable 'id' declaration and its first usage is 2," + + " but allowed 1.", + "542: Distance between variable 'parentId' declaration and its first usage is 4," + + " but allowed 1.", }; verify(checkConfig, getPath("InputVariableDeclarationUsageDistance.java"), expected); } @Test public void testIgnoreFinalOption() throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(VariableDeclarationUsageDistanceCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(VariableDeclarationUsageDistanceCheck.class); checkConfig.addAttribute("allowedDistance", "1"); checkConfig.addAttribute("ignoreVariablePattern", ""); checkConfig.addAttribute("validateBetweenScopes", "true"); @@ -227,7 +236,8 @@ public class VariableDeclarationUsageDistanceCheckTest extends @Test public void testDefaultConfiguration() throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(VariableDeclarationUsageDistanceCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(VariableDeclarationUsageDistanceCheck.class); final String[] expected = { "71: " + getCheckMessage(MSG_KEY_EXT, "count", 4, 3), "219: " + getCheckMessage(MSG_KEY_EXT, "t", 5, 3), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java index 75bf336fa..32f6d7c0b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java @@ -49,7 +49,8 @@ public class MutableExceptionCheckTest extends BaseCheckTestSupport { String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("InputMutableExceptionClassExtendsGenericClass.java"), expected); + verify(checkConfig, getPath("InputMutableExceptionClassExtendsGenericClass.java"), + expected); } @Test diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java index 4ff5795f3..60fb9a376 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java @@ -55,7 +55,8 @@ public class OneTopLevelClassCheckTest extends BaseCheckTestSupport { public void testAcceptableTokens() throws Exception { final OneTopLevelClassCheck check = new OneTopLevelClassCheck(); check.getAcceptableTokens(); - // ZERO tokens as Check do Traverse of Tree himself, he does not need to subscribed to Tokens + // ZERO tokens as Check do Traverse of Tree himself, he does not need to subscribed to + // Tokens Assert.assertEquals(0, check.getAcceptableTokens().length); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java index a65738819..4d0525518 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java @@ -213,7 +213,8 @@ public class VisibilityModifierCheckTest final DefaultConfiguration checkConfig = createCheckConfig(VisibilityModifierCheck.class); checkConfig.addAttribute("ignoreAnnotationCanonicalNames", - "com.puppycrawl.tools.checkstyle.checks.design.InputAnnotatedVisibility.CustomAnnotation"); + "com.puppycrawl.tools.checkstyle.checks.design." + + "InputAnnotatedVisibility.CustomAnnotation"); final String[] expected = { "15:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"), "18:28: " + getCheckMessage(MSG_KEY, "fqPublicJUnitRule"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportTest.java index d2e4a4444..bc6d45fe6 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportTest.java @@ -57,8 +57,12 @@ public class AvoidStaticImportTest "26: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), "27: " + getCheckMessage(MSG_KEY, "java.io.File.createTempFile"), "28: " + getCheckMessage(MSG_KEY, "java.io.File.pathSeparator"), - "29: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass"), - "30: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass.one"), + "29: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass"), + "30: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass.one"), }; verify(checkConfig, getPath("InputAvoidStaticImport.java"), expected); @@ -74,8 +78,12 @@ public class AvoidStaticImportTest final String[] expected = { "25: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), "26: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), - "29: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass"), - "30: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass.one"), + "29: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass"), + "30: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass.one"), }; verify(checkConfig, getPath("InputAvoidStaticImport.java"), expected); } @@ -92,8 +100,12 @@ public class AvoidStaticImportTest "26: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), "27: " + getCheckMessage(MSG_KEY, "java.io.File.createTempFile"), "28: " + getCheckMessage(MSG_KEY, "java.io.File.pathSeparator"), - "29: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass"), - "30: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass.one"), + "29: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass"), + "30: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass.one"), }; verify(checkConfig, getPath("InputAvoidStaticImport.java"), expected); } @@ -108,15 +120,20 @@ public class AvoidStaticImportTest checkConfig.addAttribute( "excludes", "java.io.File.listRoots.listRoots, javax.swing.WindowConstants, javax.swing.*," - + "sun.net.ftpclient.FtpClient.*FtpClient, sun.net.ftpclient.FtpClientjunk, java.io.File.listRootsmorejunk"); + + "sun.net.ftpclient.FtpClient.*FtpClient, sun.net.ftpclient.FtpClientjunk," + + " java.io.File.listRootsmorejunk"); final String[] expected = { "23: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), "25: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), "26: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), "27: " + getCheckMessage(MSG_KEY, "java.io.File.createTempFile"), "28: " + getCheckMessage(MSG_KEY, "java.io.File.pathSeparator"), - "29: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass"), - "30: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass.one"), + "29: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass"), + "30: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass.one"), }; verify(checkConfig, getPath("InputAvoidStaticImport.java"), expected); } @@ -127,17 +144,21 @@ public class AvoidStaticImportTest final DefaultConfiguration checkConfig = createCheckConfig(AvoidStaticImportCheck.class); - // should mask com.puppycrawl.tools.checkstyle.imports.InputAvoidStaticImportNestedClass.InnerClass.one + // should mask com.puppycrawl.tools.checkstyle.imports.InputAvoidStaticImportNestedClass. + // InnerClass.one checkConfig.addAttribute( "excludes", - "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass.*"); + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass.*"); final String[] expected = { "23: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), "25: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), "26: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), "27: " + getCheckMessage(MSG_KEY, "java.io.File.createTempFile"), "28: " + getCheckMessage(MSG_KEY, "java.io.File.pathSeparator"), - "29: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputAvoidStaticImportNestedClass.InnerClass"), + "29: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports." + + "InputAvoidStaticImportNestedClass.InnerClass"), }; verify(checkConfig, getPath("InputAvoidStaticImport.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java index e0691beda..dd7b2c9c6 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java @@ -82,8 +82,10 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "STATIC###SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"); checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true"); final String[] expected = { - "4: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), - "5: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", "java.io.File.createTempFile"), + "4: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", + "java.io.File.createTempFile"), + "5: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", + "java.io.File.createTempFile"), "8: " + getCheckMessage(MSG_ORDER, STD, SAME, "java.awt.Button"), "9: " + getCheckMessage(MSG_ORDER, STD, SAME, "java.awt.Frame"), "10: " + getCheckMessage(MSG_ORDER, STD, SAME, "java.awt.Dialog"), @@ -113,14 +115,17 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE"); checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true"); final String[] expected = { - "4: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), - "5: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", "java.io.File.createTempFile"), + "4: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", + "java.io.File.createTempFile"), + "5: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", + "java.io.File.createTempFile"), "10: " + getCheckMessage(MSG_LEX, "java.awt.Dialog", "java.awt.Frame"), "15: " + getCheckMessage(MSG_LEX, "java.io.File", "javax.swing.JTable"), "16: " + getCheckMessage(MSG_LEX, "java.io.IOException", "javax.swing.JTable"), "17: " + getCheckMessage(MSG_LEX, "java.io.InputStream", "javax.swing.JTable"), "18: " + getCheckMessage(MSG_LEX, "java.io.Reader", "javax.swing.JTable"), - "22: " + getCheckMessage(MSG_LEX, "com.google.common.collect.*", "com.puppycrawl.tools.*"), + "22: " + getCheckMessage(MSG_LEX, "com.google.common.collect.*", + "com.puppycrawl.tools.*"), }; verify(checkConfig, getPath("InputCustomImportOrder.java"), expected); @@ -138,8 +143,10 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###SAME_PACKAGE(3)"); checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true"); final String[] expected = { - "4: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), - "5: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", "java.io.File.createTempFile"), + "4: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", + "java.io.File.createTempFile"), + "5: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", + "java.io.File.createTempFile"), "10: " + getCheckMessage(MSG_LEX, "java.awt.Dialog", "java.awt.Frame"), "15: " + getCheckMessage(MSG_LEX, "java.io.File", "javax.swing.JTable"), "16: " + getCheckMessage(MSG_LEX, "java.io.IOException", "javax.swing.JTable"), @@ -162,12 +169,16 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "STANDARD_JAVA_PACKAGE"); checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true"); final String[] expected = { - "4: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), + "4: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", + "java.io.File.createTempFile"), "7: " + getCheckMessage(MSG_LEX, "java.util.List", "javax.swing.WindowConstants.*"), - "8: " + getCheckMessage(MSG_LEX, "java.util.StringTokenizer", "javax.swing.WindowConstants.*"), + "8: " + getCheckMessage(MSG_LEX, "java.util.StringTokenizer", + "javax.swing.WindowConstants.*"), "9: " + getCheckMessage(MSG_LEX, "java.util.*", "javax.swing.WindowConstants.*"), - "10: " + getCheckMessage(MSG_LEX, "java.util.concurrent.AbstractExecutorService", "javax.swing.WindowConstants.*"), - "11: " + getCheckMessage(MSG_LEX, "java.util.concurrent.*", "javax.swing.WindowConstants.*"), + "10: " + getCheckMessage(MSG_LEX, "java.util.concurrent.AbstractExecutorService", + "javax.swing.WindowConstants.*"), + "11: " + getCheckMessage(MSG_LEX, "java.util.concurrent.*", + "javax.swing.WindowConstants.*"), "14: " + getCheckMessage(MSG_LEX, "com.*", "com.puppycrawl.tools.*"), "16: " + getCheckMessage(MSG_LEX, "com.google.common.base.*", "com.puppycrawl.tools.*"), }; @@ -189,12 +200,14 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "7: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STATIC, "java.awt.Button.ABORT"), "8: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STATIC, "javax.swing.WindowConstants.*"), "9: " + getCheckMessage(MSG_LEX, "com.puppycrawl.tools.*", "java.util.StringTokenizer"), - "10: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.AbstractExecutorService"), + "10: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, + "java.util.concurrent.AbstractExecutorService"), "11: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STATIC, "java.io.File.createTempFile"), "12: " + getCheckMessage(MSG_LEX, "com.*", "java.util.StringTokenizer"), }; - verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackage.java"), expected); + verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackage.java"), + expected); } @Test @@ -212,12 +225,14 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "7: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STATIC, "java.awt.Button.ABORT"), "8: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STATIC, "javax.swing.WindowConstants.*"), "9: " + getCheckMessage(MSG_LEX, "com.puppycrawl.tools.*", "java.util.StringTokenizer"), - "10: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.AbstractExecutorService"), + "10: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, + "java.util.concurrent.AbstractExecutorService"), "11: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STATIC, "java.io.File.createTempFile"), "12: " + getCheckMessage(MSG_LEX, "com.*", "java.util.StringTokenizer"), }; - verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackage.java"), expected); + verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackage.java"), + expected); } @Test @@ -229,7 +244,8 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "STATIC###STANDARD_JAVA_PACKAGE"); checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true"); final String[] expected = { - "4: " + getCheckMessage(MSG_LEX, "java.io.File.createTempFile", "javax.swing.WindowConstants.*"), + "4: " + getCheckMessage(MSG_LEX, "java.io.File.createTempFile", + "javax.swing.WindowConstants.*"), "8: " + getCheckMessage(MSG_LEX, "com.*", "com.puppycrawl.tools.*"), }; @@ -276,7 +292,8 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("sortImportsInGroupAlphabetically", "true"); final String[] expected = { - "7: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), + "7: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", + "java.io.File.createTempFile"), "10: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.awt.Button"), "11: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.awt.Frame"), "12: " + getCheckMessage(MSG_ORDER, STD, THIRD, "java.awt.Dialog"), @@ -314,7 +331,8 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("customImportOrderRules", "SAME_PACKAGE(3)###THIRD_PARTY_PACKAGE###STATIC###SPECIAL_IMPORTS"); final String[] expected = { - "11: " + getCheckMessage(MSG_ORDER, THIRD, SPECIAL, "com.google.common.annotations.GwtCompatible"), + "11: " + getCheckMessage(MSG_ORDER, THIRD, SPECIAL, + "com.google.common.annotations.GwtCompatible"), }; verify(checkConfig, getPath("InputCustomImportOrderThirdPartyAndSpecial.java"), expected); @@ -381,13 +399,16 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "8: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.List"), "9: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.StringTokenizer"), "10: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.*"), - "11: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.AbstractExecutorService"), - "12: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.locks.LockSupport"), + "11: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, + "java.util.concurrent.AbstractExecutorService"), + "12: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, + "java.util.concurrent.locks.LockSupport"), "13: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.regex.Pattern"), "14: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.regex.Matcher"), }; - verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackageDepth2-5.java"), expected); + verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackageDepth2-5.java"), + expected); } @Test @@ -400,11 +421,14 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "SAME_PACKAGE(3)"); final String[] expected = { "10: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.*"), - "11: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.AbstractExecutorService"), - "12: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.locks.LockSupport"), + "11: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, + "java.util.concurrent.AbstractExecutorService"), + "12: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, + "java.util.concurrent.locks.LockSupport"), }; - verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackageDepth2-5.java"), expected); + verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackageDepth2-5.java"), + expected); } @Test @@ -416,10 +440,12 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("customImportOrderRules", "SAME_PACKAGE(4)"); final String[] expected = { - "12: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.locks.LockSupport"), + "12: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, + "java.util.concurrent.locks.LockSupport"), }; - verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackageDepth2-5.java"), expected); + verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackageDepth2-5.java"), + expected); } @Test @@ -432,7 +458,8 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "SAME_PACKAGE(5)"); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackageDepth2-5.java"), expected); + verify(checkConfig, getNonCompilablePath("InputCustomImportOrderSamePackageDepth2-5.java"), + expected); } @Test(expected = CheckstyleException.class) @@ -512,13 +539,19 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { "THIRD_PARTY_PACKAGE###SAME_PACKAGE(6)###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS"); checkConfig.addAttribute("standardPackageRegExp", "com.puppycrawl.tools.*Check$"); checkConfig.addAttribute("specialImportsRegExp", "com.puppycrawl.tools.*Tag*"); - checkConfig.addAttribute("thirdPartyPackageRegExp", "com.puppycrawl.tools.checkstyle.checks.javadoc.*Javadoc*"); + checkConfig.addAttribute("thirdPartyPackageRegExp", + "com.puppycrawl.tools.checkstyle.checks.javadoc.*Javadoc*"); final String[] expected = { - "9: " + getCheckMessage(MSG_ORDER, THIRD, STD, "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocNodeImpl"), - "21: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck"), - "25: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SPECIAL, "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag"), - "26: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"), - "27: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheck"), + "9: " + getCheckMessage(MSG_ORDER, THIRD, STD, + "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocNodeImpl"), + "21: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, + "com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck"), + "25: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SPECIAL, + "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag"), + "26: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, + "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck"), + "27: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, + "com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheck"), }; createChecker(checkConfig); @@ -536,7 +569,8 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; createChecker(checkConfig); - verify(checkConfig, getPath("InputCustomImportOrder_MultiplePatternMatches.java"), expected); + verify(checkConfig, getPath("InputCustomImportOrder_MultiplePatternMatches.java"), + expected); } @Test @@ -550,7 +584,8 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; createChecker(checkConfig); - verify(checkConfig, getPath("InputCustomImportOrder_MultiplePatternMatches.java"), expected); + verify(checkConfig, getPath("InputCustomImportOrder_MultiplePatternMatches.java"), + expected); } @Test @@ -564,6 +599,7 @@ public class CustomImportOrderCheckTest extends BaseCheckTestSupport { String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; createChecker(checkConfig); - verify(checkConfig, getPath("InputCustomImportOrder_MultiplePatternMatches.java"), expected); + verify(checkConfig, getPath("InputCustomImportOrder_MultiplePatternMatches.java"), + expected); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java index 744fe9b89..e1582bb58 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java @@ -234,6 +234,7 @@ public class ImportControlCheckTest extends BaseCheckTestSupport { * @return String message of original exception */ private static String getInvocationTargetExceptionMessage(CheckstyleException ex) { - return ((InvocationTargetException) ex.getCause().getCause()).getTargetException().getMessage(); + return ((InvocationTargetException) ex.getCause().getCause()) + .getTargetException().getMessage(); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java index f3b801235..dfc6371ff 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java @@ -48,14 +48,16 @@ public class ImportControlLoaderTest { @Test(expected = CheckstyleException.class) public void testWrongFormatURI() throws Exception { final PkgControl root = - ImportControlLoader.load(new URI("aaa://" + getPath("import-control_complete.xml"))); + ImportControlLoader.load(new URI("aaa://" + + getPath("import-control_complete.xml"))); assertNotNull(root); } @Test public void testExtraElementInConfig() throws Exception { final PkgControl root = - ImportControlLoader.load(new File(getPath("import-control_WithNewElement.xml")).toURI()); + ImportControlLoader.load( + new File(getPath("import-control_WithNewElement.xml")).toURI()); assertNotNull(root); } @@ -70,7 +72,8 @@ public class ImportControlLoaderTest { }; try { Class<?> clazz = ImportControlLoader.class; - Method privateMethod = clazz.getDeclaredMethod("safeGet", Attributes.class, String.class); + Method privateMethod = clazz.getDeclaredMethod("safeGet", + Attributes.class, String.class); privateMethod.setAccessible(true); privateMethod.invoke(null, attr, "you_cannot_find_me"); } @@ -90,7 +93,8 @@ public class ImportControlLoaderTest { Class<?> clazz = ImportControlLoader.class; Method privateMethod = clazz.getDeclaredMethod("load", InputSource.class, URI.class); privateMethod.setAccessible(true); - privateMethod.invoke(null, source, new File(getPath("import-control_complete.xml")).toURI()); + privateMethod.invoke(null, source, + new File(getPath("import-control_complete.xml")).toURI()); } catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException e) { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java index 1b060e8f6..623479ad4 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java @@ -259,7 +259,8 @@ public class ImportOrderCheckTest extends BaseCheckTestSupport { final DefaultConfiguration checkConfig = createCheckConfig(ImportOrderCheck.class); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("InputImportOrder_NoFailureForRedundantImports.java"), expected); + verify(checkConfig, getPath("InputImportOrder_NoFailureForRedundantImports.java"), + expected); } @Test @@ -357,7 +358,8 @@ public class ImportOrderCheckTest extends BaseCheckTestSupport { final String[] expected = { "8: " + getCheckMessage(MSG_ORDERING, "org.antlr.v4.runtime.CommonToken.*"), }; - verify(checkConfig, getPath("InputImportOrderStaticOnDemandGroupOrderBottom.java"), expected); + verify(checkConfig, getPath("InputImportOrderStaticOnDemandGroupOrderBottom.java"), + expected); } @Test @@ -368,7 +370,8 @@ public class ImportOrderCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("groups", "org, java"); checkConfig.addAttribute("sortStaticImportsAlphabetically", "true"); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("InputImportOrderStaticOnDemandGroupOrderBottom.java"), expected); + verify(checkConfig, getPath("InputImportOrderStaticOnDemandGroupOrderBottom.java"), + expected); } @Test @@ -382,7 +385,8 @@ public class ImportOrderCheckTest extends BaseCheckTestSupport { "7: " + getCheckMessage(MSG_ORDERING, "java.lang.Math.*"), "8: " + getCheckMessage(MSG_ORDERING, "org.antlr.v4.runtime.CommonToken.*"), }; - verify(checkConfig, getPath("InputImportOrderStaticOnDemandGroupOrderBottom.java"), expected); + verify(checkConfig, getPath("InputImportOrderStaticOnDemandGroupOrderBottom.java"), + expected); } @Test(expected = CheckstyleException.class) @@ -400,7 +404,8 @@ public class ImportOrderCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("groups", "java.awt."); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getPath("InputImportOrder_NoFailureForRedundantImports.java"), expected); + verify(checkConfig, getPath("InputImportOrder_NoFailureForRedundantImports.java"), + expected); } @Test @@ -409,7 +414,8 @@ public class ImportOrderCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("groups", "/java/,/rga/,/myO/,/org/,/organ./"); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; - verify(checkConfig, getNonCompilablePath("InputImportOrder_MultiplePatternMatches.java"), expected); + verify(checkConfig, getNonCompilablePath("InputImportOrder_MultiplePatternMatches.java"), + expected); } @Test(expected = IllegalStateException.class) diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java index 8b9511da4..2040b97cb 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java @@ -65,7 +65,8 @@ public class RedundantImportCheckTest createCheckConfig(RedundantImportCheck.class); final String[] expected = { "7:1: " + getCheckMessage(MSG_SAME, "com.puppycrawl.tools.checkstyle.checks.imports.*"), - "8:1: " + getCheckMessage(MSG_SAME, "com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"), + "8:1: " + getCheckMessage(MSG_SAME, + "com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"), "10:1: " + getCheckMessage(MSG_LANG, "java.lang.*"), "11:1: " + getCheckMessage(MSG_LANG, "java.lang.String"), "14:1: " + getCheckMessage(MSG_DUPLICATE, 13, "java.util.List"), @@ -83,7 +84,8 @@ public class RedundantImportCheckTest "2:1: " + getCheckMessage(MSG_DUPLICATE, 1, "java.util.List"), "4:1: " + getCheckMessage(MSG_LANG, "java.lang.String"), }; - verify(checkConfig, getNonCompilablePath("InputRedundantImport_UnnamedPackage.java"), expected); + verify(checkConfig, getNonCompilablePath("InputRedundantImport_UnnamedPackage.java"), + expected); } @Test diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java index d8bc81736..d5eb96219 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java @@ -49,7 +49,8 @@ public class UnusedImportsCheckTest extends BaseCheckTestSupport { public void testDefault() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(UnusedImportsCheck.class); final String[] expected = { - "8:45: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"), + "8:45: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"), "11:8: " + getCheckMessage(MSG_KEY, "java.lang.String"), "13:8: " + getCheckMessage(MSG_KEY, "java.util.List"), "14:8: " + getCheckMessage(MSG_KEY, "java.util.List"), @@ -66,12 +67,17 @@ public class UnusedImportsCheckTest extends BaseCheckTestSupport { "35:8: " + getCheckMessage(MSG_KEY, "java.util.BitSet"), "37:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.Checker"), "38:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.CheckerTest"), - "39:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport"), + "39:8: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.BaseFileSetCheckTestSupport"), "40:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.Definitions"), - "41:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.Input15Extensions"), - "42:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest"), - "43:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.PackageNamesLoader"), - "44:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.DefaultConfiguration"), + "41:8: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.Input15Extensions"), + "42:8: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.ConfigurationLoaderTest"), + "43:8: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.PackageNamesLoader"), + "44:8: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.DefaultConfiguration"), "45:8: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.DefaultLogger"), }; verify(checkConfig, getPath("InputUnusedImports.java"), expected); @@ -82,7 +88,8 @@ public class UnusedImportsCheckTest extends BaseCheckTestSupport { final DefaultConfiguration checkConfig = createCheckConfig(UnusedImportsCheck.class); checkConfig.addAttribute("processJavadoc", "true"); final String[] expected = { - "8:45: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"), + "8:45: " + getCheckMessage(MSG_KEY, + "com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"), "11:8: " + getCheckMessage(MSG_KEY, "java.lang.String"), "13:8: " + getCheckMessage(MSG_KEY, "java.util.List"), "14:8: " + getCheckMessage(MSG_KEY, "java.util.List"), @@ -168,7 +175,8 @@ public class UnusedImportsCheckTest extends BaseCheckTestSupport { "3:8: " + getCheckMessage(MSG_KEY, "java.util.Arrays"), "4:8: " + getCheckMessage(MSG_KEY, "java.lang.String"), }; - verify(checkConfig, getNonCompilablePath("InputRedundantImport_UnnamedPackage.java"), expected); + verify(checkConfig, getNonCompilablePath("InputRedundantImport_UnnamedPackage.java"), + expected); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java index 0eb36a425..36ae295b2 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java @@ -56,7 +56,8 @@ public class IndentationCheckTest extends BaseCheckTestSupport { Pattern.compile(".*?\\S+.*?"); private static final Pattern LINE_WITH_COMMENT_REGEX = - Pattern.compile(".*?\\S+.*?(//indent:(\\d+) exp:((>=\\d+)|(\\d+(,\\d+)*?))( warn)?)"); + Pattern.compile(".*?\\S+.*?(//indent:(\\d+)" + + " exp:((>=\\d+)|(\\d+(,\\d+)*?))( warn)?)"); private static final Pattern GET_INDENT_FROM_COMMENT_REGEX = Pattern.compile("//indent:(\\d+).*?"); @@ -162,8 +163,8 @@ public class IndentationCheckTest extends BaseCheckTestSupport { throw new IllegalStateException("Comments are not consistent"); } - private static boolean isSingleLevelCommentConsistent(int indentInComment, boolean isWarnComment, - int expectedLevel) { + private static boolean isSingleLevelCommentConsistent(int indentInComment, + boolean isWarnComment, int expectedLevel) { return expectedLevel == indentInComment && !isWarnComment || expectedLevel != indentInComment && isWarnComment; } @@ -765,7 +766,8 @@ public class IndentationCheckTest extends BaseCheckTestSupport { "40: " + getCheckMessage(MSG_ERROR, "array initialization lcurly", 2, 4), "44: " + getCheckMessage(MSG_ERROR_MULTI, "array initialization rcurly", 6, "4, 8"), "48: " + getCheckMessage(MSG_ERROR, "array initialization lcurly", 2, 4), - "52: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 20, "8, 31, 33"), + "52: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 20, + "8, 31, 33"), "53: " + getCheckMessage(MSG_CHILD_ERROR_MULTI, "array initialization", 4, "8, 31, 33"), "58: " + getCheckMessage(MSG_CHILD_ERROR, "array initialization", 6, 8), "63: " + getCheckMessage(MSG_ERROR, "member def type", 2, 4), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java index 5b076bc48..22f3f4a60 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java @@ -118,7 +118,8 @@ public class AbstractJavadocCheckTest extends BaseCheckTestSupport { } @Test - public void testCheckReuseAfterParseErrorWithFollowingAntlrErrorInSingleFile() throws Exception { + public void testCheckReuseAfterParseErrorWithFollowingAntlrErrorInSingleFile() + throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(TempCheck.class); final String[] expected = { "4: " + getCheckMessage(JAVADOC_MISSED_HTML_CLOSE, 4, "unclosedTag"), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractTypeAwareCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractTypeAwareCheckTest.java index 024f55fc3..c75a52f75 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractTypeAwareCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractTypeAwareCheckTest.java @@ -82,7 +82,7 @@ public class AbstractTypeAwareCheckTest extends BaseCheckTestSupport { Class<?> regularClassType = Class .forName( - "com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck$RegularClass"); + "com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck$RegularClass"); Constructor<?> regularClassConstructor = regularClassType.getDeclaredConstructor(tokenType, String.class, AbstractTypeAwareCheck.class); regularClassConstructor.setAccessible(true); @@ -125,7 +125,7 @@ public class AbstractTypeAwareCheckTest extends BaseCheckTestSupport { Class<?> regularClassType = Class .forName( - "com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck$RegularClass"); + "com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck$RegularClass"); Constructor<?> regularClassConstructor = regularClassType.getDeclaredConstructor(tokenType, String.class, AbstractTypeAwareCheck.class); regularClassConstructor.setAccessible(true); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java index 5447ee63a..e669a02ae 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java @@ -342,7 +342,8 @@ public class JavadocStyleCheckTest }; verify(createChecker(checkConfig), - getPath("pkginfo" + File.separator + "invalidinherit" + File.separator + "package-info.java"), + getPath("pkginfo" + File.separator + "invalidinherit" + File.separator + + "package-info.java"), expected); } @@ -355,7 +356,8 @@ public class JavadocStyleCheckTest }; verify(createChecker(checkConfig), - getPath("pkginfo" + File.separator + "invalidformat" + File.separator + "package-info.java"), + getPath("pkginfo" + File.separator + "invalidformat" + File.separator + + "package-info.java"), expected); } @@ -366,7 +368,8 @@ public class JavadocStyleCheckTest final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; verify(createChecker(checkConfig), - getPath("pkginfo" + File.separator + "annotation" + File.separator + "package-info.java"), + getPath("pkginfo" + File.separator + "annotation" + File.separator + + "package-info.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfoTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfoTest.java index d1b812a96..f05062c20 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfoTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfoTest.java @@ -351,7 +351,8 @@ public class JavadocTagInfoTest { public void testCoverage() { assertEquals(JavadocTagInfo.Type.BLOCK, JavadocTagInfo.VERSION.getType()); - assertEquals("text [@version] name [version] type [BLOCK]", JavadocTagInfo.VERSION.toString()); + assertEquals("text [@version] name [version] type [BLOCK]", + JavadocTagInfo.VERSION.toString()); try { JavadocTagInfo.fromName(null); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java index 8d657cc13..a86e51676 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java @@ -92,7 +92,8 @@ public class WriteTagCheckTest extends BaseCheckTestSupport { checkConfig.addAttribute("tagFormat", "\\S"); checkConfig.addAttribute("tagSeverity", "warning"); final String[] expected = { - "11: " + getCheckMessage(WRITE_TAG, "warning: @incomplete", "This class needs more code..."), + "11: " + getCheckMessage(WRITE_TAG, "warning: @incomplete", + "This class needs more code..."), }; final boolean printSeverity = true; verify(checkConfig, printSeverity, getPath("InputWriteTag.java"), expected); @@ -204,9 +205,12 @@ public class WriteTagCheckTest extends BaseCheckTestSupport { "ANNOTATION_DEF, ENUM_DEF, ANNOTATION_FIELD_DEF, ENUM_CONSTANT_DEF"); final String[] expected = { "9: " + getCheckMessage(WRITE_TAG, "@incomplete", "This enum needs more code..."), - "13: " + getCheckMessage(WRITE_TAG, "@incomplete", "This enum constant needs more code..."), - "19: " + getCheckMessage(WRITE_TAG, "@incomplete", "This annotation needs more code..."), - "23: " + getCheckMessage(WRITE_TAG, "@incomplete", "This annotation field needs more code..."), + "13: " + getCheckMessage(WRITE_TAG, "@incomplete", + "This enum constant needs more code..."), + "19: " + getCheckMessage(WRITE_TAG, "@incomplete", + "This annotation needs more code..."), + "23: " + getCheckMessage(WRITE_TAG, "@incomplete", + "This annotation field needs more code..."), }; verify(checkConfig, getPath("InputWriteTag2.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java index c4855b7a9..f969705ea 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java @@ -80,7 +80,8 @@ public class BooleanExpressionComplexityCheckTest extends BaseCheckTestSupport { @Test(expected = IllegalArgumentException.class) public void testWrongToken() { - BooleanExpressionComplexityCheck booleanExpressionComplexityCheckObj = new BooleanExpressionComplexityCheck(); + BooleanExpressionComplexityCheck booleanExpressionComplexityCheckObj = + new BooleanExpressionComplexityCheck(); DetailAST ast = new DetailAST(); ast.initialize(new CommonHiddenStreamToken(TokenTypes.INTERFACE_DEF, "interface")); booleanExpressionComplexityCheckObj.visitToken(ast); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java index 2a96954bf..95e7ed69b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java @@ -70,7 +70,8 @@ public class ClassDataAbstractionCouplingCheckTest extends BaseCheckTestSupport @Test(expected = IllegalArgumentException.class) public void testWrongToken() { - ClassDataAbstractionCouplingCheck classDataAbstractionCouplingCheckObj = new ClassDataAbstractionCouplingCheck(); + ClassDataAbstractionCouplingCheck classDataAbstractionCouplingCheckObj = + new ClassDataAbstractionCouplingCheck(); DetailAST ast = new DetailAST(); ast.initialize(new CommonHiddenStreamToken(TokenTypes.CTOR_DEF, "ctor")); classDataAbstractionCouplingCheckObj.visitToken(ast); 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 e39a8bea1..3c95f0a64 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 @@ -43,7 +43,8 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { @Test public void testTypeNamesForThreePermittedCapitalLetters() throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); final int expectedCapitalCount = 3; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); @@ -66,7 +67,8 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { final int expectedCapitalCount = 4; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); checkConfig.addAttribute("allowedAbbreviations", "CLASS,FACTORY"); checkConfig.addAttribute("tokens", "CLASS_DEF"); @@ -84,7 +86,8 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { final int expectedCapitalCount = 5; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); checkConfig.addAttribute("allowedAbbreviations", "CLASS"); checkConfig.addAttribute("tokens", "CLASS_DEF"); @@ -102,7 +105,8 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { final int expectedCapitalCount = 5; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); checkConfig.addAttribute("allowedAbbreviations", "CLASS"); checkConfig.addAttribute("tokens", "CLASS_DEF" @@ -128,7 +132,8 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { final int expectedCapitalCount = 5; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); checkConfig.addAttribute("allowedAbbreviations", "NUMBER,MARAZMATIC,VARIABLE"); checkConfig.addAttribute("ignoreStatic", "false"); @@ -157,7 +162,8 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { final int expectedCapitalCount = 5; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); checkConfig.addAttribute("allowedAbbreviations", "NUMBER,MARAZMATIC,VARIABLE"); checkConfig.addAttribute("ignoreStatic", "true"); @@ -182,7 +188,8 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { final int expectedCapitalCount = 4; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); checkConfig.addAttribute("allowedAbbreviations", "MARAZMATIC,VARIABLE"); checkConfig.addAttribute("ignoreStatic", "false"); @@ -210,7 +217,8 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { final int expectedCapitalCount = 5; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); checkConfig.addAttribute("allowedAbbreviations", "MARAZMATIC,VARIABLE"); checkConfig.addAttribute("ignoreStatic", "true"); @@ -233,9 +241,11 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { } @Test - public void testTypeNamesForThreePermittedCapitalLettersWithOverriddenMethod() throws Exception { + public void testTypeNamesForThreePermittedCapitalLettersWithOverriddenMethod() + throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); final int expectedCapitalCount = 3; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); @@ -300,7 +310,8 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport { @Test public void testNPE() throws Exception { - final DefaultConfiguration checkConfig = createCheckConfig(AbbreviationAsWordInNameCheck.class); + final DefaultConfiguration checkConfig = + createCheckConfig(AbbreviationAsWordInNameCheck.class); final int expectedCapitalCount = 1; warningMessage = getCheckMessage(MSG_KEY, expectedCapitalCount); checkConfig.addAttribute("allowedAbbreviationLength", String.valueOf(expectedCapitalCount)); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java index 795187af5..8e1d3bed8 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java @@ -49,9 +49,11 @@ public class AbstractClassNameCheckTest extends BaseCheckTestSupport { final String pattern = "^Abstract.+$"; final String[] expected = { - "3:1: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "InputAbstractClassName", pattern), + "3:1: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "InputAbstractClassName", + pattern), "6:1: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "NonAbstractClassName", pattern), - "10:5: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "NonAbstractInnerClass", pattern), + "10:5: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "NonAbstractInnerClass", + pattern), }; verify(checkConfig, getPath("InputAbstractClassName.java"), expected); @@ -80,9 +82,11 @@ public class AbstractClassNameCheckTest extends BaseCheckTestSupport { final String pattern = "^Abstract.+$"; final String[] expected = { - "3:1: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "InputAbstractClassName", pattern), + "3:1: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "InputAbstractClassName", + pattern), "6:1: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "NonAbstractClassName", pattern), - "10:5: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "NonAbstractInnerClass", pattern), + "10:5: " + getCheckMessage(ILLEGAL_ABSTRACT_CLASS_NAME, "NonAbstractInnerClass", + pattern), "18:1: " + getCheckMessage(NO_ABSTRACT_CLASS_MODIFIER, "AbstractClass"), "22:5: " + getCheckMessage(NO_ABSTRACT_CLASS_MODIFIER, "AbstractInnerClass"), }; diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java index ac58e06e8..0cdd41564 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java @@ -87,7 +87,8 @@ public class LocalFinalVariableNameCheckTest @Test public void testGetAcceptableTokens() { - LocalFinalVariableNameCheck localFinalVariableNameCheckObj = new LocalFinalVariableNameCheck(); + LocalFinalVariableNameCheck localFinalVariableNameCheckObj = + new LocalFinalVariableNameCheck(); int[] actual = localFinalVariableNameCheckObj.getAcceptableTokens(); int[] expected = { TokenTypes.VARIABLE_DEF, diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java index 91501bd02..490de90c9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java @@ -72,7 +72,8 @@ public class MethodNameCheckTest final String[] expected = { "12:16: " + getCheckMessage(MSG_KEY, "InputMethNameEqualClsName"), "12:16: " + getCheckMessage(MSG_INVALID_PATTERN, "InputMethNameEqualClsName", pattern), - "17:17: " + getCheckMessage(MSG_INVALID_PATTERN, "PRIVATEInputMethNameEqualClsName", pattern), + "17:17: " + getCheckMessage(MSG_INVALID_PATTERN, "PRIVATEInputMethNameEqualClsName", + pattern), "23:20: " + getCheckMessage(MSG_KEY, "Inner"), "23:20: " + getCheckMessage(MSG_INVALID_PATTERN, "Inner", pattern), "28:20: " + getCheckMessage(MSG_INVALID_PATTERN, "InputMethNameEqualClsName", pattern), @@ -99,7 +100,8 @@ public class MethodNameCheckTest final String[] expected = { "12:16: " + getCheckMessage(MSG_INVALID_PATTERN, "InputMethNameEqualClsName", pattern), - "17:17: " + getCheckMessage(MSG_INVALID_PATTERN, "PRIVATEInputMethNameEqualClsName", pattern), + "17:17: " + getCheckMessage(MSG_INVALID_PATTERN, "PRIVATEInputMethNameEqualClsName", + pattern), "23:20: " + getCheckMessage(MSG_INVALID_PATTERN, "Inner", pattern), "28:20: " + getCheckMessage(MSG_INVALID_PATTERN, "InputMethNameEqualClsName", pattern), "37:24: " + getCheckMessage(MSG_INVALID_PATTERN, "InputMethNameEqualClsName", pattern), diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java index 7c0ac09cf..88171e4e1 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java @@ -57,7 +57,8 @@ public class PackageNameCheckTest final String pattern = "[A-Z]+"; final String[] expected = { - "6:9: " + getCheckMessage(MSG_INVALID_PATTERN, "com.puppycrawl.tools.checkstyle.checks.naming", pattern), + "6:9: " + getCheckMessage(MSG_INVALID_PATTERN, + "com.puppycrawl.tools.checkstyle.checks.naming", pattern), }; verify(checkConfig, getPath("InputSimple.java"), expected); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeParameterNameTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeParameterNameTest.java index 14d874555..ec758496b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeParameterNameTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeParameterNameTest.java @@ -166,7 +166,8 @@ public class TypeParameterNameTest @Test public void testGetAcceptableTokens() { - AbstractTypeParameterNameCheck typeParameterNameCheckObj = new ClassTypeParameterNameCheck(); + AbstractTypeParameterNameCheck typeParameterNameCheckObj = + new ClassTypeParameterNameCheck(); int[] actual = typeParameterNameCheckObj.getAcceptableTokens(); int[] expected = { TokenTypes.TYPE_PARAMETER, diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java index 093ff3fe2..7413351a9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java @@ -171,7 +171,8 @@ public class RegexpMultilineCheckTest extends BaseFileSetCheckTestSupport { } private static CharSequence makeLargeXYString() { - // now needs 10'000 or 100'000, as just 1000 is no longer enough today to provoke the StackOverflowError + // now needs 10'000 or 100'000, as just 1000 is no longer enough today to provoke the + // StackOverflowError final int size = 100000; StringBuffer largeString = new StringBuffer(size); for (int i = 0; i < size / 2; i++) { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java index 7431a6561..ca5bd861e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java @@ -75,7 +75,8 @@ public class EmptyForInitializerPadCheckTest @Test public void testGetAcceptableTokens() { - EmptyForInitializerPadCheck emptyForInitializerPadCheckObj = new EmptyForInitializerPadCheck(); + EmptyForInitializerPadCheck emptyForInitializerPadCheckObj = + new EmptyForInitializerPadCheck(); int[] actual = emptyForInitializerPadCheckObj.getAcceptableTokens(); int[] expected = { TokenTypes.FOR_INIT, diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java index 3a47c48d4..8d0c2bba9 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java @@ -131,7 +131,8 @@ public class EmptyLineSeparatorCheckTest final String[] expected = { "1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), }; - verify(checkConfig, getPath("InputEmptyLineSeparatorMultipleImportEmptyClass.java"), expected); + verify(checkConfig, getPath("InputEmptyLineSeparatorMultipleImportEmptyClass.java"), + expected); } @Test diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterTest.java index 55d689105..f0137bad8 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterTest.java @@ -82,7 +82,8 @@ public class SeverityMatchFilterTest { final AuditEvent ev2 = new AuditEvent(this, "ATest.java", errorMessage); assertTrue("level:" + errorLevel, filter.accept(ev2)); SeverityLevel infoLevel = SeverityLevel.INFO; - LocalizedMessage infoMessage = new LocalizedMessage(0, 0, "", "", null, infoLevel, null, getClass(), null); + LocalizedMessage infoMessage = new LocalizedMessage(0, 0, "", "", null, infoLevel, null, + getClass(), null); final AuditEvent ev3 = new AuditEvent(this, "ATest.java", infoMessage); assertFalse("level:" + infoLevel, filter.accept(ev3)); } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilterTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilterTest.java index 33e36f82c..e141697d4 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilterTest.java @@ -40,7 +40,8 @@ public class SuppressionFilterTest { @Test public void testAccept() throws CheckstyleException { SuppressionFilter filter = new SuppressionFilter(); - filter.setFile("src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppressions_none.xml"); + filter.setFile("src/test/resources/com/puppycrawl/tools/checkstyle/filters/" + + "suppressions_none.xml"); final AuditEvent ev = new AuditEvent(this, "ATest.java", null); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java index 6d14e79b0..355bc05a7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java @@ -68,7 +68,8 @@ public class SuppressionsLoaderTest extends BaseCheckTestSupport { public void testLoadFromURL() throws Exception { final String[] urlCandidates = { "http://checkstyle.sourceforge.net/files/suppressions_none.xml", - "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/site/resources/files/suppressions_none.xml", + "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/site/resources/" + + "files/suppressions_none.xml", }; FilterSet actualFilterSet = null; @@ -130,7 +131,8 @@ public class SuppressionsLoaderTest extends BaseCheckTestSupport { } catch (CheckstyleException ex) { assertEquals( - "Unable to parse " + fn + " - Attribute \"files\" is required and must be specified for element type \"suppress\".", + "Unable to parse " + fn + " - Attribute \"files\" is required and must be" + + " specified for element type \"suppress\".", ex.getMessage()); } } @@ -143,7 +145,8 @@ public class SuppressionsLoaderTest extends BaseCheckTestSupport { } catch (CheckstyleException ex) { assertEquals( - "Unable to parse " + fn + " - Attribute \"checks\" is required and must be specified for element type \"suppress\".", + "Unable to parse " + fn + " - Attribute \"checks\" is required and must be" + + " specified for element type \"suppress\".", ex.getMessage()); } } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/grammars/javadoc/JavadocParseTreeTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/grammars/javadoc/JavadocParseTreeTest.java index 298666e0c..7890c676e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammars/javadoc/JavadocParseTreeTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammars/javadoc/JavadocParseTreeTest.java @@ -67,7 +67,8 @@ public class JavadocParseTreeTest { private static String getPath(String filename) throws IOException { return new File( - "src/test/resources/com/puppycrawl/tools/checkstyle/grammars/javadoc/" + filename).getCanonicalPath(); + "src/test/resources/com/puppycrawl/tools/checkstyle/grammars/javadoc/" + + filename).getCanonicalPath(); } private static String getHtmlPath(String filename) throws IOException { diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/utils/CommonUtilsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/utils/CommonUtilsTest.java index 6d96b8f44..c6e8cb260 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/CommonUtilsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/CommonUtilsTest.java @@ -128,7 +128,8 @@ public class CommonUtilsTest { final String absoluteFilePath = sampleAbsolutePath + "/SampleFile.java"; final String basePath = sampleAbsolutePath + PATH_DENORMALIZER; - final String relativePath = CommonUtils.relativizeAndNormalizePath(basePath, absoluteFilePath); + final String relativePath = CommonUtils.relativizeAndNormalizePath(basePath, + absoluteFilePath); assertEquals("SampleFile.java", relativePath); } |