diff --git a/.ci/pitest.sh b/.ci/pitest.sh index ee8368ffd0c5..b11dfb5f2590 100755 --- a/.ci/pitest.sh +++ b/.ci/pitest.sh @@ -73,7 +73,6 @@ pitest-imports) declare -a ignoredItems=( "AvoidStarImportCheck.java.html:
            && ast.getType() == TokenTypes.STATIC_IMPORT) {
" "AvoidStarImportCheck.java.html:
            if (exclude.endsWith(STAR_IMPORT_SUFFIX)) {
" - "AvoidStaticImportCheck.java.html:
        if (exclude.endsWith(".*")) {
" "CustomImportOrderCheck.java.html:
                        && matcher.start() < betterMatchCandidate.matchPosition) {
" "CustomImportOrderCheck.java.html:
        else if (customImportOrderRules.contains(SAME_PACKAGE_RULE_GROUP)) {
" "CustomImportOrderCheck.java.html:
        if (bestMatch.group.equals(NON_GROUP_RULE_GROUP)) {
" diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java index 95921cab231f..2736343ed647 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java @@ -55,10 +55,11 @@ public void testDefaultOperation() "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, + "29: " + getCheckMessage(MSG_KEY, "java.lang.Math.sqrt"), + "30: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass"), - "30: " + getCheckMessage(MSG_KEY, + "31: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass.one"), }; @@ -76,10 +77,11 @@ public void testStarExcludes() final String[] expected = { "25: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), "26: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), - "29: " + getCheckMessage(MSG_KEY, + "29: " + getCheckMessage(MSG_KEY, "java.lang.Math.sqrt"), + "30: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass"), - "30: " + getCheckMessage(MSG_KEY, + "31: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass.one"), }; @@ -91,17 +93,18 @@ public void testMemberExcludes() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(AvoidStaticImportCheck.class); - checkConfig.addAttribute("excludes", "java.io.File.listRoots"); + checkConfig.addAttribute("excludes", "java.io.File.listRoots,java.lang.Math.E"); // allow the java.io.File.listRoots member imports final String[] expected = { "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, + "29: " + getCheckMessage(MSG_KEY, "java.lang.Math.sqrt"), + "30: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass"), - "30: " + getCheckMessage(MSG_KEY, + "31: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass.one"), }; @@ -126,10 +129,11 @@ public void testBogusMemberExcludes() "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, + "29: " + getCheckMessage(MSG_KEY, "java.lang.Math.sqrt"), + "30: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass"), - "30: " + getCheckMessage(MSG_KEY, + "31: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass.one"), }; @@ -154,7 +158,8 @@ public void testInnerClassMemberExcludesStar() "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, + "29: " + getCheckMessage(MSG_KEY, "java.lang.Math.sqrt"), + "30: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports." + "avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass"), }; diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/avoidstaticimport/InputAvoidStaticImportDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/avoidstaticimport/InputAvoidStaticImportDefault.java index f53801a70d22..6f8231d4827c 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/avoidstaticimport/InputAvoidStaticImportDefault.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/avoidstaticimport/InputAvoidStaticImportDefault.java @@ -26,6 +26,7 @@ import static javax.swing.WindowConstants.*; import static java.io.File.createTempFile; import static java.io.File.pathSeparator; +import static java.lang.Math.sqrt; import static com.puppycrawl.tools.checkstyle.checks.imports.avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass; import static com.puppycrawl.tools.checkstyle.checks.imports.avoidstaticimport.InputAvoidStaticImportNestedClass.InnerClass.one;