fb-contrib-commit Mailing List for fb-contrib (Page 62)
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: Dave B. <dbr...@us...> - 2006-03-05 04:37:19
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7897 Modified Files: build.xml Log Message: initial checkin - new SWCO detector Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- build.xml 22 Feb 2006 03:57:04 -0000 1.31 +++ build.xml 5 Mar 2006 04:37:13 -0000 1.32 @@ -68,8 +68,8 @@ <target name="compile_samples" depends="-init" description="compiles sample problem files"> <javac srcdir="${samples.dir}" destdir="${samples.dir}" - source="${javac.source}" - target="${javac.target}" + source="1.5" + target="1.5" deprecation="${javac.deprecation}" debug="${javac.debug}"> <classpath refid="fb-contrib.classpath"/> |
From: Dave B. <dbr...@us...> - 2006-03-02 02:05:55
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11884/src/com/mebigfatguy/fbcontrib/detect Modified Files: DateComparison.java Log Message: add Timestamp Index: DateComparison.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- DateComparison.java 28 Feb 2006 03:17:23 -0000 1.1 +++ DateComparison.java 2 Mar 2006 02:05:46 -0000 1.2 @@ -18,6 +18,9 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.HashSet; +import java.util.Set; + import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; @@ -40,6 +43,13 @@ private static final int SEEN_LOAD2_2 = 6; private static final int SEEN_CMP_2 = 7; + private static final Set<String> dateClasses = new HashSet<String>(); + static { + dateClasses.add("java.util.Date"); + dateClasses.add("java.sql.Date"); + dateClasses.add("java.sql.Timestamp"); + } + private BugReporter bugReporter; private int state; private int register1_1; @@ -114,7 +124,7 @@ case SEEN_LOAD1_2: if (seen == INVOKEVIRTUAL) { String cls = getDottedClassConstantOperand(); - if ((cls.equals("java.util.Date")) || (cls.equals("java.sql.Date"))) { + if (dateClasses.contains(cls)) { String methodName = getNameConstantOperand(); if (methodName.equals( "equals" ) || methodName.equals( "after" ) |
From: Dave B. <dbr...@us...> - 2006-03-01 05:09:08
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17661/src/com/mebigfatguy/fbcontrib/detect Modified Files: ClassEnvy.java FloatingPointLoops.java SloppyClassReflection.java SyncCollectionIterators.java UnnecessaryStoreBeforeReturn.java UnrelatedCollectionContents.java Log Message: various cleanups Index: SloppyClassReflection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SloppyClassReflection.java 12 Feb 2006 03:47:53 -0000 1.3 +++ SloppyClassReflection.java 1 Mar 2006 05:09:01 -0000 1.4 @@ -131,9 +131,9 @@ switch (state) { case COLLECT: if ((seen == INVOKESTATIC) - && (seen == INVOKEVIRTUAL) - && (seen == INVOKEINTERFACE) - && (seen == INVOKESPECIAL)) { + || (seen == INVOKEVIRTUAL) + || (seen == INVOKEINTERFACE) + || (seen == INVOKESPECIAL)) { refClasses.add(getClassConstantOperand()); String signature = getSigConstantOperand(); Type[] argTypes = Type.getArgumentTypes(signature); Index: UnrelatedCollectionContents.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- UnrelatedCollectionContents.java 6 Feb 2006 01:36:23 -0000 1.13 +++ UnrelatedCollectionContents.java 1 Mar 2006 05:09:01 -0000 1.14 @@ -56,7 +56,7 @@ COLLECTION_CLASSES.add("java/util/Set"); COLLECTION_CLASSES.add("java/util/SortedMap"); COLLECTION_CLASSES.add("java/util/SortedSet"); - }; + } private BugReporter bugReporter; private OpcodeStack stack; private Map<String, Set<String>> memberCollections; Index: SyncCollectionIterators.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- SyncCollectionIterators.java 6 Feb 2006 01:36:23 -0000 1.12 +++ SyncCollectionIterators.java 1 Mar 2006 05:09:01 -0000 1.13 @@ -51,13 +51,13 @@ synchCollectionNames.add("synchronizedList"); synchCollectionNames.add("synchronizedSortedSet"); synchCollectionNames.add("synchronizedSortedMap"); - }; + } private static Set<String> mapToSetMethods = new HashSet<String>(); static { mapToSetMethods.add("keySet"); mapToSetMethods.add("entrySet"); mapToSetMethods.add("values"); - }; + } private static final int SEEN_NOTHING = 0; private static final int SEEN_SYNC = 1; Index: ClassEnvy.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- ClassEnvy.java 31 Jan 2006 02:14:26 -0000 1.19 +++ ClassEnvy.java 1 Mar 2006 05:09:01 -0000 1.20 @@ -51,7 +51,7 @@ ignorableInterfaces.add("java.io.Serializable"); ignorableInterfaces.add("java.lang.Cloneable"); ignorableInterfaces.add("java.lang.Comparable"); - }; + } private BugReporter bugReporter; private OpcodeStack stack; @@ -374,11 +374,9 @@ int dot1 = packName1.indexOf("."); int dot2 = packName2.indexOf("."); - if (dot1 < 0) { - if (dot2 < 0) - return true; - return false; - } else if (dot2 < 0) + if (dot1 < 0) + return (dot2 < 0); + else if (dot2 < 0) return false; String s1 = packName1.substring(0, dot1); Index: UnnecessaryStoreBeforeReturn.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- UnnecessaryStoreBeforeReturn.java 1 Mar 2006 02:58:19 -0000 1.8 +++ UnnecessaryStoreBeforeReturn.java 1 Mar 2006 05:09:01 -0000 1.9 @@ -63,7 +63,6 @@ private Set<Integer> branchTargets = new HashSet<Integer>(); private int state; private int storeReg; - private int loadReg; /** * constructs a USBR detector given the reporter to report bugs on @@ -91,7 +90,8 @@ @Override public void sawOpcode(int seen) { - switch (state) { + int loadReg; + switch (state) { case SEEN_NOTHING: if ((seen >= ISTORE) && (seen <= ASTORE)) { storeReg = getRegisterOperand(); Index: FloatingPointLoops.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- FloatingPointLoops.java 6 Feb 2006 01:36:23 -0000 1.9 +++ FloatingPointLoops.java 1 Mar 2006 05:09:01 -0000 1.10 @@ -126,9 +126,7 @@ if ((seen >= IFEQ) && (seen <= IFLE)) { state = SEEN_IFX; gotoPC = getBranchTarget() - 3; - if (gotoPC <= getPC()) - return false; - return true; + return (gotoPC > getPC()); } break; |
From: Dave B. <dbr...@us...> - 2006-03-01 04:52:08
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5363/src/com/mebigfatguy/fbcontrib/detect Modified Files: AbnormalFinallyBlockReturn.java BloatedSynchronizedBlock.java Log Message: picky warnings Index: AbnormalFinallyBlockReturn.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- AbnormalFinallyBlockReturn.java 4 Jan 2006 02:40:42 -0000 1.8 +++ AbnormalFinallyBlockReturn.java 1 Mar 2006 04:52:03 -0000 1.9 @@ -36,9 +36,7 @@ */ public class AbnormalFinallyBlockReturn extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; - private CodeException[] exc; private List<FinallyBlockInfo> fbInfo = new ArrayList<FinallyBlockInfo>(); - private int majorVersion; private int loadedReg; /** @@ -67,7 +65,7 @@ */ @Override public void visitClassContext(ClassContext classContext) { - majorVersion = classContext.getJavaClass().getMajor(); + int majorVersion = classContext.getJavaClass().getMajor(); if (majorVersion >= MAJOR_1_4) super.visitClassContext(classContext); } @@ -82,7 +80,7 @@ fbInfo.clear(); loadedReg = -1; - exc = obj.getExceptionTable(); + CodeException[] exc = obj.getExceptionTable(); if (exc != null) { for (CodeException ce : exc) { if ((ce.getCatchType() == 0) Index: BloatedSynchronizedBlock.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- BloatedSynchronizedBlock.java 6 Feb 2006 01:36:22 -0000 1.16 +++ BloatedSynchronizedBlock.java 1 Mar 2006 04:52:03 -0000 1.17 @@ -39,14 +39,14 @@ */ public class BloatedSynchronizedBlock extends BytecodeScanningDetector implements StatelessDetector { - private BugReporter bugReporter; + private final BugReporter bugReporter; private static final String BSB_MIN_SAFE_CODE_SIZE = "fb-contrib.bsb.minsize"; - private OpcodeStack stack = new OpcodeStack(); - private Set<Integer> unsafeAliases = new HashSet<Integer>(); - private Map<Integer, Integer> branchInfo = new HashMap<Integer, Integer>(); + private final OpcodeStack stack = new OpcodeStack(); + private final Set<Integer> unsafeAliases = new HashSet<Integer>(); + private final Map<Integer, Integer> branchInfo = new HashMap<Integer, Integer>(); private int syncPC; private boolean isStatic; - private int minSafeCodeLength; + private final int minSafeCodeLength; private boolean unsafeCallOccurred; /** @@ -63,8 +63,10 @@ * clone this detector so that it can be a StatelessDetector * * @return a clone of this object + * + * @throws CloneNotSupportedException never */ - public Object clone() throws CloneNotSupportedException { + public final Object clone() throws CloneNotSupportedException { return super.clone(); } |
From: Dave B. <dbr...@us...> - 2006-03-01 02:58:22
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6313/src/com/mebigfatguy/fbcontrib/detect Modified Files: UnnecessaryStoreBeforeReturn.java Log Message: fix false positives due to typo Index: UnnecessaryStoreBeforeReturn.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- UnnecessaryStoreBeforeReturn.java 6 Feb 2006 01:36:23 -0000 1.7 +++ UnnecessaryStoreBeforeReturn.java 1 Mar 2006 02:58:19 -0000 1.8 @@ -116,7 +116,7 @@ case SEEN_STORE: if (branchTargets.contains(new Integer(getPC()))) { - seen = SEEN_NOTHING; + state = SEEN_NOTHING; return; } |
From: Dave B. <dbr...@us...> - 2006-02-28 03:20:48
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12906/htdocs Modified Files: index.html Log Message: doc DDC Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- index.html 18 Feb 2006 23:23:09 -0000 1.65 +++ index.html 28 Feb 2006 03:20:44 -0000 1.66 @@ -55,6 +55,9 @@ Looks for methods that implement synchronized blocks that appear to contain some code at the beginning that does not need to be synchronized. Moving these lines out of the synchronized block should help multithreaded performance.</li> + <li><b>[DDC] Double Date Compare</b><br/> + Looks for methods that compare two dates using .equals and after or before. + This combination of two comparisons can be accomplished with just one comparison.</li> </ul> </div> |
From: Dave B. <dbr...@us...> - 2006-02-28 03:17:27
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11131/src/com/mebigfatguy/fbcontrib/detect Added Files: DateComparison.java Log Message: initial checkin - new DDC detector --- NEW FILE: DateComparison.java --- /* * fb-contrib - Auxilliary detectors for Java programs * Copyright (C) 2005-2006 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.Method; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.visitclass.Constants2; /** * Looks for inefficient comparison of Date objects using two comparisons when one would do. */ public class DateComparison extends BytecodeScanningDetector implements Constants2, StatelessDetector { private static final int SEEN_NOTHING = 0; private static final int SEEN_LOAD1_1 = 1; private static final int SEEN_LOAD1_2 = 2; private static final int SEEN_CMP_1 = 3; private static final int SEEN_IFNE = 4; private static final int SEEN_LOAD2_1 = 5; private static final int SEEN_LOAD2_2 = 6; private static final int SEEN_CMP_2 = 7; private BugReporter bugReporter; private int state; private int register1_1; private int register1_2; private int register2_1; private int register2_2; /** * constructs a DDC detector given the reporter to report bugs on * @param bugReporter the sync of bug reports */ public DateComparison(BugReporter bugReporter) { this.bugReporter = bugReporter; } /** * clone this detector so that it can be a StatelessDetector * * @return a clone of this object */ @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * overrides the visitor to reset the registers * * @param obj the method of the currently parsed method */ @Override public void visit(Method obj) { state = SEEN_NOTHING; register1_1 = -1; register1_2 = -1; register2_1 = -1; register2_2 = -1; super.visit(obj); } /** * overrides the visitor to look for double date compares using the same registers * * @param seen the current opcode parsed. */ @Override public void sawOpcode(int seen) { switch (state) { case SEEN_NOTHING: if ((seen >= ALOAD_0) || (seen <= ALOAD_3)) register1_1 = seen - ALOAD_0; else if (seen == ALOAD) register1_1 = getRegisterOperand(); if (register1_1 > -1) state = SEEN_LOAD1_1; break; case SEEN_LOAD1_1: if ((seen >= ALOAD_0) || (seen <= ALOAD_3)) register1_2 = seen - ALOAD_0; else if (seen == ALOAD) register1_2 = getRegisterOperand(); if (register1_2 > -1) state = SEEN_LOAD1_2; else state = SEEN_NOTHING; break; case SEEN_LOAD1_2: if (seen == INVOKEVIRTUAL) { String cls = getDottedClassConstantOperand(); if ((cls.equals("java.util.Date")) || (cls.equals("java.sql.Date"))) { String methodName = getNameConstantOperand(); if (methodName.equals( "equals" ) || methodName.equals( "after" ) || methodName.equals( "before" )) { state = SEEN_CMP_1; } } } if (state != SEEN_CMP_1) state = SEEN_NOTHING; break; case SEEN_CMP_1: if (seen == IFNE) state = SEEN_IFNE; else state = SEEN_NOTHING; break; case SEEN_IFNE: if ((seen >= ALOAD_0) || (seen <= ALOAD_3)) register2_1 = seen - ALOAD_0; else if (seen == ALOAD) register2_1 = getRegisterOperand(); if (register2_1 > -1) state = SEEN_LOAD2_1; else state = SEEN_NOTHING; break; case SEEN_LOAD2_1: if ((seen >= ALOAD_0) || (seen <= ALOAD_3)) register2_2 = seen - ALOAD_0; else if (seen == ALOAD) register2_2 = getRegisterOperand(); if ((register2_2 > -1) && ( ((register1_1 == register2_1) && (register1_2 == register2_2)) ||((register1_1 == register2_2) && (register1_2 == register2_1)))) state = SEEN_LOAD2_2; else state = SEEN_NOTHING; break; case SEEN_LOAD2_2: if (seen == INVOKEVIRTUAL) { String cls = getDottedClassConstantOperand(); if ((cls.equals("java.util.Date")) || (cls.equals("java.sql.Date"))) { String methodName = getNameConstantOperand(); if (methodName.equals( "equals" ) || methodName.equals( "after" ) || methodName.equals( "before" )) { state = SEEN_CMP_2; } } } if (state != SEEN_CMP_2) state = SEEN_NOTHING; break; case SEEN_CMP_2: if (seen == IFEQ) { bugReporter.reportBug(new BugInstance("DDC_DOUBLE_DATE_COMPARISON", NORMAL_PRIORITY) .addClassAndMethod(this) .addSourceLine(this)); } state = SEEN_NOTHING; break; } } } |
From: Dave B. <dbr...@us...> - 2006-02-28 03:17:27
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11131/samples Added Files: DDC_Sample.java Log Message: initial checkin - new DDC detector --- NEW FILE: DDC_Sample.java --- import java.util.Date; public class DDC_Sample { public void test1( Date d1, Date d2 ) { if (d1.equals( d2 ) || d1.after( d2 )) System.out.println( "d1 is greater than or equal to d2" ); else System.out.println( "d1 is less than d2" ); } public void test2( Date d1, Date d2 ) { if (d1.before( d2 ) || d1.equals( d2 )) System.out.println( "d1 is less than or equal to d2" ); else System.out.println( "d1 is greater than d2" ); } public void test3( Date d1, Date d2 ) { if (d1.before( d2 ) || d1.after( d2 )) System.out.println( "d1 is not equal to d2" ); else System.out.println( "d1 is equal to d2" ); }} |
From: Dave B. <dbr...@us...> - 2006-02-28 03:17:26
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11131/etc Modified Files: findbugs.xml messages.xml Log Message: initial checkin - new DDC detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- messages.xml 6 Feb 2006 01:21:49 -0000 1.54 +++ messages.xml 28 Feb 2006 03:17:23 -0000 1.55 @@ -441,6 +441,15 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.DateComparison"> + <Details> + <![CDATA[ + <p> Looks for inefficient comparison of Date objects using two comparisons when one would do. + It is a fast detector. + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -871,6 +880,40 @@ </Details> </BugPattern> + <BugPattern type="DDC_DOUBLE_DATE_COMPARISON"> + <ShortDescription>Method uses two date comparisons when one would do</ShortDescription> + <LongDescription>Method uses two date comparisons when one would do</LongDescription> + <Details> + <![CDATA[ + <p>This method compares dates with two comparisons, rather than using the reverse comparison. + So This pattern +<pre> + if ((date1.equals( date2 )) || (date1.after( date2 ))) +</pre> + could become +<pre> + if (!date2.before( date1 )) +</pre> + and +<pre> + if ((date1.equals( date2 )) || (date1.before( date2 ))) +</pre> + could become +<pre> + if (!date2.after( date1 )) +</pre> + and +<pre> + if ((date1.before( date2 )) || (date1.after( date2 ))) +</pre> + could become +<pre> + if (!date1.equals( date2 )) +</pre> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -907,4 +950,5 @@ <BugCode abbrev="AWCBR">Array Wrapped Call By Reference</BugCode> <BugCode abbrev="SG">Sluggish Gui</BugCode> <BugCode abbrev="NIR">Needless Instance Retrieval</BugCode> + <BugCode abbrev="DDC">Double Date comparison</BugCode> </MessageCollection> \ No newline at end of file Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- findbugs.xml 22 Feb 2006 03:57:04 -0000 1.64 +++ findbugs.xml 28 Feb 2006 03:17:23 -0000 1.65 @@ -150,6 +150,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessInstanceRetrieval" speed="fast" reports="NIR_NEEDLESS_INSTANCE_RETRIEVAL" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.DateComparison" + speed="fast" + reports="DDC_DOUBLE_DATE_COMPARISON" /> <!-- BugPattern --> @@ -187,4 +191,5 @@ <BugPattern abbrev="AWCBR" type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" category="STYLE" /> <BugPattern abbrev="SG" type="SG_SLUGGISH_GUI" category="PERFORMANCE" /> <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" /> + <BugPattern abbrev="DDC" type="DDC_DOUBLE_DATE_COMPARISON" category="PERFORMANCE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-02-28 02:06:14
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6235/samples Modified Files: USBR_Sample.java Log Message: add a possible false positive Index: USBR_Sample.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/samples/USBR_Sample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- USBR_Sample.java 3 Dec 2005 16:46:47 -0000 1.1 +++ USBR_Sample.java 28 Feb 2006 02:06:10 -0000 1.2 @@ -1,5 +1,3 @@ -import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.StatelessDetector; public class USBR_Sample { @@ -15,4 +13,19 @@ int ave = sum / tokens.length; return ave; } + + public int dontReport(int j) + { + int i; + try + { + i = 0; + i = i / j; + } + catch (Exception e) + { + i = -1; + } + return i; + } } |
From: Dave B. <dbr...@us...> - 2006-02-26 03:51:38
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30702/src/com/mebigfatguy/fbcontrib/detect Modified Files: DubiousListCollection.java Log Message: report DLC at LOW_PRIORITY if class is less than 1.4 as no LinkedHashSet exists. If a list is returned from a method, remove it from consideration. Index: DubiousListCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- DubiousListCollection.java 26 Feb 2006 03:28:46 -0000 1.14 +++ DubiousListCollection.java 26 Feb 2006 03:51:35 -0000 1.15 @@ -60,8 +60,10 @@ listMethods.add("remove(I)Ljava/lang/Object;"); listMethods.add("set(ILjava/lang/Object;)Ljava/lang/Object;"); listMethods.add("subList(II)Ljava/util/List;"); + listMethods.add("listIterator()Ljava/util/ListIterator;"); + listMethods.add("listIterator(I)Ljava/util/ListIterator;"); - //Theoretically get(i) and indexOf(Object) are setMethods but are so abused, as to be meaningless + //Theoretically get(i) and indexOf(Object) are list Methods but are so abused, as to be meaningless } private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); @@ -150,6 +152,15 @@ fieldsReported.remove(field); } } + } else if (seen == ARETURN) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + FieldAnnotation fa = item.getField(); + if (fa != null) { + String field = fa.getFieldName(); + fieldsReported.remove(field); + } + } } } finally { stack.sawOpcode(this, seen); @@ -178,6 +189,7 @@ * implements the detector, by reporting all remaining fields that only have set based access */ private void reportBugs() { + int major = getClassContext().getJavaClass().getMajor(); for (Map.Entry<String, FieldInfo> entry : fieldsReported.entrySet()) { String field = entry.getKey(); FieldInfo fi = entry.getValue(); @@ -185,7 +197,8 @@ if (cnt > 0) { FieldAnnotation fa = getFieldAnnotation(field); if (fa != null) { - bugReporter.reportBug(new BugInstance(this, "DLC_DUBIOUS_LIST_COLLECTION", NORMAL_PRIORITY) + //can't use LinkedHashSet in 1.3 so report at LOW + bugReporter.reportBug(new BugInstance(this, "DLC_DUBIOUS_LIST_COLLECTION", (major >= MAJOR_1_4) ? NORMAL_PRIORITY : LOW_PRIORITY) .addClass(this) .addField(fa) .addSourceLine(fi.getSourceLineAnnotation())); |
From: Dave B. <dbr...@us...> - 2006-02-26 03:51:38
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30702/samples Modified Files: DLC_Sample.java Log Message: report DLC at LOW_PRIORITY if class is less than 1.4 as no LinkedHashSet exists. If a list is returned from a method, remove it from consideration. Index: DLC_Sample.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/samples/DLC_Sample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- DLC_Sample.java 22 Sep 2005 05:28:29 -0000 1.1 +++ DLC_Sample.java 26 Feb 2006 03:51:35 -0000 1.2 @@ -5,6 +5,7 @@ { private List<String> badList = new ArrayList<String>(); private List<String> goodList = new ArrayList<String>(); + private List<String> questionableList = new ArrayList<String>(); public void test1(String s1, String s2) { if (badList.contains(s1)) @@ -21,4 +22,12 @@ int idx = goodList.indexOf(s1); goodList.set(idx, s2); } + + public List<String> test3(String s1) { + if (questionableList.contains(s1)) + return questionableList; + List<String> nl = new ArrayList<String>(); + nl.add(s1); + return nl; + } } \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-02-26 03:28:54
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21370/src/com/mebigfatguy/fbcontrib/detect Modified Files: DubiousListCollection.java Log Message: add sourceline of first use, to bug report Index: DubiousListCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- DubiousListCollection.java 18 Feb 2006 23:31:30 -0000 1.13 +++ DubiousListCollection.java 26 Feb 2006 03:28:46 -0000 1.14 @@ -34,6 +34,7 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.SourceLineAnnotation; import edu.umd.cs.findbugs.ba.ClassContext; /** @@ -44,8 +45,6 @@ */ public class DubiousListCollection extends BytecodeScanningDetector { - private static final Integer FIELD_UNKNOWN = new Integer(0); - private static Set<String> setMethods = new HashSet<String>(); private static Set<String> listMethods = new HashSet<String>(); static { @@ -66,7 +65,7 @@ } private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); - private Map<String, Integer> fieldsReported = new HashMap<String, Integer>(); + private Map<String, FieldInfo> fieldsReported = new HashMap<String, FieldInfo>(); /** * constructs a DLC detector given the reporter to report bugs on @@ -90,7 +89,7 @@ if (sig.charAt(0) == 'L') { sig = sig.substring(1, sig.length() - 1); if (sig.startsWith("java/util/") && sig.endsWith("List")) { - fieldsReported.put(f.getName(), FIELD_UNKNOWN); + fieldsReported.put(f.getName(), new FieldInfo()); } } } @@ -132,15 +131,13 @@ FieldAnnotation fa = getFieldFromStack(stack, signature); if (fa != null) { String field = fa.getFieldName(); - Integer cnt = fieldsReported.get(field); - if (cnt != null) { + FieldInfo fi = fieldsReported.get(field); + if (fi != null) { String methodInfo = methodName + signature; if (listMethods.contains(methodInfo)) fieldsReported.remove(field); - else if (setMethods.contains(methodInfo)) { - cnt = new Integer(cnt.intValue() + 1); - fieldsReported.put(field, cnt); - } + else if (setMethods.contains(methodInfo)) + fi.addUse(getPC()); } } } @@ -181,15 +178,17 @@ * implements the detector, by reporting all remaining fields that only have set based access */ private void reportBugs() { - for (Map.Entry<String, Integer> entry : fieldsReported.entrySet()) { + for (Map.Entry<String, FieldInfo> entry : fieldsReported.entrySet()) { String field = entry.getKey(); - int cnt = entry.getValue().intValue(); + FieldInfo fi = entry.getValue(); + int cnt = fi.getSetCount(); if (cnt > 0) { FieldAnnotation fa = getFieldAnnotation(field); if (fa != null) { bugReporter.reportBug(new BugInstance(this, "DLC_DUBIOUS_LIST_COLLECTION", NORMAL_PRIORITY) .addClass(this) - .addField(fa)); + .addField(fa) + .addSourceLine(fi.getSourceLineAnnotation())); } } } @@ -211,4 +210,31 @@ } return null; //shouldn't happen } + + class FieldInfo + { + private int setCnt = 0; + private SourceLineAnnotation slAnnotation = null; + + public FieldInfo() + { + } + + public void addUse(int pc) + { + setCnt++; + if (slAnnotation == null) + slAnnotation = SourceLineAnnotation.fromVisitedInstruction(DubiousListCollection.this.getClassContext(), DubiousListCollection.this, pc); + } + + public SourceLineAnnotation getSourceLineAnnotation() + { + return slAnnotation; + } + + public int getSetCount() + { + return setCnt; + } + } } |
From: Dave B. <dbr...@us...> - 2006-02-22 03:57:11
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15582/etc Modified Files: findbugs.xml Log Message: back to 2.3.0 dev Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- findbugs.xml 22 Feb 2006 03:45:42 -0000 1.63 +++ findbugs.xml 22 Feb 2006 03:57:04 -0000 1.64 @@ -44,8 +44,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="moderate" reports="CE_CLASS_ENVY" - disabled="true" - hidden="true" /> + disabled="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="moderate" @@ -130,8 +129,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" - disabled="true" - hidden="true" /> + disabled="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ConstantListIndex" speed="fast" @@ -184,9 +182,9 @@ <BugPattern abbrev="AOM" type="AOM_ABSTRACT_OVERRIDDEN_METHOD" category="CORRECTNESS" /> <BugPattern abbrev="CBX" type="CBX_CUSTOM_BUILT_XML" category="STYLE" /> <BugPattern abbrev="BSB" type="BSB_BLOATED_SYNCHRONIZED_BLOCK" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="CLI" type="CLI_CONSTANT_LIST_INDEX" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SCR" type="SCR_SLOPPY_CLASS_REFLECTION" category="STYLE" experimental="true" /> - <BugPattern abbrev="AWCBR" type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" category="STYLE" experimental="true" /> - <BugPattern abbrev="SG" type="SG_SLUGGISH_GUI" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="CLI" type="CLI_CONSTANT_LIST_INDEX" category="CORRECTNESS" /> + <BugPattern abbrev="SCR" type="SCR_SLOPPY_CLASS_REFLECTION" category="STYLE" /> + <BugPattern abbrev="AWCBR" type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" category="STYLE" /> + <BugPattern abbrev="SG" type="SG_SLUGGISH_GUI" category="PERFORMANCE" /> + <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-02-22 03:57:11
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15582 Modified Files: build.xml Log Message: back to 2.3.0 dev Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- build.xml 22 Feb 2006 03:45:41 -0000 1.30 +++ build.xml 22 Feb 2006 03:57:04 -0000 1.31 @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="2.2.1"/> + <property name="fb-contrib.version" value="2.3.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2006-02-22 03:45:45
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10365/etc Modified Files: findbugs.xml Log Message: prepare for release 2.2.1 Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- findbugs.xml 18 Feb 2006 03:36:55 -0000 1.62 +++ findbugs.xml 22 Feb 2006 03:45:42 -0000 1.63 @@ -44,7 +44,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="moderate" reports="CE_CLASS_ENVY" - disabled="true" /> + disabled="true" + hidden="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="moderate" @@ -129,7 +130,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" - disabled="true" /> + disabled="true" + hidden="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ConstantListIndex" speed="fast" @@ -181,10 +183,10 @@ <BugPattern abbrev="ODN" type="ODN_ORPHANED_DOM_NODE" category="CORRECTNESS" /> <BugPattern abbrev="AOM" type="AOM_ABSTRACT_OVERRIDDEN_METHOD" category="CORRECTNESS" /> <BugPattern abbrev="CBX" type="CBX_CUSTOM_BUILT_XML" category="STYLE" /> - <BugPattern abbrev="BSB" type="BSB_BLOATED_SYNCHRONIZED_BLOCK" category="PERFORMANCE" experimental="true"/> - <BugPattern abbrev="CLI" type="CLI_CONSTANT_LIST_INDEX" category="CORRECTNESS" /> - <BugPattern abbrev="SCR" type="SCR_SLOPPY_CLASS_REFLECTION" category="STYLE" /> - <BugPattern abbrev="AWCBR" type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" category="STYLE" /> - <BugPattern abbrev="SG" type="SG_SLUGGISH_GUI" category="PERFORMANCE" /> - <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" /> + <BugPattern abbrev="BSB" type="BSB_BLOATED_SYNCHRONIZED_BLOCK" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="CLI" type="CLI_CONSTANT_LIST_INDEX" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SCR" type="SCR_SLOPPY_CLASS_REFLECTION" category="STYLE" experimental="true" /> + <BugPattern abbrev="AWCBR" type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" category="STYLE" experimental="true" /> + <BugPattern abbrev="SG" type="SG_SLUGGISH_GUI" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-02-22 03:45:44
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10365 Modified Files: build.xml Log Message: prepare for release 2.2.1 Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- build.xml 18 Feb 2006 03:36:55 -0000 1.29 +++ build.xml 22 Feb 2006 03:45:41 -0000 1.30 @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="2.3.0"/> + <property name="fb-contrib.version" value="2.2.1"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2006-02-22 03:39:32
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7659/src/com/mebigfatguy/fbcontrib/detect Modified Files: ArrayBasedCollections.java Log Message: guard against empty signatures Index: ArrayBasedCollections.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ArrayBasedCollections.java 6 Feb 2006 01:36:22 -0000 1.6 +++ ArrayBasedCollections.java 22 Feb 2006 03:39:28 -0000 1.7 @@ -124,7 +124,7 @@ if (stack.getStackDepth() > 1) { OpcodeStack.Item itm = stack.getStackItem(1); String pushedSig = itm.getSignature(); - if (pushedSig.charAt(0) == '[') { + if ((pushedSig.length() > 0) && (pushedSig.charAt(0) == '[')) { bugList = mapBugs; found = true; } |
From: Dave B. <dbr...@us...> - 2006-02-18 23:43:19
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19847/src/com/mebigfatguy/fbcontrib/detect Modified Files: StaticMethodInstanceInvocation.java Log Message: don't report SMII for Class.forName("foo") and A.class.getName("foo") as the user can't do anything about it. Index: StaticMethodInstanceInvocation.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- StaticMethodInstanceInvocation.java 6 Feb 2006 01:36:23 -0000 1.7 +++ StaticMethodInstanceInvocation.java 18 Feb 2006 23:43:14 -0000 1.8 @@ -140,7 +140,7 @@ boolean classDefinesStaticMethod(String popSignature) throws ClassNotFoundException { popSignature = popSignature.replace('/', '.'); - if ("java.lang.Object".equals(popSignature)) + if ("java.lang.Object".equals(popSignature) || "java.lang.Class".equals(popSignature)) return false; JavaClass cls = Repository.lookupClass(popSignature); |
From: Dave B. <dbr...@us...> - 2006-02-18 23:43:17
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19847/samples Modified Files: SMII_Sample.java Log Message: don't report SMII for Class.forName("foo") and A.class.getName("foo") as the user can't do anything about it. Index: SMII_Sample.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/samples/SMII_Sample.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SMII_Sample.java 10 Dec 2005 03:41:02 -0000 1.3 +++ SMII_Sample.java 18 Feb 2006 23:43:14 -0000 1.4 @@ -37,4 +37,14 @@ Set s = new HashSet(); s.add(String.class); } + + public void test_ClassForName() throws ClassNotFoundException + { + Class c = Class.forName("java.lang.Object"); + } + + public void test_ClassGetName() + { + String name = Object.class.getName(); + } } \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-02-18 23:31:36
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15145/src/com/mebigfatguy/fbcontrib/detect Modified Files: DubiousListCollection.java Log Message: fix javadoc Index: DubiousListCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- DubiousListCollection.java 6 Feb 2006 01:36:23 -0000 1.12 +++ DubiousListCollection.java 18 Feb 2006 23:31:30 -0000 1.13 @@ -37,9 +37,10 @@ import edu.umd.cs.findbugs.ba.ClassContext; /** - * looks for constructors of non final classes that make method calls to non final methods. - * As these methods could be overridden, the overridden method will be accessing an object that - * is only partially constructed, perhaps causing problems. + * looks for fields that are implementations of java.util.List, but that are used in a set-like fashion. + * Since lookup type operations are performed using a linear search for Lists, the performance for large + * Lists will be poor. Consideration should be made as to whether these fields should be sets. In the + * case that order is important, consider using LinkedHashSet. */ public class DubiousListCollection extends BytecodeScanningDetector { |
From: Dave B. <dbr...@us...> - 2006-02-18 23:23:13
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11423/htdocs Modified Files: index.html Log Message: add Abbreviations Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- index.html 18 Feb 2006 03:03:41 -0000 1.64 +++ index.html 18 Feb 2006 23:23:09 -0000 1.65 @@ -51,7 +51,7 @@ Note: these detectors are still in testing<br/> <div id="cvs" style="display:none;"> <ul> - <li><b>Bloated Synchronized Block</b><br/> + <li><b>[BSB] Bloated Synchronized Block</b><br/> Looks for methods that implement synchronized blocks that appear to contain some code at the beginning that does not need to be synchronized. Moving these lines out of the synchronized block should help multithreaded performance.</li> @@ -64,28 +64,28 @@ Note: fb-contrib v2.2.0 requires FindBugs™ v0.95 or later<br/> <div id="v2_2_0" style="display:block;"> <ul> - <li><b>Constant List Index</b><br/> + <li><b>[CLI] Constant List Index</b><br/> Looks for methods that access an array or list using a constant integer index. Often, this is a typo where a loop variable is intended to be used. If however, specific list indices mean different specific things, then perhaps replacing the list with a first-class object with meaningful accessors would make the code less brittle.</li> - <li><b>Sloppy Class Reflection</b><br/> + <li><b>[SCR] Sloppy Class Reflection</b><br/> Looks for methods that use Class.forName("XXX") to load a class object for a class that is already referenced by this class. It is simpler to just use XXX.class, and doing so protects the integrity of this code from such transformations as obfuscation. Use of Class.forName should only be used when the class in question isn't already statically bound to this context.</li> - <li><b>Array Wrapped Call By Reference</b><br/> + <li><b>[AWCBR] Array Wrapped Call By Reference</b><br/> Looks for methods that use an array of length one to pass a variable to achieve call by pointer ala C++. It is better to define a proper return class type that holds all the relevant information retrieved from the called method.</li> - <li><b>Sluggish Gui</b><br/> + <li><b>[SG] Sluggish Gui</b><br/> Looks for methods that implement awt or swing listeners and perform time consuming operations. Doing these operations in the gui thread will cause the interface to appear sluggish and non-responsive to the user. It is better to use a separate thread to do the time consuming work so that the user has a better experience.</li> - <li><b>Needless Instance Retrieval</b><br/> + <li><b>[NIR] Needless Instance Retrieval</b><br/> Looks for methods that call a method to retrieve a reference to an object only to then load a static field of that object's class. It is simpler and more performant to just directly load the field from the class itself.</li> @@ -97,19 +97,19 @@ Detectors added in v2.0.0<br/> <div id="v2_0_0" style="display:none;"> <ul> - <li><b>Array Based Collections</b><br/> + <li><b>[ABC] Array Based Collections</b><br/> Looks for methods that use arrays for items in the keyset of a map, or as an element of a set, or in a list when using the contains method. Since arrays do not, and cannot define an equals method, reference equality is used for these collections, which is probably not desired. If it is, consider using the IdentityHashMap class when using Maps in this case, to better document your intentions.</li> - <li><b>Orphaned DOM Nodes</b><br/> + <li><b>[ODN] Orphaned DOM Nodes</b><br/> Looks for methods that create DOM nodes but do not append them to any Document.</li> - <li><b>Abstract Overridden Method</b><br/> + <li><b>[A0M] Abstract Overridden Method</b><br/> Looks for abstract methods that override a concrete method in a super class. Doing this casts away the implementation of the super class, and breaks the implied contract as set forth by the parent class.</li> - <li><b>Custom Built XML</b><br/> + <li><b>[CBX] Custom Built XML</b><br/> Looks for methods that build xml based strings by concatenation strings and custom values together. Doing so makes brittle code, that is difficult to modify, validate and understand. It is cleaner to create external xml files that are @@ -122,20 +122,20 @@ Detectors added in v1.8.0<br/> <div id="v1_8_0" style="display:none;"> <ul> - <li><b>Spurious Thread States</b><br/> + <li><b>[STS] Spurious Thread States</b><br/> Finds methods that call wait, notify or notifyAll on an instance of a java.lang.Thread. Since the internal workings of the thread is to synchronize on the thread itself, introducing client calls will confuse the thread state of the object in question, and will cause spurious thread state changes, either waking threads up when not intended, or removing the thread from the runnable state.</li> - <li><b>Needless Autoboxing</b><br/> + <li><b>[NAB] Needless Autoboxing</b><br/> Finds methods that pass an instance of a primitive wrapper class, to a constructor of the same class. Since wrapper classes are immutable, you can just use the original instance, instead of creating a new one. This bug is a misuse of autoboxing.</li> - <li><b>UnnecessaryStoreBeforeReturn</b><br/> + <li><b>[USBR] UnnecessaryStoreBeforeReturn</b><br/> Finds methods that store the return result in a local variable, and then immediately returns that local variable.</li> - <li><b>CopiedOverriddenMethod</b><br/> + <li><b>[COM] CopiedOverriddenMethod</b><br/> Finds methods that are implemented with an exact copy of their super class method's implementation. In most cases, this means that this method can just be removed.</li> </ul> @@ -146,20 +146,20 @@ Detectors added in v1.6.0<br/> <div id="v1_6_0" style="display:none;"> <ul> - <li><b>Static Method Instance Invocation</b><br/> + <li><b>[SMII] Static Method Instance Invocation</b><br/> Finds methods that make static method calls using an instance reference. For documentation purposes, it is better to call the method using the class name. This may represent a change in definition that should be noticed.</li> - <li><b>Abnormal Finally Block Return</b><br/> + <li><b>[AFBR] Abnormal Finally Block Return</b><br/> Finds methods that return or throw an exception from a finally block. Since a finally block is executed after any return or throw statements that are present in the try or catch block, these exit values are swallowed by the finally block's actions.</li> - <li><b>Non Collections Method Use</b><br/> + <li><b>[NCMU] Non Collections Method Use</b><br/> Finds calls to collections objects using methods that are not defined in the Collections interfaces, but that have equivalent methods defined in such. By using the new methods, it allows for the replacement of concrete classes with interfaces, and simplifies changing collection types if desired.</li> - <li><b>Confusing Autoboxed Overloading</b><br/> + <li><b>[CAO] Confusing Autoboxed Overloading</b><br/> Finds classes that define overloaded methods where the only difference is a parameter being of type java.lang.Character, and int, long, float or double. Due to autoboxing, one might conclude that a parameter of 'a' would autobox to Character, but would instead be cast to a double.</li> @@ -171,17 +171,17 @@ Detectors added in v1.4.0<br/> <div id="v1_4_0" style="display:none;"> <ul> - <li><b>Final Parameters</b><br/> + <li><b>[FP] Final Parameters</b><br/> Finds parameters that could be marked as final, but aren't. Doing so helps document the method, keeps unwanted changes to creep in, and may help the jvm jit compiler to optimize better.</li> - <li><b>Abstract Class Empty Methods</b><br/> + <li><b>[ACEM] Abstract Class Empty Methods</b><br/> Finds empty methods, or methods that just throw an exception in abstract classes. In these cases, it probably is more correct to just define the method to be abstract as well, so that proper subclass implementation is enforced.</li> - <li><b>Manual Array Copy</b><br/> + <li><b>[MAC] Manual Array Copy</b><br/> Finds methods that copy elements from one array to another manually using a loop. It is better performing to use System.arraycopy, as this method is native.</li> - <li><b>Floating Point Loops</b><br/> + <li><b>[FPL] Floating Point Loops</b><br/> Finds methods that use floating point variables as the index to loops. Since floating point math is inprecise, errors will accumulate each time through the loop, making the logic suspect. It is better to use an integer index, and calculate the desired floating point value from this integer.</li> @@ -193,19 +193,19 @@ Detectors added in v1.2.0<br/> <div id="v1_2_0" style="display:none;"> <ul> - <li><b>Parallel Lists</b><br/> + <li><b>[PL] Parallel Lists</b><br/> Finds classes that maintain two or more lists or arrays that appear to share a one-to-one relationship through a common index. It is usually better to create a separate class that holds all corresponding attributes, and add instances of this class to just one list or array.</li> - <li><b>Dubious List Collection</b><br/> + <li><b>[DLC] Dubious List Collection</b><br/> Finds fields that are implementations of java.util.List, but that are used in a set-like fashion. Since lookup type operations are performed using a linear search for Lists, the performance for large Lists will be poor. Consideration should be made as to whether these fields should be sets.</li> - <li><b>Partially Constructed Object Access</b><br/> + <li><b>[PCOA] Partially Constructed Object Access</b><br/> Finds constructors that call non-final methods in non-final classes. If this class is derived from, and the method is overridden, then that method will be executing on an object that hasn't been constructed in regards to the subclass implementation. These methods should probably be defined as final.</li> - <li><b>Literal String Comparison</b><br/> + <li><b>[LSC] Literal String Comparison</b><br/> Finds methods that call the equals or compareTo methods on a String variable passing in a String literal. A NullPointerException may occur if the string variable is null. If instead the method was called on the string literal, and the variable was passed as an argument, this exception could never happen</li> @@ -217,21 +217,21 @@ Detectors added in v1.0.0<br/> <div id="v1_0_0" style="display:none;"> <ul> - <li><b>Overly Concrete Parameters</b><br/> + <li><b>[OCP] Overly Concrete Parameters</b><br/> Finds parameters to methods that are defined as concrete classes, when they're usage pattern can be defined by an implemented interface. By switching to the interface, you can reduce coupling, which helps making the code more testable and changeable.</li> - <li><b>List Indexed Iterating</b><br/> + <li><b>[LII] List Indexed Iterating</b><br/> Looks for uses of using loop indexed variables to 'iterate' over a List by calling get(i) each time thru the loop. Depending on the List implementation, using Iterators can be significantly faster. Using Iterators also makes it easier to substitute other collection types.</li> - <li><b>Unrelated Collection Contents</b><br/> + <li><b>[UCC] Unrelated Collection Contents</b><br/> Looks for collections that hold objects that are unrelated by class or interface inheritance, other than java.lang.Object. Doing so, leads to brittle code, either by 'encoding' type knowledge in the position of an element, or using instanceof tests. It is usually better to create a separate class, add the individual types as members to it, and add an instance of this class to the collection.</li> - <li><b>Declared Runtime Exception</b><br/> + <li><b>[DRE] Declared Runtime Exception</b><br/> Finds methods that declare RuntimeExceptions in their throws clause. While not illegal, this may indicate a misunderstanding as to how unchecked exceptions are handled. If is felt that a RuntimeException is so prevalent that it should be declared, it @@ -244,14 +244,14 @@ Detectors added in v0.9.3 <div id="v0_9_3" style="display:none;"> <ul> - <li><b>Inefficient String Buffering</b><br/> + <li><b>[ISB] Inefficient String Buffering</b><br/> Finds Concatenation inside of a StringBuffer.append call, which creates temporary StringBuffers.</li> - <li><b>Synchronized Collection Iterators</b><br/> + <li><b>[SCI] Synchronized Collection Iterators</b><br/> Finds use of iterators on collections built from Collection.synchronizedXXX() calls. As iterators are by default not multithread safe, there use with a synchronized collections seems dubious.</li> - <li><b>Cyclomatic Complexity</b><br/> + <li><b>[CC] Cyclomatic Complexity</b><br/> Finds methods that are overly complex based on the McCabe algorithm for counting number of unique branches in the method</li> </ul> |
From: Dave B. <dbr...@us...> - 2006-02-18 03:37:06
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19813 Modified Files: build.xml Log Message: get ready for 2.3.0 dev Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- build.xml 18 Feb 2006 03:03:41 -0000 1.28 +++ build.xml 18 Feb 2006 03:36:55 -0000 1.29 @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="2.2.0"/> + <property name="fb-contrib.version" value="2.3.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2006-02-18 03:37:05
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19813/etc Modified Files: findbugs.xml Log Message: get ready for 2.3.0 dev Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- findbugs.xml 18 Feb 2006 03:07:19 -0000 1.61 +++ findbugs.xml 18 Feb 2006 03:36:55 -0000 1.62 @@ -44,7 +44,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="moderate" reports="CE_CLASS_ENVY" - hidden="true" /> + disabled="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="moderate" @@ -129,7 +129,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" - hidden="true" /> + disabled="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ConstantListIndex" speed="fast" @@ -181,10 +181,10 @@ <BugPattern abbrev="ODN" type="ODN_ORPHANED_DOM_NODE" category="CORRECTNESS" /> <BugPattern abbrev="AOM" type="AOM_ABSTRACT_OVERRIDDEN_METHOD" category="CORRECTNESS" /> <BugPattern abbrev="CBX" type="CBX_CUSTOM_BUILT_XML" category="STYLE" /> - <BugPattern abbrev="BSB" type="BSB_BLOATED_SYNCHRONIZED_BLOCK" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="CLI" type="CLI_CONSTANT_LIST_INDEX" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SCR" type="SCR_SLOPPY_CLASS_REFLECTION" category="STYLE" experimental="true" /> - <BugPattern abbrev="AWCBR" type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" category="STYLE" experimental="true" /> - <BugPattern abbrev="SG" type="SG_SLUGGISH_GUI" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="BSB" type="BSB_BLOATED_SYNCHRONIZED_BLOCK" category="PERFORMANCE" experimental="true"/> + <BugPattern abbrev="CLI" type="CLI_CONSTANT_LIST_INDEX" category="CORRECTNESS" /> + <BugPattern abbrev="SCR" type="SCR_SLOPPY_CLASS_REFLECTION" category="STYLE" /> + <BugPattern abbrev="AWCBR" type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" category="STYLE" /> + <BugPattern abbrev="SG" type="SG_SLUGGISH_GUI" category="PERFORMANCE" /> + <BugPattern abbrev="NIR" type="NIR_NEEDLESS_INSTANCE_RETRIEVAL" category="PERFORMANCE" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2006-02-18 03:28:09
|
Update of /cvsroot/fb-contrib/fb-contrib/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16382/lib Modified Files: findbugs.jar Log Message: version 0.9.5 Index: findbugs.jar =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/lib/findbugs.jar,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 Binary files /tmp/cvsFZtmZ3 and /tmp/cvsSewsNZ differ |