fb-contrib-commit Mailing List for fb-contrib (Page 40)
Brought to you by:
dbrosius
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(56) |
Oct
(60) |
Nov
(58) |
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(66) |
Feb
(55) |
Mar
(85) |
Apr
(115) |
May
(35) |
Jun
(28) |
Jul
(3) |
Aug
(48) |
Sep
(37) |
Oct
(22) |
Nov
(14) |
Dec
(66) |
2007 |
Jan
(45) |
Feb
(63) |
Mar
(10) |
Apr
(1) |
May
(1) |
Jun
(12) |
Jul
|
Aug
|
Sep
(25) |
Oct
(21) |
Nov
(39) |
Dec
|
2008 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(5) |
May
(2) |
Jun
(32) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2009 |
Jan
(10) |
Feb
(31) |
Mar
(32) |
Apr
(35) |
May
(25) |
Jun
|
Jul
(31) |
Aug
(10) |
Sep
(95) |
Oct
(35) |
Nov
(10) |
Dec
(34) |
2010 |
Jan
(90) |
Feb
(4) |
Mar
(7) |
Apr
(20) |
May
(20) |
Jun
(13) |
Jul
(7) |
Aug
(18) |
Sep
(25) |
Oct
(4) |
Nov
(16) |
Dec
(2) |
2011 |
Jan
(1) |
Feb
|
Mar
(11) |
Apr
(3) |
May
(2) |
Jun
(26) |
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(14) |
Nov
(3) |
Dec
(4) |
2013 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(4) |
May
|
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(3) |
2014 |
Jan
(4) |
Feb
(2) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(2) |
Nov
(7) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(3) |
2018 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(5) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dbr...@us...> - 2007-02-20 01:38:25
|
Revision: 866 http://svn.sourceforge.net/fb-contrib/?rev=866&view=rev Author: dbrosius Date: 2007-02-19 17:38:25 -0800 (Mon, 19 Feb 2007) Log Message: ----------- add experimental tag Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-02-20 01:36:20 UTC (rev 865) +++ trunk/fb-contrib/etc/findbugs.xml 2007-02-20 01:38:25 UTC (rev 866) @@ -360,7 +360,7 @@ <BugPattern abbrev="SPP" type="SPP_USE_BIGDECIMAL_STRING_CTOR" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_STRINGBUFFER_WITH_EMPTY_STRING" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_ENUM" category="CORRECTNESS" /> - <BugPattern abbrev="SPP" type="SPP_INVALID_BOOLEAN_NULL_CHECK" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_INVALID_BOOLEAN_NULL_CHECK" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-20 01:36:19
|
Revision: 865 http://svn.sourceforge.net/fb-contrib/?rev=865&view=rev Author: dbrosius Date: 2007-02-19 17:36:20 -0800 (Mon, 19 Feb 2007) Log Message: ----------- more isb fixes Modified Paths: -------------- trunk/fb-contrib/samples/ISB_Sample.java Modified: trunk/fb-contrib/samples/ISB_Sample.java =================================================================== --- trunk/fb-contrib/samples/ISB_Sample.java 2007-02-20 01:35:46 UTC (rev 864) +++ trunk/fb-contrib/samples/ISB_Sample.java 2007-02-20 01:36:20 UTC (rev 865) @@ -72,9 +72,11 @@ public String testFPISB9(String a, String b, String c) { + String d = a + c; + StringBuilder sb = new StringBuilder(); - sb.append(ISB_Sample.getBigger(a + b, c)); + sb.append(ISB_Sample.getBigger(a + b, d)); return sb.toString(); } @@ -85,4 +87,12 @@ return a; return b; } + + public String testFPISB10() + { + int i = 1; + int j = 2; + throw new RuntimeException("i=" + i + ", j=" + j); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-20 01:35:54
|
Revision: 864 http://svn.sourceforge.net/fb-contrib/?rev=864&view=rev Author: dbrosius Date: 2007-02-19 17:35:46 -0800 (Mon, 19 Feb 2007) Log Message: ----------- add SPP fix for pattern if (b && b.booleanValue()) Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml 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/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2007-02-20 00:31:17 UTC (rev 863) +++ trunk/fb-contrib/etc/findbugs.xml 2007-02-20 01:35:46 UTC (rev 864) @@ -256,7 +256,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri" speed="fast" - reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM" /> + reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" @@ -360,6 +360,7 @@ <BugPattern abbrev="SPP" type="SPP_USE_BIGDECIMAL_STRING_CTOR" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_STRINGBUFFER_WITH_EMPTY_STRING" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_ENUM" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_INVALID_BOOLEAN_NULL_CHECK" category="CORRECTNESS" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-20 00:31:17 UTC (rev 863) +++ trunk/fb-contrib/etc/messages.xml 2007-02-20 01:35:46 UTC (rev 864) @@ -1741,6 +1741,23 @@ </Details> </BugPattern> + <BugPattern type="SPP_INVALID_BOOLEAN_NULL_CHECK"> + <ShortDescription>Method uses invalid C++ style null check on Boolean</ShortDescription> + <LongDescription>Method {1} uses invalid C++ style null check on Boolean</LongDescription> + <Details> + <![CDATA[ + <p>This method attempts to check for null by just refering to the variable name + as would be done in C++. This ordinarily would be considered a compile error, except the + variable in question is a Boolean, which does an auto unbox to boolean.</p> + <pre> + if (b && b.booleanValue()) + should be + if ((b != null) && b.booleanValue()) + </pre> + ]]> + </Details> + </BugPattern> + <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> <LongDescription>Method {1} assigns a variable in a larger scope then is needed</LongDescription> Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2007-02-20 00:31:17 UTC (rev 863) +++ trunk/fb-contrib/samples/SPP_Sample.java 2007-02-20 01:35:46 UTC (rev 864) @@ -62,4 +62,12 @@ if (f.equals(Flap.Jack)) System.out.println("Flap Jacks"); } + + public void testCPPBoolean(Boolean a, Boolean b, Boolean c, Boolean d, Boolean e) + { + if (b && b.booleanValue()) + System.out.println("Booya"); + if (e && e.booleanValue()) + System.out.println("Booya"); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-02-20 00:31:17 UTC (rev 863) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-02-20 01:35:46 UTC (rev 864) @@ -18,6 +18,8 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.Arrays; + import org.apache.bcel.Repository; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.ConstantDouble; @@ -38,6 +40,7 @@ { private BugReporter bugReporter; private OpcodeStack stack; + private int lastPCs[]; private int lastOpcode; private int lastReg; @@ -53,9 +56,11 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); + lastPCs = new int[4]; super.visitClassContext(classContext); } finally { stack = null; + lastPCs = null; } } @@ -69,6 +74,7 @@ stack.resetForMethodEntry(this); lastOpcode = -1; lastReg = -1; + Arrays.fill(lastPCs, -1); super.visitCode(obj); } @@ -181,6 +187,33 @@ } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } + } else if ("java/lang/Boolean".equals(className) + && "booleanValue".equals(methodName)) { + if (lastPCs[0] != -1) { + int range1Size = lastPCs[2] - lastPCs[0]; + if (range1Size == (getNextPC() - lastPCs[3])) { + byte[] bytes = getCode().getCode(); + int ifeq = 0x000000FF & bytes[lastPCs[2]]; + if (ifeq == IFEQ) { + int start1 = lastPCs[0]; + int start2 = lastPCs[3]; + boolean found = true; + for (int i = 0; i < range1Size; i++) { + if (bytes[start1+i] != bytes[start2+i]) { + found = false; + break; + } + } + + if (found) { + bugReporter.reportBug(new BugInstance(this, "SPP_INVALID_BOOLEAN_NULL_CHECK", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + } } } else if (seen == INVOKESPECIAL) { String className = getClassConstantOperand(); @@ -239,6 +272,8 @@ stack.sawOpcode(this, seen); lastOpcode = seen; lastReg = reg; + System.arraycopy(lastPCs, 1, lastPCs, 0, 3); + lastPCs[3] = getPC(); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-20 00:31:18
|
Revision: 863 http://svn.sourceforge.net/fb-contrib/?rev=863&view=rev Author: dbrosius Date: 2007-02-19 16:31:17 -0800 (Mon, 19 Feb 2007) Log Message: ----------- better words Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-17 08:20:21 UTC (rev 862) +++ trunk/fb-contrib/etc/messages.xml 2007-02-20 00:31:17 UTC (rev 863) @@ -1893,5 +1893,5 @@ <BugCode abbrev="SCII">Spoiled Child Interface Implementor</BugCode> <BugCode abbrev="DWI">Deleting While Iterating</BugCode> <BugCode abbrev="USS">Use String Split</BugCode> - <BugCode abbrev="SJVU">Suspicious JDK VersionUse</BugCode> + <BugCode abbrev="SJVU">Suspicious JDK Version Use</BugCode> </MessageCollection> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-17 08:20:21
|
Revision: 862 http://svn.sourceforge.net/fb-contrib/?rev=862&view=rev Author: dbrosius Date: 2007-02-17 00:20:21 -0800 (Sat, 17 Feb 2007) Log Message: ----------- attempt #2: fix fp sb.append(ISB_Sample.getBigger(a + b, d)); Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 07:43:47 UTC (rev 861) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 08:20:21 UTC (rev 862) @@ -75,6 +75,7 @@ @Override public void sawOpcode(final int seen) { + Boolean nestedSB = null; try { stack.mergeJumps(this); @@ -85,12 +86,8 @@ && "<init>".equals(getNameConstantOperand()) && "()V".equals(getSigConstantOperand())) { OpcodeStack.Item itm = getStringBufferItemAt(2); - if ((itm != null) && (itm.getUserValue() == null)) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + if (itm != null) { + nestedSB = Boolean.TRUE; } } } else if (seen == INVOKEVIRTUAL) { @@ -119,11 +116,36 @@ } } } + String calledClass = getClassConstantOperand(); + if (("java/lang/StringBuffer".equals(calledClass) + || "java/lang/StringBuilder".equals(calledClass))) { + String methodName = getNameConstantOperand(); + if ("append".equals(methodName)) { + OpcodeStack.Item itm = getStringBufferItemAt(1); + nestedSB = (itm == null) ? null : (Boolean)itm.getUserValue(); + + if (stack.getStackDepth() > 0) { + itm = stack.getStackItem(0); + if (itm.getUserValue() != null) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + + } + } + } else if ("toString".equals(methodName)) { + OpcodeStack.Item itm = getStringBufferItemAt(0); + nestedSB = (itm == null) ? null : (Boolean)itm.getUserValue(); + } + } + } else if (seen == GOTO) { int depth = stack.getStackDepth(); for (int i = 0; i < depth; i++) { OpcodeStack.Item itm = stack.getStackItem(i); - itm.setUserValue(Boolean.TRUE); + itm.setUserValue(Boolean.FALSE); } } else if (seen == LDC) { Constant c = getConstantRefOperand(); @@ -135,6 +157,12 @@ } } finally { stack.sawOpcode(this, seen); + if (nestedSB != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + itm.setUserValue(nestedSB); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-17 07:43:47
|
Revision: 861 http://svn.sourceforge.net/fb-contrib/?rev=861&view=rev Author: dbrosius Date: 2007-02-16 23:43:47 -0800 (Fri, 16 Feb 2007) Log Message: ----------- revert - that was a disaster Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 06:41:09 UTC (rev 860) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 07:43:47 UTC (rev 861) @@ -75,11 +75,25 @@ @Override public void sawOpcode(final int seen) { - boolean markAsSBToString = false; try { stack.mergeJumps(this); - if (seen == INVOKEVIRTUAL) { + if (seen == INVOKESPECIAL) { + String calledClass = getClassConstantOperand(); + if (("java/lang/StringBuffer".equals(calledClass) + || "java/lang/StringBuilder".equals(calledClass)) + && "<init>".equals(getNameConstantOperand()) + && "()V".equals(getSigConstantOperand())) { + OpcodeStack.Item itm = getStringBufferItemAt(2); + if ((itm != null) && (itm.getUserValue() == null)) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } else if (seen == INVOKEVIRTUAL) { if (sawLDCEmpty) { String calledClass = getClassConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) @@ -104,52 +118,12 @@ } } } - } else { - String calledClass = getClassConstantOperand(); - if (("java/lang/StringBuffer".equals(calledClass) - || "java/lang/StringBuilder".equals(calledClass))) { - if (("toString".equals(getNameConstantOperand()) - && "()Ljava/lang/String;".equals(getSigConstantOperand()))) { - markAsSBToString = true; - } else if (("append".equals(getNameConstantOperand()) - && (("(Ljava/lang/String;)L" + calledClass + ";").equals(getSigConstantOperand())))) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(0); - Boolean sbVal = (Boolean)itm.getUserValue(); - if ((sbVal != null) && sbVal.booleanValue()) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } - } } - } else if (seen == INVOKESPECIAL) { - String calledClass = getClassConstantOperand(); - if (("java/lang/StringBuffer".equals(calledClass) - || "java/lang/StringBuilder".equals(calledClass)) - && "<init>".equals(getNameConstantOperand()) - && "(Ljava/lang/String;)V".equals(getSigConstantOperand())) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(0); - Boolean sbVal = (Boolean)itm.getUserValue(); - if ((sbVal != null) && sbVal.booleanValue()) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } } else if (seen == GOTO) { int depth = stack.getStackDepth(); for (int i = 0; i < depth; i++) { OpcodeStack.Item itm = stack.getStackItem(i); - itm.setUserValue(Boolean.FALSE); + itm.setUserValue(Boolean.TRUE); } } else if (seen == LDC) { Constant c = getConstantRefOperand(); @@ -161,12 +135,6 @@ } } finally { stack.sawOpcode(this, seen); - if (markAsSBToString) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - itm.setUserValue(Boolean.TRUE); - } - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-17 06:41:38
|
Revision: 860 http://svn.sourceforge.net/fb-contrib/?rev=860&view=rev Author: dbrosius Date: 2007-02-16 22:41:09 -0800 (Fri, 16 Feb 2007) Log Message: ----------- fix false positive sb.append(ISB_Sample.getBigger(a + b, c)); Modified Paths: -------------- trunk/fb-contrib/samples/ISB_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/samples/ISB_Sample.java =================================================================== --- trunk/fb-contrib/samples/ISB_Sample.java 2007-02-14 07:01:14 UTC (rev 859) +++ trunk/fb-contrib/samples/ISB_Sample.java 2007-02-17 06:41:09 UTC (rev 860) @@ -69,4 +69,20 @@ sb.append(a + ":" + b); return sb.toString(); } + + public String testFPISB9(String a, String b, String c) + { + StringBuilder sb = new StringBuilder(); + + sb.append(ISB_Sample.getBigger(a + b, c)); + + return sb.toString(); + } + + private static String getBigger(String a, String b) + { + if (a.length() > b.length()) + return a; + return b; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-14 07:01:14 UTC (rev 859) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2007-02-17 06:41:09 UTC (rev 860) @@ -75,25 +75,11 @@ @Override public void sawOpcode(final int seen) { + boolean markAsSBToString = false; try { stack.mergeJumps(this); - if (seen == INVOKESPECIAL) { - String calledClass = getClassConstantOperand(); - if (("java/lang/StringBuffer".equals(calledClass) - || "java/lang/StringBuilder".equals(calledClass)) - && "<init>".equals(getNameConstantOperand()) - && "()V".equals(getSigConstantOperand())) { - OpcodeStack.Item itm = getStringBufferItemAt(2); - if ((itm != null) && (itm.getUserValue() == null)) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } else if (seen == INVOKEVIRTUAL) { + if (seen == INVOKEVIRTUAL) { if (sawLDCEmpty) { String calledClass = getClassConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) @@ -118,12 +104,52 @@ } } } + } else { + String calledClass = getClassConstantOperand(); + if (("java/lang/StringBuffer".equals(calledClass) + || "java/lang/StringBuilder".equals(calledClass))) { + if (("toString".equals(getNameConstantOperand()) + && "()Ljava/lang/String;".equals(getSigConstantOperand()))) { + markAsSBToString = true; + } else if (("append".equals(getNameConstantOperand()) + && (("(Ljava/lang/String;)L" + calledClass + ";").equals(getSigConstantOperand())))) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item itm = stack.getStackItem(0); + Boolean sbVal = (Boolean)itm.getUserValue(); + if ((sbVal != null) && sbVal.booleanValue()) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + } } + } else if (seen == INVOKESPECIAL) { + String calledClass = getClassConstantOperand(); + if (("java/lang/StringBuffer".equals(calledClass) + || "java/lang/StringBuilder".equals(calledClass)) + && "<init>".equals(getNameConstantOperand()) + && "(Ljava/lang/String;)V".equals(getSigConstantOperand())) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item itm = stack.getStackItem(0); + Boolean sbVal = (Boolean)itm.getUserValue(); + if ((sbVal != null) && sbVal.booleanValue()) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } } else if (seen == GOTO) { int depth = stack.getStackDepth(); for (int i = 0; i < depth; i++) { OpcodeStack.Item itm = stack.getStackItem(i); - itm.setUserValue(Boolean.TRUE); + itm.setUserValue(Boolean.FALSE); } } else if (seen == LDC) { Constant c = getConstantRefOperand(); @@ -135,6 +161,12 @@ } } finally { stack.sawOpcode(this, seen); + if (markAsSBToString) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + itm.setUserValue(Boolean.TRUE); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-14 07:01:15
|
Revision: 859 http://svn.sourceforge.net/fb-contrib/?rev=859&view=rev Author: dbrosius Date: 2007-02-13 23:01:14 -0800 (Tue, 13 Feb 2007) Log Message: ----------- make sure temp 'plugin' directory is deleted Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-02-14 06:58:27 UTC (rev 858) +++ trunk/fb-contrib/build.xml 2007-02-14 07:01:14 UTC (rev 859) @@ -33,6 +33,7 @@ <include name="**/*.class"/> </fileset> </delete> + <delete dir="${basedir}/plugin"/> </target> <target name="-init" description="prepares repository for a build"> @@ -161,7 +162,7 @@ failOnError="true"> <class location="${basedir}/fb-contrib.jar"/> </findbugs> - <!--<delete dir="${basedir}/plugin"/>--> + <delete dir="${basedir}/plugin"/> </target> <target name="build" depends="clean, -init, validate_xml, compile, compile_samples, jar" description="builds the plugin jar"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-14 06:58:27
|
Revision: 858 http://svn.sourceforge.net/fb-contrib/?rev=858&view=rev Author: dbrosius Date: 2007-02-13 22:58:27 -0800 (Tue, 13 Feb 2007) Log Message: ----------- create a release target Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-02-14 06:52:09 UTC (rev 857) +++ trunk/fb-contrib/build.xml 2007-02-14 06:58:27 UTC (rev 858) @@ -121,15 +121,6 @@ in="${etc.dir}/messages.xml" out="${htdocs.dir}/bugdescriptions.html"/> </target> - <target name="install" depends="clean, build" description="installs the plugin into FindBugs"> - <property environment="env"/> - <copy todir="${env.FINDBUGS_HOME}/plugin"> - <fileset dir="${basedir}"> - <include name="fb-contrib.jar"/> - </fileset> - </copy> - </target> - <target name="srczip" description="builds the source distribution zip file"> <zip destfile="${basedir}/fb-contrib-src.zip" basedir="${basedir}"> <fileset dir="${src.dir}"> @@ -164,7 +155,7 @@ home="${basedir}" auxClasspath="${sampleslib.dir}/jsp-api.jar;${lib.dir}/findbugs.jar;${lib.dir}/bcel.jar" visitors="SuspiciousJDKVersionUse" - reportLevel="medium" + reportLevel="high" outputFile="${basedir}/plugin/findbugs.xml" jvmargs="-Xmx800m -Dfb-contrib.sjvu.jdkhome=${jdk14.home}" failOnError="true"> @@ -173,8 +164,18 @@ <!--<delete dir="${basedir}/plugin"/>--> </target> - <target name="build" depends="-init, validate_xml, compile, compile_samples, jar, check14, javadoc" description="builds the plugin jar"> + <target name="build" depends="clean, -init, validate_xml, compile, compile_samples, jar" description="builds the plugin jar"> </target> + <target name="install" depends="build" description="installs the plugin into FindBugs"> + <property environment="env"/> + <copy todir="${env.FINDBUGS_HOME}/plugin"> + <fileset dir="${basedir}"> + <include name="fb-contrib.jar"/> + </fileset> + </copy> + </target> + + <target name="release" depends="build, check14, javadoc" description="prepares everything for a release"/> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-14 06:52:09
|
Revision: 857 http://svn.sourceforge.net/fb-contrib/?rev=857&view=rev Author: dbrosius Date: 2007-02-13 22:52:09 -0800 (Tue, 13 Feb 2007) Log Message: ----------- add build step to check for 1.5 methods Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/lib/findbugs.jar Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-02-14 06:51:31 UTC (rev 856) +++ trunk/fb-contrib/build.xml 2007-02-14 06:52:09 UTC (rev 857) @@ -121,9 +121,6 @@ in="${etc.dir}/messages.xml" out="${htdocs.dir}/bugdescriptions.html"/> </target> - <target name="build" depends="-init, validate_xml, compile, compile_samples, jar" description="builds the plugin jar"> - </target> - <target name="install" depends="clean, build" description="installs the plugin into FindBugs"> <property environment="env"/> <copy todir="${env.FINDBUGS_HOME}/plugin"> @@ -156,4 +153,28 @@ <bottom><![CDATA[<i>Copyright © 2005-2007 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> </javadoc> </target> + + <target name="check14" depends="jar" description="Check for 1.5 only methods"> + <mkdir dir="${basedir}/plugin"/> + <copy file="${basedir}/fb-contrib.jar" todir="${basedir}/plugin"/> + + <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${lib.dir}/findbugs-ant.jar;${lib.dir}/findbugs.jar;${lib.dir}/bcel.jar;${lib.dir}/dom4j-full.jar;${lib.dir}/asm-3.0.jar"/> + + <findbugs output="xml" + home="${basedir}" + auxClasspath="${sampleslib.dir}/jsp-api.jar;${lib.dir}/findbugs.jar;${lib.dir}/bcel.jar" + visitors="SuspiciousJDKVersionUse" + reportLevel="medium" + outputFile="${basedir}/plugin/findbugs.xml" + jvmargs="-Xmx800m -Dfb-contrib.sjvu.jdkhome=${jdk14.home}" + failOnError="true"> + <class location="${basedir}/fb-contrib.jar"/> + </findbugs> + <!--<delete dir="${basedir}/plugin"/>--> + </target> + + <target name="build" depends="-init, validate_xml, compile, compile_samples, jar, check14, javadoc" description="builds the plugin jar"> + </target> + + </project> \ No newline at end of file Modified: trunk/fb-contrib/lib/findbugs.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-14 06:51:31
|
Revision: 856 http://svn.sourceforge.net/fb-contrib/?rev=856&view=rev Author: dbrosius Date: 2007-02-13 22:51:31 -0800 (Tue, 13 Feb 2007) Log Message: ----------- add jdk.home property Added Paths: ----------- trunk/fb-contrib/build.properties Added: trunk/fb-contrib/build.properties =================================================================== --- trunk/fb-contrib/build.properties (rev 0) +++ trunk/fb-contrib/build.properties 2007-02-14 06:51:31 UTC (rev 856) @@ -0,0 +1 @@ +jdk14.home=C:/j2sdk1.4.2_13 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-14 06:50:35
|
Revision: 855 http://svn.sourceforge.net/fb-contrib/?rev=855&view=rev Author: dbrosius Date: 2007-02-13 22:50:35 -0800 (Tue, 13 Feb 2007) Log Message: ----------- add jars for ant task Added Paths: ----------- trunk/fb-contrib/lib/asm-3.0.jar trunk/fb-contrib/lib/dom4j-full.jar trunk/fb-contrib/lib/findbugs-ant.jar Added: trunk/fb-contrib/lib/asm-3.0.jar =================================================================== (Binary files differ) Property changes on: trunk/fb-contrib/lib/asm-3.0.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/fb-contrib/lib/dom4j-full.jar =================================================================== (Binary files differ) Property changes on: trunk/fb-contrib/lib/dom4j-full.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/fb-contrib/lib/findbugs-ant.jar =================================================================== (Binary files differ) Property changes on: trunk/fb-contrib/lib/findbugs-ant.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-13 23:58:58
|
Revision: 854 http://svn.sourceforge.net/fb-contrib/?rev=854&view=rev Author: dbrosius Date: 2007-02-13 15:58:59 -0800 (Tue, 13 Feb 2007) Log Message: ----------- rid the world of 1.5 methods Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-13 23:35:42 UTC (rev 853) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-13 23:58:59 UTC (rev 854) @@ -72,7 +72,7 @@ modifyingMethods.put("add(Ljava/lang/Object;)Z", Integer14.valueOf(1)); modifyingMethods.put("addAll(Ljava/util/Collection;)Z", Integer14.valueOf(1)); modifyingMethods.put("addAll(ILjava/util/Collection;)Z", Integer14.valueOf(2)); - modifyingMethods.put("clear()V", Integer.valueOf(0)); + modifyingMethods.put("clear()V", Integer14.valueOf(0)); modifyingMethods.put("remove(I)Ljava/lang/Object;", Integer14.valueOf(1)); modifyingMethods.put("removeAll(Ljava/util/Collection;)Z", Integer14.valueOf(1)); modifyingMethods.put("retainAll(Ljava/util/Collection;)Z", Integer14.valueOf(1)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-13 23:35:44
|
Revision: 853 http://svn.sourceforge.net/fb-contrib/?rev=853&view=rev Author: dbrosius Date: 2007-02-13 15:35:42 -0800 (Tue, 13 Feb 2007) Log Message: ----------- made a copy Added Paths: ----------- tags/v3_2_4/ Copied: tags/v3_2_4 (from rev 852, trunk/fb-contrib) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-13 23:22:14
|
Revision: 852 http://svn.sourceforge.net/fb-contrib/?rev=852&view=rev Author: dbrosius Date: 2007-02-13 15:22:14 -0800 (Tue, 13 Feb 2007) Log Message: ----------- get ready for 3.2.4 Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-02-13 23:19:12 UTC (rev 851) +++ trunk/fb-contrib/build.xml 2007-02-13 23:22:14 UTC (rev 852) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.2.3"/> + <property name="fb-contrib.version" value="3.2.4"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-13 23:19:13
|
Revision: 851 http://svn.sourceforge.net/fb-contrib/?rev=851&view=rev Author: dbrosius Date: 2007-02-13 15:19:12 -0800 (Tue, 13 Feb 2007) Log Message: ----------- Fix [ 1655778 ] SPOILED_CHILD_INTERFACE_IMPLEMENTOR: wrong analysis If a superclass implements a super interface of the interface that the child implements, and the super interface has the same methods as the child, then don't report -- even if hinky. Modified Paths: -------------- trunk/fb-contrib/samples/SCII_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java Modified: trunk/fb-contrib/samples/SCII_Sample.java =================================================================== --- trunk/fb-contrib/samples/SCII_Sample.java 2007-02-13 04:34:14 UTC (rev 850) +++ trunk/fb-contrib/samples/SCII_Sample.java 2007-02-13 23:19:12 UTC (rev 851) @@ -34,6 +34,10 @@ interface A { public void a(); + + public void b(); + + public void c(); } interface B extends A @@ -41,15 +45,27 @@ public void b(); } + interface C extends B + { + public void c(); + } + class AA implements A { public void a() {} public void b() {} + + public void c() {} } class BB extends AA implements B { } + + class CC extends BB implements C + { + + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2007-02-13 04:34:14 UTC (rev 850) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2007-02-13 23:19:12 UTC (rev 851) @@ -71,18 +71,21 @@ infMethods.removeAll(clsMethods); if (infMethods.size() > 0) { JavaClass superCls = cls.getSuperClass(); - if (!superCls.implementationOf(inf)) { - int priority = AnalysisContext.currentAnalysisContext().getSubtypes().isApplicationClass(superCls) ? NORMAL_PRIORITY : LOW_PRIORITY; - BugInstance bi = new BugInstance(this, "SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR", priority) - .addClass(cls) - .addString("Implementing interface: " + inf.getClassName()) - .addString("Methods:"); - for (String nameSig : infMethods) - bi.addString("\t" + nameSig); - - bugReporter.reportBug(bi); - return; - } + filterSuperInterfaceMethods(inf, infMethods, superCls); + if (infMethods.size() > 0) { + if (!superCls.implementationOf(inf)) { + int priority = AnalysisContext.currentAnalysisContext().getSubtypes().isApplicationClass(superCls) ? NORMAL_PRIORITY : LOW_PRIORITY; + BugInstance bi = new BugInstance(this, "SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR", priority) + .addClass(cls) + .addString("Implementing interface: " + inf.getClassName()) + .addString("Methods:"); + for (String nameSig : infMethods) + bi.addString("\t" + nameSig); + + bugReporter.reportBug(bi); + return; + } + } } } } @@ -105,7 +108,7 @@ * @param cls the class to build the method set from * @return a set of method names/signatures */ - public Set<String> buildMethodSet(JavaClass cls) { + private Set<String> buildMethodSet(JavaClass cls) { Set<String> methods = new HashSet<String>(); for (Method m : cls.getMethods()) { @@ -117,6 +120,35 @@ return methods; } + + /** + * removes methods found in an interface when a superinterface having the same methods + * is implemented in a parent. While this is somewhat hinky, we'll allow it. + * + * @param inf the interface to look for super interfaces for + * @param infMethods the remaining methods that are needed to be found + * @param cls the super class to look for these methods in + */ + private void filterSuperInterfaceMethods(JavaClass inf, Set<String> infMethods, JavaClass cls) { + try { + if (infMethods.size() == 0) + return; + + JavaClass[] superInfs = inf.getInterfaces(); + for (JavaClass superInf : superInfs) { + if (cls.implementationOf(superInf)) { + Set<String> superInfMethods = buildMethodSet(superInf); + infMethods.removeAll(superInfMethods); + if (infMethods.size() == 0) + return; + } + filterSuperInterfaceMethods(superInf, infMethods, cls); + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + infMethods.clear(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-13 04:34:15
|
Revision: 850 http://svn.sourceforge.net/fb-contrib/?rev=850&view=rev Author: dbrosius Date: 2007-02-12 20:34:14 -0800 (Mon, 12 Feb 2007) Log Message: ----------- if an iterator is reused for a new collection, make sure to remove it from the collection group to iterator map Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-09 23:31:55 UTC (rev 849) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-13 04:34:14 UTC (rev 850) @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -229,7 +230,13 @@ try { JavaClass cls = itm.getJavaClass(); if ((cls != null) && cls.implementationOf(iteratorClass)) { - groupToIterator.put(id, Integer14.valueOf(reg)); + Integer regIt = Integer14.valueOf(reg); + Iterator<Integer> curIt = groupToIterator.values().iterator(); + while (curIt.hasNext()) { + if (curIt.next().equals(regIt)) + curIt.remove(); + } + groupToIterator.put(id, regIt); } Set<Comparable> group = collectionGroups.get(id.intValue()); @@ -362,5 +369,10 @@ public boolean hasPC(int pc) { return (loopStart <= pc) && (pc <= loopFinish); } + + @Override + public String toString() { + return "Start=" + loopStart + " Finish=" + loopFinish; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-09 23:31:55
|
Revision: 849 http://svn.sourceforge.net/fb-contrib/?rev=849&view=rev Author: dbrosius Date: 2007-02-09 15:31:55 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Modified Paths: -------------- trunk/fb-contrib/samples/SCII_Sample.java Modified: trunk/fb-contrib/samples/SCII_Sample.java =================================================================== --- trunk/fb-contrib/samples/SCII_Sample.java 2007-02-09 23:30:56 UTC (rev 848) +++ trunk/fb-contrib/samples/SCII_Sample.java 2007-02-09 23:31:55 UTC (rev 849) @@ -30,4 +30,26 @@ // TODO Auto-generated method stub } + + interface A + { + public void a(); + } + + interface B extends A + { + public void b(); + } + + class AA implements A + { + public void a() {} + + public void b() {} + } + + class BB extends AA implements B + { + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-09 23:30:56
|
Revision: 848 http://svn.sourceforge.net/fb-contrib/?rev=848&view=rev Author: dbrosius Date: 2007-02-09 15:30:56 -0800 (Fri, 09 Feb 2007) Log Message: ----------- 3.2.3 Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-02-09 23:10:11 UTC (rev 847) +++ trunk/fb-contrib/build.xml 2007-02-09 23:30:56 UTC (rev 848) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.3.0"/> + <property name="fb-contrib.version" value="3.2.3"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-09 23:10:12
|
Revision: 847 http://svn.sourceforge.net/fb-contrib/?rev=847&view=rev Author: dbrosius Date: 2007-02-09 15:10:11 -0800 (Fri, 09 Feb 2007) Log Message: ----------- made a copy Added Paths: ----------- tags/v3_2_3/ Copied: tags/v3_2_3 (from rev 846, trunk/fb-contrib) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-09 22:57:05
|
Revision: 846 http://svn.sourceforge.net/fb-contrib/?rev=846&view=rev Author: dbrosius Date: 2007-02-09 14:57:00 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Fix for [ 1655774 ] NAB_NEEDLESS_AUTOBOXING_PARSE for boolean? Boolean.parseBoolean(String s) wasn't introduced until 1.5, so don't report before then. Modified Paths: -------------- trunk/fb-contrib/samples/NAB_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java Modified: trunk/fb-contrib/samples/NAB_Sample.java =================================================================== --- trunk/fb-contrib/samples/NAB_Sample.java 2007-02-08 03:40:25 UTC (rev 845) +++ trunk/fb-contrib/samples/NAB_Sample.java 2007-02-09 22:57:00 UTC (rev 846) @@ -43,6 +43,7 @@ public void testNeedsParse(String data) { + //The first one is a false positive for < 1.5 boolean bo = Boolean.valueOf(data).booleanValue(); byte b = Byte.valueOf(data).byteValue(); short s = Short.valueOf(data).shortValue(); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-08 03:40:25 UTC (rev 845) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-09 22:57:00 UTC (rev 846) @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.Map; +import org.apache.bcel.Constants; import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; @@ -96,7 +97,8 @@ boxClass = getClassConstantOperand(); if (boxClasses.containsKey(boxClass)) { if ("valueOf".equals(getNameConstantOperand()) && getSigConstantOperand().startsWith("(Ljava/lang/String;)")) { - state = SEEN_VALUEOF; + if (!"java/lang/Boolean".equals(boxClass) || (getClassContext().getJavaClass().getMajor() >= Constants.MAJOR_1_5)) + state = SEEN_VALUEOF; } else { String parseSig = parseClasses.get(boxClass); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-08 03:40:25
|
Revision: 845 http://svn.sourceforge.net/fb-contrib/?rev=845&view=rev Author: dbrosius Date: 2007-02-07 19:40:25 -0800 (Wed, 07 Feb 2007) Log Message: ----------- move to 3.3.0 dev Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2007-02-07 22:46:16 UTC (rev 844) +++ trunk/fb-contrib/build.xml 2007-02-08 03:40:25 UTC (rev 845) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.2.2"/> + <property name="fb-contrib.version" value="3.3.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-07 22:48:06
|
Revision: 844 http://svn.sourceforge.net/fb-contrib/?rev=844&view=rev Author: dbrosius Date: 2007-02-07 14:46:16 -0800 (Wed, 07 Feb 2007) Log Message: ----------- if throwing InvocationTargetException.getTargetException don't report as LEST Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2007-02-07 04:52:12 UTC (rev 843) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2007-02-07 22:46:16 UTC (rev 844) @@ -199,18 +199,22 @@ break; } } - } else if ((seen == INVOKEVIRTUAL) && "initCause".equals(getNameConstantOperand())) { - String className = getClassConstantOperand(); - JavaClass exClass = Repository.lookupClass(className); - if (exClass.instanceOf(throwableClass)) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(1); - int reg = itm.getRegisterNumber(); - if (reg >= 0) - exReg.put(Integer14.valueOf(reg), Boolean.TRUE); - markAsValid = true; // Fixes javac generated code - } - } + } else if (seen == INVOKEVIRTUAL) { + if ("initCause".equals(getNameConstantOperand())) { + String className = getClassConstantOperand(); + JavaClass exClass = Repository.lookupClass(className); + if (exClass.instanceOf(throwableClass)) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item itm = stack.getStackItem(1); + int reg = itm.getRegisterNumber(); + if (reg >= 0) + exReg.put(Integer14.valueOf(reg), Boolean.TRUE); + markAsValid = true; // Fixes javac generated code + } + } + } else if ("getTargetException".equals(getNameConstantOperand()) && "java/lang/reflect/InvocationTargetException".equals(getClassConstantOperand())) { + markAsValid = true; + } } else if (seen == ATHROW) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-07 04:52:12
|
Revision: 843 http://svn.sourceforge.net/fb-contrib/?rev=843&view=rev Author: dbrosius Date: 2007-02-06 20:52:12 -0800 (Tue, 06 Feb 2007) Log Message: ----------- remove some false positives Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-07 01:55:25 UTC (rev 842) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2007-02-07 04:52:12 UTC (rev 843) @@ -35,9 +35,11 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.ba.XField; +import edu.umd.cs.findbugs.classfile.FieldDescriptor; /** * looks for deletion of items from a collection using the remove method @@ -64,16 +66,16 @@ collectionMethods.add("keySet()Ljava/lang/Set;"); collectionMethods.add("values()Ljava/lang/Collection;"); } - private static final Set<String> modifyingMethods = new HashSet<String>(); + private static final Map<String, Integer> modifyingMethods = new HashMap<String, Integer>(); static { - modifyingMethods.add("add(Ljava/lang/Object;)Z"); - modifyingMethods.add("addAll(Ljava/util/Collection;)Z"); - modifyingMethods.add("addAll(ILjava/util/Collection;)Z"); - modifyingMethods.add("clear()V"); - modifyingMethods.add("remove(I)Ljava/lang/Object;"); - modifyingMethods.add("removeAll(Ljava/util/Collection;)Z"); - modifyingMethods.add("retainAll(Ljava/util/Collection;)Z"); - modifyingMethods.add("set(ILjava/lang/Object;)Ljava/lang/Object;"); + modifyingMethods.put("add(Ljava/lang/Object;)Z", Integer14.valueOf(1)); + modifyingMethods.put("addAll(Ljava/util/Collection;)Z", Integer14.valueOf(1)); + modifyingMethods.put("addAll(ILjava/util/Collection;)Z", Integer14.valueOf(2)); + modifyingMethods.put("clear()V", Integer.valueOf(0)); + modifyingMethods.put("remove(I)Ljava/lang/Object;", Integer14.valueOf(1)); + modifyingMethods.put("removeAll(Ljava/util/Collection;)Z", Integer14.valueOf(1)); + modifyingMethods.put("retainAll(Ljava/util/Collection;)Z", Integer14.valueOf(1)); + modifyingMethods.put("set(ILjava/lang/Object;)Ljava/lang/Object;", Integer14.valueOf(2)); } @@ -176,20 +178,23 @@ } } } - } else if (modifyingMethods.contains(methodInfo)) { - if (stack.getStackDepth() > 1) { - OpcodeStack.Item itm = stack.getStackItem(1); - int id = findCollectionGroup(itm, true); - if (id >= 0) { - Integer it = groupToIterator.get(Integer14.valueOf(id)); - Loop loop = loops.get(it); - if (loop != null) { - int pc = getPC(); - if (loop.hasPC(pc)) { - bugReporter.reportBug(new BugInstance(this, "DWI_MODIFYING_WHILE_ITERATING", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + } else { + Integer numArgs = modifyingMethods.get(methodInfo); + if (numArgs != null) { + if (stack.getStackDepth() > numArgs.intValue()) { + OpcodeStack.Item itm = stack.getStackItem(numArgs.intValue()); + int id = findCollectionGroup(itm, true); + if (id >= 0) { + Integer it = groupToIterator.get(Integer14.valueOf(id)); + Loop loop = loops.get(it); + if (loop != null) { + int pc = getPC(); + if (loop.hasPC(pc)) { + bugReporter.reportBug(new BugInstance(this, "DWI_MODIFYING_WHILE_ITERATING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } } } @@ -203,7 +208,18 @@ groupId = id.intValue(); } } - } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { + } else if (seen == PUTFIELD) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item itm = stack.getStackItem(0); + + Integer id = (Integer)itm.getUserValue(); + if (id == null) { + FieldAnnotation fa = FieldAnnotation.fromFieldDescriptor(new FieldDescriptor(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand(), false)); + itm = new OpcodeStack.Item(itm.getSignature(), fa, stack.getStackItem(1).getRegisterNumber()); + removeFromCollectionGroup(itm); + } + } + } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); Integer id = (Integer)itm.getUserValue(); @@ -253,7 +269,6 @@ OpcodeStack.Item itm = stack.getStackItem(0); itm.setUserValue(Integer14.valueOf(groupId)); } - } } @@ -267,13 +282,9 @@ } } - private int findCollectionGroup(OpcodeStack.Item itm, boolean addIfNotFound) { + private Comparable getGroupElement(OpcodeStack.Item itm) { Comparable groupElement = null; - - Integer id = (Integer)itm.getUserValue(); - if (id != null) - return id.intValue(); - + int reg = itm.getRegisterNumber(); if (reg >= 0) groupElement = Integer14.valueOf(reg); @@ -282,10 +293,20 @@ if (field != null) { int regLoad = itm.getFieldLoadedFromRegister(); if (regLoad >= 0) - groupElement = field.getName() + "[" + regLoad + "]"; + groupElement = field.getName() + ":{" + regLoad + "}"; } } - + + return groupElement; + } + + private int findCollectionGroup(OpcodeStack.Item itm, boolean addIfNotFound) { + + Integer id = (Integer)itm.getUserValue(); + if (id != null) + return id.intValue(); + + Comparable groupElement = getGroupElement(itm); if (groupElement != null) { int numGroups = collectionGroups.size(); for (int i = 0; i < numGroups; i++) { @@ -306,6 +327,20 @@ return -1; } + private void removeFromCollectionGroup(OpcodeStack.Item itm) { + Comparable groupElement = getGroupElement(itm); + if (groupElement != null) { + int numGroups = collectionGroups.size(); + for (int i = 0; i < numGroups; i++) { + Set<? extends Comparable> group = collectionGroups.get(i); + if (group.contains(groupElement)) { + group.remove(groupElement); + break; + } + } + } + } + static class Loop { public int loopStart; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2007-02-07 01:55:25
|
Revision: 842 http://svn.sourceforge.net/fb-contrib/?rev=842&view=rev Author: dbrosius Date: 2007-02-06 17:55:25 -0800 (Tue, 06 Feb 2007) Log Message: ----------- add a fp to fix Modified Paths: -------------- trunk/fb-contrib/samples/DWI_Sample.java Modified: trunk/fb-contrib/samples/DWI_Sample.java =================================================================== --- trunk/fb-contrib/samples/DWI_Sample.java 2007-02-06 05:16:30 UTC (rev 841) +++ trunk/fb-contrib/samples/DWI_Sample.java 2007-02-07 01:55:25 UTC (rev 842) @@ -1,9 +1,12 @@ import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class DWI_Sample { + Set<String> avail; + public void deleteOdds(Set<Integer> bagOInts) { Iterator<Integer> it = bagOInts.iterator(); @@ -22,4 +25,15 @@ s.addAll(c); } } + + public void fpUnaliased() + { + Iterator<String> it = avail.iterator(); + avail = new HashSet<String>(); + + while (it.hasNext()) + { + avail.add(it.next() + "booya"); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |