net.sourceforge.pmd.rules.strings

Class UseStringBufferLength

public class UseStringBufferLength extends AbstractRule

This rule finds places where StringBuffer.toString() is called just to see if the string is 0 length by either using .equals("") or toString().length()

 StringBuffer sb = new StringBuffer("some string");
 if (sb.toString().equals("")) {
     // this is wrong
 }
 if (sb.length() == 0) {
     // this is right
 }
 

Author: acaplan

Method Summary
Objectvisit(ASTCompilationUnit acu, Object data)
Objectvisit(ASTName decl, Object data)

Method Detail

visit

public Object visit(ASTCompilationUnit acu, Object data)

visit

public Object visit(ASTName decl, Object data)