Issue #5005: increased pitest coverage for metrics package
diff --git a/pom.xml b/pom.xml
index 0881813..30bbc01 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1948,7 +1948,7 @@
               <targetTests>
                 <param>com.puppycrawl.tools.checkstyle.checks.metrics.*</param>
               </targetTests>
-              <mutationThreshold>97</mutationThreshold>
+              <mutationThreshold>98</mutationThreshold>
               <timeoutFactor>${pitest.plugin.timeout.factor}</timeoutFactor>
               <timeoutConstant>${pitest.plugin.timeout.constant}</timeoutConstant>
               <threads>${pitest.plugin.threads}</threads>
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheck.java
index b960dd5..8c41a8c 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheck.java
@@ -59,14 +59,7 @@
 
     @Override
     public int[] getAcceptableTokens() {
-        return new int[] {
-            TokenTypes.PACKAGE_DEF,
-            TokenTypes.IMPORT,
-            TokenTypes.CLASS_DEF,
-            TokenTypes.INTERFACE_DEF,
-            TokenTypes.ENUM_DEF,
-            TokenTypes.LITERAL_NEW,
-        };
+        return getRequiredTokens();
     }
 
     // -@cs[SimpleAccessorNameNotation] Overrides method from the base class.
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 a749d18..bd58329 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
@@ -45,9 +45,10 @@
 
         final String[] expected = {
             "13:9: " + getCheckMessage(MSG_KEY, 4, 3),
-            "32:9: " + getCheckMessage(MSG_KEY, 6, 3),
-            "38:34: " + getCheckMessage(MSG_KEY, 4, 3),
-            "40:34: " + getCheckMessage(MSG_KEY, 4, 3),
+            "29:99: " + getCheckMessage(MSG_KEY, 4, 3),
+            "39:9: " + getCheckMessage(MSG_KEY, 6, 3),
+            "45:34: " + getCheckMessage(MSG_KEY, 4, 3),
+            "47:34: " + getCheckMessage(MSG_KEY, 4, 3),
         };
 
         verify(checkConfig, getPath("InputBooleanExpressionComplexity.java"), expected);
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 e141d09..0476374 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
@@ -20,7 +20,9 @@
 package com.puppycrawl.tools.checkstyle.checks.metrics;
 
 import static com.puppycrawl.tools.checkstyle.checks.metrics.ClassDataAbstractionCouplingCheck.MSG_KEY;
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -41,6 +43,17 @@
     }
 
     @Test
+    public void testTokens() {
+        final ClassDataAbstractionCouplingCheck check = new ClassDataAbstractionCouplingCheck();
+        assertNotNull("Required tokens should not be null", check.getRequiredTokens());
+        assertNotNull("Acceptable tokens should not be null", check.getAcceptableTokens());
+        assertArrayEquals("Invalid default tokens", check.getDefaultTokens(),
+                check.getAcceptableTokens());
+        assertArrayEquals("Invalid acceptable tokens", check.getDefaultTokens(),
+                check.getRequiredTokens());
+    }
+
+    @Test
     public void test() throws Exception {
         final DefaultConfiguration checkConfig =
             createModuleConfig(ClassDataAbstractionCouplingCheck.class);
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java
index b72b3f6..a7cb8bd 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java
@@ -21,7 +21,9 @@
 
 import static com.puppycrawl.tools.checkstyle.checks.metrics.NPathComplexityCheck.MSG_KEY;
 
+import java.io.File;
 import java.util.Collection;
+import java.util.Optional;
 import java.util.SortedSet;
 
 import org.junit.Assert;
@@ -139,6 +141,35 @@
     }
 
     @Test
+    public void testStatefulFieldsClearedOnBeginTree3() throws Exception {
+        final NPathComplexityCheck check = new NPathComplexityCheck();
+        final Optional<DetailAST> question = TestUtil.findTokenInAstByPredicate(
+            TestUtil.parseFile(new File(getPath("InputNPathComplexity.java"))),
+            ast -> ast.getType() == TokenTypes.QUESTION);
+
+        Assert.assertTrue("Ast should contain QUESTION", question.isPresent());
+
+        Assert.assertTrue("State is not cleared on beginTree",
+            TestUtil.isStatefulFieldClearedDuringBeginTree(
+                check,
+                question.get(),
+                "processingTokenEnd",
+                processingTokenEnd -> {
+                    try {
+                        return (Integer) TestUtil.getClassDeclaredField(
+                            processingTokenEnd.getClass(), "endLineNo").get(
+                            processingTokenEnd) == 0
+                            && (Integer) TestUtil.getClassDeclaredField(
+                                processingTokenEnd.getClass(), "endColumnNo").get(
+                                processingTokenEnd) == 0;
+                    }
+                    catch (IllegalAccessException | NoSuchFieldException ex) {
+                        throw new IllegalStateException(ex);
+                    }
+                }));
+    }
+
+    @Test
     public void testDefaultConfiguration() throws Exception {
         final DefaultConfiguration checkConfig =
             createModuleConfig(NPathComplexityCheck.class);
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/booleanexpressioncomplexity/InputBooleanExpressionComplexity.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/booleanexpressioncomplexity/InputBooleanExpressionComplexity.java
index 8d5bd7a..1c8b481 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/booleanexpressioncomplexity/InputBooleanExpressionComplexity.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/booleanexpressioncomplexity/InputBooleanExpressionComplexity.java
@@ -24,6 +24,13 @@
     }
 
     public boolean equals(Object object) {
+        new NestedClass() {
+            public void method() {
+                new Settings(Settings.FALSE || Settings.FALSE || Settings.FALSE || Settings.FALSE || Settings.FALSE);
+            }
+            public void method2() {
+            }
+        };
         return (((_a && (_b & _c)) || (_c ^ _d) || (_a && _d)));
     }
     
@@ -68,4 +75,9 @@
         {
         }
     }
+
+    abstract class NestedClass {
+        public abstract void method();
+        public abstract void method2();
+    }
 }