Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [417] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-08 22:37:29
|
Revision: 417 Author: dbrosius Date: 2006-04-08 15:37:22 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=417&view=rev Log Message: ----------- don't check small methods Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-08 14:24:57 UTC (rev 416) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-08 22:37:22 UTC (rev 417) @@ -22,6 +22,7 @@ import java.util.Iterator; import java.util.Set; +import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; import edu.umd.cs.findbugs.BugInstance; @@ -92,9 +93,15 @@ @Override public void visitMethod(final Method obj) { try { - if (obj.getCode() == null) + Code code = obj.getCode(); + if (code == null) return; + //There really is no valid relationship between reportLimit and code + //length, but it is good enough. If the method is small, don't bother + if (code.getCode().length < reportLimit) + return; + Set<Integer> exceptionNodeTargets = new HashSet<Integer>(); CFG cfg = classContext.getCFG(obj); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-08 22:59:09
|
Revision: 418 Author: dbrosius Date: 2006-04-08 15:59:04 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=418&view=rev Log Message: ----------- the method length needs to twice the reportSize to even check it. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-08 22:37:22 UTC (rev 417) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-08 22:59:04 UTC (rev 418) @@ -99,7 +99,7 @@ //There really is no valid relationship between reportLimit and code //length, but it is good enough. If the method is small, don't bother - if (code.getCode().length < reportLimit) + if (code.getCode().length < (2*reportLimit)) return; Set<Integer> exceptionNodeTargets = new HashSet<Integer>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-17 15:30:10
|
Revision: 461 Author: dbrosius Date: 2006-04-17 08:29:54 -0700 (Mon, 17 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=461&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-17 15:28:23 UTC (rev 460) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-17 15:29:54 UTC (rev 461) @@ -18,30 +18,12 @@ */ package com.mebigfatguy.fbcontrib.detect; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import org.apache.bcel.classfile.Code; -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.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.EdgeTypes; -import edu.umd.cs.findbugs.visitclass.PreorderVisitor; - /** * Calculates the McCabe Cyclomatic Complexity measure and reports methods that have an * excessive value. This report value can be set with system property 'fb-contrib.cc.limit'. */ -public class CyclomaticComplexity extends PreorderVisitor implements Detector, StatelessDetector +public class CyclomaticComplexity extends PreorderVisitor implements Detector { public static final String LIMIT_PROPERTY = "fb-contrib.cc.limit"; private BugReporter bugReporter; @@ -60,16 +42,6 @@ } /** - * 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 to store the class context * * @param context the context object for the currently parsed class @@ -77,6 +49,7 @@ public void visitClassContext(final ClassContext context) { classContext = context; classContext.getJavaClass().accept(this); + classContext = null; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |