diff --git a/config/pitest-suppressions/pitest-metrics-suppressions.xml b/config/pitest-suppressions/pitest-metrics-suppressions.xml
index f7faecc2a32..60b1ebc4fd0 100644
--- a/config/pitest-suppressions/pitest-metrics-suppressions.xml
+++ b/config/pitest-suppressions/pitest-metrics-suppressions.xml
@@ -99,51 +99,6 @@
private int recordMaximum = RECORD_MAX_NCSS;
-
- JavaNCSSCheck.java
- com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck
- isExpressionCountable
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_2
- RemoveSwitch 2 (case value 83)
- switch (parentType) {
-
-
-
- JavaNCSSCheck.java
- com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck
- isExpressionCountable
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_3
- RemoveSwitch 3 (case value 84)
- switch (parentType) {
-
-
-
- JavaNCSSCheck.java
- com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck
- isExpressionCountable
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_4
- RemoveSwitch 4 (case value 85)
- switch (parentType) {
-
-
-
- JavaNCSSCheck.java
- com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck
- isExpressionCountable
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_5
- RemoveSwitch 5 (case value 91)
- switch (parentType) {
-
-
-
- JavaNCSSCheck.java
- com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck
- isExpressionCountable
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_6
- RemoveSwitch 6 (case value 92)
- switch (parentType) {
-
-
NPathComplexityCheck.java
com.puppycrawl.tools.checkstyle.checks.metrics.NPathComplexityCheck
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java
index bedc66fa083..b5523b2628f 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java
@@ -106,6 +106,17 @@ public void testRecordsAndCompactCtors() throws Exception {
expected);
}
+ @Test
+ public void testForMutation() throws Exception {
+ final String[] expected = {
+ "13:1: " + getCheckMessage(MSG_CLASS, 84, 80),
+ "16:5: " + getCheckMessage(MSG_CLASS, 83, 80),
+ };
+ verifyWithInlineConfigParser(
+ getPath("InputJavaNCSSResolveMutation.java"),
+ expected);
+ }
+
@Test
public void testGetAcceptableTokens() {
final JavaNCSSCheck javaNcssCheckObj = new JavaNCSSCheck();
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/javancss/InputJavaNCSSResolveMutation.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/javancss/InputJavaNCSSResolveMutation.java
new file mode 100644
index 00000000000..f3fe5749726
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/javancss/InputJavaNCSSResolveMutation.java
@@ -0,0 +1,120 @@
+/*
+JavaNCSS
+methodMaximum = (default)50
+classMaximum = 80
+fileMaximum = (default)2000
+recordMaximum = (default)150
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.metrics.javancss;
+
+public class InputJavaNCSSResolveMutation {
+ // violation above 'NCSS for this class is 84 (max allowed is 80)'
+
+ public static class Some // violation 'NCSS for this class is 83 (max allowed is 80)'
+ {
+ static class SomeClass {
+ boolean flag = true;
+
+ static boolean test(boolean k) {
+ return k;
+ }
+ }
+
+ private int foo() {
+ if (SomeClass.test(true)) return 4;
+ return 0;
+ }
+
+ private int foo1() {
+ return 4;
+ }
+
+ private int foo2() {
+ if (SomeClass.test(true))
+ return 4;
+ return 0;
+ }
+
+ private int foo3() {
+ if (SomeClass.test(true)) if (true) return 4;
+ return 0;
+ }
+
+ private void foo(Object o) {
+ if (o != null) this.notify();
+ }
+
+ private void foo2(Object o) {
+ if (o != null)
+ this.notify();
+ }
+
+ private void loopTest(Object o) {
+ while (o != null) {
+ this.notify();
+ }
+ while (o != null)
+ this.notify();
+ while (o != null) this.notify();
+ do {
+ this.notify();
+ } while (o != null);
+ do this.notify(); while (o != null);
+ do
+ this.notify();
+ while (o != null);
+ for (; ; )
+ break;
+ for (; ; ) break;
+ for (int i = 0; i < 10; i++) {
+ this.notify();
+ }
+ for (int i = 0; i < 10; i++)
+ this.notify();
+ for (int i = 0; ; ) this.notify();
+ }
+
+ private int getSmth(int num) {
+ int counter = 0;
+ switch (num) {
+ case 1:
+ counter++;
+ break;
+ case 2: // ok
+ counter += 2;
+ break;
+ case 3: // ok
+ counter += 3;
+ break;
+ case 6:
+ counter += 10;
+ break;
+ default:
+ counter = 100;
+ break;
+ }
+ return counter;
+ }
+
+ private void testElse(int k) {
+ if (k == 4) System.identityHashCode("yes");
+ else System.identityHashCode("no");
+ for (; ; ) ;
+ }
+
+ void enhancedForLoop(int[] array) {
+ for (int value : array) return;
+ }
+
+ private void forEachLoop() {
+ for (String s : new String[]{""}) break;
+ for (String s : new String[]{""})
+ break;
+ for (; ; )
+ ;
+ }
+ }
+}