aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorrnveach <rveach02@gmail.com>2015-10-29 16:37:38 -0400
committerRoman Ivanov <ivanov-jr@mail.ru>2015-10-29 21:10:29 -0700
commit2ba55edc4e35866afbb154e3ea03cf03e56ab9bc (patch)
tree77a60c241053bf1b472c7dc09024f87323caa0dd /src/test/java
parent10ebe0d8d371b78306faeffd9250975d9c8e0854 (diff)
downloadcheckstyle-2ba55edc4e35866afbb154e3ea03cf03e56ab9bc.tar.gz
Issue #2268: require all checks appear in checkstyle_checks.xml
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/puppycrawl/tools/checkstyle/AllChecksTest.java28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/AllChecksTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/AllChecksTest.java
index f52c240d7..7e53d5dbb 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/AllChecksTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/AllChecksTest.java
@@ -53,6 +53,8 @@ import com.puppycrawl.tools.checkstyle.api.Filter;
import com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck;
public class AllChecksTest extends BaseCheckTestSupport {
+ private static final String CONFIG_PATH = "config" + File.separator
+ + "checkstyle_checks.xml";
@Test
public void testAllChecksWithDefaultConfiguration() throws Exception {
@@ -151,10 +153,9 @@ public class AllChecksTest extends BaseCheckTestSupport {
@Test
public void testAllChecksAreReferencedInConfigFile() throws Exception {
- final String configFilePath = "config/checkstyle_checks.xml";
final Set<Class<?>> checksFromClassPath = getCheckstyleChecks();
final Set<String> checksReferencedInConfig =
- getCheckStyleChecksReferencedInConfig(configFilePath);
+ getCheckStyleChecksReferencedInConfig(CONFIG_PATH);
final Set<String> checksNames = getSimpleNames(checksFromClassPath);
for (String check : checksNames) {
@@ -185,6 +186,23 @@ public class AllChecksTest extends BaseCheckTestSupport {
}
}
+ @Test
+ public void testAllCheckstyleModulesInCheckstyleConfig() throws Exception {
+ final Set<String> configChecks = getCheckStyleChecksReferencedInConfig(CONFIG_PATH);
+
+ for (String moduleName : getSimpleNames(getCheckstyleModules())) {
+ if ("SuppressionCommentFilter".equals(moduleName)
+ || "SeverityMatchFilter".equals(moduleName)
+ || "SuppressWithNearbyCommentFilter".equals(moduleName)
+ || "SuppressWarningsFilter".equals(moduleName)) {
+ continue;
+ }
+
+ Assert.assertTrue("checkstyle_checks.xml is missing module: " + moduleName,
+ configChecks.contains(moduleName));
+ }
+ }
+
/**
* Gets the checkstyle's non abstract checks.
* @return the set of checkstyle's non abstract check classes.
@@ -261,7 +279,8 @@ public class AllChecksTest extends BaseCheckTestSupport {
final String className = loadedClass.getSimpleName();
return isCheckstyleNonAbstractCheck(loadedClass, className)
|| isFilterModule(loadedClass, className)
- || "SuppressWarningsHolder".equals(className);
+ || "SuppressWarningsHolder".equals(className)
+ || "FileContentsHolder".equals(className);
}
/**
@@ -332,8 +351,7 @@ public class AllChecksTest extends BaseCheckTestSupport {
final Element module = (Element) currentNode;
final String checkName = module.getAttribute("name");
if (!"Checker".equals(checkName)
- && !"TreeWalker".equals(checkName)
- && !"SuppressionFilter".equals(checkName)) {
+ && !"TreeWalker".equals(checkName)) {
checksReferencedInCheckstyleChecksXML.add(checkName);
}
}