View Javadoc
1 package net.sourceforge.pmd.rules; 2 3 import net.sourceforge.pmd.AbstractRule; 4 import net.sourceforge.pmd.RuleContext; 5 import net.sourceforge.pmd.ast.ASTMethodDeclaration; 6 import net.sourceforge.pmd.symboltable.VariableNameDeclaration; 7 8 import java.text.MessageFormat; 9 import java.util.Iterator; 10 11 public class UnusedFormalParameterRule extends AbstractRule { 12 13 public Object visit(ASTMethodDeclaration node, Object data) { 14 if (node.isPrivate() && !node.isNative()) { // make sure it's both private and not native 15 RuleContext ctx = (RuleContext) data; 16 for (Iterator i = node.getScope().getVariableDeclarations(false).keySet().iterator(); i.hasNext();) { 17 VariableNameDeclaration nameDecl = (VariableNameDeclaration) i.next(); 18 ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine(), MessageFormat.format(getMessage(), new Object[]{nameDecl.getImage()}))); 19 } 20 } 21 return data; 22 } 23 }

This page was automatically generated by Maven