From fc95f97b45dbc72ba10f000b0386d72b6c2bb1e3 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Sat, 4 Apr 2020 00:07:34 +0530 Subject: [PATCH] Issue #7804: Resolve Pitest Issues - CustomImportOrderCheck (3) --- .ci/pitest.sh | 1 - .../imports/CustomImportOrderCheck.java | 19 +++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.ci/pitest.sh b/.ci/pitest.sh index 8a380aff893..323400a67ac 100755 --- a/.ci/pitest.sh +++ b/.ci/pitest.sh @@ -69,7 +69,6 @@ pitest-header) pitest-imports) mvn -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage; declare -a ignoredItems=( - "CustomImportOrderCheck.java.html:
        if (bestMatch.group.equals(NON_GROUP_RULE_GROUP)) {
" "IllegalImportCheck.java.html:
        if (!result) {
" "ImportControlLoader.java.html:
        else if (ALLOW_ELEMENT_NAME.equals(qName) || "disallow".equals(qName)) {
" "ImportOrderCheck.java.html:
                else if (matcher.start() == bestPos && matcher.end() > bestEnd) {
" diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java index 0ce03538b89..98b88f64b20 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java @@ -786,18 +786,17 @@ else if (customOrderRules.contains(SAME_PACKAGE_RULE_GROUP)) { bestMatch.matchLength = importPath.length(); } } - if (bestMatch.group.equals(NON_GROUP_RULE_GROUP)) { - for (String group : customOrderRules) { - if (STANDARD_JAVA_PACKAGE_RULE_GROUP.equals(group)) { - bestMatch = findBetterPatternMatch(importPath, - STANDARD_JAVA_PACKAGE_RULE_GROUP, standardPackageRegExp, bestMatch); - } - if (SPECIAL_IMPORTS_RULE_GROUP.equals(group)) { - bestMatch = findBetterPatternMatch(importPath, - group, specialImportsRegExp, bestMatch); - } + for (String group : customOrderRules) { + if (STANDARD_JAVA_PACKAGE_RULE_GROUP.equals(group)) { + bestMatch = findBetterPatternMatch(importPath, + STANDARD_JAVA_PACKAGE_RULE_GROUP, standardPackageRegExp, bestMatch); + } + if (SPECIAL_IMPORTS_RULE_GROUP.equals(group)) { + bestMatch = findBetterPatternMatch(importPath, + group, specialImportsRegExp, bestMatch); } } + if (bestMatch.group.equals(NON_GROUP_RULE_GROUP) && customOrderRules.contains(THIRD_PARTY_PACKAGE_RULE_GROUP) && thirdPartyPackageRegExp.matcher(importPath).find()) {