fb-contrib-commit Mailing List for fb-contrib (Page 54)
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-05-02 02:24:18
|
Revision: 515 Author: dbrosius Date: 2006-05-01 19:24:14 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=515&view=rev Log Message: ----------- get ready for 2.7.0 development Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2006-05-02 02:05:26 UTC (rev 514) +++ trunk/fb-contrib/build.xml 2006-05-02 02:24:14 UTC (rev 515) @@ -19,7 +19,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="2.6.0"/> + <property name="fb-contrib.version" value="2.7.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-05-02 02:05:36
|
Revision: 514 Author: dbrosius Date: 2006-05-01 19:05:26 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=514&view=rev Log Message: ----------- Create tag v2_6_0 Added Paths: ----------- tags/v2_6_0/ Copied: tags/v2_6_0 (from rev 513, trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-05-02 02:02:16
|
Revision: 513 Author: dbrosius Date: 2006-05-01 19:02:10 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=513&view=rev Log Message: ----------- Prepare for the 2.6.0 release Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2006-05-01 02:53:42 UTC (rev 512) +++ trunk/fb-contrib/build.xml 2006-05-02 02:02:10 UTC (rev 513) @@ -19,7 +19,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="2.5.0"/> + <property name="fb-contrib.version" value="2.6.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> @@ -133,7 +133,7 @@ destdir="${javadoc.dir}" windowtitle="fb-contrib api"> <doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle> - <bottom><![CDATA[<i>Copyright © 2005 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> + <bottom><![CDATA[<i>Copyright © 2005-2006 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> </javadoc> </target> </project> \ No newline at end of file Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-05-01 02:53:42 UTC (rev 512) +++ trunk/fb-contrib/htdocs/index.html 2006-05-02 02:02:10 UTC (rev 513) @@ -46,16 +46,23 @@ <a href="javadoc/index.html">JavaDoc</a> <hr/> - <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> - Detectors added in SVN<br/> - Note: these detectors are still in testing<br/> - Also note that the svn version of fb-contrib requires FindBugs v0.9.7.<br/> - <div id="svn" style="display:block;"> + <img id="svn_image" src="flip1.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> + Detectors added in svn + <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_6_0_image" src="flip2.gif" onClick="toggleBlock('v2_6_0', 'v2_6_0_image');" align="top"/> + Detectors added in v2.6.0<br/> + Note: This version of fb-contrib requires FindBugs v0.9.7.<br/> + <div id="v2_6_0" style="display:block;"> + <ul> <li><b>[FCBL] Field could be Local</b><br/> Looks for classes that declare fields that are used in a locals-only fashion, specifically private fields that are accessed first in each method with a store vs. a load. These fields can be declared as one or more This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-05-01 02:53:50
|
Revision: 512 Author: dbrosius Date: 2006-04-30 19:53:42 -0700 (Sun, 30 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=512&view=rev Log Message: ----------- stop reporting the same bug on fields more than once Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2006-05-01 01:17:28 UTC (rev 511) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2006-05-01 02:53:42 UTC (rev 512) @@ -1,5 +1,8 @@ package com.mebigfatguy.fbcontrib.detect; +import java.util.HashSet; +import java.util.Set; + import org.apache.bcel.Constants; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; @@ -7,6 +10,7 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.ba.ClassContext; @@ -18,6 +22,7 @@ { private BugReporter bugReporter; private OpcodeStack stack; + private Set<String> checkedFields; private boolean methodReported; /** * constructs a UEC detector given the reporter to report bugs on @@ -37,10 +42,12 @@ JavaClass cls = classContext.getJavaClass(); if (cls.getMajor() >= Constants.MAJOR_1_5) { stack = new OpcodeStack(); + checkedFields = new HashSet<String>(); super.visitClassContext(classContext); } } finally { stack = null; + checkedFields = null; } } @@ -70,11 +77,11 @@ if (("java/util/Map".equals(clsName)) && ("put".equals(methodName)) && ("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;".equals(signature))) { - bug = isEnum(1); + bug = isEnum(1) && alreadyReported(2); } else if (("java/util/Set".equals(clsName)) && ("add".equals(methodName)) && ("(Ljava/lang/Object;)Z".equals(signature))) { - bug = isEnum(0); + bug = isEnum(0) && alreadyReported(1); } if (bug) { @@ -92,6 +99,14 @@ } } + /** + * returns whether the item at the stackPos location on the stack + * + * @param stackPos the position on the opstack to check + * + * @return whether the class is an enum + * @throws ClassNotFoundException if the class can not be loaded + */ private boolean isEnum(int stackPos) throws ClassNotFoundException { if (stack.getStackDepth() > stackPos) { OpcodeStack.Item item = stack.getStackItem(stackPos); @@ -100,4 +115,27 @@ } return false; } + + /** + * returns whether the collection has already been reported on + * + * @param stackPos the position on the opstack to check + * + * @return whether the collection has already been reported. + */ + private boolean alreadyReported(int stackPos) { + if (stack.getStackDepth() > stackPos) { + OpcodeStack.Item item = stack.getStackItem(stackPos); + FieldAnnotation fa = item.getField(); + if (fa == null) + return true; + else { + String fieldName = fa.getFieldName(); + boolean checked = checkedFields.contains(fieldName); + checkedFields.add(fieldName); + return !checked; + } + } + return false; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-05-01 01:17:38
|
Revision: 511 Author: dbrosius Date: 2006-04-30 18:17:28 -0700 (Sun, 30 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=511&view=rev Log Message: ----------- reimplement using OpcodeStack Modified Paths: -------------- trunk/fb-contrib/samples/UEC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java Modified: trunk/fb-contrib/samples/UEC_Sample.java =================================================================== --- trunk/fb-contrib/samples/UEC_Sample.java 2006-04-29 23:38:06 UTC (rev 510) +++ trunk/fb-contrib/samples/UEC_Sample.java 2006-05-01 01:17:28 UTC (rev 511) @@ -8,12 +8,23 @@ public class UEC_Sample { - enum Suite { Spades, Hearts, Clubs, Diamonds }; + public enum Suite { Spades, Hearts, Clubs, Diamonds }; private Set<Suite> wildSuites = new HashSet<Suite>(); private EnumSet<Suite> eWildSuites = EnumSet.noneOf(Suite.class); - public Map<Suite, Integer> deal() { + public UEC_Sample() + { + wildSuites.add(Suite.Spades); + } + + public UEC_Sample(Suite s) + { + wildSuites.add(s); + } + + public Map<Suite, Integer> deal() + { Map<Suite, Integer> hand = new HashMap<Suite, Integer>(); hand.put(Suite.Spades, new Integer(10)); hand.put(Suite.Hearts, new Integer(9)); @@ -21,7 +32,8 @@ return hand; } - public EnumMap<Suite, Integer> eDeal() { + public EnumMap<Suite, Integer> eDeal() + { EnumMap<Suite, Integer> hand = new EnumMap(Suite.class); hand.put(Suite.Spades, new Integer(10)); hand.put(Suite.Hearts, new Integer(9)); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2006-04-29 23:38:06 UTC (rev 510) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2006-05-01 01:17:28 UTC (rev 511) @@ -7,6 +7,7 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.ba.ClassContext; /** @@ -14,13 +15,9 @@ * more efficient to use EnumSet or EnumMap. It is a jdk1.5 only detector. */ public class UseEnumCollections extends BytecodeScanningDetector -{ - private static final int SEEN_NOTHING = 0; - private static final int SEEN_BIPUSH = 1; - private static final int SEEN_NEWINT = 2; - +{ private BugReporter bugReporter; - private int state; + private OpcodeStack stack; private boolean methodReported; /** * constructs a UEC detector given the reporter to report bugs on @@ -31,7 +28,7 @@ } /** - * implements the visitor to check that the class is greater or equal than 1.5 + * implements the visitor to check that the class is greater or equal than 1.5, and set and clear the stack * * @param classContext the context object for the currently parsed class */ @@ -39,10 +36,11 @@ try { JavaClass cls = classContext.getJavaClass(); if (cls.getMajor() >= Constants.MAJOR_1_5) { + stack = new OpcodeStack(); super.visitClassContext(classContext); } } finally { - + stack = null; } } @@ -52,57 +50,54 @@ * @param obj the context object for the currently parsed method */ public void visitMethod(Method obj) { - state = SEEN_NOTHING; + stack.resetForMethodEntry(this); methodReported = false; super.visitMethod(obj); } public void sawOpcode(int seen) { - if (methodReported) - return; - - switch (state) { - case SEEN_NOTHING: - if (seen == BIPUSH) - state = SEEN_BIPUSH; - break; + try { - case SEEN_BIPUSH: - if ((seen == INVOKESPECIAL) - && ("java/lang/Integer".equals(getClassConstantOperand()) - && ("<init>".equals(getNameConstantOperand()) - && ("(I)V".equals(getSigConstantOperand()))))) - state = SEEN_NEWINT; - else - state = SEEN_NOTHING; - break; - - case SEEN_NEWINT: + stack.mergeJumps(this); + if (methodReported) + return; + + if (seen == INVOKEINTERFACE) { boolean bug = false; - if (seen == INVOKEINTERFACE) { - String clsName = getClassConstantOperand(); - String methodName = getNameConstantOperand(); - String signature = getSigConstantOperand(); - if (("java/util/Map".equals(clsName)) - && ("put".equals(methodName)) - && ("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;".equals(signature))) { - bug = true; - } else if (("java/util/Set".equals(clsName)) - && ("add".equals(methodName)) - && ("(Ljava/lang/Object;)Ljava/lang/Object;".equals(signature))) { - bug = true; - } - - if (bug) { - bugReporter.reportBug(new BugInstance(this, "UEC_USE_ENUM_COLLECTIONS", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - methodReported = true; - } + String clsName = getClassConstantOperand(); + String methodName = getNameConstantOperand(); + String signature = getSigConstantOperand(); + if (("java/util/Map".equals(clsName)) + && ("put".equals(methodName)) + && ("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;".equals(signature))) { + bug = isEnum(1); + } else if (("java/util/Set".equals(clsName)) + && ("add".equals(methodName)) + && ("(Ljava/lang/Object;)Z".equals(signature))) { + bug = isEnum(0); } - state = SEEN_NOTHING; - break; + + if (bug) { + bugReporter.reportBug(new BugInstance(this, "UEC_USE_ENUM_COLLECTIONS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + methodReported = true; + } + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } finally { + stack.sawOpcode(this, seen); } } + + private boolean isEnum(int stackPos) throws ClassNotFoundException { + if (stack.getStackDepth() > stackPos) { + OpcodeStack.Item item = stack.getStackItem(stackPos); + if (item.getSignature().charAt(0) == 'L') + return (item.getJavaClass().isEnum()); + } + return false; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-29 23:38:13
|
Revision: 510 Author: dbrosius Date: 2006-04-29 16:38:06 -0700 (Sat, 29 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=510&view=rev Log Message: ----------- syntax Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-29 23:22:15 UTC (rev 509) +++ trunk/fb-contrib/etc/messages.xml 2006-04-29 23:38:06 UTC (rev 510) @@ -1156,7 +1156,7 @@ <Details> <![CDATA[ <p>This method sets a Components explicitly foreground or background color which may - cause difficulty with people with visions problems from using this application. + cause difficulty with people with vision problems from using this application. Colors should be allowed to be set from the operating system.</p> ]]> </Details> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-29 23:22:26
|
Revision: 509 Author: dbrosius Date: 2006-04-29 16:22:15 -0700 (Sat, 29 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=509&view=rev Log Message: ----------- new S508C bugpattern for setting explicit colors for controls Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-29 04:17:26 UTC (rev 508) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-29 23:22:15 UTC (rev 509) @@ -185,7 +185,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance" speed="fast" - reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE,S508C_NON_ACCESSIBLE_JCOMPONENT" /> + reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE,S508C_NON_ACCESSIBLE_JCOMPONENT,S508C_SET_COMP_COLOR" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UseEnumCollections" speed="fast" @@ -239,5 +239,6 @@ <BugPattern abbrev="S508C" type="S508C_NO_SETLABELFOR" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NO_SETSIZE" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NON_ACCESSIBLE_JCOMPONENT" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="S508C" type="S508C_SET_COMP_COLOR" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="UEC" type="UEC_USE_ENUM_COLLECTIONS" category="PERFORMANCE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-29 04:17:26 UTC (rev 508) +++ trunk/fb-contrib/etc/messages.xml 2006-04-29 23:22:15 UTC (rev 509) @@ -1150,6 +1150,18 @@ </Details> </BugPattern> + <BugPattern type="S508C_SET_COMP_COLOR"> + <ShortDescription>Method explicitly sets the color of a Component</ShortDescription> + <LongDescription>Method {1} Method explicitly sets the color of a Component</LongDescription> + <Details> + <![CDATA[ + <p>This method sets a Components explicitly foreground or background color which may + cause difficulty with people with visions problems from using this application. + Colors should be allowed to be set from the operating system.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="UEC_USE_ENUM_COLLECTIONS"> <ShortDescription>Class uses an ordinary set or map with an enum class as the key</ShortDescription> <LongDescription>Class {0} uses an ordinary set or map with an enum class as the key</LongDescription> Modified: trunk/fb-contrib/samples/S508C_Sample.java =================================================================== --- trunk/fb-contrib/samples/S508C_Sample.java 2006-04-29 04:17:26 UTC (rev 508) +++ trunk/fb-contrib/samples/S508C_Sample.java 2006-04-29 23:22:15 UTC (rev 509) @@ -1,3 +1,4 @@ +import java.awt.Color; import java.awt.Container; import javax.swing.JComponent; @@ -15,6 +16,8 @@ cp.add(fLabel); JLabel lLabel = new JLabel("there"); + lLabel.setBackground(new Color(255, 0, 0)); + lLabel.setForeground(new Color(255, 255, 100)); cp.add(lLabel); cp.add(c); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-29 04:17:26 UTC (rev 508) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-29 23:22:15 UTC (rev 509) @@ -28,6 +28,7 @@ public class Section508Compliance extends BytecodeScanningDetector { private static JavaClass windowClass; + private static JavaClass componentClass; private static JavaClass jcomponentClass; private static JavaClass accessibleClass; static { @@ -37,6 +38,11 @@ windowClass = null; } try { + componentClass = Repository.lookupClass("javax/awt/Component"); + } catch (ClassNotFoundException cnfe) { + componentClass = null; + } + try { jcomponentClass = Repository.lookupClass("javax/swing/JComponent"); } catch (ClassNotFoundException cnfe) { jcomponentClass = null; @@ -191,6 +197,22 @@ .addSourceLine(this)); } } + } + + if ("setBackground".equals(methodName) + || "setForeground".equals(methodName)) { + int argCount = Type.getArgumentTypes(getSigConstantOperand()).length; + if (stack.getStackDepth() > argCount) { + OpcodeStack.Item item = stack.getStackItem(argCount); + JavaClass cls = item.getJavaClass(); + if (((jcomponentClass != null) && cls.instanceOf(jcomponentClass)) + || ((componentClass != null) && cls.instanceOf(componentClass))) { + bugReporter.reportBug(new BugInstance(this, "S508C_SET_COMP_COLOR", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } } } catch (ClassNotFoundException cnfe) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-29 04:17:31
|
Revision: 508 Author: dbrosius Date: 2006-04-28 21:17:26 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=508&view=rev Log Message: ----------- update findbugs requirements Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-04-29 04:11:15 UTC (rev 507) +++ trunk/fb-contrib/htdocs/index.html 2006-04-29 04:17:26 UTC (rev 508) @@ -49,7 +49,7 @@ <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> Detectors added in SVN<br/> Note: these detectors are still in testing<br/> - Also note that the svn version of fb-contrib requires the cvs version of FindBugs.<br/> + Also note that the svn version of fb-contrib requires FindBugs v0.9.7.<br/> <div id="svn" style="display:block;"> <ul> <li><b>[BSB] Bloated Synchronized Block</b><br/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-29 04:11:23
|
Revision: 507 Author: dbrosius Date: 2006-04-28 21:11:15 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=507&view=rev Log Message: ----------- doc UEC Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-04-29 04:03:49 UTC (rev 506) +++ trunk/fb-contrib/htdocs/index.html 2006-04-29 04:11:15 UTC (rev 507) @@ -60,17 +60,20 @@ Looks for classes that declare fields that are used in a locals-only fashion, specifically private fields that are accessed first in each method with a store vs. a load. These fields can be declared as one or more locals.</li> - <li><b>[NOS] Non Owned Synchronization</b><br> + <li><b>[NOS] Non Owned Synchronization</b><br/> looks for methods that synchronize on variables that are not owned by the current class. Doing this causes confusion when two classes use the same variable for their own synchronization purposes. For cleanest separation of interests, only synchronize on private fields of the class. Note that 'this' is not owned by the current class and synchronization on 'this' should be avoided as well.</li> - <li><b>[S508C] Section 508 Compliance</b><br> + <li><b>[S508C] Section 508 Compliance</b><br/> looks for classes and methods that do not support coding styles that allow Accessibility software to make full use of the gui for people with visual impediments. Commonly known as 'Section 508 Compliance' this detector finds a varied list of issues that hamper screen readers, - and make color/size adjustments difficult.</b><br> + and make color/size adjustments difficult.</li> + <li><b>[UEC] Use Enum Collections</b><br/> + looks for uses of sets or maps where the key is an enum. In these cases, it is + more efficient to use EnumSet or EnumMap. It is a jdk1.5 only detector.</li> </ul> </div> <hr/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-29 04:03:57
|
Revision: 506 Author: dbrosius Date: 2006-04-28 21:03:49 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=506&view=rev Log Message: ----------- fix javadoc Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2006-04-28 03:07:55 UTC (rev 505) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java 2006-04-29 04:03:49 UTC (rev 506) @@ -50,9 +50,9 @@ } /** - * clone this detector so that it can be a StatelessDetector + * implements the visitor to reset the state * - * @return a clone of this object + * @param obj the context object of the currently parsed code block */ @Override public void visitCode(Code obj) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-28 03:08:22
|
Revision: 505 Author: dbrosius Date: 2006-04-27 20:07:55 -0700 (Thu, 27 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=505&view=rev Log Message: ----------- initial checkin - new UEC Detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Added Paths: ----------- trunk/fb-contrib/samples/UEC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-27 03:27:09 UTC (rev 504) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-28 03:07:55 UTC (rev 505) @@ -187,6 +187,10 @@ speed="fast" reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE,S508C_NON_ACCESSIBLE_JCOMPONENT" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.UseEnumCollections" + speed="fast" + reports="UEC_USE_ENUM_COLLECTIONS" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -235,4 +239,5 @@ <BugPattern abbrev="S508C" type="S508C_NO_SETLABELFOR" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NO_SETSIZE" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NON_ACCESSIBLE_JCOMPONENT" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="UEC" type="UEC_USE_ENUM_COLLECTIONS" category="PERFORMANCE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-27 03:27:09 UTC (rev 504) +++ trunk/fb-contrib/etc/messages.xml 2006-04-28 03:07:55 UTC (rev 505) @@ -537,6 +537,15 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.UseEnumCollections"> + <Details> + <![CDATA[ + <p>looks for use of sets and maps using enums. It is more efficient to use EnumSet or EnumMap</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1141,6 +1150,17 @@ </Details> </BugPattern> + <BugPattern type="UEC_USE_ENUM_COLLECTIONS"> + <ShortDescription>Class uses an ordinary set or map with an enum class as the key</ShortDescription> + <LongDescription>Class {0} uses an ordinary set or map with an enum class as the key</LongDescription> + <Details> + <![CDATA[ + <p>This class uses an ordinary set or map collection and uses an enum class as the key type. + It is better performant to use the jdk 1.5 EnumSet or EnumMap classes.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1186,4 +1206,5 @@ <BugCode abbrev="NOS">Non Owned Synchronization</BugCode> <BugCode abbrev="NRTL">Non Recycleable Taglib</BugCode> <BugCode abbrev="S508C">Section 508 Compliance Violations</BugCode> + <BugCode abbrev="UEC">Use Enum Collections</BugCode> </MessageCollection> \ No newline at end of file Added: trunk/fb-contrib/samples/UEC_Sample.java =================================================================== --- trunk/fb-contrib/samples/UEC_Sample.java (rev 0) +++ trunk/fb-contrib/samples/UEC_Sample.java 2006-04-28 03:07:55 UTC (rev 505) @@ -0,0 +1,31 @@ +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + + +public class UEC_Sample +{ + enum Suite { Spades, Hearts, Clubs, Diamonds }; + + private Set<Suite> wildSuites = new HashSet<Suite>(); + private EnumSet<Suite> eWildSuites = EnumSet.noneOf(Suite.class); + + public Map<Suite, Integer> deal() { + Map<Suite, Integer> hand = new HashMap<Suite, Integer>(); + hand.put(Suite.Spades, new Integer(10)); + hand.put(Suite.Hearts, new Integer(9)); + + return hand; + } + + public EnumMap<Suite, Integer> eDeal() { + EnumMap<Suite, Integer> hand = new EnumMap(Suite.class); + hand.put(Suite.Spades, new Integer(10)); + hand.put(Suite.Hearts, new Integer(9)); + + return hand; + } +} Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2006-04-28 03:07:55 UTC (rev 505) @@ -0,0 +1,108 @@ +package com.mebigfatguy.fbcontrib.detect; + +import org.apache.bcel.Constants; +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.ba.ClassContext; + +/** + * looks for uses of sets or maps where the key is an enum. In these cases, it is + * more efficient to use EnumSet or EnumMap. It is a jdk1.5 only detector. + */ +public class UseEnumCollections extends BytecodeScanningDetector +{ + private static final int SEEN_NOTHING = 0; + private static final int SEEN_BIPUSH = 1; + private static final int SEEN_NEWINT = 2; + + private BugReporter bugReporter; + private int state; + private boolean methodReported; + /** + * constructs a UEC detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public UseEnumCollections(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to check that the class is greater or equal than 1.5 + * + * @param classContext the context object for the currently parsed class + */ + public void visitClassContext(ClassContext classContext) { + try { + JavaClass cls = classContext.getJavaClass(); + if (cls.getMajor() >= Constants.MAJOR_1_5) { + super.visitClassContext(classContext); + } + } finally { + + } + } + + /** + * implements the visitor to reset the state + * + * @param obj the context object for the currently parsed method + */ + public void visitMethod(Method obj) { + state = SEEN_NOTHING; + methodReported = false; + super.visitMethod(obj); + } + + public void sawOpcode(int seen) { + if (methodReported) + return; + + switch (state) { + case SEEN_NOTHING: + if (seen == BIPUSH) + state = SEEN_BIPUSH; + break; + + case SEEN_BIPUSH: + if ((seen == INVOKESPECIAL) + && ("java/lang/Integer".equals(getClassConstantOperand()) + && ("<init>".equals(getNameConstantOperand()) + && ("(I)V".equals(getSigConstantOperand()))))) + state = SEEN_NEWINT; + else + state = SEEN_NOTHING; + break; + + case SEEN_NEWINT: + boolean bug = false; + if (seen == INVOKEINTERFACE) { + String clsName = getClassConstantOperand(); + String methodName = getNameConstantOperand(); + String signature = getSigConstantOperand(); + if (("java/util/Map".equals(clsName)) + && ("put".equals(methodName)) + && ("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;".equals(signature))) { + bug = true; + } else if (("java/util/Set".equals(clsName)) + && ("add".equals(methodName)) + && ("(Ljava/lang/Object;)Ljava/lang/Object;".equals(signature))) { + bug = true; + } + + if (bug) { + bugReporter.reportBug(new BugInstance(this, "UEC_USE_ENUM_COLLECTIONS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + methodReported = true; + } + } + state = SEEN_NOTHING; + break; + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-27 03:27:15
|
Revision: 504 Author: dbrosius Date: 2006-04-26 20:27:09 -0700 (Wed, 26 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=504&view=rev Log Message: ----------- don't report ISB's caused by trinaries inserting a second StringBuffer inside a parent string buffer Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2006-04-25 20:52:37 UTC (rev 503) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2006-04-27 03:27:09 UTC (rev 504) @@ -24,7 +24,6 @@ import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; -import edu.umd.cs.findbugs.OpcodeStack.Item; /** * looks for appending strings inside of calls to StringBuffer or StringBuilder append. @@ -67,22 +66,35 @@ || "java/lang/StringBuilder".equals(calledClass)) && "<init>".equals(getNameConstantOperand()) && "()V".equals(getSigConstantOperand())) { - if (opStack.getStackDepth() > 2) { - Item itm = opStack.getStackItem(2); - String signature = itm.getSignature(); - if ("Ljava/lang/StringBuffer;".equals(signature) - || "Ljava/lang/StringBuilder;".equals(signature)) { - bugReporter.reportBug( - new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } + OpcodeStack.Item itm = getStringBufferItemAt(2); + if ((itm != null) && (itm.getUserValue() == null)) { + bugReporter.reportBug( + new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); } } + } else if (seen == GOTO) { + OpcodeStack.Item itm = getStringBufferItemAt(1); + if (itm != null) + itm.setUserValue(Boolean.TRUE); } } finally { opStack.sawOpcode(this, seen); } } + + private OpcodeStack.Item getStringBufferItemAt(int depth) { + if (opStack.getStackDepth() > depth) { + OpcodeStack.Item itm = opStack.getStackItem(depth); + String signature = itm.getSignature(); + if ("Ljava/lang/StringBuffer;".equals(signature) + || "Ljava/lang/StringBuilder;".equals(signature)) { + return itm; + } + } + + return null; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-25 20:52:42
|
Revision: 503 Author: dbrosius Date: 2006-04-25 13:52:37 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=503&view=rev Log Message: ----------- doc S508C Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-04-25 17:35:42 UTC (rev 502) +++ trunk/fb-contrib/htdocs/index.html 2006-04-25 20:52:37 UTC (rev 503) @@ -66,6 +66,11 @@ for their own synchronization purposes. For cleanest separation of interests, only synchronize on private fields of the class. Note that 'this' is not owned by the current class and synchronization on 'this' should be avoided as well.</li> + <li><b>[S508C] Section 508 Compliance</b><br> + looks for classes and methods that do not support coding styles that allow Accessibility + software to make full use of the gui for people with visual impediments. Commonly known as + 'Section 508 Compliance' this detector finds a varied list of issues that hamper screen readers, + and make color/size adjustments difficult.</b><br> </ul> </div> <hr/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-25 17:35:57
|
Revision: 502 Author: dbrosius Date: 2006-04-25 10:35:42 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=502&view=rev Log Message: ----------- add check for JComponent derived classes that don't implement the Accessible interface Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-25 17:19:19 UTC (rev 501) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-25 17:35:42 UTC (rev 502) @@ -185,7 +185,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance" speed="fast" - reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE" /> + reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE,S508C_NON_ACCESSIBLE_JCOMPONENT" /> <!-- BugPattern --> @@ -234,4 +234,5 @@ <BugPattern abbrev="S508C" type="S508C_NULL_LAYOUT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NO_SETLABELFOR" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NO_SETSIZE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="S508C" type="S508C_NON_ACCESSIBLE_JCOMPONENT" category="CORRECTNESS" experimental="true"/> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-25 17:19:19 UTC (rev 501) +++ trunk/fb-contrib/etc/messages.xml 2006-04-25 17:35:42 UTC (rev 502) @@ -1129,6 +1129,18 @@ </Details> </BugPattern> + <BugPattern type="S508C_NON_ACCESSIBLE_JCOMPONENT"> + <ShortDescription>Class extends JComponent but does not implement Accessible interface</ShortDescription> + <LongDescription>Class {0} extends JComponent but does not implement Accessible interface</LongDescription> + <Details> + <![CDATA[ + <p>This class extends the JComponent gui control but does not implement the Accessibility interface. + This makes this control unable to be processed by screen readers, etc, for people with reading/vision + difficulties</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> Modified: trunk/fb-contrib/samples/S508C_Sample.java =================================================================== --- trunk/fb-contrib/samples/S508C_Sample.java 2006-04-25 17:19:19 UTC (rev 501) +++ trunk/fb-contrib/samples/S508C_Sample.java 2006-04-25 17:35:42 UTC (rev 502) @@ -1,11 +1,13 @@ import java.awt.Container; +import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; public class S508C_Sample extends JFrame { private JLabel fLabel = new JLabel("Hello"); + private JComponent c = new MyComponent(); public S508C_Sample() { Container cp = getContentPane(); @@ -14,7 +16,13 @@ cp.add(fLabel); JLabel lLabel = new JLabel("there"); cp.add(lLabel); + cp.add(c); setSize(300, 200); } } + +class MyComponent extends JComponent +{ + +} Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-25 17:19:19 UTC (rev 501) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-25 17:35:42 UTC (rev 502) @@ -28,12 +28,24 @@ public class Section508Compliance extends BytecodeScanningDetector { private static JavaClass windowClass; + private static JavaClass jcomponentClass; + private static JavaClass accessibleClass; static { try { windowClass = Repository.lookupClass("java/awt/Window"); } catch (ClassNotFoundException cnfe) { windowClass = null; } + try { + jcomponentClass = Repository.lookupClass("javax/swing/JComponent"); + } catch (ClassNotFoundException cnfe) { + jcomponentClass = null; + } + try { + accessibleClass = Repository.lookupClass("javax.accessibility.Accessible"); + } catch (ClassNotFoundException cnfe) { + accessibleClass = null; + } } private BugReporter bugReporter; private OpcodeStack stack; @@ -56,6 +68,16 @@ @Override public void visitClassContext(ClassContext classContext) { try { + if ((jcomponentClass != null) && (accessibleClass != null)) { + JavaClass cls = classContext.getJavaClass(); + if (cls.instanceOf(jcomponentClass)) { + if (!cls.implementationOf(accessibleClass)) { + bugReporter.reportBug(new BugInstance(this, "S508C_NON_ACCESSIBLE_JCOMPONENT", NORMAL_PRIORITY) + .addClass(cls)); + } + } + } + stack = new OpcodeStack(); fieldLabels = new HashSet<FieldAnnotation>(); localLabels = new HashMap<Integer, SourceLineAnnotation>(); @@ -65,6 +87,8 @@ .addClass(this) .addField(fa)); } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); } finally { stack = null; fieldLabels = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-25 17:19:24
|
Revision: 501 Author: dbrosius Date: 2006-04-25 10:19:19 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=501&view=rev Log Message: ----------- fix setSize check Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-23 02:00:31 UTC (rev 500) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-25 17:19:19 UTC (rev 501) @@ -155,18 +155,16 @@ } } } - } else if ("java/awt/Component".equals(className)) { - if ("setSize".equals(methodName)) { - int argCount = Type.getArgumentTypes(getSigConstantOperand()).length; - if ((windowClass != null) && (stack.getStackDepth() > argCount)) { - OpcodeStack.Item item = stack.getStackItem(argCount); - JavaClass cls = item.getJavaClass(); - if (cls.instanceOf(windowClass)) { - bugReporter.reportBug(new BugInstance(this, "S508C_NO_SETSIZE", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } + } else if ("setSize".equals(methodName)) { + int argCount = Type.getArgumentTypes(getSigConstantOperand()).length; + if ((windowClass != null) && (stack.getStackDepth() > argCount)) { + OpcodeStack.Item item = stack.getStackItem(argCount); + JavaClass cls = item.getJavaClass(); + if (cls.instanceOf(windowClass)) { + bugReporter.reportBug(new BugInstance(this, "S508C_NO_SETSIZE", 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-04-23 02:00:40
|
Revision: 500 Author: dbrosius Date: 2006-04-22 19:00:31 -0700 (Sat, 22 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=500&view=rev Log Message: ----------- add setSize checks for Windows Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-23 01:39:07 UTC (rev 499) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-23 02:00:31 UTC (rev 500) @@ -185,7 +185,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance" speed="fast" - reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR" /> + reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE" /> <!-- BugPattern --> @@ -233,4 +233,5 @@ <BugPattern abbrev="NRTL" type="NRTL_NON_RECYCLEABLE_TAG_LIB" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NULL_LAYOUT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NO_SETLABELFOR" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="S508C" type="S508C_NO_SETSIZE" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-23 01:39:07 UTC (rev 499) +++ trunk/fb-contrib/etc/messages.xml 2006-04-23 02:00:31 UTC (rev 500) @@ -1117,6 +1117,18 @@ </Details> </BugPattern> + <BugPattern type="S508C_NO_SETSIZE"> + <ShortDescription>Window sets size manually, and doesn't use pack</ShortDescription> + <LongDescription>Window sets size manually, and doesn't use pack</LongDescription> + <Details> + <![CDATA[ + <p>This class creates a window, and sizes the window using setSize. It is better + to handle font size changes to use the pack method. + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-23 01:39:07 UTC (rev 499) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-23 02:00:31 UTC (rev 500) @@ -5,8 +5,11 @@ import java.util.Map; import java.util.Set; +import org.apache.bcel.Repository; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -24,6 +27,14 @@ */ public class Section508Compliance extends BytecodeScanningDetector { + private static JavaClass windowClass; + static { + try { + windowClass = Repository.lookupClass("java/awt/Window"); + } catch (ClassNotFoundException cnfe) { + windowClass = null; + } + } private BugReporter bugReporter; private OpcodeStack stack; private Set<FieldAnnotation> fieldLabels; @@ -144,8 +155,24 @@ } } } + } else if ("java/awt/Component".equals(className)) { + if ("setSize".equals(methodName)) { + int argCount = Type.getArgumentTypes(getSigConstantOperand()).length; + if ((windowClass != null) && (stack.getStackDepth() > argCount)) { + OpcodeStack.Item item = stack.getStackItem(argCount); + JavaClass cls = item.getJavaClass(); + if (cls.instanceOf(windowClass)) { + bugReporter.reportBug(new BugInstance(this, "S508C_NO_SETSIZE", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } } } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); } 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-04-23 01:39:16
|
Revision: 499 Author: dbrosius Date: 2006-04-22 18:39:07 -0700 (Sat, 22 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=499&view=rev Log Message: ----------- more checks - far from complete Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-23 00:22:03 UTC (rev 498) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-23 01:39:07 UTC (rev 499) @@ -185,7 +185,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance" speed="fast" - reports="S508C_NULL_LAYOUT" /> + reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR" /> <!-- BugPattern --> @@ -232,4 +232,5 @@ <BugPattern abbrev="NOS" type="NOS_NON_OWNED_SYNCHRONIZATION" category="STYLE" experimental="true" /> <BugPattern abbrev="NRTL" type="NRTL_NON_RECYCLEABLE_TAG_LIB" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NULL_LAYOUT" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="S508C" type="S508C_NO_SETLABELFOR" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-23 00:22:03 UTC (rev 498) +++ trunk/fb-contrib/etc/messages.xml 2006-04-23 01:39:07 UTC (rev 499) @@ -1105,6 +1105,18 @@ </Details> </BugPattern> + <BugPattern type="S508C_NO_SETLABELFOR"> + <ShortDescription>JLabel doesn't specify what it's labeling</ShortDescription> + <LongDescription>JLabel doesn't specify what it's labeling</LongDescription> + <Details> + <![CDATA[ + <p>This class uses JLabels that do not specify what fields are being labeled. + This hampers screen readers from given appropriate feed back to users. + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> Modified: trunk/fb-contrib/samples/S508C_Sample.java =================================================================== --- trunk/fb-contrib/samples/S508C_Sample.java 2006-04-23 00:22:03 UTC (rev 498) +++ trunk/fb-contrib/samples/S508C_Sample.java 2006-04-23 01:39:07 UTC (rev 499) @@ -1,11 +1,20 @@ import java.awt.Container; import javax.swing.JFrame; +import javax.swing.JLabel; public class S508C_Sample extends JFrame { + private JLabel fLabel = new JLabel("Hello"); + public S508C_Sample() { Container cp = getContentPane(); cp.setLayout(null); + + cp.add(fLabel); + JLabel lLabel = new JLabel("there"); + cp.add(lLabel); + + setSize(300, 200); } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-23 00:22:03 UTC (rev 498) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-23 01:39:07 UTC (rev 499) @@ -1,6 +1,8 @@ package com.mebigfatguy.fbcontrib.detect; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; import org.apache.bcel.classfile.Code; @@ -11,7 +13,9 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.SourceLineAnnotation; import edu.umd.cs.findbugs.ba.ClassContext; /** @@ -22,8 +26,8 @@ { private BugReporter bugReporter; private OpcodeStack stack; - private Set<String> fieldLabels; - private Set<Integer> localLabels; + private Set<FieldAnnotation> fieldLabels; + private Map<Integer, SourceLineAnnotation> localLabels; /** * constructs a S508C detector given the reporter to report bugs on @@ -33,14 +37,6 @@ this.bugReporter = bugReporter; } - @Override - public void visitField(Field obj) { - String fieldSig = obj.getSignature(); - if ("java/awt/Label".equals(fieldSig) || "javax/swing/JLabel".equals(fieldSig)) { - fieldLabels.add(obj.getName()); - } - } - /** * implements the visitor to create and clear the stack * @@ -50,9 +46,14 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); - fieldLabels = new HashSet<String>(); - localLabels = new HashSet<Integer>(); + fieldLabels = new HashSet<FieldAnnotation>(); + localLabels = new HashMap<Integer, SourceLineAnnotation>(); super.visitClassContext(classContext); + for (FieldAnnotation fa : fieldLabels) { + bugReporter.reportBug(new BugInstance(this, "S508C_NO_SETLABELFOR", NORMAL_PRIORITY) + .addClass(this) + .addField(fa)); + } } finally { stack = null; fieldLabels = null; @@ -61,6 +62,20 @@ } /** + * looks for fields that are JLabels and stores them in a set + * + * @param obj the field object of the current field + */ + @Override + public void visitField(Field obj) { + String fieldSig = obj.getSignature(); + if ("Ljavax/swing/JLabel;".equals(fieldSig)) { + FieldAnnotation fa = FieldAnnotation.fromVisitedField(this); + fieldLabels.add(fa); + } + } + + /** * implements the visitor to reset the stack * * @param obj the context object for the currently visited code block @@ -70,6 +85,16 @@ stack.resetForMethodEntry(this); localLabels.clear(); super.visitCode(obj); + for (SourceLineAnnotation sla : localLabels.values()) { + BugInstance bug = new BugInstance(this, "S508C_NO_SETLABELFOR", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this); + + if (sla != null) + bug.addSourceLine(sla); + + bugReporter.reportBug(bug); + } } /** @@ -82,7 +107,13 @@ try { stack.mergeJumps(this); if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { - int reg = RegisterUtils.getAStoreReg(this, seen); + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if ("Ljavax/swing/JLabel;".equals(item.getSignature())) { + int reg = RegisterUtils.getAStoreReg(this, seen); + localLabels.put(new Integer(reg), SourceLineAnnotation.fromVisitedInstruction(this)); + } + } } else if (seen == INVOKEVIRTUAL) { String className = getClassConstantOperand(); String methodName = getNameConstantOperand(); @@ -98,6 +129,21 @@ .addSourceLine(this)); } } + } else if ("javax/swing/JLabel".equals(className)) { + if ("setLabelFor".equals(methodName)) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item item = stack.getStackItem(1); + FieldAnnotation fa = item.getField(); + if (fa != null) + fieldLabels.remove(fa.getFieldName()); + else { + int reg = item.getRegisterNumber(); + if (reg >= 0) { + localLabels.remove(new Integer(reg)); + } + } + } + } } } } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-23 00:22:18
|
Revision: 498 Author: dbrosius Date: 2006-04-22 17:22:03 -0700 (Sat, 22 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=498&view=rev Log Message: ----------- Initial checkin - S508C detector - very premature Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Added Paths: ----------- trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-22 19:20:11 UTC (rev 497) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-23 00:22:03 UTC (rev 498) @@ -183,6 +183,10 @@ speed="fast" reports="NRTL_NON_RECYCLEABLE_TAG_LIBS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance" + speed="fast" + reports="S508C_NULL_LAYOUT" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -227,4 +231,5 @@ <BugPattern abbrev="FCBL" type="FCBL_FIELD_COULD_BE_LOCAL" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="NOS" type="NOS_NON_OWNED_SYNCHRONIZATION" category="STYLE" experimental="true" /> <BugPattern abbrev="NRTL" type="NRTL_NON_RECYCLEABLE_TAG_LIB" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="S508C" type="S508C_NULL_LAYOUT" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-22 19:20:11 UTC (rev 497) +++ trunk/fb-contrib/etc/messages.xml 2006-04-23 00:22:03 UTC (rev 498) @@ -527,6 +527,16 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance"> + <Details> + <![CDATA[ + <p>looks for violation of Section 508, Accessibility for People with disabilities Act. + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1082,6 +1092,19 @@ </Details> </BugPattern> + <BugPattern type="S508C_NULL_LAYOUT"> + <ShortDescription>Gui uses absolute layout</ShortDescription> + <LongDescription>Gui {0} uses absolute layout</LongDescription> + <Details> + <![CDATA[ + <p>This class passes null to setLayout, which specifies that components are + to be laid out using absolute coordinates. This makes making changes for + font sizes, etc, difficult as items will not reposition + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1126,4 +1149,5 @@ <BugCode abbrev="FCBL">Field Could Be Local</BugCode> <BugCode abbrev="NOS">Non Owned Synchronization</BugCode> <BugCode abbrev="NRTL">Non Recycleable Taglib</BugCode> + <BugCode abbrev="S508C">Section 508 Compliance Violations</BugCode> </MessageCollection> \ No newline at end of file Added: trunk/fb-contrib/samples/S508C_Sample.java =================================================================== --- trunk/fb-contrib/samples/S508C_Sample.java (rev 0) +++ trunk/fb-contrib/samples/S508C_Sample.java 2006-04-23 00:22:03 UTC (rev 498) @@ -0,0 +1,11 @@ +import java.awt.Container; + +import javax.swing.JFrame; + +public class S508C_Sample extends JFrame +{ + public S508C_Sample() { + Container cp = getContentPane(); + cp.setLayout(null); + } +} Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-23 00:22:03 UTC (rev 498) @@ -0,0 +1,107 @@ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.HashSet; +import java.util.Set; + +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Field; + +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; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for interfaces that ignore 508 compliance, including not using JLabel.setLabelFor, + * Using null layouts, + */ +public class Section508Compliance extends BytecodeScanningDetector +{ + private BugReporter bugReporter; + private OpcodeStack stack; + private Set<String> fieldLabels; + private Set<Integer> localLabels; + + /** + * constructs a S508C detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public Section508Compliance(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + @Override + public void visitField(Field obj) { + String fieldSig = obj.getSignature(); + if ("java/awt/Label".equals(fieldSig) || "javax/swing/JLabel".equals(fieldSig)) { + fieldLabels.add(obj.getName()); + } + } + + /** + * implements the visitor to create and clear the stack + * + * @param classContext the context object of the currently visited class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + fieldLabels = new HashSet<String>(); + localLabels = new HashSet<Integer>(); + super.visitClassContext(classContext); + } finally { + stack = null; + fieldLabels = null; + localLabels = null; + } + } + + /** + * implements the visitor to reset the stack + * + * @param obj the context object for the currently visited code block + */ + @Override + public void visitCode(Code obj) { + stack.resetForMethodEntry(this); + localLabels.clear(); + super.visitCode(obj); + } + + /** + * implements the visitor to find 508 compliance concerns + * + * @param seen the opcode of the currently parsed instruction + */ + @Override + public void sawOpcode(int seen) { + try { + stack.mergeJumps(this); + if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { + int reg = RegisterUtils.getAStoreReg(this, seen); + } else if (seen == INVOKEVIRTUAL) { + String className = getClassConstantOperand(); + String methodName = getNameConstantOperand(); + + if ("java/awt/Container".equals(className)) { + if ("setLayout".equals(methodName)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if (item.isNull()) + bugReporter.reportBug(new BugInstance(this, "S508C_NULL_LAYOUT", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(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-04-22 19:20:17
|
Revision: 497 Author: dbrosius Date: 2006-04-22 12:20:11 -0700 (Sat, 22 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=497&view=rev Log Message: ----------- more explicit exception catching Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-22 13:18:00 UTC (rev 496) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-22 19:20:11 UTC (rev 497) @@ -44,6 +44,7 @@ import edu.umd.cs.findbugs.SourceLineAnnotation; import edu.umd.cs.findbugs.ba.BasicBlock; import edu.umd.cs.findbugs.ba.CFG; +import edu.umd.cs.findbugs.ba.CFGBuilderException; import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.ba.Edge; import edu.umd.cs.findbugs.ba.BasicBlock.InstructionIterator; @@ -129,7 +130,7 @@ visitedBlocks.clear(); checkBlock(bb, uncheckedFields); } - catch (Exception e) { + catch (CFGBuilderException cbe) { localizableFields.clear(); } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-22 13:18:13
|
Revision: 496 Author: dbrosius Date: 2006-04-22 06:18:00 -0700 (Sat, 22 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=496&view=rev Log Message: ----------- fix false positive due to incomplete changeover to iterative Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-19 01:07:38 UTC (rev 495) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2006-04-22 13:18:00 UTC (rev 496) @@ -204,7 +204,7 @@ visitedBlocks.set(bb.getId()); InstructionIterator ii = bb.instructionIterator(); - while (ii.hasNext()) { + while ((uncheckedFields.size() > 0) && ii.hasNext()) { InstructionHandle ih = ii.next(); Instruction ins = ih.getInstruction(); if (ins instanceof FieldInstruction) { @@ -221,8 +221,6 @@ if (finfo != null) finfo.setSrcLineAnnotation(SourceLineAnnotation.fromVisitedInstruction(clsContext, this, ih.getPosition())); } - if (uncheckedFields.size() == 0) - return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-19 01:07:43
|
Revision: 495 Author: dbrosius Date: 2006-04-18 18:07:38 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=495&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2006-04-19 01:06:26 UTC (rev 494) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java 2006-04-19 01:07:38 UTC (rev 495) @@ -34,6 +34,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 methods that make static method calls using an instance reference. @@ -42,8 +43,8 @@ */ public class StaticMethodInstanceInvocation extends BytecodeScanningDetector { private BugReporter bugReporter; - private OpcodeStack stack = new OpcodeStack(); - private List<PopInfo> popStack = new ArrayList<PopInfo>(); + private OpcodeStack stack; + private List<PopInfo> popStack; /** * constructs a SMII detector given the reporter to report bugs on @@ -52,17 +53,18 @@ public StaticMethodInstanceInvocation(BugReporter bugReporter) { this.bugReporter = bugReporter; } - - /** - * clone this detector so that it can be a StatelessDetector - * - * @return a clone of this object - */ + @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + popStack = new ArrayList<PopInfo>(); + super.visitClassContext(classContext); + } finally { + stack = null; + popStack = null; + } } - /** * looks for methods that contain a INVOKESTATIC opcodes * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-19 01:06:38
|
Revision: 494 Author: dbrosius Date: 2006-04-18 18:06:26 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=494&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java 2006-04-19 01:04:58 UTC (rev 493) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java 2006-04-19 01:06:26 UTC (rev 494) @@ -47,24 +47,19 @@ */ public PartiallyConstructedObjectAccess(final BugReporter bugReporter) { this.bugReporter = bugReporter; - stack = new OpcodeStack(); } - /** - * clone this detector so that it can be a StatelessDetector - * - * @return a clone of this object - */ @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - @Override public void visitClassContext(final ClassContext classContext) { - JavaClass cls = classContext.getJavaClass(); - if ((cls.getAccessFlags() & Constants.ACC_FINAL) == 0) - super.visitClassContext(classContext); + try { + JavaClass cls = classContext.getJavaClass(); + if ((cls.getAccessFlags() & Constants.ACC_FINAL) == 0) { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } + } finally { + stack = null; + } } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-19 01:05:07
|
Revision: 493 Author: dbrosius Date: 2006-04-18 18:04:58 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=493&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2006-04-19 01:02:44 UTC (rev 492) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2006-04-19 01:04:58 UTC (rev 493) @@ -24,6 +24,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 methods that compare strings against literal strings, where the literal string @@ -40,18 +41,22 @@ * @param bugReporter the sync of bug reports */ public LiteralStringComparison(final BugReporter bugReporter) { - this.bugReporter = bugReporter; - stack = new OpcodeStack(); + this.bugReporter = bugReporter; } - + /** - * clone this detector so that it can be a StatelessDetector + * implements the visitor to create and clear the stack * - * @return a clone of this object + * @param classContext the context object for the currently parsed class */ @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + stack = null; + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-19 01:02:48
|
Revision: 492 Author: dbrosius Date: 2006-04-18 18:02:44 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=492&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. 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-04-19 00:59:29 UTC (rev 491) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java 2006-04-19 01:02:44 UTC (rev 492) @@ -35,7 +35,6 @@ import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.SourceLineAnnotation; -import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; /** @@ -46,7 +45,7 @@ * which defines the different types required, and add an instance of that class to the * collection, or array. */ -public class UnrelatedCollectionContents extends BytecodeScanningDetector implements StatelessDetector +public class UnrelatedCollectionContents extends BytecodeScanningDetector { private static final Set<String> COLLECTION_CLASSES = new HashSet<String>(); static { @@ -71,33 +70,40 @@ */ public UnrelatedCollectionContents(final BugReporter bugReporter) { this.bugReporter = bugReporter; - stack = new OpcodeStack(); } /** - * clone this detector so that it can be a StatelessDetector + * implements the visitor to create and destroy the stack and member collections * - * @return a clone of this object + * @param classContext the context object for the currently parsed class */ @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - @Override public void visitClassContext(final ClassContext classContext) { - memberCollections = new HashMap<String, Set<String>>(); - memberSourceLineAnnotations = new HashMap<String, Set<SourceLineAnnotation>>(); - super.visitClassContext(classContext); + try { + stack = new OpcodeStack(); + memberCollections = new HashMap<String, Set<String>>(); + memberSourceLineAnnotations = new HashMap<String, Set<SourceLineAnnotation>>(); + super.visitClassContext(classContext); + } finally { + stack = null; + memberCollections = null; + memberSourceLineAnnotations = null; + } } @Override public void visitCode(final Code obj) { - localCollections = new HashMap<Integer, Set<String>>(); - localScopeEnds = new HashMap<Integer, Set<Integer>>(); - localSourceLineAnnotations = new HashMap<Integer, Set<SourceLineAnnotation>>(); - stack.resetForMethodEntry(this); - super.visitCode(obj); + try { + localCollections = new HashMap<Integer, Set<String>>(); + localScopeEnds = new HashMap<Integer, Set<Integer>>(); + localSourceLineAnnotations = new HashMap<Integer, Set<SourceLineAnnotation>>(); + stack.resetForMethodEntry(this); + super.visitCode(obj); + } finally { + localCollections = null; + localScopeEnds = null; + localSourceLineAnnotations = null; + } } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-19 00:59:35
|
Revision: 491 Author: dbrosius Date: 2006-04-18 17:59:29 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=491&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2006-04-19 00:57:10 UTC (rev 490) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2006-04-19 00:59:29 UTC (rev 491) @@ -39,7 +39,6 @@ import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; -import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; /** @@ -47,14 +46,14 @@ * implemented interface or super class. Relying on concrete classes in public signatures causes cohesion, * and makes low impact changes more difficult. */ -public class OverlyConcreteParameter extends BytecodeScanningDetector implements StatelessDetector +public class OverlyConcreteParameter extends BytecodeScanningDetector { private BugReporter bugReporter; - private JavaClass[] interfaces = null; - private Map<Integer, Map<JavaClass, List<String>>> parameterDefiners = new HashMap<Integer, Map<JavaClass, List<String>>>(); - private Set<Integer> usedParameters = new HashSet<Integer>(); + private JavaClass[] interfaces; + private Map<Integer, Map<JavaClass, List<String>>> parameterDefiners; + private Set<Integer> usedParameters; private JavaClass objectClass; - private OpcodeStack stack = new OpcodeStack(); + private OpcodeStack stack; private int parmCount; private boolean methodImplementsInterface; private boolean methodIsStatic; @@ -73,24 +72,21 @@ } } - /** - * clone this detector so that it can be a StatelessDetector - * - * @return a clone of this object - */ @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - @Override public void visitClassContext(ClassContext classContext) { try { interfaces = classContext.getJavaClass().getAllInterfaces(); + parameterDefiners = new HashMap<Integer, Map<JavaClass, List<String>>>(); + usedParameters = new HashSet<Integer>(); + stack = new OpcodeStack(); super.visitClassContext(classContext); - interfaces = null; } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); + } finally { + interfaces = null; + parameterDefiners = null; + usedParameters = null; + stack = null; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |