fb-contrib-commit Mailing List for fb-contrib (Page 51)
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...> - 2006-08-08 03:59:48
|
Revision: 590 Author: dbrosius Date: 2006-08-07 20:59:39 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=590&view=rev Log Message: ----------- add info for LEST 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 2006-08-08 03:19:37 UTC (rev 589) +++ trunk/fb-contrib/etc/findbugs.xml 2006-08-08 03:59:39 UTC (rev 590) @@ -230,6 +230,10 @@ speed="fast" reports="UTA_USE_TO_ARRAY" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.LostExceptionStackTrace" + speed="moderate" + reports="LEST_LOST_EXCEPTION_STACK_TRACE" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -283,8 +287,9 @@ <BugPattern abbrev="UEC" type="UEC_USE_ENUM_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="SIL" type="SIL_SQL_IN_LOOP" category="PERFORMANCE" /> <BugPattern abbrev="NMCS" type="NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION" category="PERFORMANCE" /> - <BugPattern abbrev="ITC" type="ITC_INHERITANCE_TYPE_CHECKING" category="STYLE" experimental="true" /> - <BugPattern abbrev="SACM" type="SACM_STATIC_ARRAY_CREATED_IN_METHOD" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="RMC" type="RMC_REDUNDANT_METHOD_CALLS" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="UTA" type="UTA_USE_TO_ARRAY" category="STYLE" experimental="true" /> + <BugPattern abbrev="ITC" type="ITC_INHERITANCE_TYPE_CHECKING" category="STYLE" /> + <BugPattern abbrev="SACM" type="SACM_STATIC_ARRAY_CREATED_IN_METHOD" category="PERFORMANCE" /> + <BugPattern abbrev="RMC" type="RMC_REDUNDANT_METHOD_CALLS" category="PERFORMANCE" /> + <BugPattern abbrev="UTA" type="UTA_USE_TO_ARRAY" category="STYLE" /> + <BugPattern abbrev="LEST" type="LEST_LOST_EXCEPTION_STACK_TRACE" category="CORRECTNESS" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-08-08 03:19:37 UTC (rev 589) +++ trunk/fb-contrib/etc/messages.xml 2006-08-08 03:59:39 UTC (rev 590) @@ -619,6 +619,17 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.LostExceptionStackTrace"> + <Details> + <![CDATA[ + <p>looks for methods that catch exceptions, and then throw a different exception, + without embedding the original exception in the thrown one. Doing so, hides the real + source of the exception, making debugging and fixing these problems difficult.</p> + <p>It is a moderately fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1340,6 +1351,19 @@ </Details> </BugPattern> + <BugPattern type="LEST_LOST_EXCEPTION_STACK_TRACE"> + <ShortDescription>Method throws alternative exception from catch block without history</ShortDescription> + <LongDescription>Method {1} throws alternative exception from catch block without history</LongDescription> + <Details> + <![CDATA[ + <p>This method catches an exception, and throws a different exception, without incorporating the + original exception. Doing so hides the original source of the exception making debugging and fixing + these problems difficult. It is better to use the constructor of this new exception that takes an + original exception so that this detail can be passed along to the user.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1392,4 +1416,5 @@ <BugCode abbrev="SACM">Static Array Created in Method</BugCode> <BugCode abbrev="RMC">Redundant Method Calls</BugCode> <BugCode abbrev="UTA">Use toArray</BugCode> + <BugCode abbrev="LEST">Lost Exception Stack Trace</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...> - 2006-08-08 03:19:54
|
Revision: 589 Author: dbrosius Date: 2006-08-07 20:19:37 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=589&view=rev Log Message: ----------- start working on LEST detector Added Paths: ----------- trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Added: trunk/fb-contrib/samples/LEST_Sample.java =================================================================== --- trunk/fb-contrib/samples/LEST_Sample.java (rev 0) +++ trunk/fb-contrib/samples/LEST_Sample.java 2006-08-08 03:19:37 UTC (rev 589) @@ -0,0 +1,20 @@ +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class LEST_Sample +{ + public Date testLest1(String input) + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + throw new IllegalArgumentException(pe.getMessage()); + } + } +} Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-08 03:19:37 UTC (rev 589) @@ -0,0 +1,114 @@ +/* + * 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 java.util.BitSet; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.CodeException; +import org.apache.bcel.classfile.ExceptionTable; +import org.apache.bcel.classfile.Method; + +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; + +/** + * looks for methods that catch exceptions, and rethrow another exception without encapsulating + * the original exception within it. Doing this loses the stack history, and where the original + * problem occurred. This makes finding and fixing errors difficult. + */ +public class LostExceptionStackTrace extends BytecodeScanningDetector +{ + private BugReporter bugReporter; + private OpcodeStack stack; + + /** + * constructs a LEST detector given the reporter to report bugs on + + * @param bugReporter the sync of bug reports + */ + public LostExceptionStackTrace(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to make sure the jdk is 1.4 or better + * + * @param classContext the context object of the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + int majorVersion = classContext.getJavaClass().getMajor(); + if (majorVersion >= Constants.MAJOR_1_4) { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } + } finally { + stack = null; + } + } + + /** + * looks for methods that contain a catch block and an ATHROW opcode + * + * @param code the context object of the current code block + * @param method the context object of the current method + * @return if the class throws exceptions + */ + public boolean prescreen(Code code, Method method) { + CodeException[] ce = code.getExceptionTable(); + if ((ce == null) || (ce.length == 0)) + return false; + + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.ATHROW)); + } + + /** + * implements the visitor to filter out methods that don't throw exceptions + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + if (prescreen(obj, getMethod())) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } + } + + /** + * implements the visitor to find throwing alternative exceptions from a catch block, without + * forwarding along the original exception + */ + @Override + public void sawOpcode(int seen) { + try { + stack.mergeJumps(this); + + } + finally { + stack.sawOpcode(this, seen); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-05 22:16:29
|
Revision: 588 Author: dbrosius Date: 2006-08-05 15:16:24 -0700 (Sat, 05 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=588&view=rev Log Message: ----------- fix LII due to changes in OpcodeStack, not setting a variable constant to 0 when the assignment is a for loop. Use couldBeZero() instead. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-08-05 22:05:43 UTC (rev 587) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-08-05 22:16:24 UTC (rev 588) @@ -248,8 +248,7 @@ fl.setLoopState(LOOP_IN_BODY_WITH_GET); if (stack.getStackDepth() > 1) { OpcodeStack.Item itm = stack.getStackItem(0); - Integer initValue = (Integer)itm.getConstant(); - if ((initValue == null) || (initValue.intValue() != 0)) + if (!itm.couldBeZero()) it.remove(); else { itm = stack.getStackItem(1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-05 22:05:47
|
Revision: 587 Author: dbrosius Date: 2006-08-05 15:05:43 -0700 (Sat, 05 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=587&view=rev Log Message: ----------- make sure get is called on the loop index, before considering this loop an LII case. [ 1524122 ] LII thrown even if get(i) not called Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-08-05 21:47:21 UTC (rev 586) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-08-05 22:05:43 UTC (rev 587) @@ -47,6 +47,7 @@ private static final int LOOP_NOT_STARTED = 0; private static final int LOOP_INDEX_LOADED_FOR_TEST = 1; private static final int LOOP_IN_BODY = 2; + private static final int LOOP_IN_BODY_WITH_GET = 3; private static final int FIND_LOOP_STAGE = 0; private static final int FIND_BUG_STAGE = 1; @@ -220,7 +221,8 @@ break; case LOOP_IN_BODY: - if (getPC() == fl.getLoopEnd()) { + case LOOP_IN_BODY_WITH_GET: + if ((getPC() == fl.getLoopEnd()) && (fl.getLoopState() == LOOP_IN_BODY_WITH_GET)) { bugReporter.reportBug(new BugInstance( this, "LII_LIST_INDEXED_ITERATING", NORMAL_PRIORITY ) .addClass(this) .addMethod(this) @@ -236,12 +238,14 @@ if (loopReg == fl.getLoopReg()) fl.setLoopRegLoaded(true); } else if (fl.getLoopRegLoaded()) { - if (!((seen == INVOKEINTERFACE) - && "java/util/List".equals(getClassConstantOperand()) - && "get".equals(getNameConstantOperand()) - && "(I)Ljava/lang/Object;".equals(getSigConstantOperand()))) { + boolean sawGet = ((seen == INVOKEINTERFACE) + && "java/util/List".equals(getClassConstantOperand()) + && "get".equals(getNameConstantOperand()) + && "(I)Ljava/lang/Object;".equals(getSigConstantOperand())); + if (!sawGet) { it.remove(); } else { + fl.setLoopState(LOOP_IN_BODY_WITH_GET); if (stack.getStackDepth() > 1) { OpcodeStack.Item itm = stack.getStackItem(0); Integer initValue = (Integer)itm.getConstant(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-05 21:47:46
|
Revision: 586 Author: dbrosius Date: 2006-08-05 14:47:21 -0700 (Sat, 05 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=586&view=rev Log Message: ----------- prescreen for IINC as well. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-08-05 21:31:40 UTC (rev 585) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-08-05 21:47:21 UTC (rev 586) @@ -92,7 +92,7 @@ */ public boolean prescreen(Method method) { BitSet bytecodeSet = getClassContext().getBytecodeSet(method); - return (bytecodeSet != null) && (bytecodeSet.get(Constants.GOTO) || bytecodeSet.get(Constants.GOTO_W)); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.IINC)) && (bytecodeSet.get(Constants.GOTO) || bytecodeSet.get(Constants.GOTO_W)); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-05 21:31:56
|
Revision: 585 Author: dbrosius Date: 2006-08-05 14:31:40 -0700 (Sat, 05 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=585&view=rev Log Message: ----------- add false positive for bug report [ 1524122 ] LII thrown even if get(i) not called Modified Paths: -------------- trunk/fb-contrib/samples/LII_Sample.java Modified: trunk/fb-contrib/samples/LII_Sample.java =================================================================== --- trunk/fb-contrib/samples/LII_Sample.java 2006-08-05 03:29:36 UTC (rev 584) +++ trunk/fb-contrib/samples/LII_Sample.java 2006-08-05 21:31:40 UTC (rev 585) @@ -57,4 +57,14 @@ return sb.toString(); } + + public void test7FP(List<Integer> editedIndexes, List<Integer> pageTokens, List<Integer> tokens) + { + Integer index = pageTokens.size(); + for ( int i = 0; i < tokens.size(); i++ ) + { + editedIndexes.add( index ); + index++; + } + } } \ 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...> - 2006-08-05 03:29:44
|
Revision: 584 Author: dbrosius Date: 2006-08-04 20:29:36 -0700 (Fri, 04 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=584&view=rev Log Message: ----------- clear the statistics, each run Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-04 14:24:59 UTC (rev 583) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-05 03:29:36 UTC (rev 584) @@ -15,11 +15,10 @@ private static final int SG_SAW_GETFIELD = 2; private static final int SG_SAW_RETURN = 3; - private Statistics statistics = Statistics.getStatistics(); private int sgState; public CollectStatistics(BugReporter bugReporter) { - + Statistics.getStatistics().clear(); } @Override @@ -67,7 +66,7 @@ case SG_SAW_GETFIELD: if ((seen >= IRETURN) && (seen <= ARETURN)) { - statistics.addSimpleGetter(getClassName(), getMethodName(), getMethodSig()); + Statistics.getStatistics().addSimpleGetter(getClassName(), getMethodName(), getMethodSig()); } sgState = SG_INVALID; break; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2006-08-04 14:24:59 UTC (rev 583) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2006-08-05 03:29:36 UTC (rev 584) @@ -9,9 +9,11 @@ private Set<String> simpleGetters = new HashSet<String>(); + private Statistics() { + + } - public static Statistics getStatistics() - { + public static Statistics getStatistics() { return statistics; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-04 14:25:15
|
Revision: 583 Author: dbrosius Date: 2006-08-04 07:24:59 -0700 (Fri, 04 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=583&view=rev Log Message: ----------- it would make sense if the classname was included to differentiate simple getters. duh! Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-04 06:37:49 UTC (rev 582) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-04 14:24:59 UTC (rev 583) @@ -67,7 +67,7 @@ case SG_SAW_GETFIELD: if ((seen >= IRETURN) && (seen <= ARETURN)) { - statistics.addSimpleGetter(getMethodName(), getMethodSig()); + statistics.addSimpleGetter(getClassName(), getMethodName(), getMethodSig()); } sgState = SG_INVALID; break; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2006-08-04 06:37:49 UTC (rev 582) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2006-08-04 14:24:59 UTC (rev 583) @@ -19,11 +19,11 @@ simpleGetters.clear(); } - public void addSimpleGetter(String methodName, String signature) { - simpleGetters.add(methodName + ":" + signature); + public void addSimpleGetter(String className, String methodName, String signature) { + simpleGetters.add(className + ":" + methodName + ":" + signature); } - public boolean isSimpleGetter(String methodName, String signature) { - return simpleGetters.contains(methodName + ":" + signature); + public boolean isSimpleGetter(String className, String methodName, String signature) { + return simpleGetters.contains(className + ":" + methodName + ":" + signature); } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-08-04 06:37:49 UTC (rev 582) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-08-04 14:24:59 UTC (rev 583) @@ -174,7 +174,7 @@ Object[] parms = mc.getParms(); if (Arrays.equals(parms, parmConstants)) { Statistics statistics = Statistics.getStatistics(); - bugReporter.reportBug(new BugInstance(this, "RMC_REDUNDANT_METHOD_CALLS", statistics.isSimpleGetter(methodName, signature) ? LOW_PRIORITY : NORMAL_PRIORITY) + bugReporter.reportBug(new BugInstance(this, "RMC_REDUNDANT_METHOD_CALLS", statistics.isSimpleGetter(getClassConstantOperand(), methodName, signature) ? LOW_PRIORITY : 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...> - 2006-08-04 06:37:53
|
Revision: 582 Author: dbrosius Date: 2006-08-03 23:37:49 -0700 (Thu, 03 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=582&view=rev Log Message: ----------- RMC uses the getter statistics to report gettors at a low priority Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-08-04 06:28:08 UTC (rev 581) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-08-04 06:37:49 UTC (rev 582) @@ -29,6 +29,7 @@ import org.apache.bcel.classfile.CodeException; import org.apache.bcel.generic.Type; +import com.mebigfatguy.fbcontrib.collect.Statistics; import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -172,7 +173,8 @@ if (!signature.endsWith("V") && methodName.equals(mc.getName()) && signature.equals(mc.getSignature()) && !isRiskyName(methodName)) { Object[] parms = mc.getParms(); if (Arrays.equals(parms, parmConstants)) { - bugReporter.reportBug(new BugInstance(this, "RMC_REDUNDANT_METHOD_CALLS", NORMAL_PRIORITY) + Statistics statistics = Statistics.getStatistics(); + bugReporter.reportBug(new BugInstance(this, "RMC_REDUNDANT_METHOD_CALLS", statistics.isSimpleGetter(methodName, signature) ? LOW_PRIORITY : 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...> - 2006-08-04 06:28:14
|
Revision: 581 Author: dbrosius Date: 2006-08-03 23:28:08 -0700 (Thu, 03 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=581&view=rev Log Message: ----------- impl visitClassContext Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-04 06:12:13 UTC (rev 580) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-04 06:28:08 UTC (rev 581) @@ -24,7 +24,7 @@ @Override public void visitClassContext(ClassContext classContext) { - + super.visitClassContext(classContext); } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-04 06:12:19
|
Revision: 580 Author: dbrosius Date: 2006-08-03 23:12:13 -0700 (Thu, 03 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=580&view=rev Log Message: ----------- spanplugins=true Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-08-04 06:05:37 UTC (rev 579) +++ trunk/fb-contrib/etc/findbugs.xml 2006-08-04 06:12:13 UTC (rev 580) @@ -16,7 +16,7 @@ <OrderingConstraints> <SplitPass> <Earlier class="com.mebigfatguy.fbcontrib.collect.CollectStatistics"/> - <LaterCategory name="reporting" spanplugins="false"/> + <LaterCategory name="reporting" spanplugins="true"/> </SplitPass> </OrderingConstraints> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-04 06:05:43
|
Revision: 579 Author: dbrosius Date: 2006-08-03 23:05:37 -0700 (Thu, 03 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=579&view=rev Log Message: ----------- describe the collector 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 2006-08-04 06:00:56 UTC (rev 578) +++ trunk/fb-contrib/etc/findbugs.xml 2006-08-04 06:05:37 UTC (rev 579) @@ -10,9 +10,24 @@ defaultenabled="true" provider="fb-contrib project" website="http://fb-contrib.sourceforge.net"> - + + <!-- Passes --> + + <OrderingConstraints> + <SplitPass> + <Earlier class="com.mebigfatguy.fbcontrib.collect.CollectStatistics"/> + <LaterCategory name="reporting" spanplugins="false"/> + </SplitPass> + </OrderingConstraints> + <!-- Detectors --> + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" + speed="fast" + reports="" + hidden="true" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering" speed="fast" reports="ISB_INEFFICIENT_STRING_BUFFERING,ISB_EMPTY_STRING_APPENDING" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-08-04 06:00:56 UTC (rev 578) +++ trunk/fb-contrib/etc/messages.xml 2006-08-04 06:05:37 UTC (rev 579) @@ -16,6 +16,14 @@ <!-- Detectors --> + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics"> + <Details> + <![CDATA[ + <p>Collects statistics for other detectors</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering"> <Details> <![CDATA[ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-04 06:01:02
|
Revision: 578 Author: dbrosius Date: 2006-08-03 23:00:56 -0700 (Thu, 03 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=578&view=rev Log Message: ----------- first pass detector must implement NonReportingDetector Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-02 01:05:27 UTC (rev 577) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-04 06:00:56 UTC (rev 578) @@ -4,9 +4,10 @@ import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.NonReportingDetector; import edu.umd.cs.findbugs.ba.ClassContext; -public class CollectStatistics extends BytecodeScanningDetector +public class CollectStatistics extends BytecodeScanningDetector implements NonReportingDetector { private static final int SG_INVALID = -1; private static final int SG_SAW_NOTHING = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-02 01:05:37
|
Revision: 577 Author: dbrosius Date: 2006-08-01 18:05:27 -0700 (Tue, 01 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=577&view=rev Log Message: ----------- Initial attempt at a first pass collector/not working yet Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-02 01:05:27 UTC (rev 577) @@ -0,0 +1,75 @@ +package com.mebigfatguy.fbcontrib.collect; + +import org.apache.bcel.classfile.Method; + +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.ba.ClassContext; + +public class CollectStatistics extends BytecodeScanningDetector +{ + private static final int SG_INVALID = -1; + private static final int SG_SAW_NOTHING = 0; + private static final int SG_SAW_ALOAD_0 = 1; + private static final int SG_SAW_GETFIELD = 2; + private static final int SG_SAW_RETURN = 3; + + private Statistics statistics = Statistics.getStatistics(); + private int sgState; + + public CollectStatistics(BugReporter bugReporter) { + + } + + @Override + public void visitClassContext(ClassContext classContext) { + + } + + @Override + public void visitMethod(Method obj) { + String methodName = obj.getName(); + String signature = obj.getSignature(); + if (methodName.startsWith("get") + && (signature.indexOf("()") >= 0) + && (signature.indexOf(")V") < 0)) + { + sgState = SG_SAW_NOTHING; + } + else + { + sgState = SG_INVALID; + } + } + + @Override + public void sawOpcode(int seen) { + if (sgState != SG_INVALID) + sawSimpleGetter(seen); + } + + private void sawSimpleGetter(int seen) { + switch (sgState) { + case SG_SAW_NOTHING: + if (seen == ALOAD_0) + sgState = SG_SAW_ALOAD_0; + else + sgState = SG_INVALID; + break; + + case SG_SAW_ALOAD_0: + if (seen == GETFIELD) + sgState = SG_SAW_GETFIELD; + else + sgState = SG_INVALID; + break; + + case SG_SAW_GETFIELD: + if ((seen >= IRETURN) && (seen <= ARETURN)) { + statistics.addSimpleGetter(getMethodName(), getMethodSig()); + } + sgState = SG_INVALID; + break; + } + } +} Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2006-08-02 01:05:27 UTC (rev 577) @@ -0,0 +1,29 @@ +package com.mebigfatguy.fbcontrib.collect; + +import java.util.HashSet; +import java.util.Set; + +public class Statistics { + + private static Statistics statistics = new Statistics(); + + private Set<String> simpleGetters = new HashSet<String>(); + + + public static Statistics getStatistics() + { + return statistics; + } + + public void clear() { + simpleGetters.clear(); + } + + public void addSimpleGetter(String methodName, String signature) { + simpleGetters.add(methodName + ":" + signature); + } + + public boolean isSimpleGetter(String methodName, String signature) { + return simpleGetters.contains(methodName + ":" + signature); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-07-30 04:26:17
|
Revision: 576 Author: dbrosius Date: 2006-07-29 21:26:10 -0700 (Sat, 29 Jul 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=576&view=rev Log Message: ----------- add ordering constraints Modified Paths: -------------- trunk/fb-contrib/etc/findbugsplugin.xsd Modified: trunk/fb-contrib/etc/findbugsplugin.xsd =================================================================== --- trunk/fb-contrib/etc/findbugsplugin.xsd 2006-07-11 22:04:12 UTC (rev 575) +++ trunk/fb-contrib/etc/findbugsplugin.xsd 2006-07-30 04:26:10 UTC (rev 576) @@ -57,6 +57,8 @@ <xsd:simpleType name="DetectorCategoryType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="reporting"/> + <xsd:enumeration value="training"/> + <xsd:enumeration value="interprocedural"/> </xsd:restriction> </xsd:simpleType> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-07-11 22:05:04
|
Revision: 575 Author: dbrosius Date: 2006-07-11 15:04:12 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=575&view=rev Log Message: ----------- add 'clone' to the list of methods not to report in RMC Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-07-07 18:32:44 UTC (rev 574) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-07-11 22:04:12 UTC (rev 575) @@ -58,6 +58,7 @@ riskyMethodNameContents.add("write"); riskyMethodNameContents.add("push"); riskyMethodNameContents.add("pop"); + riskyMethodNameContents.add("clone"); String userNameProp = System.getProperty(RMC_RISKY_USER_KEY); if (userNameProp != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-07-07 18:32:50
|
Revision: 574 Author: dbrosius Date: 2006-07-07 11:32:44 -0700 (Fri, 07 Jul 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=574&view=rev Log Message: ----------- guard against odd npe due to empty signature Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java 2006-06-28 18:59:10 UTC (rev 573) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java 2006-07-07 18:32:44 UTC (rev 574) @@ -232,9 +232,13 @@ private void addNewItem(final Set<String> supers, final OpcodeStack.Item addItm) throws ClassNotFoundException { - if (addItm.getSignature().charAt(0) == '[') { - supers.add(addItm.getSignature()); + String itemSignature = addItm.getSignature(); + if (itemSignature.length() == 0) return; + + if (itemSignature.charAt(0) == '[') { + supers.add(itemSignature); + return; } JavaClass cls = addItm.getJavaClass(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-28 19:07:15
|
Revision: 573 Author: dbrosius Date: 2006-06-28 11:59:10 -0700 (Wed, 28 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=573&view=rev Log Message: ----------- If a java.lang.Object method is called on an instance of a jdbc class, that's ok - don't report Modified Paths: -------------- trunk/fb-contrib/samples/JVR_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java Modified: trunk/fb-contrib/samples/JVR_Sample.java =================================================================== --- trunk/fb-contrib/samples/JVR_Sample.java 2006-06-21 02:08:15 UTC (rev 572) +++ trunk/fb-contrib/samples/JVR_Sample.java 2006-06-28 18:59:10 UTC (rev 573) @@ -13,6 +13,12 @@ VendorBlob vb = (VendorBlob)rs.getBlob(1); return vb.convertBlobToString(); } + + public String falsePositive(ResultSet rs) throws SQLException + { + Blob vb = rs.getBlob(1); + return vb.getClass().getName(); + } } class VendorBlob implements Blob Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java 2006-06-21 02:08:15 UTC (rev 572) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java 2006-06-28 18:59:10 UTC (rev 573) @@ -98,7 +98,7 @@ if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) { String clsName = getClassConstantOperand(); - if (!isJDBCClass(clsName)) { + if (!"java/lang/Object".equals(clsName) && !isJDBCClass(clsName)) { int parmCnt = Type.getArgumentTypes(getSigConstantOperand()).length; if (stack.getStackDepth() > parmCnt) { OpcodeStack.Item itm = stack.getStackItem(parmCnt); @@ -158,7 +158,7 @@ if (clsName.endsWith(";")) clsName = clsName.substring(1, clsName.length() - 1); clsName = clsName.replace('.', '/'); - + if (!clsName.startsWith("java/sql/") && !clsName.startsWith("javax/sql/")) return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-21 02:08:24
|
Revision: 572 Author: dbrosius Date: 2006-06-20 19:08:15 -0700 (Tue, 20 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=572&view=rev Log Message: ----------- prepare for starting version 3.0.0 Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2006-06-21 02:06:25 UTC (rev 571) +++ trunk/fb-contrib/build.xml 2006-06-21 02:08:15 UTC (rev 572) @@ -19,7 +19,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="2.8.0"/> + <property name="fb-contrib.version" value="2.9.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-21 02:06:35
|
Revision: 571 Author: dbrosius Date: 2006-06-20 19:06:25 -0700 (Tue, 20 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=571&view=rev Log Message: ----------- Tag v2.8.0 Added Paths: ----------- tags/v2_8_0/ Copied: tags/v2_8_0 (from rev 570, trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-20 03:59:42
|
Revision: 570 Author: dbrosius Date: 2006-06-19 20:59:30 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=570&view=rev Log Message: ----------- Prepare for v2.8.0 Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/htdocs/index.html trunk/fb-contrib/samples/ISB_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2006-06-20 03:26:29 UTC (rev 569) +++ trunk/fb-contrib/build.xml 2006-06-20 03:59:30 UTC (rev 570) @@ -19,7 +19,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="2.7.0"/> + <property name="fb-contrib.version" value="2.8.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 2006-06-20 03:26:29 UTC (rev 569) +++ trunk/fb-contrib/etc/findbugs.xml 2006-06-20 03:59:30 UTC (rev 570) @@ -266,8 +266,8 @@ <BugPattern abbrev="S508C" type="S508C_NON_ACCESSIBLE_JCOMPONENT" category="CORRECTNESS" /> <BugPattern abbrev="S508C" type="S508C_SET_COMP_COLOR" category="CORRECTNESS" /> <BugPattern abbrev="UEC" type="UEC_USE_ENUM_COLLECTIONS" category="PERFORMANCE" /> - <BugPattern abbrev="SIL" type="SIL_SQL_IN_LOOP" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="NMCS" type="NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="SIL" type="SIL_SQL_IN_LOOP" category="PERFORMANCE" /> + <BugPattern abbrev="NMCS" type="NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION" category="PERFORMANCE" /> <BugPattern abbrev="ITC" type="ITC_INHERITANCE_TYPE_CHECKING" category="STYLE" experimental="true" /> <BugPattern abbrev="SACM" type="SACM_STATIC_ARRAY_CREATED_IN_METHOD" category="PERFORMANCE" experimental="true" /> <BugPattern abbrev="RMC" type="RMC_REDUNDANT_METHOD_CALLS" category="PERFORMANCE" experimental="true" /> Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-06-20 03:26:29 UTC (rev 569) +++ trunk/fb-contrib/htdocs/index.html 2006-06-20 03:59:30 UTC (rev 570) @@ -44,17 +44,24 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <img src="vbar.gif" height="12"/> <a href="javadoc/index.html">JavaDoc</a> - - <hr/> - <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> + + <hr/> + <img id="svn_image" src="flip1.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> Detectors added in svn<br/> - Note: This version of fb-contrib requires FindBugs v1.0.0<br/> - <div id="svn" style="display:block;"> + <div id="svn" style="display:none;"> <ul> <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> + </ul> + </div> + <hr/> + <img id="v2_8_0_image" src="flip2.gif" onClick="toggleBlock('v2_8_0', 'v2_8_0_image');" align="top"/> + Detectors added in v2.8.0<br/> + Note: This version of fb-contrib requires FindBugs v1.0.0<br/> + <div id="v2_8_0" style="display:block;"> + <ul> <li><b>[NMCS] Needless Member Collection Synchronization</b><br/> Looks for private collection members, either static or instance, that are only initialized in the clinit or init, but are synchronized. This is not necessary as the constructor or static @@ -72,7 +79,6 @@ cleaner to use mycollection.toArray(new type[mycollection.size()].</li> </ul> </div> - <hr/> <img id="v2_6_0_image" src="flip1.gif" onClick="toggleBlock('v2_6_0', 'v2_6_0_image');" align="top"/> Detectors added in v2.6.0<br/> Modified: trunk/fb-contrib/samples/ISB_Sample.java =================================================================== --- trunk/fb-contrib/samples/ISB_Sample.java 2006-06-20 03:26:29 UTC (rev 569) +++ trunk/fb-contrib/samples/ISB_Sample.java 2006-06-20 03:59:30 UTC (rev 570) @@ -51,6 +51,14 @@ return sb.toString(); } + public String testFPISB8(int x) + { + StringBuffer sb = new StringBuffer(); + sb.append(x); + sb.append("hello"); + return sb.toString(); + } + public String toString() { String a = System.getProperty("foo"); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2006-06-20 03:26:29 UTC (rev 569) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2006-06-20 03:59:30 UTC (rev 570) @@ -26,6 +26,7 @@ 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; /** * looks for appending strings inside of calls to StringBuffer or StringBuilder append. @@ -33,7 +34,8 @@ public class InefficientStringBuffering extends BytecodeScanningDetector { private BugReporter bugReporter; - private OpcodeStack opStack; + private OpcodeStack stack; + private boolean sawLDCEmpty; /** * constructs a ISB detector given the reporter to report bugs on @@ -43,6 +45,19 @@ this.bugReporter = bugReporter; } + /** + * implements the visitor to create an clear the stack + * + * @param classContext the context object of the currently parsed class + */ + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + stack = null; + } + } /** * implements the visitor to create and clear the stack * @@ -51,16 +66,16 @@ @Override public void visitCode(final Code obj) { if (obj.getCode() != null) { - opStack = new OpcodeStack(); + stack.resetForMethodEntry(this); + sawLDCEmpty = false; super.visit(obj); - opStack = null; } } @Override public void sawOpcode(final int seen) { try { - opStack.mergeJumps(this); + stack.mergeJumps(this); if (seen == INVOKESPECIAL) { String calledClass = getClassConstantOperand(); @@ -78,40 +93,49 @@ } } } else if (seen == INVOKEVIRTUAL) { - String calledClass = getClassConstantOperand(); - if (("java/lang/StringBuffer".equals(calledClass) - || "java/lang/StringBuilder".equals(calledClass)) - && "append".equals(getNameConstantOperand()) - && getSigConstantOperand().startsWith("(Ljava/lang/String;)")) { - if (opStack.getStackDepth() > 0) { - OpcodeStack.Item itm = opStack.getStackItem(0); - Object cons = itm.getConstant(); - if ((cons instanceof String) && (itm.getRegisterNumber() < 0)) { - if (((String)cons).length() == 0) { - bugReporter.reportBug( - new BugInstance(this, "ISB_EMPTY_STRING_APPENDING", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + if (sawLDCEmpty) { + String calledClass = getClassConstantOperand(); + if (("java/lang/StringBuffer".equals(calledClass) + || "java/lang/StringBuilder".equals(calledClass)) + && "append".equals(getNameConstantOperand()) + && getSigConstantOperand().startsWith("(Ljava/lang/String;)")) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + Object cons = itm.getConstant(); + if ((cons instanceof String) && (itm.getRegisterNumber() < 0)) { + if (((String)cons).length() == 0) { + bugReporter.reportBug( + new BugInstance(this, "ISB_EMPTY_STRING_APPENDING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } } } } } else if (seen == GOTO) { - int depth = opStack.getStackDepth(); + int depth = stack.getStackDepth(); for (int i = 0; i < depth; i++) { - OpcodeStack.Item itm = opStack.getStackItem(i); + OpcodeStack.Item itm = stack.getStackItem(i); itm.setUserValue(Boolean.TRUE); } + } else if (seen == LDC) { + Constant c = getConstantRefOperand(); + if (c instanceof ConstantString) { + String s = ((ConstantString) c).getBytes(getConstantPool()); + if (s.length() == 0) + sawLDCEmpty = true; + } } } finally { - opStack.sawOpcode(this, seen); + stack.sawOpcode(this, seen); } } private OpcodeStack.Item getStringBufferItemAt(int depth) { - if (opStack.getStackDepth() > depth) { - OpcodeStack.Item itm = opStack.getStackItem(depth); + if (stack.getStackDepth() > depth) { + OpcodeStack.Item itm = stack.getStackItem(depth); String signature = itm.getSignature(); if ("Ljava/lang/StringBuffer;".equals(signature) || "Ljava/lang/StringBuilder;".equals(signature)) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2006-06-20 03:26:29 UTC (rev 569) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2006-06-20 03:59:30 UTC (rev 570) @@ -26,7 +26,6 @@ import org.apache.bcel.classfile.JavaClass; import com.mebigfatguy.fbcontrib.utils.Integer14; -import com.mebigfatguy.fbcontrib.utils.MapEntry; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import edu.umd.cs.findbugs.BugInstance; @@ -60,6 +59,11 @@ this.bugReporter = bugReporter; } + /** + * implements the visitor to create and clear the stack, and report missing class errors + * + * @param classContext the context object of the currently parsed class + */ public void visitClassContext(ClassContext classContext) { if (collectionClass == null) { if (ex != null) { @@ -77,6 +81,11 @@ } } + /** + * implements the visitor to reset the stack and uservalues + * + * @param obj the context object of the currently parsed code block + */ @Override public void visitCode(Code obj) { try { @@ -88,6 +97,11 @@ } } + /** + * implements the visitor to look for manually copying of collections to arrays + * + * @param seen the opcode of the currently parsed instruction + */ @Override public void sawOpcode(int seen) { int reg = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-20 03:26:33
|
Revision: 569 Author: dbrosius Date: 2006-06-19 20:26:29 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=569&view=rev Log Message: ----------- Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-06-20 03:24:48 UTC (rev 568) +++ trunk/fb-contrib/htdocs/index.html 2006-06-20 03:26:29 UTC (rev 569) @@ -66,7 +66,7 @@ <li><b>[RMC] Redundant Method Calls</b><br/> Looks for calls of the same method on the same object when that object hasn't changed. This often is redundant, and the second call can be removed, or combined.</li> - <li><b>[UTA]Use toArray</b><br/> + <li><b>[UTA] Use toArray</b><br/> Looks for code that builds an array of values from a collection, by manually looping over the elements of the collection, and adding them to the array. It is simpler and cleaner to use mycollection.toArray(new type[mycollection.size()].</li> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-20 03:24:53
|
Revision: 568 Author: dbrosius Date: 2006-06-19 20:24:48 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=568&view=rev Log Message: ----------- doc UTA Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-06-19 05:47:54 UTC (rev 567) +++ trunk/fb-contrib/htdocs/index.html 2006-06-20 03:24:48 UTC (rev 568) @@ -47,7 +47,8 @@ <hr/> <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> - Detectors added in svn + Detectors added in svn<br/> + Note: This version of fb-contrib requires FindBugs v1.0.0<br/> <div id="svn" style="display:block;"> <ul> <li><b>[BSB] Bloated Synchronized Block</b><br/> @@ -65,6 +66,10 @@ <li><b>[RMC] Redundant Method Calls</b><br/> Looks for calls of the same method on the same object when that object hasn't changed. This often is redundant, and the second call can be removed, or combined.</li> + <li><b>[UTA]Use toArray</b><br/> + Looks for code that builds an array of values from a collection, by manually looping + over the elements of the collection, and adding them to the array. It is simpler and + cleaner to use mycollection.toArray(new type[mycollection.size()].</li> </ul> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-19 05:48:06
|
Revision: 567 Author: dbrosius Date: 2006-06-18 22:47:54 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=567&view=rev Log Message: ----------- allow iterators Modified Paths: -------------- trunk/fb-contrib/samples/UTA_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java Modified: trunk/fb-contrib/samples/UTA_Sample.java =================================================================== --- trunk/fb-contrib/samples/UTA_Sample.java 2006-06-19 05:28:38 UTC (rev 566) +++ trunk/fb-contrib/samples/UTA_Sample.java 2006-06-19 05:47:54 UTC (rev 567) @@ -1,3 +1,4 @@ +import java.util.Iterator; import java.util.List; public class UTA_Sample @@ -20,4 +21,14 @@ return data; } + + public Long[] testList3(List<Long> l) + { + Iterator<Long> it = l.iterator(); + Long[] data = new Long[l.size()]; + for (int i = 0; i < l.size(); i++) + data[i] = it.next(); + + return data; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2006-06-19 05:28:38 UTC (rev 566) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2006-06-19 05:47:54 UTC (rev 567) @@ -116,6 +116,14 @@ sawAlias = true; } } + } else if ("keySet".equals(methodName) || "values".equals(methodName) || "iterator".equals(methodName) || "next".equals(methodName)) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item itm = stack.getStackItem(1); + reg = isLocalCollection(itm); + if (reg >= 0) { + sawAlias = true; + } + } } } else if (((seen == ISTORE) || ((seen >= ISTORE_0) && (seen <= ISTORE_3))) || ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3)))) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-19 05:28:47
|
Revision: 566 Author: dbrosius Date: 2006-06-18 22:28:38 -0700 (Sun, 18 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=566&view=rev Log Message: ----------- UTA starting to work for integer indexing, todo using iterators Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-06-19 05:09:54 UTC (rev 565) +++ trunk/fb-contrib/etc/findbugs.xml 2006-06-19 05:28:38 UTC (rev 566) @@ -213,8 +213,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UseToArray" speed="fast" - reports="UTA_USE_TO_ARRAY" - hidden="true" /> + reports="UTA_USE_TO_ARRAY" /> <!-- BugPattern --> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2006-06-19 05:09:54 UTC (rev 565) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java 2006-06-19 05:28:38 UTC (rev 566) @@ -29,6 +29,7 @@ import com.mebigfatguy.fbcontrib.utils.MapEntry; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; +import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; @@ -50,9 +51,6 @@ private BugReporter bugReporter; private OpcodeStack stack; private Map<Integer, Object> userValues; - /** map of pc of loop starts to map entry of index register to collection register */ - private Map<Integer, Map.Entry<Integer, Integer>> loopStarts; - /** * constructs a UTA detector given the reporter to report bugs on @@ -84,11 +82,9 @@ try { stack.resetForMethodEntry(this); userValues = new HashMap<Integer, Object>(); - loopStarts = new HashMap<Integer, Map.Entry<Integer, Integer>>(); super.visitCode(obj); } finally { userValues = null; - loopStarts = null; } } @@ -96,20 +92,30 @@ public void sawOpcode(int seen) { int reg = -1; Object uValue = null; - boolean sawSize = false; + boolean sawAlias = false; boolean sawLoad = false; boolean sawNewArray = false; try { if (seen == INVOKEINTERFACE) { - if ("size".equals(getNameConstantOperand()) && "()I".equals(getSigConstantOperand())) { + String methodName = getNameConstantOperand(); + String signature = getSigConstantOperand(); + if ("size".equals(methodName) && "()I".equals(signature)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); reg = isLocalCollection(itm); if (reg >= 0) { - sawSize = true; + sawAlias = true; } } + } else if ("get".equals(methodName) && "(I)Ljava/lang/Object;".equals(signature)) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item itm = stack.getStackItem(1); + reg = isLocalCollection(itm); + if (reg >= 0) { + sawAlias = true; + } + } } } else if (((seen == ISTORE) || ((seen >= ISTORE_0) && (seen <= ISTORE_3))) || ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3)))) { @@ -131,23 +137,44 @@ if (stack.getStackDepth() > 1) { OpcodeStack.Item itm1 = stack.getStackItem(1); OpcodeStack.Item itm2 = stack.getStackItem(0); - Object const1 = itm1.getConstant(); reg = itm1.getRegisterNumber(); - if ((reg >= 0) && (const1 instanceof Integer)) { - if (0 == ((Integer) const1).intValue()) { - uValue = itm2.getUserValue(); - if (uValue != null) { - loopStarts.put(Integer14.valueOf(getPC()), new MapEntry<Integer, Integer>(Integer14.valueOf(reg), (Integer)uValue)); - } + if ((reg >= 0) && (itm1.couldBeZero())) { + uValue = itm2.getUserValue(); + if (uValue != null) { + userValues.put(Integer14.valueOf(reg), uValue); } } } + } else if ((seen >= IASTORE) && (seen <= SASTORE)) { + if (stack.getStackDepth() > 2) { + OpcodeStack.Item arItem = stack.getStackItem(2); + OpcodeStack.Item idxItem = stack.getStackItem(1); + OpcodeStack.Item valueItem = stack.getStackItem(0); + reg = isLocalCollection(arItem); + if ((reg >= 0) + && (idxItem.getUserValue() != null) + && (valueItem.getUserValue() != null)) { + bugReporter.reportBug(new BugInstance(this, "UTA_USE_TO_ARRAY", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } else if (seen == CHECKCAST) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + uValue = itm.getUserValue(); + if (uValue instanceof Integer) { + reg = ((Integer)uValue).intValue(); + sawAlias = true; + } + } } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } finally { stack.sawOpcode(this, seen); - if (sawSize) { + if (sawAlias) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); itm.setUserValue(Integer14.valueOf(reg)); @@ -188,7 +215,7 @@ return -1; JavaClass cls = item.getJavaClass(); - if (cls.implementationOf(collectionClass)) + if ((cls != null) && cls.implementationOf(collectionClass)) return reg; return -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |