[Fb-contrib-commit] SF.net SVN: fb-contrib: [835] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-02-04 03:29:45
|
Revision: 835 http://svn.sourceforge.net/fb-contrib/?rev=835&view=rev Author: dbrosius Date: 2007-02-03 19:29:45 -0800 (Sat, 03 Feb 2007) Log Message: ----------- add check for pattern new BoxedPrimitive(BoxedPrimitive.parseBoxedPrimitive("1")) Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-02-04 03:20:48 UTC (rev 834) +++ trunk/fb-contrib/etc/findbugs.xml 2007-02-04 03:29:45 UTC (rev 835) @@ -115,7 +115,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessAutoboxing" speed="fast" - reports="NAB_NEEDLESS_AUTOBOXING_CTOR,NAB_NEEDLESS_AUTOBOXING_VALUEOF,NAB_NEEDLESS_BOXING_PARSE,NAB_NEEDLESS_BOXING_VALUEOF" /> + reports="NAB_NEEDLESS_AUTOBOXING_CTOR,NAB_NEEDLESS_BOXING_STRING_CTOR,NAB_NEEDLESS_AUTOBOXING_VALUEOF,NAB_NEEDLESS_BOXING_PARSE,NAB_NEEDLESS_BOXING_VALUEOF" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryStoreBeforeReturn" speed="fast" @@ -305,6 +305,7 @@ <BugPattern abbrev="SMII" type="SMII_STATIC_METHOD_INSTANCE_INVOCATION" category="STYLE" /> <BugPattern abbrev="STS" type="STS_SPURIOUS_THREAD_STATES" category="MT_CORRECTNESS" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_AUTOBOXING_CTOR" category="PERFORMANCE" /> + <BugPattern abbrev="NAB" type="NAB_NEEDLESS_BOXING_STRING_CTOR" category="PERFORMANCE" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_AUTOBOXING_VALUEOF" category="PERFORMANCE" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_BOXING_PARSE" category="PERFORMANCE" /> <BugPattern abbrev="NAB" type="NAB_NEEDLESS_BOXING_VALUEOF" category="PERFORMANCE" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-04 03:20:48 UTC (rev 834) +++ trunk/fb-contrib/etc/messages.xml 2007-02-04 03:29:45 UTC (rev 835) @@ -1043,6 +1043,18 @@ ]]> </Details> </BugPattern> + + <BugPattern type="NAB_NEEDLESS_BOXING_STRING_CTOR"> + <ShortDescription>method passes parsed string to primitive wrapper constructor</ShortDescription> + <LongDescription>method {1} passes parsed string to primitive wrapper constructor</LongDescription> + <Details> + <![CDATA[ + <p>This method passes a primitive value retrieved from a BoxedPrimitive.parseBoxedPrimitive("1") call to + the same class's constructor. It is simpler to just pass the string to the BoxedPrimitives constructor. + </p> + ]]> + </Details> + </BugPattern> <BugPattern type="NAB_NEEDLESS_AUTOBOXING_VALUEOF"> <ShortDescription>method passes primitive wrapper to Wrapper class valueOf method</ShortDescription> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-04 03:20:48 UTC (rev 834) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-04 03:29:45 UTC (rev 835) @@ -167,6 +167,13 @@ .addSourceLine(this)); } } + } else if (seen == INVOKESPECIAL) { + if ("<init>".equals(getNameConstantOperand()) && (boxClass.equals(getClassConstantOperand()))) { + bugReporter.reportBug(new BugInstance(this, "NAB_NEEDLESS_BOXING_STRING_CTOR", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } state = SEEN_NOTHING; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |