diff --git a/config/pitest-suppressions/pitest-coding-2-suppressions.xml b/config/pitest-suppressions/pitest-coding-2-suppressions.xml
index 06586a30ffb..f270c9ecfee 100644
--- a/config/pitest-suppressions/pitest-coding-2-suppressions.xml
+++ b/config/pitest-suppressions/pitest-coding-2-suppressions.xml
@@ -153,204 +153,6 @@
this.query = query;
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_10
- RemoveSwitch 10 (case value 102)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_11
- RemoveSwitch 11 (case value 103)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_12
- RemoveSwitch 12 (case value 104)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_13
- RemoveSwitch 13 (case value 105)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_14
- RemoveSwitch 14 (case value 106)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_15
- RemoveSwitch 15 (case value 107)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_16
- RemoveSwitch 16 (case value 108)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_2
- RemoveSwitch 2 (case value 26)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_7
- RemoveSwitch 7 (case value 99)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_8
- RemoveSwitch 8 (case value 100)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- leaveToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_9
- RemoveSwitch 9 (case value 101)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_10
- RemoveSwitch 10 (case value 102)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_11
- RemoveSwitch 11 (case value 103)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_12
- RemoveSwitch 12 (case value 104)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_13
- RemoveSwitch 13 (case value 105)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_14
- RemoveSwitch 14 (case value 106)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_15
- RemoveSwitch 15 (case value 107)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_16
- RemoveSwitch 16 (case value 108)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_2
- RemoveSwitch 2 (case value 26)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_7
- RemoveSwitch 7 (case value 99)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_8
- RemoveSwitch 8 (case value 100)
- switch (ast.getType()) {
-
-
-
- ModifiedControlVariableCheck.java
- com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck
- visitToken
- org.pitest.mutationtest.engine.gregor.mutators.experimental.RemoveSwitchMutator_9
- RemoveSwitch 9 (case value 101)
- switch (ast.getType()) {
-
-
MultipleStringLiteralsCheck.java
com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java
index c20df91a531..8bd43df7012 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java
@@ -131,6 +131,37 @@ public void testImproperToken() {
}
}
+ @Test
+ public void testVariousAssignments() throws Exception {
+ final String[] expected = {
+ "14:15: " + getCheckMessage(MSG_KEY, "i"),
+ "15:15: " + getCheckMessage(MSG_KEY, "k"),
+ "21:15: " + getCheckMessage(MSG_KEY, "i"),
+ "22:15: " + getCheckMessage(MSG_KEY, "k"),
+ "28:15: " + getCheckMessage(MSG_KEY, "i"),
+ "29:15: " + getCheckMessage(MSG_KEY, "k"),
+ "35:15: " + getCheckMessage(MSG_KEY, "i"),
+ "36:15: " + getCheckMessage(MSG_KEY, "k"),
+ "42:15: " + getCheckMessage(MSG_KEY, "i"),
+ "43:15: " + getCheckMessage(MSG_KEY, "k"),
+ "48:15: " + getCheckMessage(MSG_KEY, "i"),
+ "49:15: " + getCheckMessage(MSG_KEY, "k"),
+ "55:15: " + getCheckMessage(MSG_KEY, "i"),
+ "56:15: " + getCheckMessage(MSG_KEY, "k"),
+ "62:15: " + getCheckMessage(MSG_KEY, "i"),
+ "63:15: " + getCheckMessage(MSG_KEY, "k"),
+ "69:15: " + getCheckMessage(MSG_KEY, "i"),
+ "70:15: " + getCheckMessage(MSG_KEY, "k"),
+ "76:15: " + getCheckMessage(MSG_KEY, "i"),
+ "77:15: " + getCheckMessage(MSG_KEY, "k"),
+ "83:14: " + getCheckMessage(MSG_KEY, "i"),
+ "84:14: " + getCheckMessage(MSG_KEY, "k"),
+ };
+ verifyWithInlineConfigParser(
+ getPath("InputModifiedControlVariableTestVariousAssignments.java"),
+ expected);
+ }
+
/**
* We cannot reproduce situation when visitToken is called and leaveToken is not.
* So, we have to use reflection to be sure that even in such situation
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/modifiedcontrolvariable/InputModifiedControlVariableTestVariousAssignments.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/modifiedcontrolvariable/InputModifiedControlVariableTestVariousAssignments.java
new file mode 100644
index 00000000000..fda9167e545
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/modifiedcontrolvariable/InputModifiedControlVariableTestVariousAssignments.java
@@ -0,0 +1,87 @@
+/*
+ModifiedControlVariable
+skipEnhancedForLoopVariable = (default)false
+
+
+*/
+
+package com.puppycrawl.tools.checkstyle.checks.coding.modifiedcontrolvariable;
+
+public class InputModifiedControlVariableTestVariousAssignments {
+
+ void method() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i -= 3; // violation 'Control variable 'i' is modified'
+ k -= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+
+ void method1() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i *= 3; // violation 'Control variable 'i' is modified'
+ k *= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+
+ void method2() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i /= 3; // violation 'Control variable 'i' is modified'
+ k /= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+
+ void method3() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i %= 3; // violation 'Control variable 'i' is modified'
+ k %= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+
+ void method4() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i >>= 3; // violation 'Control variable 'i' is modified'
+ k >>= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+ void method5() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i >>>= 3; // violation 'Control variable 'i' is modified'
+ k >>>= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+
+ void method6() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i <<= 3; // violation 'Control variable 'i' is modified'
+ k <<= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+
+ void method7() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i &= 3; // violation 'Control variable 'i' is modified'
+ k &= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+
+ void method8() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i ^= 3; // violation 'Control variable 'i' is modified'
+ k ^= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+
+ void method9() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i |= 3; // violation 'Control variable 'i' is modified'
+ k |= 4; // violation 'Control variable 'k' is modified'
+ }
+ }
+
+ void method10() {
+ for (int i=0,k=0; i<10 && k < 10; ++i,++k) {
+ i--; // violation 'Control variable 'i' is modified'
+ k--; // violation 'Control variable 'k' is modified'
+ }
+ }
+}