fb-contrib-commit Mailing List for fb-contrib (Page 77)
Brought to you by:
dbrosius
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(56) |
Oct
(60) |
Nov
(58) |
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(66) |
Feb
(55) |
Mar
(85) |
Apr
(115) |
May
(35) |
Jun
(28) |
Jul
(3) |
Aug
(48) |
Sep
(37) |
Oct
(22) |
Nov
(14) |
Dec
(66) |
2007 |
Jan
(45) |
Feb
(63) |
Mar
(10) |
Apr
(1) |
May
(1) |
Jun
(12) |
Jul
|
Aug
|
Sep
(25) |
Oct
(21) |
Nov
(39) |
Dec
|
2008 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(5) |
May
(2) |
Jun
(32) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2009 |
Jan
(10) |
Feb
(31) |
Mar
(32) |
Apr
(35) |
May
(25) |
Jun
|
Jul
(31) |
Aug
(10) |
Sep
(95) |
Oct
(35) |
Nov
(10) |
Dec
(34) |
2010 |
Jan
(90) |
Feb
(4) |
Mar
(7) |
Apr
(20) |
May
(20) |
Jun
(13) |
Jul
(7) |
Aug
(18) |
Sep
(25) |
Oct
(4) |
Nov
(16) |
Dec
(2) |
2011 |
Jan
(1) |
Feb
|
Mar
(11) |
Apr
(3) |
May
(2) |
Jun
(26) |
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(14) |
Nov
(3) |
Dec
(4) |
2013 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(4) |
May
|
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(3) |
2014 |
Jan
(4) |
Feb
(2) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(2) |
Nov
(7) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(3) |
2018 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(5) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Dave B. <dbr...@us...> - 2005-09-17 04:43:41
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8901 Modified Files: build.xml Log Message: go to next version Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- build.xml 16 Sep 2005 05:11:32 -0000 1.7 +++ build.xml 17 Sep 2005 04:43:31 -0000 1.8 @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="1.0.0"/> + <property name="fb-contrib.version" value="1.1.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2005-09-17 04:42:43
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8800/src/com/mebigfatguy/fbcontrib/detect Added Files: ClassEnvy.java Log Message: Initial Checkin: Class Envy Detector --- NEW FILE: ClassEnvy.java --- package com.mebigfatguy.fbcontrib.detect; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; 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 ClassEnvy extends BytecodeScanningDetector implements StatelessDetector { private static final String ENVY_PERCENT_PROPERTY = "fb-contrib.ce.percentt"; private BugReporter bugReporter; private OpcodeStack stack; private String packageName; private String clsName; private Map<String, Integer> clsMethodCount; private int thisClsMethodCount; private double envyPercent = 0.80; public ClassEnvy(BugReporter bugReporter) { this.bugReporter = bugReporter; stack = new OpcodeStack(); String percent = System.getProperty(ENVY_PERCENT_PROPERTY); if (percent != null) { try { envyPercent = Double.valueOf(percent); } catch (NumberFormatException nfe) { //Stick with original } } } public Object clone() throws CloneNotSupportedException { return super.clone(); } public void visitClassContext(ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); packageName = cls.getPackageName(); clsName = cls.getClassName(); super.visitClassContext(classContext); } public void visitCode(Code obj) { stack.resetForMethodEntry(this); clsMethodCount = new HashMap<String, Integer>(); thisClsMethodCount = 0; super.visitCode(obj); String bestEnvy = null; double bestPercent = -1.0; Iterator<Map.Entry<String,Integer>> it = clsMethodCount.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String,Integer> entry = it.next(); Integer mc = entry.getValue(); if (mc.intValue() < 3) continue; double percent = ((double)mc.intValue()) / ((double)(mc.intValue() + thisClsMethodCount)); if (percent > bestPercent) { bestPercent = percent; bestEnvy = entry.getKey(); } } if (bestPercent > envyPercent) { bugReporter.reportBug( new BugInstance( this, "CE_CLASS_ENVY", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this, 0) .addString(bestEnvy)); } } public void sawOpcode(int seen) { try { if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE) || (seen == INVOKESTATIC)) { String calledClass = getClassConstantOperand().replace('/', '.'); if (calledClass.startsWith("java.") || calledClass.startsWith("javax.")) return; if (seen == INVOKEINTERFACE) { int parmCount = Type.getArgumentTypes(this.getMethodSig()).length; try { if (stack.getStackDepth() > parmCount) { OpcodeStack.Item itm = stack.getStackItem(parmCount); JavaClass jcls = itm.getJavaClass(); if (jcls != null) calledClass = itm.getJavaClass().getClassName(); } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } } String calledPackage = getPackageName(calledClass); if (calledClass.equals(clsName)) thisClsMethodCount++; else { if (similarPackages(calledPackage, packageName, 2)) { Integer cnt = clsMethodCount.get(calledClass); if (cnt == null) { cnt = new Integer(1); clsMethodCount.put(calledClass, cnt); } else { clsMethodCount.put(calledClass, new Integer(cnt.intValue() + 1)); } } } } } finally { stack.sawOpcode(this, seen); } } private String getPackageName(String className) { int dotPos = className.lastIndexOf("."); if (dotPos < 0) return ""; return className.substring(0, dotPos); } private boolean similarPackages(String packName1, String packName2, int depth) { if (depth == 0) return true; int dot1 = packName1.indexOf("."); int dot2 = packName2.indexOf("."); if (dot1 < 0) { if (dot2 < 0) return true; return false; } else if (dot2 < 0) return false; String s1 = packName1.substring(0, dot1); String s2 = packName2.substring(0, dot2); if (!s1.equals(s2)) return false; return similarPackages(packName1.substring(dot1+1), packName2.substring(dot2+1), depth-1); } } |
From: Dave B. <dbr...@us...> - 2005-09-17 04:42:43
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8800/etc Modified Files: findbugs.xml messages.xml Log Message: Initial Checkin: Class Envy Detector Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- messages.xml 15 Sep 2005 04:03:12 -0000 1.9 +++ messages.xml 17 Sep 2005 04:42:35 -0000 1.10 @@ -100,7 +100,18 @@ </Details> </Detector> - <!-- BugPattern --> + <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy"> + <Details> + <![CDATA[ + <p> Looks for methods that use a high percentage of methods from another class over it's own + methods. When this is the case, it is often to implement this method in that other class. + The reporting percentage can be set with system property 'fb-contrib.ce.percent'.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> <ShortDescription>method passes simple concatenating string in StringBuffer or StringBuilder append</ShortDescription> @@ -188,6 +199,19 @@ </Details> </BugPattern> + <BugPattern type="CE_CLASS_ENVY"> + <ShortDescription>method excessively uses methods of another class</ShortDescription> + <LongDescription>method {1} excessively uses methods of another class</LongDescription> + <Details> + <![CDATA[ + <p>This method makes extensive use of methods from another class over methods of it's own + class. Typically this means that the functionality that is accomplished by this method + most likely belongs with the class that is being used so liberally. Consider moving this + method to that class.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -197,5 +221,6 @@ <BugCode abbrev="LII">List Indexed Iterating</BugCode> <BugCode abbrev="UCC">Unrelated Collection Contents</BugCode> <BugCode abbrev="DRE">Declared Runtime Exception</BugCode> + <BugCode abbrev="CE">Class Envy</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.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- findbugs.xml 15 Sep 2005 04:03:12 -0000 1.10 +++ findbugs.xml 17 Sep 2005 04:42:35 -0000 1.11 @@ -40,15 +40,20 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" speed="fast" reports="DRE_DECLARED_RUNTIME_EXCEPTION" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" + speed="fast" + reports="CE_CLASS_ENVY" /> <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> <BugPattern abbrev="SCI" type="SCI_SYNCHRONIZED_COLLECTION_ITERATORS" category="CORRECTNESS" /> <BugPattern abbrev="CC" type="CC_CYCLOMATIC_COMPLEXITY" category="STYLE" /> - <BugPattern abbrev="OCP" type="OCP_OVERLY_CONCRETE_PARAMETER" category="STYLE" experimental="true" /> - <BugPattern abbrev="LII" type="LII_LIST_INDEXED_ITERATING" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="UCC" type="UCC_UNRELATED_COLLECTION_CONTENTS" category="STYLE" experimental="true" /> - <BugPattern abbrev="DRE" type="DRE_DECLARED_RUNTIME_EXCEPTION" category="STYLE" experimental="true" /> + <BugPattern abbrev="OCP" type="OCP_OVERLY_CONCRETE_PARAMETER" category="STYLE" /> + <BugPattern abbrev="LII" type="LII_LIST_INDEXED_ITERATING" category="PERFORMANCE" /> + <BugPattern abbrev="UCC" type="UCC_UNRELATED_COLLECTION_CONTENTS" category="STYLE" /> + <BugPattern abbrev="DRE" type="DRE_DECLARED_RUNTIME_EXCEPTION" category="STYLE" /> + <BugPattern abbrev="CE" type="CE_CLASS_ENVY" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-09-17 04:42:43
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8800/samples Added Files: CE_Sample.java Log Message: Initial Checkin: Class Envy Detector --- NEW FILE: CE_Sample.java --- public class CE_Sample { public void test() { Envy e = new Envy(); e.a(); e.b(); test2(); e.c(); e.d(); e.e(); e.f(); } public void test2() { } } class Envy { public void a() {} public void b() {} public void c() {} public void d() {} public void e() {} public void f() {} } |
From: Dave B. <dbr...@us...> - 2005-09-16 05:12:43
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13172/htdocs Modified Files: index.html Log Message: release 1.0.0 Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- index.html 16 Sep 2005 04:30:19 -0000 1.7 +++ index.html 16 Sep 2005 05:12:35 -0000 1.8 @@ -15,8 +15,7 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> - Detectors added in CVS for a future release<br/> - Note: these detectors are still being tested. + Detectors added in v1.0.0<br/> <ul> <li><b>Overly Concrete Parameters</b><br/> Finds parameters to methods that are defined as concrete classes, |
From: Dave B. <dbr...@us...> - 2005-09-16 05:11:42
|
Update of /cvsroot/fb-contrib/fb-contrib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12970 Modified Files: build.xml Log Message: release 1.0.0 Index: build.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/build.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- build.xml 10 Sep 2005 04:19:45 -0000 1.6 +++ build.xml 16 Sep 2005 05:11:32 -0000 1.7 @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on"/> <property name="javac.debug" value="on"/> - <property name="fb-contrib.version" value="0.9.3"/> + <property name="fb-contrib.version" value="1.0.0"/> <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}"/> |
From: Dave B. <dbr...@us...> - 2005-09-16 04:30:27
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6442/htdocs Modified Files: index.html Log Message: bigger headline Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- index.html 16 Sep 2005 04:21:00 -0000 1.6 +++ index.html 16 Sep 2005 04:30:19 -0000 1.7 @@ -3,8 +3,8 @@ <meta name="keywords" content="findbugs,plugin,detector,bug,static,jar"/> <title>fb-contrib: A FindBugs auxiliary detector plugin</title> </head> -<body> - <h3>fb-contrib: A FindBugs auxiliary detector plugin</h3> +<body background> + <h1>fb-contrib: A FindBugs auxiliary detector plugin</h1> <p>fb-contrib is an extra detector plugin to be used with the static bug finder FindBugs (findbugs.sourceforge.net). Just download the fb-contrib.jar |
From: Dave B. <dbr...@us...> - 2005-09-16 04:21:08
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5230/htdocs Modified Files: index.html Log Message: spelling Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- index.html 15 Sep 2005 04:06:39 -0000 1.5 +++ index.html 16 Sep 2005 04:21:00 -0000 1.6 @@ -1,10 +1,10 @@ <html> <head> <meta name="keywords" content="findbugs,plugin,detector,bug,static,jar"/> -<title>fb-contrib: A FindBugs auxillary detector plugin</title> +<title>fb-contrib: A FindBugs auxiliary detector plugin</title> </head> <body> - <h3>fb-contrib: A FindBugs auxillary detector plugin</h3> + <h3>fb-contrib: A FindBugs auxiliary detector plugin</h3> <p>fb-contrib is an extra detector plugin to be used with the static bug finder FindBugs (findbugs.sourceforge.net). Just download the fb-contrib.jar |
From: Dave B. <dbr...@us...> - 2005-09-16 03:20:23
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28126/src/com/mebigfatguy/fbcontrib/detect Modified Files: CyclomaticComplexity.java Log Message: fix CC counting with regards to Handled exceptions Index: CyclomaticComplexity.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CyclomaticComplexity.java 6 Sep 2005 03:03:51 -0000 1.2 +++ CyclomaticComplexity.java 16 Sep 2005 03:20:14 -0000 1.3 @@ -81,7 +81,8 @@ if ((edgeType != EdgeTypes.FALL_THROUGH_EDGE) && (edgeType != EdgeTypes.RETURN_EDGE) && (edgeType != EdgeTypes.UNKNOWN_EDGE)) { - if (edgeType == EdgeTypes.UNHANDLED_EXCEPTION_EDGE) { + if ((edgeType == EdgeTypes.UNHANDLED_EXCEPTION_EDGE) + || (edgeType == EdgeTypes.HANDLED_EXCEPTION_EDGE)) { Integer nodeTarget = new Integer(e.getTarget().getId()); if (!exceptionNodeTargets.contains(nodeTarget)) { exceptionNodeTargets.add(nodeTarget); |
From: Dave B. <dbr...@us...> - 2005-09-16 02:36:27
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20192/src/com/mebigfatguy/fbcontrib/detect Modified Files: DeclaredRuntimeException.java Log Message: report non java.lang exceptions as low priority Index: DeclaredRuntimeException.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- DeclaredRuntimeException.java 15 Sep 2005 04:03:12 -0000 1.1 +++ DeclaredRuntimeException.java 16 Sep 2005 02:36:19 -0000 1.2 @@ -49,6 +49,7 @@ if (et != null) { String[] exNames = et.getExceptionNames(); Set<String> methodRTExceptions = new HashSet<String>(); + int priority = LOW_PRIORITY; boolean foundRuntime = false; for (String ex : exNames) { boolean isRuntime = false; @@ -59,6 +60,8 @@ JavaClass exClass = Repository.lookupClass(ex); if (exClass.instanceOf(runtimeExceptionClass)) { runtimeExceptions.add(ex); + if (ex.startsWith("java.lang.")) + priority = NORMAL_PRIORITY; isRuntime = true; } } catch (ClassNotFoundException cnfe) { @@ -75,7 +78,7 @@ } if (foundRuntime) { - BugInstance bug = new BugInstance(this, "DRE_DECLARED_RUNTIME_EXCEPTION", NORMAL_PRIORITY) + BugInstance bug = new BugInstance(this, "DRE_DECLARED_RUNTIME_EXCEPTION", priority) .addClass(this) .addMethod(this); |
From: Dave B. <dbr...@us...> - 2005-09-15 04:06:48
|
Update of /cvsroot/fb-contrib/fb-contrib/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21149/htdocs Modified Files: index.html Log Message: add DRE Index: index.html =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/htdocs/index.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- index.html 13 Sep 2005 06:00:35 -0000 1.4 +++ index.html 15 Sep 2005 04:06:39 -0000 1.5 @@ -15,20 +15,6 @@ <a href="http://www.sourceforge.net/projects/fb-contrib">Project Page</a> <hr/> - Detectors added in v0.9.3 - <ul> - <li><b>Inefficient String Buffering</b><br/> - Finds Concatenation inside of a StringBuffer.append call, which - creates temporary StringBuffers.</li> - <li><b>Synchronized Collection Iterators</b><br/> - Finds use of iterators on collections built from Collection.synchronizedXXX() - calls. As iterators are by default not multithread safe, there use with a - synchronized collections seems dubious.</li> - <li><b>Cyclomatic Complexity</b><br/> - Finds methods that are overly complex based on the McCabe algorithm for - counting number of unique branches in the method</li> - </ul> - <hr/> Detectors added in CVS for a future release<br/> Note: these detectors are still being tested. <ul> @@ -46,6 +32,25 @@ than java.lang.Object. Doing so, leads to brittle code, either by 'encoding' type knowledge in the position of an element, or using instanceof tests. It is usually better to create a separate class, add the individual types as members to it, and add an instance of this class to the collection.</li> + <li><b>Declared Runtime Exception</b><br/> + Finds methods that declare RuntimeExceptions in their throws clause. While not illegal, + this may indicate a misunderstanding as to how unchecked exceptions are handled. + If is felt that a RuntimeException is so prevalent that it should be declared, it + is probably a better idea to prevent the occurance in code.</li> + </ul> + <hr/> + Detectors added in v0.9.3 + <ul> + <li><b>Inefficient String Buffering</b><br/> + Finds Concatenation inside of a StringBuffer.append call, which + creates temporary StringBuffers.</li> + <li><b>Synchronized Collection Iterators</b><br/> + Finds use of iterators on collections built from Collection.synchronizedXXX() + calls. As iterators are by default not multithread safe, there use with a + synchronized collections seems dubious.</li> + <li><b>Cyclomatic Complexity</b><br/> + Finds methods that are overly complex based on the McCabe algorithm for + counting number of unique branches in the method</li> </ul> </body> </html> \ No newline at end of file |
From: Dave B. <dbr...@us...> - 2005-09-15 04:03:21
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20538/src/com/mebigfatguy/fbcontrib/detect Added Files: DeclaredRuntimeException.java Log Message: Initial Checkin: DRE --- NEW FILE: DeclaredRuntimeException.java --- package com.mebigfatguy.fbcontrib.detect; import java.util.HashSet; import java.util.Set; import org.apache.bcel.Repository; import org.apache.bcel.classfile.ExceptionTable; 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.StringAnnotation; import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.visitclass.PreorderVisitor; public class DeclaredRuntimeException extends PreorderVisitor implements Detector, StatelessDetector { private BugReporter bugReporter; private static final Set<String> runtimeExceptions = new HashSet<String>(); private static final Set<String> notFoundExceptions = new HashSet<String>(); private static JavaClass runtimeExceptionClass; { try { runtimeExceptionClass = Repository.lookupClass("java.lang.RuntimeException"); } catch (ClassNotFoundException cnfe) { runtimeExceptionClass = null; } } public DeclaredRuntimeException(BugReporter bugReporter) { this.bugReporter = bugReporter; } public Object clone() throws CloneNotSupportedException { return super.clone(); } public void visitClassContext(ClassContext classContext) { if (runtimeExceptionClass != null) classContext.getJavaClass().accept(this); } public void visitMethod(Method obj) { ExceptionTable et = obj.getExceptionTable(); if (et != null) { String[] exNames = et.getExceptionNames(); Set<String> methodRTExceptions = new HashSet<String>(); boolean foundRuntime = false; for (String ex : exNames) { boolean isRuntime = false; if (runtimeExceptions.contains(ex)) isRuntime = true; else { try { JavaClass exClass = Repository.lookupClass(ex); if (exClass.instanceOf(runtimeExceptionClass)) { runtimeExceptions.add(ex); isRuntime = true; } } catch (ClassNotFoundException cnfe) { if (!notFoundExceptions.contains(ex)) { bugReporter.reportMissingClass(cnfe); notFoundExceptions.add(ex); } } } if (isRuntime) { foundRuntime = true; methodRTExceptions.add(ex); } } if (foundRuntime) { BugInstance bug = new BugInstance(this, "DRE_DECLARED_RUNTIME_EXCEPTION", NORMAL_PRIORITY) .addClass(this) .addMethod(this); for (String ex : methodRTExceptions) { bug.add(new StringAnnotation(ex)); } bugReporter.reportBug(bug); } } } public void report() { } } |
From: Dave B. <dbr...@us...> - 2005-09-15 04:03:21
|
Update of /cvsroot/fb-contrib/fb-contrib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20538/samples Added Files: DRE_Sample.java Log Message: Initial Checkin: DRE --- NEW FILE: DRE_Sample.java --- import java.io.IOException; import java.sql.SQLException; public class DRE_Sample { public void test1(int a) throws NullPointerException { } public void test2(int b) throws ClassCastException, IOException, IllegalMonitorStateException { if (b == 0) throw new IOException("test"); } public void test3(int c) throws SQLException { if (c == 0) throw new SQLException("test"); } } |
From: Dave B. <dbr...@us...> - 2005-09-15 04:03:21
|
Update of /cvsroot/fb-contrib/fb-contrib/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20538/etc Modified Files: findbugs.xml messages.xml Log Message: Initial Checkin: DRE Index: messages.xml =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/etc/messages.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- messages.xml 13 Sep 2005 05:46:39 -0000 1.8 +++ messages.xml 15 Sep 2005 04:03:12 -0000 1.9 @@ -83,6 +83,19 @@ determine type. A better design usually can be had by creating a seperate class, which defines the different types required, and add an instance of that class to the collection, or array.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException"> + <Details> + <![CDATA[ + <p> Looks for methods that declare Runtime exceptions in their throws clause. While doing + so is not illegal, it may represent a misunderstanding as to the exception in question. + If a RuntimeException is declared, it implies that this exception type is expected to happen, + which if true, should be handled in code, and not propogated. </p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -162,6 +175,19 @@ </Details> </BugPattern> + <BugPattern type="DRE_DECLARED_RUNTIME_EXCEPTION"> + <ShortDescription>method declares RuntimeException in throws clause</ShortDescription> + <LongDescription>method {1} declares RuntimeException in throws clause</LongDescription> + <Details> + <![CDATA[ + <p>This method declares a RuntimeException derived class in it's throws clause. + This may indicate a misunderstanding as to how unchecked exceptions are handled. + If is felt that a RuntimeException is so prevalent that it should be declared, it + is probably a better idea to prevent the occurance in code.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -170,5 +196,6 @@ <BugCode abbrev="OCP">Overly Concrete Parameters</BugCode> <BugCode abbrev="LII">List Indexed Iterating</BugCode> <BugCode abbrev="UCC">Unrelated Collection Contents</BugCode> + <BugCode abbrev="DRE">Declared Runtime Exception</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.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- findbugs.xml 13 Sep 2005 05:46:39 -0000 1.9 +++ findbugs.xml 15 Sep 2005 04:03:12 -0000 1.10 @@ -37,6 +37,10 @@ speed="fast" reports="UCC_UNRELATED_COLLECTION_CONTENTS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" + speed="fast" + reports="DRE_DECLARED_RUNTIME_EXCEPTION" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -45,5 +49,6 @@ <BugPattern abbrev="OCP" type="OCP_OVERLY_CONCRETE_PARAMETER" category="STYLE" experimental="true" /> <BugPattern abbrev="LII" type="LII_LIST_INDEXED_ITERATING" category="PERFORMANCE" experimental="true" /> <BugPattern abbrev="UCC" type="UCC_UNRELATED_COLLECTION_CONTENTS" category="STYLE" experimental="true" /> + <BugPattern abbrev="DRE" type="DRE_DECLARED_RUNTIME_EXCEPTION" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file |