diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/ArrayInitializationVerbosenessRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/ArrayInitializationVerbosenessRule.java index 56d531ec41..6018e4fd91 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/ArrayInitializationVerbosenessRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/ArrayInitializationVerbosenessRule.java @@ -14,9 +14,11 @@ public class ArrayInitializationVerbosenessRule extends AbstractJavaRule { @Override public Object visit(ASTLocalVariableDeclaration node, Object data) { - if (node.isArray() && node.getImage() != null) { + boolean isArrayPlaceholder = true; + + if (isArrayPlaceholder && node.getImage() != null) { Pattern verbosePattern = Pattern.compile("(= ?new).+\\{"); - Matcher matcher = verbosePattern.matcher(string); + Matcher matcher = verbosePattern.matcher(node.getImage()); while (matcher.find()) { addViolation(data, node);