Incorrect StringBuffer warning when that class is not used
A source code analyzer
Brought to you by:
adangel,
juansotuyo
The following code when checked with "-R java-strings", gives a warning about StringBuffer despite no StringBuffer being used at all in the code. This first appeared when I updated from 5.0.5 to 5.1.0.
public class Ineffecient { public static String getValue(int in) { Integer i = new Integer(in); if (i.toString().length() == 1) { return "length 1"; } return ""; } public String toString() { return "Ineffecient"; } }
The exact warning is:
Inefficient.java:6: This is an inefficient use of StringBuffer.toString; call StringBuffer.length instead.
Removing the class's toString method also means there is no warning, perhaps that is related to the problem.
Will be fixed with the next release.