net.sourceforge.pmd.rules.strings

Class ConsecutiveLiteralAppends

public class ConsecutiveLiteralAppends extends AbstractRule

This rule finds concurrent calls to StringBuffer.append where String literals are used It would be much better to make these calls using one call to .append

example:

 StringBuffer buf = new StringBuffer();
 buf.append("Hello");
 buf.append(" ").append("World");
 

This would be more eloquently put as:

 StringBuffer buf = new StringBuffer();
 buf.append("Hello World");
 

The rule takes one parameter, threshold, which defines the lower limit of consecutive appends before a violation is created. The default is 1.

Method Summary
Objectvisit(ASTVariableDeclaratorId node, Object data)

Method Detail

visit

public Object visit(ASTVariableDeclaratorId node, Object data)