# Package net.sourceforge.pmd.lang.java.rule.strings

- Class Summary
  Class | Description
  --- | ---
  AppendCharacterWithCharRule | This rule finds the following: StringBuffer.append("c"); // appends a single character It is preferable to use StringBuffer.append('c'); // appends a single character Implementation of PMD RFE 1373863
  AvoidDuplicateLiteralsRule |
  AvoidDuplicateLiteralsRule.ExceptionParser |
  ConsecutiveLiteralAppendsRule | This rule finds concurrent calls to StringBuffer/Builder.append where String literals are used It would be much better to make these calls using one call to .append example: StringBuilder buf = new StringBuilder(); buf.append("Hello"); buf.append(" ").append("World"); This would be more eloquently put as: StringBuilder buf = new StringBuilder(); buf.append("Hello World"); The rule takes one parameter, threshold, which defines the lower limit of consecutive appends before a violation is created.
  InefficientEmptyStringCheckRule | This rule finds code which inefficiently determines empty strings.
  InefficientStringBufferingRule | How this rule works: find additive expressions: + check that the addition is between anything other than two literals if true and also the parent is StringBuffer constructor or append, report a violation.
  InsufficientStringBufferDeclarationRule | This rule finds StringBuffers which may have been pre-sized incorrectly See http://sourceforge.net/forum/forum.php?
  StringInstantiationRule |
  StringToStringRule |
  UnnecessaryCaseChangeRule |
  UseIndexOfCharRule |
  UselessStringValueOfRule |
  UseStringBufferLengthRule | 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 }

Copyright © 2002-2013 InfoEther. All Rights Reserved.