diff --git a/pmd/src/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java b/pmd/src/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java index c2d85d15dc..d2959d8a3a 100644 --- a/pmd/src/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java +++ b/pmd/src/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java @@ -7,6 +7,9 @@ import net.sourceforge.pmd.ast.ASTInterfaceDeclaration; import net.sourceforge.pmd.ast.ASTName; import java.util.*; import net.sourceforge.pmd.ast.ASTBlock; +import net.sourceforge.pmd.RuleContext; +import java.text.MessageFormat; +import net.sourceforge.pmd.ast.ASTVariableDeclaratorId; public class UnusedFormalParameterRule extends AbstractRule { @@ -23,7 +26,20 @@ public class UnusedFormalParameterRule extends AbstractRule { * @param paramNames list of param names to check */ private void checkParamNames(HashSet paramNames, SimpleNode startNode) { - + if (paramNames.isEmpty()) return; //if there are no more paramNames then there's no reason to keep checking + int index = 0; + if (startNode instanceof ASTName) { + String nodeImage = ((ASTName)startNode).getImage(); + if (paramNames.contains(nodeImage)) { + paramNames.remove(nodeImage); //the name is used so let's remove it from the list + } + } + else if (startNode.jjtGetNumChildren() > 0) { + for (int i=0; i