fb-contrib-commit Mailing List for fb-contrib (Page 32)
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...> - 2008-08-08 15:49:41
|
Revision: 1066 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1066&view=rev Author: dbrosius Date: 2008-08-08 15:49:48 +0000 (Fri, 08 Aug 2008) Log Message: ----------- add log4j.jar to samples lib Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2008-08-08 15:48:57 UTC (rev 1065) +++ trunk/fb-contrib/build.xml 2008-08-08 15:49:48 UTC (rev 1066) @@ -47,6 +47,7 @@ <pathelement location="${sampleslib.dir}/jsp-api.jar"/> <pathelement location="${sampleslib.dir}/junit.jar"/> <pathelement location="${sampleslib.dir}/servlet-api.jar"/> + <pathelement location="${sampleslib.dir}/log4j.jar"/> </path> <mkdir dir="${classes.dir}/com"/> <mkdir dir="${classes.dir}/com/mebigfatguy"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-08-08 15:48:53
|
Revision: 1065 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1065&view=rev Author: dbrosius Date: 2008-08-08 15:48:57 +0000 (Fri, 08 Aug 2008) Log Message: ----------- test for LoggerOddities Added Paths: ----------- trunk/fb-contrib/samples/LO_Sample.java Added: trunk/fb-contrib/samples/LO_Sample.java =================================================================== --- trunk/fb-contrib/samples/LO_Sample.java (rev 0) +++ trunk/fb-contrib/samples/LO_Sample.java 2008-08-08 15:48:57 UTC (rev 1065) @@ -0,0 +1,8 @@ +import org.apache.log4j.Logger; + + +public class LO_Sample +{ + private static Logger l1 = Logger.getLogger(String.class); + private static Logger l2 = Logger.getLogger("com.foo.LO_Sample"); +} Property changes on: trunk/fb-contrib/samples/LO_Sample.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-08-08 05:31:27
|
Revision: 1064 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1064&view=rev Author: dbrosius Date: 2008-08-08 05:31:36 +0000 (Fri, 08 Aug 2008) Log Message: ----------- hook up LO Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2008-08-08 05:18:21 UTC (rev 1063) +++ trunk/fb-contrib/etc/findbugs.xml 2008-08-08 05:31:36 UTC (rev 1064) @@ -320,6 +320,10 @@ speed="fast" reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" + speed="fast" + reports="LO_SUSPECT_LOG_CLASS" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -421,11 +425,12 @@ <BugPattern abbrev="EXS" type="EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS" category="STYLE" /> <BugPattern abbrev="EXS" type="EXS_EXCEPTION_SOFTENING_HAS_CHECKED" category="STYLE" /> <BugPattern abbrev="EXS" type="EXS_EXCEPTION_SOFTENING_NO_CHECKED" category="STYLE" /> - <BugPattern abbrev="CFS" type="CFS_CONFUSING_FUNCTION_SEMANTICS" category="STYLE" experimental="true" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT" category="STYLE" experimental="true" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE" category="STYLE" experimental="true" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT" category="STYLE" experimental="true" /> - <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" experimental="true" /> + <BugPattern abbrev="CFS" type="CFS_CONFUSING_FUNCTION_SEMANTICS" category="STYLE" /> + <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT" category="STYLE" /> + <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE" category="STYLE" /> + <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT" category="STYLE" /> + <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" /> + <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" /> <BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_CLASS" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2008-08-08 05:18:21 UTC (rev 1063) +++ trunk/fb-contrib/etc/messages.xml 2008-08-08 05:31:36 UTC (rev 1064) @@ -880,6 +880,16 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities"> + <Details> + <![CDATA[ + <p>looks for code that allocates a Logger object by passing a specification of a class that + is not related to the class in which the logger is used.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -2277,6 +2287,17 @@ </Details> </BugPattern> + <BugPattern type="LO_SUSPECT_LOG_CLASS"> + <ShortDescription>method specifies an unrelated class when allocating a Logger</ShortDescription> + <LongDescription>method {1} specifies an unrelated class when allocating a Logger</LongDescription> + <Details> + <![CDATA[ + <p>This method creates a Logger by passing in a specification for a class that is unrelated + to the class in which the logger is going to be used. This is likely caused by copy/paste code. + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2351,4 +2372,5 @@ <BugCode abbrev="SCA">Suspicious Clone Algorithm</BugCode> <BugCode abbrev="WEM">Weak Exception Messaging</BugCode> <BugCode abbrev="SCSS">Suspicious Clustered Session Support</BugCode> + <BugCode abbrev="LO">Logger Oddities</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...> - 2008-08-08 05:18:12
|
Revision: 1063 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1063&view=rev Author: dbrosius Date: 2008-08-08 05:18:21 +0000 (Fri, 08 Aug 2008) Log Message: ----------- initial check in for LO detector Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2008-08-08 05:18:21 UTC (rev 1063) @@ -0,0 +1,152 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.classfile.ConstantClass; +import org.apache.bcel.classfile.ConstantPool; +import org.apache.bcel.classfile.ConstantUtf8; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.ba.ClassContext; + +public class LoggerOddities extends BytecodeScanningDetector { + private BugReporter bugReporter; + private OpcodeStack stack; + private String clsName; + + /** + * constructs a LO detector given the reporter to report bugs on. + + * @param bugReporter the sync of bug reports + */ + public LoggerOddities(final BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + + /** + * implements the visitor to discover what the class name is if it is a normal class, + * or the owning class, if the class is an anonymous class. + * + * @param classContext the context object of the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + clsName = classContext.getJavaClass().getClassName(); + int subclassIndex = clsName.indexOf('$'); + while (subclassIndex >= 0) { + String simpleName = clsName.substring(subclassIndex+1); + try { + Integer.parseInt(simpleName); + clsName = clsName.substring(0, subclassIndex); + subclassIndex = clsName.indexOf('$'); + } catch (NumberFormatException nfe) { + subclassIndex = -1; + } + } + clsName = clsName.replace('.', '/'); + super.visitClassContext(classContext); + } finally { + stack = null; + } + } + + /** + * implements the visitor to reset the stack + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } + + /** + * implements the visitor to look for calls to Logger.getLogger with the wrong class name + * + * @param seen the opcode of the currently parsed instruction + */ + @Override + public void sawOpcode(int seen) { + String ldcClassName = null; + try { + if (seen == LDC) { + Constant c = getConstantRefOperand(); + if (c instanceof ConstantClass) { + ConstantPool pool = getConstantPool(); + ldcClassName = ((ConstantUtf8)pool.getConstant(((ConstantClass) c).getNameIndex())).getBytes(); + } + } + else if (seen == INVOKESTATIC) { + String clsName = getClassConstantOperand(); + String mthName = getNameConstantOperand(); + if ("org/apache/log4j/Logger".equals(clsName) + && "getLogger".equals(mthName)) { + String signature = getSigConstantOperand(); + String loggingClassName = null; + + if ("(Ljava/lang/Class;)Lorg/apache/log4j/Logger;".equals(signature)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + loggingClassName = (String)item.getUserValue(); + } + } else if ("(Ljava/lang/String;)Lorg/apache/log4j/Logger;".equals(signature)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + loggingClassName = (String)item.getConstant(); + } + } else if ("(Ljava/lang/String;Lorg/apache/log4j/spi/LoggerFactory;)Lorg/apache/log4j/Logger;".equals(signature)) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item item = stack.getStackItem(1); + loggingClassName = (String)item.getConstant(); + } + } + + if (loggingClassName != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if ((loggingClassName != null) && !loggingClassName.equals(clsName)) { + bugReporter.reportBug(new BugInstance(this, "LO_SUSPECT_LOG_CLASS", clsName.contains("$") ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + } + } + } finally { + stack.sawOpcode(this, seen); + if (ldcClassName != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(ldcClassName); + } + } + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-29 02:33:35
|
Revision: 1062 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1062&view=rev Author: dbrosius Date: 2008-07-29 02:33:45 +0000 (Tue, 29 Jul 2008) Log Message: ----------- Fix DDC documentation, thanks to Johan Parent Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2008-07-11 04:00:57 UTC (rev 1061) +++ trunk/fb-contrib/etc/messages.xml 2008-07-29 02:33:45 UTC (rev 1062) @@ -1453,7 +1453,7 @@ </pre> could become <pre> - if (!date2.after( date1 )) + if (!date1.after( date2 )) </pre> and <pre> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-11 04:00:48
|
Revision: 1061 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1061&view=rev Author: dbrosius Date: 2008-07-10 21:00:57 -0700 (Thu, 10 Jul 2008) Log Message: ----------- patch bug in findbugs proper, with mergeJumps throwing away static typing. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-11 03:58:04 UTC (rev 1060) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-11 04:00:57 UTC (rev 1061) @@ -409,7 +409,9 @@ && ("after".equals(methodName) || "before".equals(methodName))) { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(0); - if (!"Ljava/util/Calendar;".equals(item.getSignature()) && !"Ljava/util/GregorianCalendar;".equals(item.getSignature())) { + String itemSig = item.getSignature(); + //Rule out java.lang.Object as mergeJumps can throw away type info (BUG) + if (!"Ljava/lang/Object;".equals(itemSig) && !"Ljava/util/Calendar;".equals(itemSig) && !"Ljava/util/GregorianCalendar;".equals(itemSig)) { bugReporter.reportBug(new BugInstance(this, "SPP_INVALID_CALENDAR_COMPARE", NORMAL_PRIORITY) .addClass(this) .addMethod(this) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-11 03:57:55
|
Revision: 1060 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1060&view=rev Author: dbrosius Date: 2008-07-10 20:58:04 -0700 (Thu, 10 Jul 2008) Log Message: ----------- don't report DWI if the next statement is a break. 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 2008-07-11 03:40:42 UTC (rev 1059) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2008-07-11 03:58:04 UTC (rev 1060) @@ -26,12 +26,14 @@ import java.util.Map; import java.util.Set; +import org.apache.bcel.Constants; import org.apache.bcel.Repository; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.LocalVariableTable; +import com.mebigfatguy.fbcontrib.utils.CodeByteUtils; import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -177,10 +179,25 @@ if (loop != null) { int pc = getPC(); if (loop.hasPC(pc)) { - bugReporter.reportBug(new BugInstance(this, "DWI_DELETING_WHILE_ITERATING", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + boolean breakFollows = false; + byte[] code = getCode().getCode(); + int nextPC = getNextPC(); + int popOp = CodeByteUtils.getbyte(code, nextPC++); + if (popOp == Constants.POP) { + int gotoOp = CodeByteUtils.getbyte(code, nextPC); + if (gotoOp == Constants.GOTO) { + int target = nextPC + CodeByteUtils.getshort(code, nextPC+1); + if (target > loop.getLoopFinish()) + breakFollows = true; + } + } + + if (!breakFollows) { + bugReporter.reportBug(new BugInstance(this, "DWI_DELETING_WHILE_ITERATING", NORMAL_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. |
From: <dbr...@us...> - 2008-07-11 03:40:33
|
Revision: 1059 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1059&view=rev Author: dbrosius Date: 2008-07-10 20:40:42 -0700 (Thu, 10 Jul 2008) Log Message: ----------- use the moved getbyte and getshort methods in CodeByteUtils Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-11 03:38:43 UTC (rev 1058) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-11 03:40:42 UTC (rev 1059) @@ -36,6 +36,7 @@ import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.LocalVariableTable; +import com.mebigfatguy.fbcontrib.utils.CodeByteUtils; import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -126,20 +127,20 @@ if ((seen == IFEQ) || (seen == IFLE) || (seen == IFNE)) { if (lastLoadWasString && (lastPCs[0] != -1)) { byte[] bytes = getCode().getCode(); - int loadIns = getbyte(bytes, lastPCs[2]); + int loadIns = CodeByteUtils.getbyte(bytes, lastPCs[2]); int brOffset = (loadIns == ALOAD) ? 11 : 10; if ((((loadIns >= ALOAD_0) && (loadIns <= ALOAD_3)) || (loadIns == ALOAD)) - && (getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) - && (getbyte(bytes, lastPCs[2]) == loadIns) - && (getbyte(bytes, lastPCs[1]) == IFNULL) - && (getbyte(bytes, lastPCs[0]) == loadIns) - && ((loadIns != ALOAD) || (getbyte(bytes, lastPCs[2]+1) == getbyte(bytes, lastPCs[0]+1))) - && ((seen == IFNE) ? getshort(bytes, lastPCs[1]+1) > brOffset : getshort(bytes, lastPCs[1]+1) == brOffset)) { - int nextOp = getbyte(bytes, getNextPC()); + && (CodeByteUtils.getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) + && (CodeByteUtils.getbyte(bytes, lastPCs[2]) == loadIns) + && (CodeByteUtils.getbyte(bytes, lastPCs[1]) == IFNULL) + && (CodeByteUtils.getbyte(bytes, lastPCs[0]) == loadIns) + && ((loadIns != ALOAD) || (CodeByteUtils.getbyte(bytes, lastPCs[2]+1) == CodeByteUtils.getbyte(bytes, lastPCs[0]+1))) + && ((seen == IFNE) ? CodeByteUtils.getshort(bytes, lastPCs[1]+1) > brOffset : CodeByteUtils.getshort(bytes, lastPCs[1]+1) == brOffset)) { + int nextOp = CodeByteUtils.getbyte(bytes, getNextPC()); if ((nextOp != GOTO) && (nextOp != GOTO_W)) { ConstantPool pool = getConstantPool(); - int mpoolIndex = getshort(bytes, lastPCs[3]+1); + int mpoolIndex = CodeByteUtils.getshort(bytes, lastPCs[3]+1); ConstantMethodref cmr = (ConstantMethodref)pool.getConstant(mpoolIndex); int nandtIndex = cmr.getNameAndTypeIndex(); ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); @@ -157,17 +158,17 @@ if (seen == IFNE) { byte[] bytes = getCode().getCode(); if (lastPCs[2] != -1) { - if ((getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) - && (getbyte(bytes, lastPCs[2]) == INVOKEVIRTUAL)) { + if ((CodeByteUtils.getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) + && (CodeByteUtils.getbyte(bytes, lastPCs[2]) == INVOKEVIRTUAL)) { ConstantPool pool = getConstantPool(); - int toStringIndex = getshort(bytes, lastPCs[2]+1); + int toStringIndex = CodeByteUtils.getshort(bytes, lastPCs[2]+1); ConstantMethodref toStringMR = (ConstantMethodref)pool.getConstant(toStringIndex); String toStringCls = toStringMR.getClass(pool); if (toStringCls.startsWith("java.lang.StringBu")) { int nandtIndex = toStringMR.getNameAndTypeIndex(); ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); if ("toString".equals(cnt.getName(pool))) { - int lengthIndex = getshort(bytes, lastPCs[3]+1); + int lengthIndex = CodeByteUtils.getshort(bytes, lastPCs[3]+1); ConstantMethodref lengthMR = (ConstantMethodref)pool.getConstant(lengthIndex); nandtIndex = lengthMR.getNameAndTypeIndex(); cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); @@ -189,23 +190,23 @@ byte[] bytes = getCode().getCode(); if (lastPCs[1] != -1) { - int loadIns = getbyte(bytes, lastPCs[2]); - if ((getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) + int loadIns = CodeByteUtils.getbyte(bytes, lastPCs[2]); + if ((CodeByteUtils.getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) && ((loadIns == LDC) || (loadIns == LDC_W)) - && (getbyte(bytes, lastPCs[1]) == INVOKEVIRTUAL)) { + && (CodeByteUtils.getbyte(bytes, lastPCs[1]) == INVOKEVIRTUAL)) { ConstantPool pool = getConstantPool(); - int toStringIndex = getshort(bytes, lastPCs[1]+1); + int toStringIndex = CodeByteUtils.getshort(bytes, lastPCs[1]+1); ConstantMethodref toStringMR = (ConstantMethodref)pool.getConstant(toStringIndex); String toStringCls = toStringMR.getClass(pool); if (toStringCls.startsWith("java.lang.StringBu")) { - int consIndex = getbyte(bytes, lastPCs[2]+1); + int consIndex = CodeByteUtils.getbyte(bytes, lastPCs[2]+1); Constant c = pool.getConstant(consIndex); if (c instanceof ConstantString) { if ("".equals(((ConstantString) c).getBytes(pool))) { int nandtIndex = toStringMR.getNameAndTypeIndex(); ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); if ("toString".equals(cnt.getName(pool))) { - int lengthIndex = getshort(bytes, lastPCs[3]+1); + int lengthIndex = CodeByteUtils.getshort(bytes, lastPCs[3]+1); ConstantMethodref lengthMR = (ConstantMethodref)pool.getConstant(lengthIndex); nandtIndex = lengthMR.getNameAndTypeIndex(); cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); @@ -505,14 +506,4 @@ lastPCs[3] = getPC(); } } - - private int getbyte(byte[] bytes, int offset) - { - return (0x00FF & bytes[offset]); - } - - private int getshort(byte[] bytes, int offset) - { - return (short)((0x0000FFFF & (bytes[offset] << 8)) | (0x00FF & bytes[offset+1])); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-11 03:38:34
|
Revision: 1058 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1058&view=rev Author: dbrosius Date: 2008-07-10 20:38:43 -0700 (Thu, 10 Jul 2008) Log Message: ----------- pull out getbyte and getshort from SPP Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java 2008-07-11 03:38:43 UTC (rev 1058) @@ -0,0 +1,46 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.utils; + +public class CodeByteUtils { + + /** + * returns the code byte at a specific offset as an int + * + * @param bytes the code bytes + * @param offset the offset into the code + * @return the byte as an int + */ + public static int getbyte(byte[] bytes, int offset) + { + return (0x00FF & bytes[offset]); + } + + /** + * returns the code short at a specific offset as an int + * + * @param bytes the code bytes + * @param offset the offset into the code + * @return the short as an int + */ + public static int getshort(byte[] bytes, int offset) + { + return (short)((0x0000FFFF & (bytes[offset] << 8)) | (0x00FF & bytes[offset+1])); + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-10 04:19:29
|
Revision: 1057 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1057&view=rev Author: dbrosius Date: 2008-07-09 21:19:39 -0700 (Wed, 09 Jul 2008) Log Message: ----------- fp for DWI and break Modified Paths: -------------- trunk/fb-contrib/samples/DWI_Sample.java Modified: trunk/fb-contrib/samples/DWI_Sample.java =================================================================== --- trunk/fb-contrib/samples/DWI_Sample.java 2008-07-09 06:08:56 UTC (rev 1056) +++ trunk/fb-contrib/samples/DWI_Sample.java 2008-07-10 04:19:39 UTC (rev 1057) @@ -36,4 +36,15 @@ avail.add(it.next() + "booya"); } } + + public void fpWithBreak(Set<String> ss) + { + for (String s : ss) + { + if (s.equals("foo")) { + ss.remove("foo"); + break; + } + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-09 06:08:50
|
Revision: 1056 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1056&view=rev Author: dbrosius Date: 2008-07-08 23:08:56 -0700 (Tue, 08 Jul 2008) Log Message: ----------- look for myset.keySet().contains("foo") Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2008-07-05 05:28:32 UTC (rev 1055) +++ trunk/fb-contrib/etc/findbugs.xml 2008-07-09 06:08:56 UTC (rev 1056) @@ -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,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE" /> + 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,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" @@ -407,6 +407,7 @@ <BugPattern abbrev="SPP" type="SPP_SUSPECT_STRING_TEST" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_USE_STRINGBUILDER_LENGTH" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_INVALID_CALENDAR_COMPARE" category="CORRECTNESS"/> + <BugPattern abbrev="SPP" type="SPP_USE_CONTAINSKEY" category="STYLE"/> <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 2008-07-05 05:28:32 UTC (rev 1055) +++ trunk/fb-contrib/etc/messages.xml 2008-07-09 06:08:56 UTC (rev 1056) @@ -2006,6 +2006,16 @@ </Details> </BugPattern> + <BugPattern type="SPP_USE_CONTAINSKEY"> + <ShortDescription>Method calls keySet() just to call contains, use containsKey instead</ShortDescription> + <LongDescription>Method {1} calls keySet() just to call contains, use containsKey instead</LongDescription> + <Details> + <![CDATA[ + <p>This method calls mySet.keySet().contains("foo") when mySet.containsKey("foo") is simpler</p> + ]]> + </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/LEST_Sample.java =================================================================== --- trunk/fb-contrib/samples/LEST_Sample.java 2008-07-05 05:28:32 UTC (rev 1055) +++ trunk/fb-contrib/samples/LEST_Sample.java 2008-07-09 06:08:56 UTC (rev 1056) @@ -58,4 +58,18 @@ throw iae; } } + + public void testLestFP3(String s) + { + double d; + try + { + d = Double.parseDouble(s); + } + catch (NumberFormatException nfe) + { + + } + throw new RuntimeException("ok"); + } } Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2008-07-05 05:28:32 UTC (rev 1055) +++ trunk/fb-contrib/samples/SPP_Sample.java 2008-07-09 06:08:56 UTC (rev 1056) @@ -4,6 +4,7 @@ import java.util.Date; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; import java.util.Set; import java.util.StringTokenizer; @@ -189,4 +190,10 @@ { return c.after(d) || c.before(d); } + + public void testUseContainsKey(Map m) + { + if (m.keySet().contains("Foo")) + System.out.println("Yup"); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2008-07-05 05:28:32 UTC (rev 1055) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2008-07-09 06:08:56 UTC (rev 1056) @@ -173,6 +173,7 @@ } } else if (pc == ex.getHandlerPC()) { removePreviousHandlers(pc); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-05 05:28:32 UTC (rev 1055) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-07-09 06:08:56 UTC (rev 1056) @@ -469,6 +469,27 @@ } } } + } else if (seen == INVOKEINTERFACE) { + String className = getClassConstantOperand(); + if ("java/util/Map".equals(className)) { + String method = getNameConstantOperand(); + if ("keySet".equals(method)) { + userValue = "keySet"; + } + } else if ("java/util/Set".equals(className)) { + String method = getNameConstantOperand(); + if ("contains".equals(method)) { + if (stack.getStackDepth() >= 2) { + OpcodeStack.Item item = stack.getStackItem(1); + if ("keySet".equals(item.getUserValue())) { + bugReporter.reportBug(new BugInstance(this, "SPP_USE_CONTAINSKEY", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + } } } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-05 05:28:33
|
Revision: 1055 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1055&view=rev Author: dbrosius Date: 2008-07-04 22:28:32 -0700 (Fri, 04 Jul 2008) Log Message: ----------- google analytics new Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2008-07-05 05:23:29 UTC (rev 1054) +++ trunk/fb-contrib/htdocs/index.html 2008-07-05 05:28:32 UTC (rev 1055) @@ -443,14 +443,11 @@ </span> </div> -<script type="text/javascript"> -var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); -document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); +<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> -var pageTracker = _gat._getTracker("UA-xxxxxx-x"); -pageTracker._initData(); -pageTracker._trackPageview(); +_uacct = "UA-249537-3"; +urchinTracker(); </script> </body> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-07-05 05:23:32
|
Revision: 1054 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1054&view=rev Author: dbrosius Date: 2008-07-04 22:23:29 -0700 (Fri, 04 Jul 2008) Log Message: ----------- add google analytics Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2008-06-18 22:51:46 UTC (rev 1053) +++ trunk/fb-contrib/htdocs/index.html 2008-07-05 05:23:29 UTC (rev 1054) @@ -442,5 +442,16 @@ </p> </span> </div> + +<script type="text/javascript"> +var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); +document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); +</script> +<script type="text/javascript"> +var pageTracker = _gat._getTracker("UA-xxxxxx-x"); +pageTracker._initData(); +pageTracker._trackPageview(); +</script> + </body> </html> \ 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...> - 2008-06-18 22:51:38
|
Revision: 1053 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1053&view=rev Author: dbrosius Date: 2008-06-18 15:51:46 -0700 (Wed, 18 Jun 2008) Log Message: ----------- fix before/after with GregorianCalendar Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-14 20:57:44 UTC (rev 1052) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-18 22:51:46 UTC (rev 1053) @@ -408,7 +408,7 @@ && ("after".equals(methodName) || "before".equals(methodName))) { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(0); - if (!"Ljava/util/Calendar;".equals(item.getSignature())) { + if (!"Ljava/util/Calendar;".equals(item.getSignature()) && !"Ljava/util/GregorianCalendar;".equals(item.getSignature())) { bugReporter.reportBug(new BugInstance(this, "SPP_INVALID_CALENDAR_COMPARE", NORMAL_PRIORITY) .addClass(this) .addMethod(this) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-14 20:57:36
|
Revision: 1052 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1052&view=rev Author: dbrosius Date: 2008-06-14 13:57:44 -0700 (Sat, 14 Jun 2008) Log Message: ----------- up to 2008 Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/samples/AFBR_Sample.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2008-06-13 21:47:01 UTC (rev 1051) +++ trunk/fb-contrib/build.xml 2008-06-14 20:57:44 UTC (rev 1052) @@ -150,7 +150,7 @@ destdir="${javadoc.dir}" windowtitle="fb-contrib api"> <doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle> - <bottom><![CDATA[<i>Copyright © 2005-2007 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> + <bottom><![CDATA[<i>Copyright © 2005-2008 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> </javadoc> </target> Modified: trunk/fb-contrib/samples/AFBR_Sample.java =================================================================== --- trunk/fb-contrib/samples/AFBR_Sample.java 2008-06-13 21:47:01 UTC (rev 1051) +++ trunk/fb-contrib/samples/AFBR_Sample.java 2008-06-14 20:57:44 UTC (rev 1052) @@ -2,7 +2,6 @@ import java.io.IOException; import java.io.InputStream; - public class AFBR_Sample { public int test1(boolean b) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-13 21:47:07
|
Revision: 1051 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1051&view=rev Author: dbrosius Date: 2008-06-13 14:47:01 -0700 (Fri, 13 Jun 2008) Log Message: ----------- check GregorianCalendar and Calendar just to be safe Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-13 21:42:48 UTC (rev 1050) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-13 21:47:01 UTC (rev 1051) @@ -404,7 +404,7 @@ } } } - } else if ("java/util/GregorianCalendar".equals(className) + } else if (("java/util/GregorianCalendar".equals(className) || "java/util/Calendar".equals(className)) && ("after".equals(methodName) || "before".equals(methodName))) { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-13 21:42:41
|
Revision: 1050 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1050&view=rev Author: dbrosius Date: 2008-06-13 14:42:48 -0700 (Fri, 13 Jun 2008) Log Message: ----------- look for GregorianCalendar Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-13 19:07:03 UTC (rev 1049) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-13 21:42:48 UTC (rev 1050) @@ -404,7 +404,7 @@ } } } - } else if ("java/util/Calendar".equals(className) + } else if ("java/util/GregorianCalendar".equals(className) && ("after".equals(methodName) || "before".equals(methodName))) { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-13 19:22:32
|
Revision: 1049 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1049&view=rev Author: dbrosius Date: 2008-06-13 12:07:03 -0700 (Fri, 13 Jun 2008) Log Message: ----------- add check for Calendar.after(date) Calendar.before(date) 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 2008-06-09 18:06:22 UTC (rev 1048) +++ trunk/fb-contrib/etc/findbugs.xml 2008-06-13 19:07:03 UTC (rev 1049) @@ -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,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH" /> + 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,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" @@ -406,6 +406,7 @@ <BugPattern abbrev="SPP" type="SPP_USELESS_TRINARY" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_SUSPECT_STRING_TEST" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_USE_STRINGBUILDER_LENGTH" category="PERFORMANCE" /> + <BugPattern abbrev="SPP" type="SPP_INVALID_CALENDAR_COMPARE" 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 2008-06-09 18:06:22 UTC (rev 1048) +++ trunk/fb-contrib/etc/messages.xml 2008-06-13 19:07:03 UTC (rev 1049) @@ -1994,6 +1994,18 @@ </Details> </BugPattern> + <BugPattern type="SPP_INVALID_CALENDAR_COMPARE"> + <ShortDescription>Method passes a non calendar object to Calendar.before or Calendar.after</ShortDescription> + <LongDescription>Method {1} passes a non calendar object to Calendar.before or Calendar.after</LongDescription> + <Details> + <![CDATA[ + <p>This method passes a non calendar object to the java.util.Calendar.after or java.util.Calendar.before methods. + Even though these methods take an Object as a parameter type, only Calendar type objects are supported, otherwise + false is returned</p> + ]]> + </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 2008-06-09 18:06:22 UTC (rev 1048) +++ trunk/fb-contrib/samples/SPP_Sample.java 2008-06-13 19:07:03 UTC (rev 1049) @@ -1,5 +1,7 @@ import java.math.BigDecimal; import java.util.BitSet; +import java.util.Calendar; +import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -182,4 +184,9 @@ return null; } + + public boolean testCalBeforeAfter(Calendar c, Date d) + { + return c.after(d) || c.before(d); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-09 18:06:22 UTC (rev 1048) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2008-06-13 19:07:03 UTC (rev 1049) @@ -404,6 +404,17 @@ } } } + } else if ("java/util/Calendar".equals(className) + && ("after".equals(methodName) || "before".equals(methodName))) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item item = stack.getStackItem(0); + if (!"Ljava/util/Calendar;".equals(item.getSignature())) { + bugReporter.reportBug(new BugInstance(this, "SPP_INVALID_CALENDAR_COMPARE", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } } else if (seen == INVOKESPECIAL) { String className = getClassConstantOperand(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-09 18:06:59
|
Revision: 1048 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1048&view=rev Author: dbrosius Date: 2008-06-09 11:06:22 -0700 (Mon, 09 Jun 2008) Log Message: ----------- suppress deprecation 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 2008-06-08 16:03:17 UTC (rev 1047) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2008-06-09 18:06:22 UTC (rev 1048) @@ -363,6 +363,7 @@ if (lvt != null) { int len = lvt.getLength(); for (int i = 0; i < len; i++) { + @SuppressWarnings("deprecation") LocalVariable lv = lvt.getLocalVariable(i); if (lv != null) { Integer endPC = Integer14.valueOf(lv.getStartPC() + lv.getLength()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-08 16:03:09
|
Revision: 1047 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1047&view=rev Author: dbrosius Date: 2008-06-08 09:03:17 -0700 (Sun, 08 Jun 2008) Log Message: ----------- oi Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2008-06-08 04:16:12 UTC (rev 1046) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2008-06-08 16:03:17 UTC (rev 1047) @@ -20,7 +20,6 @@ import java.util.BitSet; -import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-08 04:16:07
|
Revision: 1046 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1046&view=rev Author: dbrosius Date: 2008-06-07 21:16:12 -0700 (Sat, 07 Jun 2008) Log Message: ----------- use slashes for lookupClass Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2008-06-07 22:43:52 UTC (rev 1045) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2008-06-08 04:16:12 UTC (rev 1046) @@ -70,7 +70,7 @@ public OverlyConcreteParameter(final BugReporter bugReporter) { this.bugReporter = bugReporter; try { - objectClass = Repository.lookupClass("java.lang.Object"); + objectClass = Repository.lookupClass("java/lang/Object"); } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); objectClass = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-07 22:45:01
|
Revision: 1045 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1045&view=rev Author: dbrosius Date: 2008-06-07 15:43:52 -0700 (Sat, 07 Jun 2008) Log Message: ----------- filter out synthetic methods Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2008-06-07 20:18:55 UTC (rev 1044) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2008-06-07 22:43:52 UTC (rev 1045) @@ -68,6 +68,7 @@ Method m = getMethod(); int aFlags = m.getAccessFlags(); if ((((aFlags & Constants.ACC_PRIVATE) != 0) || ((aFlags & Constants.ACC_STATIC) != 0)) + && ((aFlags & Constants.ACC_SYNTHETIC) == 0) && (!m.getSignature().endsWith(")Z"))) { stack.resetForMethodEntry(this); returnConstant = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-07 20:18:49
|
Revision: 1044 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1044&view=rev Author: dbrosius Date: 2008-06-07 13:18:55 -0700 (Sat, 07 Jun 2008) Log Message: ----------- add prescreening Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2008-06-07 14:28:48 UTC (rev 1043) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2008-06-07 20:18:55 UTC (rev 1044) @@ -18,7 +18,11 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.BitSet; + +import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -36,6 +40,17 @@ public static final int SEEN_ARRAY2_LOAD = 3; public static final int SEEN_ARRAY2_INDEX = 4; public static final int SEEN_ELEM_LOAD = 5; + private static final BitSet arrayLoadOps = new BitSet(); + static { + arrayLoadOps.set(AALOAD); + arrayLoadOps.set(BALOAD); + arrayLoadOps.set(CALOAD); + arrayLoadOps.set(SALOAD); + arrayLoadOps.set(IALOAD); + arrayLoadOps.set(LALOAD); + arrayLoadOps.set(DALOAD); + arrayLoadOps.set(FALOAD); + } private BugReporter bugReporter; private int state; private int arrayIndexReg; @@ -50,14 +65,27 @@ } /** + * looks for methods that contain array load opcodes + * + * @param method the context object of the current method + * @return if the class loads array contents + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); + return (bytecodeSet != null) && bytecodeSet.intersects(arrayLoadOps); + } + + /** * implements the visitor to reset the state * * @param obj the context object of the currently parsed code block */ @Override public void visitCode(Code obj) { - state = SEEN_NOTHING; - super.visitCode(obj); + if (prescreen(getMethod())) { + state = SEEN_NOTHING; + super.visitCode(obj); + } } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-07 14:28:55
|
Revision: 1043 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1043&view=rev Author: dbrosius Date: 2008-06-07 07:28:48 -0700 (Sat, 07 Jun 2008) Log Message: ----------- prescreen on LDC or LDC_W Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2008-06-07 05:29:13 UTC (rev 1042) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2008-06-07 14:28:48 UTC (rev 1043) @@ -18,7 +18,11 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.BitSet; + +import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -60,14 +64,27 @@ } /** + * looks for methods that contain a LDC or LDC_W opcodes + * + * @param method the context object of the current method + * @return if the class loads constants + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.LDC) || bytecodeSet.get(Constants.LDC_W)); + } + + /** * overrides the visitor to reset the opcode stack * * @param obj the code object for the currently parsed method */ @Override public void visitCode(final Code obj) { - stack.resetForMethodEntry(this); - super.visitCode(obj); + if (prescreen(getMethod())) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-07 05:29:05
|
Revision: 1042 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1042&view=rev Author: dbrosius Date: 2008-06-06 22:29:13 -0700 (Fri, 06 Jun 2008) Log Message: ----------- go back to 3.7.0 dev Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2008-06-07 05:28:04 UTC (rev 1041) +++ trunk/fb-contrib/build.xml 2008-06-07 05:29:13 UTC (rev 1042) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="3.6.1"/> + <property name="fb-contrib.version" value="3.7.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2008-06-07 05:28:04 UTC (rev 1041) +++ trunk/fb-contrib/etc/findbugs.xml 2008-06-07 05:29:13 UTC (rev 1042) @@ -318,8 +318,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousClusteredSessionSupport" speed="fast" - reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" - hidden="true" /> + reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" /> <!-- BugPattern --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |