fb-contrib-commit Mailing List for fb-contrib (Page 67)
Brought to you by:
dbrosius
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(56) |
Oct
(60) |
Nov
(58) |
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(66) |
Feb
(55) |
Mar
(85) |
Apr
(115) |
May
(35) |
Jun
(28) |
Jul
(3) |
Aug
(48) |
Sep
(37) |
Oct
(22) |
Nov
(14) |
Dec
(66) |
2007 |
Jan
(45) |
Feb
(63) |
Mar
(10) |
Apr
(1) |
May
(1) |
Jun
(12) |
Jul
|
Aug
|
Sep
(25) |
Oct
(21) |
Nov
(39) |
Dec
|
2008 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(5) |
May
(2) |
Jun
(32) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2009 |
Jan
(10) |
Feb
(31) |
Mar
(32) |
Apr
(35) |
May
(25) |
Jun
|
Jul
(31) |
Aug
(10) |
Sep
(95) |
Oct
(35) |
Nov
(10) |
Dec
(34) |
2010 |
Jan
(90) |
Feb
(4) |
Mar
(7) |
Apr
(20) |
May
(20) |
Jun
(13) |
Jul
(7) |
Aug
(18) |
Sep
(25) |
Oct
(4) |
Nov
(16) |
Dec
(2) |
2011 |
Jan
(1) |
Feb
|
Mar
(11) |
Apr
(3) |
May
(2) |
Jun
(26) |
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(14) |
Nov
(3) |
Dec
(4) |
2013 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(4) |
May
|
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(3) |
2014 |
Jan
(4) |
Feb
(2) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(2) |
Nov
(7) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(3) |
2018 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(5) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Dave B. <dbr...@us...> - 2006-01-01 06:36:05
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7424/htdocs Modified Files: index.html Log Message: get ready for v2_0_0 release Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- index.html 30 Dec 2005 06:35:42 -0000 1.47 +++ index.html 1 Jan 2006 06:35:55 -0000 1.48 @@ -44,10 +44,9 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> - <img id="cvs_image" src="flip2.gif" onClick="toggleBlock('cvs', 'cvs_image');" align="top"/> - Detectors added in cvs<br/> - Note: these detectors are still in testing - <div id="cvs" style="display:block;"> + <img id="v2_0_0" src="flip2.gif" onClick="toggleBlock('v2_0_0', 'v2_0_0_image');" align="top"/> + Detectors added in v2_0_0<br/> + <div id="v2_0_0" style="display:block;"> <ul> <li><b>Array Based Collections</b><br/> Looks for methods that use arrays for items in the keyset of a map, or as |
From: Dave B. <dbr...@us...> - 2005-12-31 03:21:52
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19485/src/com/mebigfatguy/fbcontrib/detect Modified Files: CustomBuiltXML.java Log Message: don't report a PC of a non-confident pattern Index: CustomBuiltXML.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CustomBuiltXML.java 31 Dec 2005 03:17:43 -0000 1.3 +++ CustomBuiltXML.java 31 Dec 2005 03:21:42 -0000 1.4 @@ -148,7 +148,7 @@ xmlItemCount++; if (entry.getValue().booleanValue()) xmlConfidentCount++; - if (firstPC < 0) + if ((firstPC < 0) && (xmlConfidentCount > 0)) firstPC = getPC(); break; } |
From: Dave B. <dbr...@us...> - 2005-12-31 03:19:06
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19124/etc Modified Files: findbugs.xml messages.xml Log Message: CBX is only moderately fast Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- messages.xml 30 Dec 2005 06:33:43 -0000 1.41 +++ messages.xml 31 Dec 2005 03:18:56 -0000 1.42 @@ -354,6 +354,7 @@ <p>Looks for methods that are declared as abstract that override concrete methods in a super class. Doing this casts away the implementation of the super class, and breaks the contract as set forth by the parent class.</p> + <p>It is a fast Detector</p> ]]> </Details> </Detector> @@ -365,6 +366,7 @@ and custom values together. Doing so makes brittle code, that is difficult to modify, validate and understand. It is cleaner to create external xml files that are transformed at runtime, using parameters set through Transformer.setParameter. + <p>It is a moderately fast Detector</p> ]]> </Details> </Detector> Index: findbugs.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/findbugs.xml,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- findbugs.xml 30 Dec 2005 06:33:43 -0000 1.47 +++ findbugs.xml 31 Dec 2005 03:18:56 -0000 1.48 @@ -123,7 +123,7 @@ reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML" - speed="fast" + speed="moderate" reports="CBX_CUSTOM_BUILT_XML" /> <!-- BugPattern --> |
From: Dave B. <dbr...@us...> - 2005-12-31 03:17:53
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18950/src/com/mebigfatguy/fbcontrib/detect Modified Files: CustomBuiltXML.java Log Message: try to filter out <= and >= Index: CustomBuiltXML.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CustomBuiltXML.java 31 Dec 2005 02:44:27 -0000 1.2 +++ CustomBuiltXML.java 31 Dec 2005 03:17:43 -0000 1.3 @@ -35,11 +35,11 @@ { private static final Map<Pattern, Boolean> xmlPatterns = new HashMap<Pattern, Boolean>(); static { - xmlPatterns.put(Pattern.compile(".*<[a-zA-Z_](\\w)*>.*"), Boolean.TRUE); - xmlPatterns.put(Pattern.compile(".*</[a-zA-Z_](\\w)*>.*"), Boolean.TRUE); - xmlPatterns.put(Pattern.compile(".*<[a-zA-Z_](\\w)*/>.*"), Boolean.TRUE); - xmlPatterns.put(Pattern.compile(".*<(//)?$"), Boolean.TRUE); - xmlPatterns.put(Pattern.compile("^(//)?>.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*<[a-zA-Z_](\\w)*>[^=]?.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*</[a-zA-Z_](\\w)*>[^=]?.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*<[a-zA-Z_](\\w)*/>[^=]?.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*<[^=]?(/)?$"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile("^(/)?>.*"), Boolean.TRUE); xmlPatterns.put(Pattern.compile(".*=(\\s)*[\"'].*"), Boolean.FALSE); xmlPatterns.put(Pattern.compile("^[\"']>.*"), Boolean.TRUE); xmlPatterns.put(Pattern.compile(".*<!\\[CDATA\\[.*", Pattern.CASE_INSENSITIVE), Boolean.TRUE); |
From: Dave B. <dbr...@us...> - 2005-12-31 02:44:36
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14248/src/com/mebigfatguy/fbcontrib/detect Modified Files: CustomBuiltXML.java Log Message: =" isn't a valid predictor of xml, it could be sql, or otherwise. So count them, but you need more than that to report. Index: CustomBuiltXML.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CustomBuiltXML.java 30 Dec 2005 06:33:43 -0000 1.1 +++ CustomBuiltXML.java 31 Dec 2005 02:44:27 -0000 1.2 @@ -18,8 +18,8 @@ */ package com.mebigfatguy.fbcontrib.detect; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -33,23 +33,24 @@ public class CustomBuiltXML extends BytecodeScanningDetector implements StatelessDetector { - private static final List<Pattern> xmlPatterns = new ArrayList<Pattern>(); + private static final Map<Pattern, Boolean> xmlPatterns = new HashMap<Pattern, Boolean>(); static { - xmlPatterns.add(Pattern.compile(".*<[a-zA-Z_](\\w)*>.*")); - xmlPatterns.add(Pattern.compile(".*</[a-zA-Z_](\\w)*>.*")); - xmlPatterns.add(Pattern.compile(".*<[a-zA-Z_](\\w)*/>.*")); - xmlPatterns.add(Pattern.compile(".*<(//)?$")); - xmlPatterns.add(Pattern.compile("^(//)?>.*")); - xmlPatterns.add(Pattern.compile(".*=(\\s)*[\"'].*")); - xmlPatterns.add(Pattern.compile("^[\"']>.*")); - xmlPatterns.add(Pattern.compile(".*<!\\[CDATA\\[.*", Pattern.CASE_INSENSITIVE)); - xmlPatterns.add(Pattern.compile(".*\\]\\]>.*")); - xmlPatterns.add(Pattern.compile(".*xmlns:.*")); + xmlPatterns.put(Pattern.compile(".*<[a-zA-Z_](\\w)*>.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*</[a-zA-Z_](\\w)*>.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*<[a-zA-Z_](\\w)*/>.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*<(//)?$"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile("^(//)?>.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*=(\\s)*[\"'].*"), Boolean.FALSE); + xmlPatterns.put(Pattern.compile("^[\"']>.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*<!\\[CDATA\\[.*", Pattern.CASE_INSENSITIVE), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*\\]\\]>.*"), Boolean.TRUE); + xmlPatterns.put(Pattern.compile(".*xmlns:.*"), Boolean.TRUE); } private static final String CBX_MIN_REPORTABLE_ITEMS = "fb-contrib.cbx.minxmlitems"; private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); private int xmlItemCount = 0; + private int xmlConfidentCount = 0; private int lowReportingThreshold; private int midReportingThreshold; private int highReportingThreshold; @@ -88,7 +89,8 @@ xmlItemCount = 0; firstPC = -1; super.visitCode(obj); - if (xmlItemCount >= lowReportingThreshold) { + if ((xmlItemCount >= lowReportingThreshold) + && (xmlConfidentCount > (lowReportingThreshold >> 1))) { bugReporter.reportBug( new BugInstance( this, "CBX_CUSTOM_BUILT_XML", (xmlItemCount >= highReportingThreshold) ? HIGH_PRIORITY : @@ -140,10 +142,12 @@ if (strCon.trim().length() == 0) return; - for (Pattern p : xmlPatterns) { - Matcher m = p.matcher(strCon); + for (Map.Entry<Pattern, Boolean> entry : xmlPatterns.entrySet()) { + Matcher m = entry.getKey().matcher(strCon); if (m.matches()) { xmlItemCount++; + if (entry.getValue().booleanValue()) + xmlConfidentCount++; if (firstPC < 0) firstPC = getPC(); break; |
From: Dave B. <dbr...@us...> - 2005-12-30 06:35:52
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25482/htdocs Modified Files: index.html Log Message: doc CBX Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- index.html 28 Dec 2005 03:43:00 -0000 1.46 +++ index.html 30 Dec 2005 06:35:42 -0000 1.47 @@ -57,10 +57,15 @@ class when using Maps in this case, to better document your intentions.</li> <li><b>Orphaned DOM Nodes</b><br/> Looks for methods that create DOM nodes but do not append them to any Document.</li> - <li><b>Abstract Overridden Method</b> + <li><b>Abstract Overridden Method</b><br/> Looks for abstract methods that override a concrete method in a super class. Doing this casts away the implementation of the super class, and breaks the implied contract as set forth by the parent class.</li> + <li><b>Custom Built XML</b><br/> + Looks for methods that build xml based strings by concatenation strings + and custom values together. Doing so makes brittle code, that is difficult to + modify, validate and understand. It is cleaner to create external xml files that are + transformed at runtime, using parameters set through Transformer.setParameter.</li> </ul> </div> |
From: Dave B. <dbr...@us...> - 2005-12-30 06:33:54
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25229/samples Added Files: CBX_Sample.java Log Message: initial checkin - new CBX detector --- NEW FILE: CBX_Sample.java --- public class CBX_Sample { public String testBuildXML(int val, String info) { StringBuffer sb = new StringBuffer(); sb.append("<sample>"); sb.append("<test name='" + val + "'>" + info + "</test>"); sb.append("</sample>"); return sb.toString(); } } |
From: Dave B. <dbr...@us...> - 2005-12-30 06:33:54
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25229/etc Modified Files: findbugs.xml messages.xml Log Message: initial checkin - new CBX detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- messages.xml 28 Dec 2005 03:40:18 -0000 1.40 +++ messages.xml 30 Dec 2005 06:33:43 -0000 1.41 @@ -358,6 +358,17 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML"> + <Details> + <![CDATA[ + <p>Looks for methods that build xml based strings by concatenation strings + and custom values together. Doing so makes brittle code, that is difficult to + modify, validate and understand. It is cleaner to create external xml files that are + transformed at runtime, using parameters set through Transformer.setParameter. + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -696,6 +707,20 @@ </Details> </BugPattern> + <BugPattern type="CBX_CUSTOM_BUILT_XML"> + <ShortDescription>method builds xml strings through adhoc concatenation</ShortDescription> + <LongDescription>method {1} builds xml strings through adhoc concatenation</LongDescription> + <Details> + <![CDATA[ + <p>This method generates an xml based string by concatenating together various + xml fragments, and variable values. Doing so makes the code difficult to read, modify + and validate. It is much more clean to built xml structures in external files that are + read in and transformed into the final product, thru modification by Transformer.setParameter. + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -725,4 +750,5 @@ <BugCode abbrev="ABC">Array Based Collection</BugCode> <BugCode abbrev="ODN">Orphaned DOM Node</BugCode> <BugCode abbrev="AOM">Abstract Overridden Method</BugCode> + <BugCode abbrev="CBX">Custom Built XML</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.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- findbugs.xml 28 Dec 2005 03:40:18 -0000 1.46 +++ findbugs.xml 30 Dec 2005 06:33:43 -0000 1.47 @@ -121,6 +121,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractOverriddenMethod" speed="fast" reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML" + speed="fast" + reports="CBX_CUSTOM_BUILT_XML" /> <!-- BugPattern --> @@ -151,4 +155,5 @@ <BugPattern abbrev="ABC" type="ABC_ARRAY_BASED_COLLECTIONS" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="ODN" type="ODN_ORPHANED_DOM_NODE" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="AOM" type="AOM_ABSTRACT_OVERRIDDEN_METHOD" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="CBX" type="CBX_CUSTOM_BUILT_XML" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-12-30 06:33:54
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25229/src/com/mebigfatguy/fbcontrib/detect Added Files: CustomBuiltXML.java Log Message: initial checkin - new CBX detector --- NEW FILE: CustomBuiltXML.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.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; 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.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; public class CustomBuiltXML extends BytecodeScanningDetector implements StatelessDetector { private static final List<Pattern> xmlPatterns = new ArrayList<Pattern>(); static { xmlPatterns.add(Pattern.compile(".*<[a-zA-Z_](\\w)*>.*")); xmlPatterns.add(Pattern.compile(".*</[a-zA-Z_](\\w)*>.*")); xmlPatterns.add(Pattern.compile(".*<[a-zA-Z_](\\w)*/>.*")); xmlPatterns.add(Pattern.compile(".*<(//)?$")); xmlPatterns.add(Pattern.compile("^(//)?>.*")); xmlPatterns.add(Pattern.compile(".*=(\\s)*[\"'].*")); xmlPatterns.add(Pattern.compile("^[\"']>.*")); xmlPatterns.add(Pattern.compile(".*<!\\[CDATA\\[.*", Pattern.CASE_INSENSITIVE)); xmlPatterns.add(Pattern.compile(".*\\]\\]>.*")); xmlPatterns.add(Pattern.compile(".*xmlns:.*")); } private static final String CBX_MIN_REPORTABLE_ITEMS = "fb-contrib.cbx.minxmlitems"; private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); private int xmlItemCount = 0; private int lowReportingThreshold; private int midReportingThreshold; private int highReportingThreshold; private int firstPC; /** * constructs a CBX detector given the reporter to report bugs on * @param bugReporter the sync of bug reports */ public CustomBuiltXML(BugReporter bugReporter) { this.bugReporter = bugReporter; lowReportingThreshold = Integer.getInteger(CBX_MIN_REPORTABLE_ITEMS, 5); midReportingThreshold = lowReportingThreshold << 1; highReportingThreshold = lowReportingThreshold << 2; } /** * clone this detector so that it can be a StatelessDetector * * @return a clone of this object */ @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * overrides the visitor reset the opcode stack * * @param obj the code object of the currently parsed method */ public void visitCode(Code obj) { stack.resetForMethodEntry(this); xmlItemCount = 0; firstPC = -1; super.visitCode(obj); if (xmlItemCount >= lowReportingThreshold) { bugReporter.reportBug( new BugInstance( this, "CBX_CUSTOM_BUILT_XML", (xmlItemCount >= highReportingThreshold) ? HIGH_PRIORITY : (xmlItemCount >= midReportingThreshold) ? NORMAL_PRIORITY : LOW_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this, firstPC)); } } /** * overrides the visitor to find String concatenations including xml strings * * @param seen the opcode that is being visited */ public void sawOpcode(int seen) { String strCon = null; try { if (seen == INVOKESPECIAL) { String clsName = getClassConstantOperand(); if ("java/lang/StringBuffer".equals(clsName) || "java/lang/StringBuilder".equals(clsName)) { String methodName = getNameConstantOperand(); String methodSig = getSigConstantOperand(); if ("<init>".equals(methodName) && ("(Ljava/lang/String;)L" + clsName + ";").equals(methodSig)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); strCon = (String)itm.getConstant(); } } } } else if (seen == INVOKEVIRTUAL) { String clsName = getClassConstantOperand(); if ("java/lang/StringBuffer".equals(clsName) || "java/lang/StringBuilder".equals(clsName)) { String methodName = getNameConstantOperand(); String methodSig = getSigConstantOperand(); if ("append".equals(methodName) && ("(Ljava/lang/String;)L" + clsName + ";").equals(methodSig)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); strCon = (String)itm.getConstant(); } } } } if (strCon != null) { if (strCon.trim().length() == 0) return; for (Pattern p : xmlPatterns) { Matcher m = p.matcher(strCon); if (m.matches()) { xmlItemCount++; if (firstPC < 0) firstPC = getPC(); break; } } } } finally { stack.sawOpcode(this, seen); } } } |
From: Dave B. <dbr...@us...> - 2005-12-28 03:43:12
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13688/htdocs Modified Files: index.html Log Message: document AOM Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- index.html 23 Dec 2005 05:25:52 -0000 1.45 +++ index.html 28 Dec 2005 03:43:00 -0000 1.46 @@ -57,6 +57,10 @@ class when using Maps in this case, to better document your intentions.</li> <li><b>Orphaned DOM Nodes</b><br/> Looks for methods that create DOM nodes but do not append them to any Document.</li> + <li><b>Abstract Overridden Method</b> + Looks for abstract methods that override a concrete method in a super class. + Doing this casts away the implementation of the super class, and breaks + the implied contract as set forth by the parent class.</li> </ul> </div> |
From: Dave B. <dbr...@us...> - 2005-12-28 03:40:31
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13344/etc Modified Files: findbugs.xml messages.xml Log Message: intial checkin, new AOM detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- messages.xml 23 Dec 2005 05:23:27 -0000 1.39 +++ messages.xml 28 Dec 2005 03:40:18 -0000 1.40 @@ -348,6 +348,16 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractOverriddenMethod"> + <Details> + <![CDATA[ + <p>Looks for methods that are declared as abstract that override concrete methods in a + super class. Doing this casts away the implementation of the super class, and breaks + the contract as set forth by the parent class.</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -674,6 +684,18 @@ </Details> </BugPattern> + <BugPattern type="AOM_ABSTRACT_OVERRIDDEN_METHOD"> + <ShortDescription>abstract method overrides a concrete implementation</ShortDescription> + <LongDescription>abstract method {1} overrides a concrete implementation</LongDescription> + <Details> + <![CDATA[ + <p>This abstract method is derived from a concrete method implementation. It is highly + suspect that the super class method's implementation would be cast away. + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -702,4 +724,5 @@ <BugCode abbrev="COM">Copied Overridden Method</BugCode> <BugCode abbrev="ABC">Array Based Collection</BugCode> <BugCode abbrev="ODN">Orphaned DOM Node</BugCode> + <BugCode abbrev="AOM">Abstract Overridden Method</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.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- findbugs.xml 23 Dec 2005 05:23:27 -0000 1.45 +++ findbugs.xml 28 Dec 2005 03:40:18 -0000 1.46 @@ -117,6 +117,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.OrphanedDOMNode" speed="fast" reports="ODN_ORPHANED_DOM_NODE" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractOverriddenMethod" + speed="fast" + reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" /> <!-- BugPattern --> @@ -146,4 +150,5 @@ <BugPattern abbrev="COM" type="COM_COPIED_OVERRIDDEN_METHOD" category="STYLE" /> <BugPattern abbrev="ABC" type="ABC_ARRAY_BASED_COLLECTIONS" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="ODN" type="ODN_ORPHANED_DOM_NODE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="AOM" type="AOM_ABSTRACT_OVERRIDDEN_METHOD" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-12-28 03:40:31
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13344/src/com/mebigfatguy/fbcontrib/detect Added Files: AbstractOverriddenMethod.java Log Message: intial checkin, new AOM detector --- NEW FILE: AbstractOverriddenMethod.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.JavaClass; import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.Detector; import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.visitclass.PreorderVisitor; /** * finds methods that are declared abstract but override concrete methods in a superclass */ public class AbstractOverriddenMethod extends PreorderVisitor implements Detector, StatelessDetector { private BugReporter bugReporter; private JavaClass[] superClasses; /** * constructs a AOM detector given the reporter to report bugs on * @param bugReporter the sync of bug reports */ public AbstractOverriddenMethod(BugReporter bugReporter) { this.bugReporter = bugReporter; } /** * clone this detector so that it can be a StatelessDetector * * @return a clone of this object */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * implements the detector to collect the super classes * * @param classContext the context object for the currently parsed class */ public void visitClassContext(ClassContext classContext) { try { JavaClass cls = classContext.getJavaClass(); superClasses = cls.getSuperClasses(); cls.accept(this); } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } } /** * overrides the visitor to find abstract methods that override concrete ones * * @param obj the context object of the currently parsed method */ @Override public void visitMethod(Method obj) { if (!obj.isAbstract()) return; String methodName = obj.getName(); String methodSig = obj.getSignature(); for (JavaClass cls : superClasses) { Method[] methods = cls.getMethods(); for (Method m : methods) { if (m.isPrivate() || m.isAbstract()) continue; if (methodName.equals(m.getName()) && methodSig.equals(m.getSignature())) { bugReporter.reportBug(new BugInstance(this, "AOM_ABSTRACT_OVERRIDDEN_METHOD", NORMAL_PRIORITY) .addClass(this) .addMethod(this)); } } } } /** * implements the Detector with a nop */ public void report() { } } |
From: Dave B. <dbr...@us...> - 2005-12-28 03:40:31
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13344/samples Added Files: AOM_Sample.java Log Message: intial checkin, new AOM detector --- NEW FILE: AOM_Sample.java --- class AOM_Super { public void test1() { test2(); System.out.println("test"); } private void test2() { System.out.println("test"); } } public abstract class AOM_Sample extends AOM_Super { public abstract void test1(); public abstract void test2(); } |
From: Dave B. <dbr...@us...> - 2005-12-24 04:59:50
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22541/src/com/mebigfatguy/fbcontrib/detect Modified Files: OrphanedDOMNode.java Log Message: add @Override annotations Index: OrphanedDOMNode.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- OrphanedDOMNode.java 24 Dec 2005 02:26:53 -0000 1.2 +++ OrphanedDOMNode.java 24 Dec 2005 04:59:42 -0000 1.3 @@ -75,6 +75,7 @@ * * @param obj the context object for the currently parsed code block */ + @Override public void visitCode(Code obj) { stack.resetForMethodEntry(this); nodeCreations.clear(); @@ -108,6 +109,7 @@ * * @param seen the currently parsed opcode */ + @Override public void sawOpcode(int seen) { boolean sawCreate = false; Integer itemPC = null; |
From: Dave B. <dbr...@us...> - 2005-12-24 02:27:02
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2813/src/com/mebigfatguy/fbcontrib/detect Modified Files: OrphanedDOMNode.java Log Message: if a dom node is passed as a parameter to any method, then we can't rule out that it is indeed attached to some document, or other dom container (ie: NodeSet) Index: OrphanedDOMNode.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OrphanedDOMNode.java 23 Dec 2005 05:23:27 -0000 1.1 +++ OrphanedDOMNode.java 24 Dec 2005 02:26:53 -0000 1.2 @@ -24,6 +24,7 @@ import java.util.Set; import org.apache.bcel.classfile.Code; +import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -34,7 +35,6 @@ public class OrphanedDOMNode extends BytecodeScanningDetector implements StatelessDetector { private static final Set<String> domCreationMethods = new HashSet<String>(); - private static final Set<String> domAppendMethods = new HashSet<String>(); static { domCreationMethods.add("createAttribute:(Ljava/lang/String;)Lorg/w3c/dom/Attr;"); domCreationMethods.add("createAttributeNS:(Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/Attr;"); @@ -44,10 +44,6 @@ domCreationMethods.add("createElementNS:(Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/Element;"); domCreationMethods.add("createProcessingInstruction:(Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/ProcessingInstruction;"); domCreationMethods.add("createTextNode:(Ljava/lang/String;)Lorg/w3c/dom/Text;"); - - domAppendMethods.add("appendChild:(Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;"); - domAppendMethods.add("setAttributeNode:(Lorg/w3c/dom/Attr;)Lorg/w3c/dom/Attr;"); - domAppendMethods.add("setAttributeNodeNS:(Lorg/w3c/dom/Attr;)Lorg/w3c/dom/Attr;"); } private BugReporter bugReporter; @@ -126,16 +122,6 @@ itemPC = new Integer(getPC()); } } - if (!sawCreate) { - if (domAppendMethods.contains(methodInfo)) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - int reg = itm.getRegisterNumber(); - nodeCreations.remove(itm); - nodeStores.remove(reg); - } - } - } } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && seen <= ASTORE_3)) { Integer pc = findDOMNodeCreationPoint(0); int reg; @@ -167,6 +153,27 @@ nodeStores.remove(new Integer(reg)); } } + + if (!sawCreate) { + if ((seen == INVOKEINTERFACE) + || (seen == INVOKEVIRTUAL) + || (seen == INVOKESTATIC) + || (seen == INVOKESPECIAL)) { + String methodSig = getSigConstantOperand(); + int argCount = Type.getArgumentTypes(methodSig).length; + if (stack.getStackDepth() >= argCount) { + for (int a = 0; a < argCount; a++) { + OpcodeStack.Item itm = stack.getStackItem(a); + if (nodeCreations.containsKey(itm)) { + int reg = itm.getRegisterNumber(); + nodeCreations.remove(itm); + nodeStores.remove(reg); + } + } + } + } + + } } finally { stack.sawOpcode(this, seen); if (sawCreate) { |
From: Dave B. <dbr...@us...> - 2005-12-23 05:26:01
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22809/htdocs Modified Files: index.html Log Message: document ODN Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- index.html 17 Dec 2005 21:36:11 -0000 1.44 +++ index.html 23 Dec 2005 05:25:52 -0000 1.45 @@ -55,6 +55,8 @@ do not, and cannot define an equals method, reference equality is used for these collections, which is probably not desired. If it is, consider using the IdentityHashMap class when using Maps in this case, to better document your intentions.</li> + <li><b>Orphaned DOM Nodes</b><br/> + Looks for methods that create DOM nodes but do not append them to any Document.</li> </ul> </div> |
From: Dave B. <dbr...@us...> - 2005-12-23 05:23:36
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22247/src/com/mebigfatguy/fbcontrib/detect Added Files: OrphanedDOMNode.java Log Message: initial checkin: new ODN detector --- NEW FILE: OrphanedDOMNode.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.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; 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.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; public class OrphanedDOMNode extends BytecodeScanningDetector implements StatelessDetector { private static final Set<String> domCreationMethods = new HashSet<String>(); private static final Set<String> domAppendMethods = new HashSet<String>(); static { domCreationMethods.add("createAttribute:(Ljava/lang/String;)Lorg/w3c/dom/Attr;"); domCreationMethods.add("createAttributeNS:(Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/Attr;"); domCreationMethods.add("createCDATASection:(Ljava/lang/String;)Lorg/w3c/dom/CDATASection;"); domCreationMethods.add("createComment:(Ljava/lang/String;)Lorg/w3c/dom/Comment;"); domCreationMethods.add("createElement:(Ljava/lang/String;)Lorg/w3c/dom/Element;"); domCreationMethods.add("createElementNS:(Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/Element;"); domCreationMethods.add("createProcessingInstruction:(Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/ProcessingInstruction;"); domCreationMethods.add("createTextNode:(Ljava/lang/String;)Lorg/w3c/dom/Text;"); domAppendMethods.add("appendChild:(Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;"); domAppendMethods.add("setAttributeNode:(Lorg/w3c/dom/Attr;)Lorg/w3c/dom/Attr;"); domAppendMethods.add("setAttributeNodeNS:(Lorg/w3c/dom/Attr;)Lorg/w3c/dom/Attr;"); } private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); private Map<OpcodeStack.Item, Integer> nodeCreations = new HashMap<OpcodeStack.Item, Integer>(); private Map<Integer, Integer> nodeStores = new HashMap<Integer, Integer>(); /** * constructs a ODN detector given the reporter to report bugs on * @param bugReporter the sync of bug reports */ public OrphanedDOMNode(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(); } /** * implements the visitor to clear the opcode stack for the next code * * @param obj the context object for the currently parsed code block */ public void visitCode(Code obj) { stack.resetForMethodEntry(this); nodeCreations.clear(); nodeStores.clear(); super.visitCode(obj); Set<Integer> reportedPCs = new HashSet<Integer>(); for (Integer pc : nodeCreations.values()) { if (!reportedPCs.contains(pc)) { bugReporter.reportBug(new BugInstance(this, "ODN_ORPHANED_DOM_NODE", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this, pc.intValue())); reportedPCs.add(pc); } } for (Integer pc : nodeStores.values()) { if (!reportedPCs.contains(pc)) { bugReporter.reportBug(new BugInstance(this, "ODN_ORPHANED_DOM_NODE", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this, pc.intValue())); reportedPCs.add(pc); } } } /** * implements the visitor to find DOM based nodes that are allocated but not appended to * an existing node (or returned). * * @param seen the currently parsed opcode */ public void sawOpcode(int seen) { boolean sawCreate = false; Integer itemPC = null; try { if (seen == INVOKEINTERFACE) { String className = getClassConstantOperand(); String methodInfo = getNameConstantOperand() + ":" + getSigConstantOperand(); if ("org/w3c/dom/Document".equals(className)) { if (domCreationMethods.contains(methodInfo)) { sawCreate = true; itemPC = new Integer(getPC()); } } if (!sawCreate) { if (domAppendMethods.contains(methodInfo)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); int reg = itm.getRegisterNumber(); nodeCreations.remove(itm); nodeStores.remove(reg); } } } } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && seen <= ASTORE_3)) { Integer pc = findDOMNodeCreationPoint(0); int reg; if (seen == ASTORE) reg = getRegisterOperand(); else reg = seen - ASTORE_0; if (pc != null) nodeStores.put(new Integer(reg), pc); else nodeStores.remove(new Integer(reg)); } else if (seen == PUTFIELD) { //Stores to member variables are assumed ok findDOMNodeCreationPoint(0); } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { int reg; if (seen == ALOAD) reg = getRegisterOperand(); else reg = seen - ALOAD_0; itemPC = nodeStores.get(new Integer(reg)); if (itemPC != null) sawCreate = true; } else if (seen == ARETURN) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); int reg = itm.getRegisterNumber(); nodeCreations.remove(itm); nodeStores.remove(new Integer(reg)); } } } finally { stack.sawOpcode(this, seen); if (sawCreate) { if (stack.getStackDepth() > 0) nodeCreations.put(stack.getStackItem(0), itemPC); } } } /** * returns the pc where this DOM Node was created, or null if this isn't a DOM node that was created * * @param index the index into the stack of the item to be checked * * @return the pc where this NODE was created, or null */ private Integer findDOMNodeCreationPoint(int index) { if (stack.getStackDepth() > index) return nodeCreations.remove(stack.getStackItem(index)); return null; } } |
From: Dave B. <dbr...@us...> - 2005-12-23 05:23:36
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22247/etc Modified Files: findbugs.xml messages.xml Log Message: initial checkin: new ODN detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- messages.xml 21 Dec 2005 04:30:56 -0000 1.38 +++ messages.xml 23 Dec 2005 05:23:27 -0000 1.39 @@ -338,6 +338,16 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.OrphanedDOMNode"> + <Details> + <![CDATA[ + <p>Looks for methods that create DOM Nodes but do not add them to any DOM Document.</p> + <p>It is a fast Detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -653,6 +663,17 @@ </Details> </BugPattern> + <BugPattern type="ODN_ORPHANED_DOM_NODE"> + <ShortDescription>method creates DOM node but doesn't attach it to a document</ShortDescription> + <LongDescription>method {1} creates DOM node but doesn't attach it to a document</LongDescription> + <Details> + <![CDATA[ + <p>This method creates a DOM node but does not attach it to a DOM document. + </p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -680,4 +701,5 @@ <BugCode abbrev="USBR">Unnecessary Store Before Return</BugCode> <BugCode abbrev="COM">Copied Overridden Method</BugCode> <BugCode abbrev="ABC">Array Based Collection</BugCode> + <BugCode abbrev="ODN">Orphaned DOM Node</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.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- findbugs.xml 17 Dec 2005 08:27:00 -0000 1.44 +++ findbugs.xml 23 Dec 2005 05:23:27 -0000 1.45 @@ -113,6 +113,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayBasedCollections" speed="fast" reports="ABC_ARRAY_BASED_COLLECTIONS" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.OrphanedDOMNode" + speed="fast" + reports="ODN_ORPHANED_DOM_NODE" /> <!-- BugPattern --> @@ -141,4 +145,5 @@ <BugPattern abbrev="USBR" type="USBR_UNNECESSARY_STORE_BEFORE_RETURN" category="STYLE" /> <BugPattern abbrev="COM" type="COM_COPIED_OVERRIDDEN_METHOD" category="STYLE" /> <BugPattern abbrev="ABC" type="ABC_ARRAY_BASED_COLLECTIONS" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="ODN" type="ODN_ORPHANED_DOM_NODE" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-12-23 05:23:36
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22247/samples Added Files: ODN_Sample.java Log Message: initial checkin: new ODN detector --- NEW FILE: ODN_Sample.java --- import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; public class ODN_Sample { public Document testSimpleElement(Document d) { Element a = d.createElement("foo"); Element b = d.createElement("bar"); d.appendChild(a); return d; } public Document testSimpleAttribute(Document d) { Element e = d.createElement("foo"); d.appendChild(e); Attr a1 = d.createAttribute("who"); Attr a2 = d.createAttribute("dat"); e.setAttributeNode(a1); return d; } public Document testSimpleText(Document d) { Element a = d.createElement("foo"); Element b = d.createElement("bar"); d.appendChild(a); d.appendChild(b); Text t1 = d.createTextNode("hello"); a.appendChild(t1); Text t2 = d.createTextNode("there"); return d; } public Element testFP(Document d) { Element e = d.createElement("this"); e.setAttribute("is", "ok"); return e; } } |
From: Dave B. <dbr...@us...> - 2005-12-23 03:24:47
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4662/src/com/mebigfatguy/fbcontrib/detect Modified Files: CopiedOverriddenMethod.java Log Message: organize imports Index: CopiedOverriddenMethod.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CopiedOverriddenMethod.java 9 Dec 2005 04:24:09 -0000 1.3 +++ CopiedOverriddenMethod.java 23 Dec 2005 03:24:35 -0000 1.4 @@ -24,7 +24,6 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; -import org.apache.bcel.generic.BranchInstruction; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.FieldInstruction; import org.apache.bcel.generic.Instruction; |
From: Dave B. <dbr...@us...> - 2005-12-22 19:12:55
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29511/src/com/mebigfatguy/fbcontrib/detect Modified Files: ArrayBasedCollections.java Log Message: javadoc, etc Index: ArrayBasedCollections.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ArrayBasedCollections.java 21 Dec 2005 05:13:39 -0000 1.2 +++ ArrayBasedCollections.java 22 Dec 2005 19:12:47 -0000 1.3 @@ -31,6 +31,12 @@ import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * Looks for methods that use arrays for items in the keyset of a map, or as + * an element of a set, or in a list when using the contains method. Since arrays + * do not, and cannot define an equals method, reference equality is used for these + * collections, which is probably not desired. + */ public class ArrayBasedCollections extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; @@ -40,15 +46,30 @@ private boolean hasMapComparator; private boolean hasSetComparator; + /** + * constructs a ABC detector given the reporter to report bugs on + + * @param bugReporter the sync of bug reports + */ public ArrayBasedCollections(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(); } + /** + * implement the visitor to report bugs if no Tree comparators were found + * + * @param classContext the context object for the class currently being parsed + */ @Override public void visitClassContext(ClassContext classContext) { mapBugs.clear(); @@ -69,12 +90,22 @@ } } + /** + * implements the visitor to reset the stack of opcodes + * + * @param obj the context object for the currently parsed code block + */ @Override public void visitCode(Code obj) { stack.resetForMethodEntry(this); super.visitCode(obj); } + /** + * implements the visitor to find accesses to maps, sets and lists using arrays + * + * @param seen the currently visitor opcode + */ @Override public void sawOpcode(int seen) { try { |
From: Dave B. <dbr...@us...> - 2005-12-21 05:13:51
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7035/src/com/mebigfatguy/fbcontrib/detect Modified Files: ArrayBasedCollections.java Log Message: if a class uses a TreeMap or TreeSet with a comparator, then call off the dogs when putting arrays in these containers. Index: ArrayBasedCollections.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ArrayBasedCollections.java 17 Dec 2005 08:27:01 -0000 1.1 +++ ArrayBasedCollections.java 21 Dec 2005 05:13:39 -0000 1.2 @@ -18,18 +18,27 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.ArrayList; +import java.util.List; + import org.apache.bcel.classfile.Code; +import org.apache.bcel.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.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; +import edu.umd.cs.findbugs.ba.ClassContext; public class ArrayBasedCollections extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); + private List<BugInstance> mapBugs = new ArrayList<BugInstance>(); + private List<BugInstance> setBugs = new ArrayList<BugInstance>(); + private boolean hasMapComparator; + private boolean hasSetComparator; public ArrayBasedCollections(BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -41,6 +50,26 @@ } @Override + public void visitClassContext(ClassContext classContext) { + mapBugs.clear(); + setBugs.clear(); + hasMapComparator = false; + hasSetComparator = false; + super.visitClassContext(classContext); + if (!hasMapComparator) { + for (BugInstance bi : mapBugs) { + bugReporter.reportBug(bi); + } + } + + if (!hasSetComparator) { + for (BugInstance bi : setBugs) { + bugReporter.reportBug(bi); + } + } + } + + @Override public void visitCode(Code obj) { stack.resetForMethodEntry(this); super.visitCode(obj); @@ -54,6 +83,7 @@ String methodName = getNameConstantOperand(); String methodSig = getSigConstantOperand(); boolean found = false; + List<BugInstance> bugList = null; if ("java/util/Map".equals(className) && "put".equals(methodName) @@ -61,8 +91,10 @@ if (stack.getStackDepth() > 1) { OpcodeStack.Item itm = stack.getStackItem(1); String pushedSig = itm.getSignature(); - if (pushedSig.charAt(0) == '[') + if (pushedSig.charAt(0) == '[') { + bugList = mapBugs; found = true; + } } } else if ("java/util/Set".equals(className) && "add".equals(methodName) @@ -70,8 +102,10 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); String pushedSig = itm.getSignature(); - if (pushedSig.charAt(0) == '[') + if (pushedSig.charAt(0) == '[') { + bugList = setBugs; found = true; + } } } else if ("java/util/List".equals(className) && "contains".equals(methodName) @@ -85,12 +119,32 @@ } if (found) { - bugReporter.reportBug(new BugInstance(this, "ABC_ARRAY_BASED_COLLECTIONS", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + BugInstance bi = new BugInstance(this, "ABC_ARRAY_BASED_COLLECTIONS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this); + if (bugList != null) + bugList.add(bi); + else + bugReporter.reportBug(bi); } + } else if (seen == INVOKESPECIAL) { + String className = getClassConstantOperand(); + String methodName = getNameConstantOperand(); + String sig = getSigConstantOperand(); + + if ("<init>".equals(methodName)) { + if (!hasMapComparator && "java/util/TreeMap".equals(className)) { + Type[] parms = Type.getArgumentTypes(sig); + if ((parms.length == 1) && "Ljava/util/Comparator;".equals(parms[0].getSignature())) + hasMapComparator = true; + } else if (!hasSetComparator && "java/util/TreeSet".equals(className)) { + Type[] parms = Type.getArgumentTypes(sig); + if ((parms.length == 1) && "Ljava/util/Comparator;".equals(parms[0].getSignature())) + hasSetComparator = true; + } + } } } finally { stack.sawOpcode(this, seen); |
From: Dave B. <dbr...@us...> - 2005-12-21 05:13:51
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7035/samples Modified Files: ABC_Sample.java Log Message: if a class uses a TreeMap or TreeSet with a comparator, then call off the dogs when putting arrays in these containers. Index: ABC_Sample.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/samples/ABC_Sample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ABC_Sample.java 17 Dec 2005 08:27:01 -0000 1.1 +++ ABC_Sample.java 21 Dec 2005 05:13:39 -0000 1.2 @@ -1,8 +1,10 @@ +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; @@ -26,4 +28,24 @@ { return l.contains(value); } + + public static class UseComparator + { + private Map<byte[], byte[]> testComp; + + public UseComparator() + { + testComp = new TreeMap<byte[], byte[]>( new Comparator<byte[]>() + { + public int compare(byte[] b1, byte[] b2) + { + return b1.length - b2.length; + } + }); + } + + public void testc() { + testComp.put(new byte[5], new byte[3]); + } + } } |
From: Dave B. <dbr...@us...> - 2005-12-21 04:31:04
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1477/etc Modified Files: messages.xml Log Message: more details Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- messages.xml 17 Dec 2005 08:27:00 -0000 1.37 +++ messages.xml 21 Dec 2005 04:30:56 -0000 1.38 @@ -646,6 +646,8 @@ <p>This method passes an array as the key to a Map, element in a Set, or item in a List when the contains method is used on the List. Since arrays do not, and cannot override the equals method, collection inclusion is based on the reference's address, which is probably not desired. + In the case that this is a TreeMap or TreeSet, consider passing a Comparator to the map's + constructor. </p> ]]> </Details> |
From: Dave B. <dbr...@us...> - 2005-12-17 21:36:20
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3117/htdocs Modified Files: index.html Log Message: doc ABC Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- index.html 9 Dec 2005 04:58:50 -0000 1.43 +++ index.html 17 Dec 2005 21:36:11 -0000 1.44 @@ -44,9 +44,24 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> - <img id="v1_8_0_image" src="flip2.gif" onClick="toggleBlock('v1_8_0', 'v1_8_0_image');" align="top"/> + <img id="cvs_image" src="flip2.gif" onClick="toggleBlock('cvs', 'cvs_image');" align="top"/> + Detectors added in cvs<br/> + Note: these detectors are still in testing + <div id="cvs" style="display:block;"> + <ul> + <li><b>Array Based Collections</b><br/> + Looks for methods that use arrays for items in the keyset of a map, or as + an element of a set, or in a list when using the contains method. Since arrays + do not, and cannot define an equals method, reference equality is used for these + collections, which is probably not desired. If it is, consider using the IdentityHashMap + class when using Maps in this case, to better document your intentions.</li> + </ul> + </div> + + <hr/> + <img id="v1_8_0_image" src="flip1.gif" onClick="toggleBlock('v1_8_0', 'v1_8_0_image');" align="top"/> Detectors added in v1_8_0<br/> - <div id="v1_8_0" style="display:block;"> + <div id="v1_8_0" style="display:none;"> <ul> <li><b>Spurious Thread States</b><br/> Finds methods that call wait, notify or notifyAll on an instance of a |