diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterRegexNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterRegexNamingConventionsRule.java index 8b0392cd92..b5f3511194 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterRegexNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterRegexNamingConventionsRule.java @@ -31,6 +31,11 @@ public class FormalParameterRegexNamingConventionsRule extends AbstractRegexNami @Override public Object visit(ASTParameter node, Object data) { + // classes that extend Exception will contains methods that have parameters with null names + if (node.getImage() == null) { + return data; + } + if (node.getModifiers().isFinal()) { checkMatches(FINAL_METHOD_PARAMETER_REGEX, node, data); } else { diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/FormalParameterRegexNamingConventions.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/FormalParameterRegexNamingConventions.xml index 76366ad383..7cc3fc943d 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/FormalParameterRegexNamingConventions.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/codestyle/xml/FormalParameterRegexNamingConventions.xml @@ -57,4 +57,12 @@ public class Foo { ]]> + + ignores null parameter names + 0 + + +