diff --git a/pom.xml b/pom.xml
index f28099554..06d4a7532 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1099,7 +1099,6 @@
.*.checks.coding.ExplicitInitializationCheck9197
.*.checks.coding.FinalLocalVariableCheck83100
.*.checks.coding.IllegalInstantiationCheck8197
- .*.checks.coding.ParameterAssignmentCheck8096
.*.checks.coding.ReturnCountCheck5574
.*.checks.coding.SimplifyBooleanReturnCheck83100
.*.checks.coding.VariableDeclarationUsageDistanceCheck9098
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java
index 949ad9617..80a8a30f6 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java
@@ -199,7 +199,7 @@ public final class ParameterAssignmentCheck extends Check {
* @param ast ident to check.
*/
private void checkIdent(DetailAST ast) {
- if (parameterNames != null && !parameterNames.isEmpty()) {
+ if (!parameterNames.isEmpty()) {
final DetailAST identAST = ast.getFirstChild();
if (identAST != null
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java
index b3d35f761..133101bef 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java
@@ -28,6 +28,8 @@ import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class ParameterAssignmentCheckTest extends BaseCheckTestSupport {
@Test
@@ -52,4 +54,28 @@ public class ParameterAssignmentCheckTest extends BaseCheckTestSupport {
Assert.assertNotNull(check.getDefaultTokens());
Assert.assertNotNull(check.getRequiredTokens());
}
+
+ @Test
+ public void testImproperToken() throws Exception {
+ ParameterAssignmentCheck check = new ParameterAssignmentCheck();
+
+ DetailAST classDefAst = new DetailAST();
+ classDefAst.setType(TokenTypes.CLASS_DEF);
+
+ try {
+ check.visitToken(classDefAst);
+ Assert.fail();
+ }
+ catch (IllegalStateException e) {
+ // it is OK
+ }
+
+ try {
+ check.leaveToken(classDefAst);
+ Assert.fail();
+ }
+ catch (IllegalStateException e) {
+ // it is OK
+ }
+ }
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/coding/InputParameterAssignment.java b/src/test/resources/com/puppycrawl/tools/checkstyle/coding/InputParameterAssignment.java
index 0b4cf4f84..bfb206a29 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/coding/InputParameterAssignment.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/coding/InputParameterAssignment.java
@@ -15,7 +15,7 @@ public class InputParameterAssignment {
void foo2() {
field = 0;
}
-
+ @SuppressWarnings(value = "unchecked")
void foo3(String field, int field1) {
this.field = (field1 += field.length());
}