diff --git a/pmd/regress/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java b/pmd/regress/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java new file mode 100644 index 0000000000..06e33f9c34 --- /dev/null +++ b/pmd/regress/net/sourceforge/pmd/rules/UnusedFormalParameterRule.java @@ -0,0 +1,45 @@ +package net.sourceforge.pmd.rules; + +import net.sourceforge.pmd.AbstractRule; +import net.sourceforge.pmd.ast.ASTMethodDeclaration; +import net.sourceforge.pmd.ast.SimpleNode; +import net.sourceforge.pmd.ast.ASTInterfaceDeclaration; +import net.sourceforge.pmd.ast.ASTName; +import java.util.*; +import net.sourceforge.pmd.ast.ASTBlock; + + +public class UnusedFormalParameterRule extends AbstractRule { + private List paramNames = null; + + /** + Skip interfaces + */ + public Object visit(ASTInterfaceDeclaration node, Object data) { + return data; + } + + public Object visit(ASTMethodDeclaration node, Object data) { + if (node.isPrivate()) { + SimpleNode md = (SimpleNode)node.jjtGetChild(1); + SimpleNode formalParams = (SimpleNode)md.jjtGetChild(0); + int paramCount = formalParams.jjtGetNumChildren(); + if (paramCount == 0) return data; //bail out if now paramters + paramNames = new ArrayList(); + for (int i=0; i + + +Complete this description + + + + + + diff --git a/pmd/test-data/UnusedFormalParam1.java b/pmd/test-data/UnusedFormalParam1.java new file mode 100644 index 0000000000..0994a40eb4 --- /dev/null +++ b/pmd/test-data/UnusedFormalParam1.java @@ -0,0 +1,11 @@ + + +class UnusedFormalParam1 { + private void testMethod(String param1) { + + } + + private void t2(){ + + } +} \ No newline at end of file