[Fb-contrib-commit] SF.net SVN: fb-contrib: [721] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-12-12 04:44:55
|
Revision: 721 http://svn.sourceforge.net/fb-contrib/?rev=721&view=rev Author: dbrosius Date: 2006-12-11 20:35:24 -0800 (Mon, 11 Dec 2006) Log Message: ----------- check for Float too Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-12-10 10:18:38 UTC (rev 720) +++ trunk/fb-contrib/etc/messages.xml 2006-12-12 04:35:24 UTC (rev 721) @@ -1598,8 +1598,8 @@ <LongDescription>Method {1} compares a double to Double.NAN</LongDescription> <Details> <![CDATA[ - <p>This method compares a douhle to the constant Double.NaN. You should use - Double.isNaN(d) if a primitive; or d.isNaN() if a boxed double, instead.</p> + <p>This method compares a douhle or float to the constant Double.NaN or Float.NaN. You should use + Double.isNaN(d) or Float.isNaN(f) if a primitive; or d.isNaN() or f.isNaN() if a boxed double, instead.</p> ]]> </Details> </BugPattern> Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2006-12-10 10:18:38 UTC (rev 720) +++ trunk/fb-contrib/samples/SPP_Sample.java 2006-12-12 04:35:24 UTC (rev 721) @@ -39,6 +39,12 @@ System.out.println("It's a nan"); } + public void testNAN(float f) + { + if (f == Float.NaN) + System.out.println("It's a nan"); + } + public void testBigDecimal() { BigDecimal d = new BigDecimal(2.1); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-12-10 10:18:38 UTC (rev 720) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-12-12 04:35:24 UTC (rev 721) @@ -107,6 +107,20 @@ .addSourceLine(this)); } } + } else if (seen == FCMPL) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item item = stack.getStackItem(0); + Float f1 = (Float)item.getConstant(); + item = stack.getStackItem(1); + Float f2 = (Float)item.getConstant(); + + if (((f1 != null) && f1.isNaN()) || ((f2 != null) && f2.isNaN())) { + bugReporter.reportBug(new BugInstance(this, "SPP_USE_ISNAN", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } else if (((seen >= ASTORE_0) && (seen < ASTORE_3)) || (seen == ASTORE)) { reg = RegisterUtils.getAStoreReg(this, seen); if (seen == lastOpcode) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |