[Fb-contrib-commit] SF.net SVN: fb-contrib: [692] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-11-19 05:42:57
|
Revision: 692 http://svn.sourceforge.net/fb-contrib/?rev=692&view=rev Author: dbrosius Date: 2006-11-18 21:42:56 -0800 (Sat, 18 Nov 2006) Log Message: ----------- try to make SPP for StringBuffer(int) with char less prone to false +, and reenable Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-11-19 05:18:32 UTC (rev 691) +++ trunk/fb-contrib/etc/messages.xml 2006-11-19 05:42:56 UTC (rev 692) @@ -1539,12 +1539,12 @@ </BugPattern> <BugPattern type="SPP_NO_CHAR_SB_CTOR"> - <ShortDescription>Method passes character to StringBuffer or StringBuilder integer constructor</ShortDescription> - <LongDescription>Method {1} passes character to StringBuffer or StringBuilder integer constructor</LongDescription> + <ShortDescription>Method appears to pass character to StringBuffer or StringBuilder integer constructor</ShortDescription> + <LongDescription>Method {1} appears to pass character to StringBuffer or StringBuilder integer constructor</LongDescription> <Details> <![CDATA[ <p>This method constructs a StringBuffer or a StringBuilder using the constructor that takes an integer, but - passes a character instead. It is probable that the author assumed that character would be appended to the + appears to pass a character instead. It is probable that the author assumed that character would be appended to the StringBuffer/Builder, but instead the integer value of the character is used as an initial size for the buffer. </p> ]]> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-19 05:18:32 UTC (rev 691) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-19 05:42:56 UTC (rev 692) @@ -131,10 +131,23 @@ String signature = getSigConstantOperand(); if ("(I)V".equals(signature)) { if (lastOpcode == BIPUSH) { - //bugReporter.reportBug(new BugInstance(this, "SPP_NO_CHAR_SB_CTOR", NORMAL_PRIORITY) - // .addClass(this) - // .addMethod(this) - // .addSourceLine(this)); + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + Object o = item.getConstant(); + if (o instanceof Integer) { + int parm = ((Integer) o).intValue(); + if ((parm > 32) + && (parm < 127) + && (parm != 64) + && ((parm % 10) != 0) + && ((parm % 5) != 0)) { + bugReporter.reportBug(new BugInstance(this, "SPP_NO_CHAR_SB_CTOR", LOW_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |