fb-contrib-commit Mailing List for fb-contrib (Page 73)
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...> - 2005-10-30 00:11:38
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27578 Modified Files: build.xml Log Message: get ready for 1.4.0 Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- build.xml 26 Oct 2005 04:29:39 -0000 1.10 +++ build.xml 30 Oct 2005 00:11:27 -0000 1.11 @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="1.3.0"/> + <property name="fb-contrib.version" value="1.4.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2005-10-30 00:11:38
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27578/htdocs Modified Files: index.html Log Message: get ready for 1.4.0 Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- index.html 29 Oct 2005 21:33:59 -0000 1.19 +++ index.html 30 Oct 2005 00:11:27 -0000 1.20 @@ -15,8 +15,7 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> - Detectors added in current cvs<br/> - Note: These detectors are still in testing<br/> + Detectors added in v1.4.0<br/> <ul> <li><b>Final Parameters</b><br/> Finds parameters that could be marked as final, but aren't. Doing so helps document the method, keeps |
From: Dave B. <dbr...@us...> - 2005-10-29 23:33:34
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20157/src/com/mebigfatguy/fbcontrib/detect Modified Files: FinalParameters.java Log Message: report all fp's for one method, in just one BugInstance Index: FinalParameters.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- FinalParameters.java 29 Oct 2005 22:01:48 -0000 1.7 +++ FinalParameters.java 29 Oct 2005 23:33:24 -0000 1.8 @@ -157,7 +157,7 @@ changedParms = new HashSet<Integer>(); super.visitCode(obj); - + BugInstance bi = null; for (int i = 0; i < parmCount; i++) { if (changedParms.remove(new Integer(i))) continue; @@ -169,11 +169,14 @@ reg = i; String parmName = getRegisterName(obj, reg); - bugReporter.reportBug( new BugInstance( this, "FP_FINAL_PARAMETERS", LOW_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this, 0) - .addString(parmName)); + if (bi == null) { + bi = new BugInstance(this, "FP_FINAL_PARAMETERS", LOW_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this, 0); + bugReporter.reportBug(bi); + } + bi.addString(parmName); } } |
From: Dave B. <dbr...@us...> - 2005-10-29 22:01:56
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31473/src/com/mebigfatguy/fbcontrib/detect Modified Files: FinalParameters.java Log Message: guard against other npes Index: FinalParameters.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- FinalParameters.java 29 Oct 2005 21:54:11 -0000 1.6 +++ FinalParameters.java 29 Oct 2005 22:01:48 -0000 1.7 @@ -147,6 +147,8 @@ return; for (int i = methodLine; i <= methodStart; i++) { + if ((i < 0) || (i >= sourceLines.length)) + return; line = sourceLines[i]; if (line.indexOf("final") >= 0) return; |
From: Dave B. <dbr...@us...> - 2005-10-29 21:54:18
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29772/src/com/mebigfatguy/fbcontrib/detect Modified Files: FinalParameters.java Log Message: guard against npes Index: FinalParameters.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- FinalParameters.java 20 Oct 2005 06:33:15 -0000 1.5 +++ FinalParameters.java 29 Oct 2005 21:54:11 -0000 1.6 @@ -136,7 +136,7 @@ int methodStart = srcLineAnnotation.getStartLine() - 2; int methodLine = methodStart; String line; - while (methodLine >= 0) { + while ((methodLine >= 0) && (methodLine < sourceLines.length)) { line = sourceLines[methodLine]; if (line.indexOf(methodName) >= 0) break; |
From: Dave B. <dbr...@us...> - 2005-10-29 21:34:07
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26710/htdocs Modified Files: index.html Log Message: try english out Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- index.html 29 Oct 2005 19:46:14 -0000 1.18 +++ index.html 29 Oct 2005 21:33:59 -0000 1.19 @@ -29,7 +29,7 @@ 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/> - Finds methods that use floating point variables as the index. Since floating point math is inprecise, + 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> </ul> |
From: Dave B. <dbr...@us...> - 2005-10-29 19:46:25
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32326/htdocs Modified Files: index.html Log Message: document FPL Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- index.html 26 Oct 2005 04:20:22 -0000 1.17 +++ index.html 29 Oct 2005 19:46:14 -0000 1.18 @@ -28,6 +28,10 @@ <li><b>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/> + Finds methods that use floating point variables as the index. 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> </ul> <hr/> Detectors added in v1.2.0<br/> |
From: Dave B. <dbr...@us...> - 2005-10-29 19:39:22
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31057/etc Modified Files: findbugs.xml messages.xml Log Message: new FPL detector - initial checkin Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- messages.xml 26 Oct 2005 04:08:12 -0000 1.26 +++ messages.xml 29 Oct 2005 19:39:14 -0000 1.27 @@ -189,6 +189,18 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.FloatingPointLoops"> + <Details> + <![CDATA[ + <p> Looks for methods that use floating point indexes for loops. Since floating point + math is inprecise, rounding errors will occur each time through the loop causing + hard to find problems. It is usually better to use integer indexing, and calculating + the correct floating point value from the index.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -374,6 +386,19 @@ </Details> </BugPattern> + <BugPattern type="FPL_FLOATING_POINT_LOOPS"> + <ShortDescription>method uses floating point indexed loops</ShortDescription> + <LongDescription>method {1} uses floating point indexed loops</LongDescription> + <Details> + <![CDATA[ + <p>This method uses floating point variables to index a loop. Since floating point + math is inprecise, rounding errors will accumulate over time each time the loop is + executed. It is usually better to use integer indexing, and calculate the new value + of the floating point number at the top of the loop body.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -391,5 +416,6 @@ <BugCode abbrev="FP">Final Parameters</BugCode> <BugCode abbrev="ACEM">Abstract Class Empty Methods</BugCode> <BugCode abbrev="MAC">Manual Array Copy</BugCode> + <BugCode abbrev="FPL">Floating Point Loops</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.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- findbugs.xml 26 Oct 2005 04:08:12 -0000 1.26 +++ findbugs.xml 29 Oct 2005 19:39:14 -0000 1.27 @@ -73,6 +73,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ManualArrayCopy" speed="fast" reports="MAC_MANUAL_ARRAY_COPY" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.FloatingPointLoops" + speed="fast" + reports="FPL_FLOATING_POINT_LOOPS" /> <!-- BugPattern --> @@ -92,5 +96,6 @@ <BugPattern abbrev="FP" type="FP_FINAL_PARAMETERS" category="STYLE" experimental="true" /> <BugPattern abbrev="ACEM" type="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" category="STYLE" experimental="true" /> <BugPattern abbrev="MAC" type="MAC_MANUAL_ARRAY_COPY" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="FPL" type="FPL_FLOATING_POINT_LOOPS" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-10-29 19:39:22
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31057/src/com/mebigfatguy/fbcontrib/detect Added Files: FloatingPointLoops.java Log Message: new FPL detector - initial checkin --- NEW FILE: FloatingPointLoops.java --- /* * fb-contrib - Auxilliary detectors for Java programs * Copyright (C) 2005 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.sql.Types; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.apache.bcel.classfile.Method; import com.sun.org.apache.bcel.internal.generic.Type; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; public class FloatingPointLoops extends BytecodeScanningDetector implements StatelessDetector { private static final int SEEN_LOAD = 1; private static final int SEEN_CMPX = 2; private static final int SEEN_IFX = 3; private static final int SEEN_STORE = 4; private BugReporter bugReporter; private Set<FloatForLoop> forLoops = new HashSet<FloatForLoop>(); public FloatingPointLoops(BugReporter bugReporter) { this.bugReporter = bugReporter; } public Object clone() throws CloneNotSupportedException { return super.clone(); } public void visitMethod(Method obj) { forLoops.clear(); } public void sawOpcode(int seen) { if (forLoops.size() > 0) { Iterator<FloatForLoop> ffl = forLoops.iterator(); while (ffl.hasNext()) { if (!ffl.next().sawOpcode(seen)) ffl.remove(); } } if ((seen == FLOAD) || (seen == DLOAD)) forLoops.add(new FloatForLoop(getRegisterOperand(), getPC())); else if ((seen >= FLOAD_0) && (seen <= FLOAD_3)) forLoops.add(new FloatForLoop(seen - FLOAD_0, getPC())); else if ((seen >= DLOAD_0) && (seen <= DLOAD_3)) forLoops.add(new FloatForLoop(seen - DLOAD_0, getPC())); } public class FloatForLoop { private int state; private int loopPC; private int loopReg; private int gotoPC; public FloatForLoop(int reg, int pc) { loopReg = reg; loopPC = pc; state = SEEN_LOAD; gotoPC = -1; } public boolean sawOpcode(int seen) { switch (state) { case SEEN_LOAD: if ((seen == FCMPG) || (seen == FCMPL) || (seen == DCMPG) || (seen == DCMPL)) { state = SEEN_CMPX; return true; } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKESTATIC) || (seen == INVOKEINTERFACE) || (seen == INVOKESPECIAL)) { String methodSig = FloatingPointLoops.this.getSigConstantOperand(); Type t = Type.getReturnType(methodSig); return t.getSignature() != "V"; } else if ((seen < ISTORE) || (seen > SASTORE)) { return true; } break; case SEEN_CMPX: if ((seen >= IFEQ) && (seen <= IFLE)) { state = SEEN_IFX; gotoPC = getBranchTarget() - 3; if (gotoPC <= getPC()) return false; return true; } break; case SEEN_IFX: if (getPC() < (gotoPC - 1)) return true; else if (getPC() == (gotoPC - 1)) { int storeReg; if ((seen == FSTORE) || (seen == DSTORE)) storeReg = getRegisterOperand(); else if ((seen >= FSTORE_0) && (seen <= FSTORE_3)) storeReg = seen - FSTORE_0; else if ((seen >= DSTORE_0) && (seen <= DSTORE_3)) storeReg = seen - DSTORE_0; else return false; state = SEEN_STORE; return storeReg == loopReg; } return false; case SEEN_STORE: if ((seen == GOTO) && (getBranchTarget() == loopPC)) { bugReporter.reportBug(new BugInstance(FloatingPointLoops.this, "FPL_FLOATING_POINT_LOOPS", NORMAL_PRIORITY) .addClass(FloatingPointLoops.this) .addMethod(FloatingPointLoops.this) .addSourceLine(FloatingPointLoops.this, loopPC)); } break; } return false; } } } |
From: Dave B. <dbr...@us...> - 2005-10-29 19:39:22
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31057/samples Modified Files: FPL_Sample.java Log Message: new FPL detector - initial checkin Index: FPL_Sample.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/samples/FPL_Sample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- FPL_Sample.java 29 Oct 2005 14:52:37 -0000 1.1 +++ FPL_Sample.java 29 Oct 2005 19:39:14 -0000 1.2 @@ -4,15 +4,23 @@ { public void testFloat() { - for (float f = 0.0f; f < 10.0f; f+=1.0f) { - + for (float f = 0.0f; f < 10.0f; f+=1.0f) + { } } public void testDouble() { - for (double d = 0.0; d < 10.0; d+= 1.0) { - + for (double d = 0.0; d < 10.0; d+= 1.0) + { } } + + public void testTougherFloat(String s) + { + for (float f = 0.0f; f < Double.valueOf(s); f+=1.0f) + { + } + + } } \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-10-29 14:52:49
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv495/samples Added Files: FPL_Sample.java Log Message: test case for FPL --- NEW FILE: FPL_Sample.java --- public class FPL_Sample { public void testFloat() { for (float f = 0.0f; f < 10.0f; f+=1.0f) { } } public void testDouble() { for (double d = 0.0; d < 10.0; d+= 1.0) { } } } |
From: Dave B. <dbr...@us...> - 2005-10-26 04:29:48
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8868 Modified Files: build.xml Log Message: dev version is now 1.3.0 Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- build.xml 19 Oct 2005 04:24:37 -0000 1.9 +++ build.xml 26 Oct 2005 04:29:39 -0000 1.10 @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="1.2.0"/> + <property name="fb-contrib.version" value="1.3.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2005-10-26 04:20:30
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7310/htdocs Modified Files: index.html Log Message: document ManualArrayCopy Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- index.html 23 Oct 2005 05:03:21 -0000 1.16 +++ index.html 26 Oct 2005 04:20:22 -0000 1.17 @@ -25,6 +25,9 @@ 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/> + 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> </ul> <hr/> Detectors added in v1.2.0<br/> |
From: Dave B. <dbr...@us...> - 2005-10-26 04:08:21
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5479/samples Added Files: MAC_Sample.java Log Message: new detector MAC, initial checkin --- NEW FILE: MAC_Sample.java --- public class MAC_Sample { public void test(String[] a) { String[] b = new String[a.length]; for (int i = 0; i < a.length; i++) b[i] = a[i]; } public void testFP(String[] a) { String[] b = new String[a.length]; int insPos = 0; for (int i = 0; i < a.length; i++) { if (!a[0].equals("*")) b[insPos++] = a[i]; } } } |
From: Dave B. <dbr...@us...> - 2005-10-26 04:08:21
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5479/etc Modified Files: findbugs.xml messages.xml Log Message: new detector MAC, initial checkin Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- messages.xml 23 Oct 2005 04:59:15 -0000 1.25 +++ messages.xml 26 Oct 2005 04:08:12 -0000 1.26 @@ -179,6 +179,16 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.ManualArrayCopy"> + <Details> + <![CDATA[ + <p> Looks for methods that copy data from one array to another using a loop. It is + better performing to use System.arraycopy to do such copying as this is a native method.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -353,6 +363,17 @@ </Details> </BugPattern> + <BugPattern type="MAC_MANUAL_ARRAY_COPY"> + <ShortDescription>method copies arrays manually</ShortDescription> + <LongDescription>method {1} copies arrays manually</LongDescription> + <Details> + <![CDATA[ + <p>This method copies data from one array to another manually using a loop. + It is much better performing to use System.arraycopy as this method is native.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -369,5 +390,6 @@ <BugCode abbrev="PL">Parallel Lists</BugCode> <BugCode abbrev="FP">Final Parameters</BugCode> <BugCode abbrev="ACEM">Abstract Class Empty Methods</BugCode> + <BugCode abbrev="MAC">Manual Array Copy</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.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- findbugs.xml 23 Oct 2005 04:59:15 -0000 1.25 +++ findbugs.xml 26 Oct 2005 04:08:12 -0000 1.26 @@ -70,6 +70,10 @@ speed="fast" reports="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.ManualArrayCopy" + speed="fast" + reports="MAC_MANUAL_ARRAY_COPY" /> + <!-- BugPattern --> @@ -87,5 +91,6 @@ <BugPattern abbrev="PL" type="PL_PARALLEL_LISTS" category="STYLE" /> <BugPattern abbrev="FP" type="FP_FINAL_PARAMETERS" category="STYLE" experimental="true" /> <BugPattern abbrev="ACEM" type="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" category="STYLE" experimental="true" /> + <BugPattern abbrev="MAC" type="MAC_MANUAL_ARRAY_COPY" category="PERFORMANCE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-10-26 04:08:21
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5479/src/com/mebigfatguy/fbcontrib/detect Added Files: ManualArrayCopy.java Log Message: new detector MAC, initial checkin --- NEW FILE: ManualArrayCopy.java --- /* * fb-contrib - Auxilliary detectors for Java programs * Copyright (C) 2005 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package com.mebigfatguy.fbcontrib.detect; import org.apache.bcel.classfile.Code; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; public class ManualArrayCopy extends BytecodeScanningDetector implements StatelessDetector { public static final int SEEN_NOTHING = 0; public static final int SEEN_ARRAY1_LOAD = 1; public static final int SEEN_ARRAY1_INDEX = 2; public static final int SEEN_ARRAY2_LOAD = 3; public static final int SEEN_ARRAY2_INDEX = 4; public static final int SEEN_ELEM_LOAD = 5; private BugReporter bugReporter; private int state; private int arrayIndexReg; private int loadInstruction; public ManualArrayCopy(BugReporter bugReporter) { this.bugReporter = bugReporter; } public Object clone() throws CloneNotSupportedException { return super.clone(); } public void visitCode(Code obj) { state = SEEN_NOTHING; super.visitCode(obj); } public void sawOpcode(int seen) { switch (state) { case SEEN_NOTHING: if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) state = SEEN_ARRAY1_LOAD; break; case SEEN_ARRAY1_LOAD: if (seen == ILOAD) { arrayIndexReg = getRegisterOperand(); state = SEEN_ARRAY1_INDEX; } else if ((seen >= ILOAD_0) && (seen <= ILOAD_3)) { arrayIndexReg = seen - ILOAD_0; state = SEEN_ARRAY1_INDEX; } else state = SEEN_NOTHING; break; case SEEN_ARRAY1_INDEX: if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) state = SEEN_ARRAY2_LOAD; else state = SEEN_NOTHING; break; case SEEN_ARRAY2_LOAD: if (seen == ILOAD) { if (arrayIndexReg == this.getRegisterOperand()) state = SEEN_ARRAY2_INDEX; else state = SEEN_NOTHING; } else if ((seen >= ILOAD_0) && (seen <= ILOAD_3)) { if (arrayIndexReg == (seen - ILOAD_0)) state = SEEN_ARRAY2_INDEX; else state = SEEN_NOTHING; } else state = SEEN_NOTHING; break; case SEEN_ARRAY2_INDEX: if ((seen == AALOAD) || (seen == BALOAD) || (seen == CALOAD) || (seen == SALOAD) || (seen == IALOAD) || (seen == LALOAD) || (seen == DALOAD) || (seen == FALOAD)) { loadInstruction = seen; state = SEEN_ELEM_LOAD; } else state = SEEN_NOTHING; break; case SEEN_ELEM_LOAD: if ((seen == AASTORE) || (seen == BASTORE) || (seen == CASTORE) || (seen == SASTORE) || (seen == IASTORE) || (seen == LASTORE) || (seen == DASTORE) || (seen == FASTORE)) { if (similarArrayInstructions(loadInstruction, seen)) { bugReporter.reportBug( new BugInstance( this, "MAC_MANUAL_ARRAY_COPY", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); } } state = SEEN_NOTHING; break; } } private boolean similarArrayInstructions(int load, int store) { if ((load == AALOAD) && (store == AASTORE)) return true; if ((load == IALOAD) && (store == IASTORE)) return true; if ((load == DALOAD) && (store == DASTORE)) return true; if ((load == LALOAD) && (store == LASTORE)) return true; if ((load == FALOAD) && (store == FASTORE)) return true; if ((load == BALOAD) && (store == BASTORE)) return true; if ((load == CALOAD) && (store == CASTORE)) return true; if ((load == SALOAD) && (store == SASTORE)) return true; return false; } } |
From: Dave B. <dbr...@us...> - 2005-10-23 05:03:30
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4011/htdocs Modified Files: index.html Log Message: doc new detectors Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- index.html 19 Oct 2005 04:43:50 -0000 1.15 +++ index.html 23 Oct 2005 05:03:21 -0000 1.16 @@ -15,6 +15,18 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> + Detectors added in current cvs<br/> + Note: These detectors are still in testing<br/> + <ul> + <li><b>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/> + 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> + </ul> + <hr/> Detectors added in v1.2.0<br/> <ul> <li><b>Parallel Lists</b><br/> |
From: Dave B. <dbr...@us...> - 2005-10-23 04:59:24
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3178/etc Modified Files: findbugs.xml messages.xml Log Message: New detector ACEM - Initial Checkin Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- messages.xml 20 Oct 2005 06:33:15 -0000 1.24 +++ messages.xml 23 Oct 2005 04:59:15 -0000 1.25 @@ -112,18 +112,6 @@ </Details> </Detector> - <Detector class="com.mebigfatguy.fbcontrib.detect.FinalParameters"> - <Details> - <![CDATA[ - <p> Looks for classes that define fields that derive from java.util.List but are used to some extent - like a set class. Because set-type operations are performed using a linear search, performance is - going to be inferior to a Set class. If this List is going to remain very small, this may not - be a problem, but if the List may grow large, performance will suffer significantly.</p> - <p>It is a slow detector</p> - ]]> - </Details> - </Detector> - <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison"> <Details> <![CDATA[ @@ -168,6 +156,29 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.FinalParameters"> + <Details> + <![CDATA[ + <p> Looks for classes that define fields that derive from java.util.List but are used to some extent + like a set class. Because set-type operations are performed using a linear search, performance is + going to be inferior to a Set class. If this List is going to remain very small, this may not + be a problem, but if the List may grow large, performance will suffer significantly.</p> + <p>It is a slow detector</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractClassEmptyMethods"> + <Details> + <![CDATA[ + <p> Looks for abstract classes that define empty methods or methods that simply throw an + exception. Since this is an abstract class, it may be cleaner to simple define this method + as abstract, so that correct subclass behaviour is enforced.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -269,18 +280,6 @@ </Details> </BugPattern> - <BugPattern type="FP_FINAL_PARAMETERS"> - <ShortDescription>method does not define a parameter as final, but could</ShortDescription> - <LongDescription>method {1} does not define a parameter as final, but could</LongDescription> - <Details> - <![CDATA[ - <p>This method correctly does not write to a parameter. To help document this, and to perhaps - help the jvm optimize the invocation of this method, you should consider defining these parameters - as final.</p> - ]]> - </Details> - </BugPattern> - <BugPattern type="LSC_LITERAL_STRING_COMPARISON"> <ShortDescription>method makes literal string comparisons passing the literal as an argument</ShortDescription> <LongDescription>method {1} makes literal string comparisons passing the literal as an argument</LongDescription> @@ -330,6 +329,30 @@ </Details> </BugPattern> + <BugPattern type="FP_FINAL_PARAMETERS"> + <ShortDescription>method does not define a parameter as final, but could</ShortDescription> + <LongDescription>method {1} does not define a parameter as final, but could</LongDescription> + <Details> + <![CDATA[ + <p>This method correctly does not write to a parameter. To help document this, and to perhaps + help the jvm optimize the invocation of this method, you should consider defining these parameters + as final.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="ACEM_ABSTRACT_CLASS_EMPTY_METHODS"> + <ShortDescription>empty method could be declared abstract</ShortDescription> + <LongDescription>empty method {1} could be declared abstract</LongDescription> + <Details> + <![CDATA[ + <p>This method is empty or merely throws an exception. Since the class it is defined in is + abstract, it may be more correct to define this method as abstract instead, so that proper + subclass behavior is enforced.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -340,10 +363,11 @@ <BugCode abbrev="UCC">Unrelated Collection Contents</BugCode> <BugCode abbrev="DRE">Declared Runtime Exception</BugCode> <BugCode abbrev="CE">Class Envy</BugCode> - <BugCode abbrev="FP">Final Parameters</BugCode> <BugCode abbrev="LSC">Literal String Comparison</BugCode> <BugCode abbrev="PCOA">Partially Constructed Object Access</BugCode> <BugCode abbrev="DLC">Dubious List Collection</BugCode> <BugCode abbrev="PL">Parallel Lists</BugCode> + <BugCode abbrev="FP">Final Parameters</BugCode> + <BugCode abbrev="ACEM">Abstract Class Empty Methods</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.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- findbugs.xml 20 Oct 2005 06:33:15 -0000 1.24 +++ findbugs.xml 23 Oct 2005 04:59:15 -0000 1.25 @@ -46,11 +46,6 @@ reports="CE_CLASS_ENVY" disabled="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.FinalParameters" - speed="fast" - reports="FP_FINAL_PARAMETERS" - disabled="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" /> @@ -66,6 +61,14 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ParallelLists" speed="fast" reports="PL_PARALLEL_LISTS" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.FinalParameters" + speed="fast" + reports="FP_FINAL_PARAMETERS" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractClassEmptyMethods" + speed="fast" + reports="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" /> <!-- BugPattern --> @@ -78,10 +81,11 @@ <BugPattern abbrev="UCC" type="UCC_UNRELATED_COLLECTION_CONTENTS" category="STYLE" /> <BugPattern abbrev="DRE" type="DRE_DECLARED_RUNTIME_EXCEPTION" category="STYLE" /> <BugPattern abbrev="CE" type="CE_CLASS_ENVY" category="STYLE" experimental="true" /> - <BugPattern abbrev="FP" type="FP_FINAL_PARAMETERS" category="STYLE" experimental="true" /> <BugPattern abbrev="LSC" type="LSC_LITERAL_STRING_COMPARISON" category="STYLE" /> <BugPattern abbrev="PCOA" type="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" category="CORRECTNESS" /> <BugPattern abbrev="DLC" type="DLC_DUBIOUS_LIST_COLLECTION" category="PERFORMANCE" /> <BugPattern abbrev="PL" type="PL_PARALLEL_LISTS" category="STYLE" /> + <BugPattern abbrev="FP" type="FP_FINAL_PARAMETERS" category="STYLE" experimental="true" /> + <BugPattern abbrev="ACEM" type="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-10-23 04:59:24
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3178/src/com/mebigfatguy/fbcontrib/detect Added Files: AbstractClassEmptyMethods.java Log Message: New detector ACEM - Initial Checkin --- NEW FILE: AbstractClassEmptyMethods.java --- /* * fb-contrib - Auxilliary detectors for Java programs * Copyright (C) 2005 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.Repository; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.ConstantString; import org.apache.bcel.classfile.JavaClass; 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.ba.ClassContext; public class AbstractClassEmptyMethods extends BytecodeScanningDetector implements StatelessDetector { public static final int SEEN_NOTHING = 0; public static final int SEEN_NEW = 1; public static final int SEEN_DUP = 2; public static final int SEEN_LDC = 3; public static final int SEEN_INVOKESPECIAL = 4; public static final int SEEN_DONE = 5; private static JavaClass EXCEPTION_CLASS; static { try { EXCEPTION_CLASS = Repository.lookupClass("java.lang.Exception"); } catch (ClassNotFoundException cnfe) { //ignore } } private BugReporter bugReporter; private String methodName; private int state; public AbstractClassEmptyMethods(BugReporter bugReporter) { this.bugReporter = bugReporter; } public Object clone() throws CloneNotSupportedException { return super.clone(); } public void visitClassContext(ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); if (cls.isAbstract()) super.visitClassContext(classContext); } public void visitMethod(Method obj) { methodName = obj.getName(); state = SEEN_NOTHING; } public void visitCode(Code obj) { if ("<init>".equals(methodName) || "<clinit>".equals(methodName)) return; super.visitCode(obj); } public void sawOpcode(int seen) { try { switch (state) { case SEEN_NOTHING: if (seen == RETURN) { bugReporter.reportBug(new BugInstance(this, "ACEM_ABSTRACT_CLASS_EMPTY_METHODS", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); state = SEEN_DONE; } else if (seen == NEW) { String newClass = getClassConstantOperand(); JavaClass exCls = Repository.lookupClass(newClass); if ((EXCEPTION_CLASS != null) && exCls.instanceOf(EXCEPTION_CLASS)) state = SEEN_NEW; else state = SEEN_DONE; } else state = SEEN_DONE; break; case SEEN_NEW: if (seen == DUP) state = SEEN_DUP; else state = SEEN_DONE; break; case SEEN_DUP: if ((seen == LDC) && (getConstantRefOperand() instanceof ConstantString)) state = SEEN_LDC; else state = SEEN_DONE; break; case SEEN_LDC: if ((seen == INVOKESPECIAL) && "<init>".equals(getNameConstantOperand())) state = SEEN_INVOKESPECIAL; else state = SEEN_DONE; break; case SEEN_INVOKESPECIAL: if (seen == ATHROW) { bugReporter.reportBug(new BugInstance("ACEM_ABSTRACT_CLASS_EMPTY_METHODS", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); } state = SEEN_DONE; break; case SEEN_DONE: break; } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); state = SEEN_DONE; } } } |
From: Dave B. <dbr...@us...> - 2005-10-23 04:59:24
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3178/samples Added Files: ACEM_Sample.java Log Message: New detector ACEM - Initial Checkin --- NEW FILE: ACEM_Sample.java --- public abstract class ACEM_Sample { public void test() { } public int test1() { throw new UnsupportedOperationException("Not implemented"); } } |
From: Dave B. <dbr...@us...> - 2005-10-20 06:33:23
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6733/etc Modified Files: findbugs.xml messages.xml Log Message: conventional wisdom says you shouldn't try to revive a bad idea, but, dag gummit, it looks like thats what i done did. Get FinalParameters working thru source line annotations Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- messages.xml 15 Oct 2005 16:34:20 -0000 1.23 +++ messages.xml 20 Oct 2005 06:33:15 -0000 1.24 @@ -119,7 +119,7 @@ like a set class. Because set-type operations are performed using a linear search, performance is going to be inferior to a Set class. If this List is going to remain very small, this may not be a problem, but if the List may grow large, performance will suffer significantly.</p> - <p>It is a fast detector</p> + <p>It is a slow detector</p> ]]> </Details> </Detector> Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- findbugs.xml 19 Oct 2005 04:22:10 -0000 1.23 +++ findbugs.xml 20 Oct 2005 06:33:15 -0000 1.24 @@ -46,12 +46,11 @@ reports="CE_CLASS_ENVY" disabled="true" /> -<!-- <Detector class="com.mebigfatguy.fbcontrib.detect.FinalParameters" speed="fast" reports="FP_FINAL_PARAMETERS" - hidden="true" /> ---> + disabled="true" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" /> |
From: Dave B. <dbr...@us...> - 2005-10-20 06:33:23
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6733/src/com/mebigfatguy/fbcontrib/detect Modified Files: FinalParameters.java Log Message: conventional wisdom says you shouldn't try to revive a bad idea, but, dag gummit, it looks like thats what i done did. Get FinalParameters working thru source line annotations Index: FinalParameters.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FinalParameters.java 1 Oct 2005 07:38:02 -0000 1.4 +++ FinalParameters.java 20 Oct 2005 06:33:15 -0000 1.5 @@ -18,7 +18,12 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; import org.apache.bcel.Constants; @@ -31,15 +36,25 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.SourceLineAnnotation; import edu.umd.cs.findbugs.StatelessDetector; +import edu.umd.cs.findbugs.ba.AnalysisContext; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.ba.SourceFile; +import edu.umd.cs.findbugs.ba.SourceFinder; public class FinalParameters extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; private Set<Integer> changedParms; + private String methodName; private int parmCount; private boolean isStatic; private boolean isAbstract; + private boolean srcInited; + private SourceLineAnnotation srcLineAnnotation; + private String[] sourceLines; + public FinalParameters(final BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -51,7 +66,19 @@ } @Override - public void visitMethod(final Method obj) { + public void visitClassContext(ClassContext classContext) { + srcInited = false; + super.visitClassContext(classContext); + } + + @Override + public void visitMethod(final Method obj) { + methodName = obj.getName(); + if ("<clinit>".equals(methodName) || "<init>".equals(methodName)) + return; + + sourceLines = getSourceLines(obj); + isStatic = (obj.getAccessFlags() & Constants.ACC_STATIC) != 0; isAbstract = (obj.getAccessFlags() & Constants.ACC_ABSTRACT) != 0; parmCount = Type.getArgumentTypes(obj.getSignature()).length; @@ -59,13 +86,76 @@ super.visitMethod(obj); } + private String[] getSourceLines(Method obj) { + + BufferedReader sourceReader = null; + + if (srcInited) + return sourceLines; + + try { + srcLineAnnotation = SourceLineAnnotation.forEntireMethod(getClassContext().getJavaClass(), obj); + if (srcLineAnnotation != null) + { + SourceFinder sourceFinder = AnalysisContext.currentAnalysisContext().getSourceFinder(); + SourceFile sourceFile = sourceFinder.findSourceFile(srcLineAnnotation.getPackageName(), srcLineAnnotation.getSourceFile()); + sourceReader = new BufferedReader(new InputStreamReader(sourceFile.getInputStream())); + + List<String> lines = new ArrayList<String>(); + String line; + while ((line = sourceReader.readLine()) != null) + lines.add(line); + sourceLines = lines.toArray(new String[lines.size()]); + } + } catch (IOException ioe) { + //noop + } + finally { + try { + if (sourceReader != null) + sourceReader.close(); + } catch (IOException ioe2) { + //noop + } + } + srcInited = true; + return sourceLines; + } + @Override public void visitCode(final Code obj) { + if (sourceLines == null) + return; + if (isAbstract) return; - + + if ("<clinit>".equals(methodName) || "<init>".equals(methodName)) + return; + + int methodStart = srcLineAnnotation.getStartLine() - 2; + int methodLine = methodStart; + String line; + while (methodLine >= 0) { + line = sourceLines[methodLine]; + if (line.indexOf(methodName) >= 0) + break; + methodLine--; + } + + if (methodLine < 0) + return; + + for (int i = methodLine; i <= methodStart; i++) { + line = sourceLines[i]; + if (line.indexOf("final") >= 0) + return; + } + changedParms = new HashSet<Integer>(); super.visitCode(obj); + + for (int i = 0; i < parmCount; i++) { if (changedParms.remove(new Integer(i))) continue; |
From: Dave B. <dbr...@us...> - 2005-10-20 04:51:40
|
Update of /cvsroot/fb-contrib/fb-contrib/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23207/lib Modified Files: bcel.jar Log Message: update to the latest svn, to pick up Comparable addition to JavaClass, so that JavaClass behaves correctly in sorted sets, et. al. Index: bcel.jar =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/lib/bcel.jar,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 Binary files /tmp/cvstkVEye and /tmp/cvsrNAcHK differ |
From: Dave B. <dbr...@us...> - 2005-10-19 04:44:01
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1528/htdocs Modified Files: index.html Log Message: update to 1.2.0 Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- index.html 5 Oct 2005 03:35:25 -0000 1.14 +++ index.html 19 Oct 2005 04:43:50 -0000 1.15 @@ -15,8 +15,7 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> - Detectors added in CVS<br/> - Note: these detectors are still in testing<br/> + Detectors added in v1.2.0<br/> <ul> <li><b>Parallel Lists</b><br/> Finds classes that maintain two or more lists or arrays that appear to share a one-to-one relationship |
From: Dave B. <dbr...@us...> - 2005-10-19 04:24:47
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31447 Modified Files: build.xml Log Message: bump to 1.2.0 Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- build.xml 17 Sep 2005 04:43:31 -0000 1.8 +++ build.xml 19 Oct 2005 04:24:37 -0000 1.9 @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="1.1.0"/> + <property name="fb-contrib.version" value="1.2.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |