net.sourceforge.pmd.rules

Class AbstractPoorMethodCall

public abstract class AbstractPoorMethodCall extends AbstractRule

Detects and flags the occurrences of specific method calls against an instance of a designated class. I.e. String.indexOf. The goal is to be able to suggest more efficient/modern ways of implementing the same function. Concrete subclasses are expected to provide the name of the target class and an array of method names that we are looking for. We then pass judgment on any literal arguments we find in the subclass as well.

Version: $Revision: 6422 $

Author: Brian Remedios

Method Summary
protected abstract booleanisViolationArgument(Node arg)
Returns whether the node being sent to the method is OK or not.
protected abstract String[]methodNames()
Return the names of all the methods we are scanning for, no brackets or argument types.
protected abstract StringtargetTypename()
The name of the type the method will be invoked against.
Objectvisit(ASTVariableDeclaratorId node, Object data)
Method visit.

Method Detail

isViolationArgument

protected abstract boolean isViolationArgument(Node arg)
Returns whether the node being sent to the method is OK or not. Return true if you want to record the method call as a violation.

Parameters: arg the node to inspect

Returns: boolean

methodNames

protected abstract String[] methodNames()
Return the names of all the methods we are scanning for, no brackets or argument types.

Returns: String[]

targetTypename

protected abstract String targetTypename()
The name of the type the method will be invoked against.

Returns: String

visit

public Object visit(ASTVariableDeclaratorId node, Object data)
Method visit.

Parameters: node ASTVariableDeclaratorId data Object

Returns: Object

See Also: JavaParserVisitor