Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [462] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-17 15:37:12
|
Revision: 462 Author: dbrosius Date: 2006-04-17 08:37:01 -0700 (Mon, 17 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=462&view=rev Log Message: ----------- oops, fix booboo Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java 2006-04-17 15:29:54 UTC (rev 461) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java 2006-04-17 15:37:01 UTC (rev 462) @@ -29,8 +29,9 @@ 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; + /** * looks for methods that build xml based strings by concatenation strings * and custom values together. Doing so makes brittle code, that is difficult to 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:29:54 UTC (rev 461) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-17 15:37:01 UTC (rev 462) @@ -18,7 +18,25 @@ */ 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.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'. Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java 2006-04-17 15:29:54 UTC (rev 461) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java 2006-04-17 15:37:01 UTC (rev 462) @@ -26,13 +26,13 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.StatelessDetector; + /** * Looks for inefficient comparison of Date objects using two comparisons when one would do. */ -public class DateComparison extends BytecodeScanningDetector implements StatelessDetector { - +public class DateComparison extends BytecodeScanningDetector +{ private static final int SEEN_NOTHING = 0; private static final int SEEN_LOAD1_1 = 1; private static final int SEEN_LOAD1_2 = 2; @@ -65,17 +65,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 reset the registers * * @param obj the method of the currently parsed method This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-18 03:13:37
|
Revision: 475 Author: dbrosius Date: 2006-04-17 20:13:27 -0700 (Mon, 17 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=475&view=rev Log Message: ----------- clear stuff in the finally block Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2006-04-18 03:13:27 UTC (rev 475) @@ -54,12 +54,15 @@ */ @Override public void visitClassContext(ClassContext classContext) { - int majorVersion = classContext.getJavaClass().getMajor(); - if (majorVersion >= MAJOR_1_4) { - fbInfo = new ArrayList<FinallyBlockInfo>(); - super.visitClassContext(classContext); - fbInfo = null; - } + try { + int majorVersion = classContext.getJavaClass().getMajor(); + if (majorVersion >= MAJOR_1_4) { + fbInfo = new ArrayList<FinallyBlockInfo>(); + super.visitClassContext(classContext); + } + } finally { + fbInfo = null; + } } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java 2006-04-18 03:13:27 UTC (rev 475) @@ -61,26 +61,29 @@ */ @Override public void visitClassContext(ClassContext classContext) { - stack = new OpcodeStack(); - mapBugs = new ArrayList<BugInstance>(); - setBugs = new ArrayList<BugInstance>(); - hasMapComparator = false; - hasSetComparator = false; - super.visitClassContext(classContext); - if (!hasMapComparator) { - for (BugInstance bi : mapBugs) { - bugReporter.reportBug(bi); + try { + stack = new OpcodeStack(); + mapBugs = new ArrayList<BugInstance>(); + setBugs = new ArrayList<BugInstance>(); + 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); + + if (!hasSetComparator) { + for (BugInstance bi : setBugs) { + bugReporter.reportBug(bi); + } } + } finally { + stack = null; + mapBugs = null; + setBugs = null; } - stack = null; - mapBugs = null; - setBugs = null; } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2006-04-18 03:13:27 UTC (rev 475) @@ -72,11 +72,14 @@ */ @Override public void visitClassContext(ClassContext classContext) { - stack = new OpcodeStack(); - wrappers = new HashMap<Integer, WrapperInfo>(); - super.visitClassContext(classContext); - stack = null; - wrappers = null; + try { + stack = new OpcodeStack(); + wrappers = new HashMap<Integer, WrapperInfo>(); + super.visitClassContext(classContext); + } finally { + stack = null; + wrappers = null; + } } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2006-04-18 03:13:27 UTC (rev 475) @@ -66,13 +66,16 @@ @Override public void visitClassContext(ClassContext classContext) { - stack = new OpcodeStack(); - unsafeAliases = new HashSet<Integer>(); - branchInfo = new HashMap<Integer, Integer>(); - super.visitClassContext(classContext); - stack = null; - unsafeAliases = null; - branchInfo = null; + try { + stack = new OpcodeStack(); + unsafeAliases = new HashSet<Integer>(); + branchInfo = new HashMap<Integer, Integer>(); + super.visitClassContext(classContext); + } finally { + stack = null; + unsafeAliases = null; + branchInfo = null; + } } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2006-04-18 03:13:27 UTC (rev 475) @@ -89,13 +89,16 @@ */ @Override public void visitClassContext(final ClassContext classContext) { - JavaClass cls = classContext.getJavaClass(); - packageName = cls.getPackageName(); - clsName = cls.getClassName(); - stack = new OpcodeStack(); - super.visitClassContext(classContext); - stack = null; - clsAccessCount = null; + try { + JavaClass cls = classContext.getJavaClass(); + packageName = cls.getPackageName(); + clsName = cls.getClassName(); + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + stack = null; + clsAccessCount = null; + } } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java 2006-04-18 03:13:27 UTC (rev 475) @@ -65,9 +65,12 @@ */ @Override public void visitClassContext(ClassContext classContext) { - iConst0Looped = new HashSet<Integer>(); - super.visitClassContext(classContext); - iConst0Looped = null; + try { + iConst0Looped = new HashSet<Integer>(); + super.visitClassContext(classContext); + } finally { + iConst0Looped = null; + } } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java 2006-04-18 03:13:27 UTC (rev 475) @@ -83,9 +83,12 @@ */ @Override public void visitClassContext(ClassContext classContext) { - stack = new OpcodeStack(); - super.visitClassContext(classContext); - stack = null; + try { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + stack = null; + } } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2006-04-18 03:13:27 UTC (rev 475) @@ -65,9 +65,12 @@ * @param context the context object for the currently parsed class */ public void visitClassContext(final ClassContext context) { - classContext = context; - classContext.getJavaClass().accept(this); - classContext = null; + try { + classContext = context; + classContext.getJavaClass().accept(this); + } finally { + classContext = null; + } } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2006-04-18 03:13:27 UTC (rev 475) @@ -63,16 +63,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 and accepts if the Exception class was loaded * * @param classContext the context object for the currently parsed class Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-04-18 03:04:50 UTC (rev 474) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2006-04-18 03:13:27 UTC (rev 475) @@ -74,11 +74,14 @@ */ @Override public void visitClassContext(ClassContext classContext) { - stack = new OpcodeStack(); - possibleForLoops = new HashSet<ForLoop>(); - super.visitClassContext(classContext); - stack = null; - possibleForLoops = null; + try { + stack = new OpcodeStack(); + possibleForLoops = new HashSet<ForLoop>(); + super.visitClassContext(classContext); + } finally { + stack = null; + possibleForLoops = null; + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-08-04 14:25:15
|
Revision: 583 Author: dbrosius Date: 2006-08-04 07:24:59 -0700 (Fri, 04 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=583&view=rev Log Message: ----------- it would make sense if the classname was included to differentiate simple getters. duh! Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-04 06:37:49 UTC (rev 582) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2006-08-04 14:24:59 UTC (rev 583) @@ -67,7 +67,7 @@ case SG_SAW_GETFIELD: if ((seen >= IRETURN) && (seen <= ARETURN)) { - statistics.addSimpleGetter(getMethodName(), getMethodSig()); + statistics.addSimpleGetter(getClassName(), getMethodName(), getMethodSig()); } sgState = SG_INVALID; break; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2006-08-04 06:37:49 UTC (rev 582) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2006-08-04 14:24:59 UTC (rev 583) @@ -19,11 +19,11 @@ simpleGetters.clear(); } - public void addSimpleGetter(String methodName, String signature) { - simpleGetters.add(methodName + ":" + signature); + public void addSimpleGetter(String className, String methodName, String signature) { + simpleGetters.add(className + ":" + methodName + ":" + signature); } - public boolean isSimpleGetter(String methodName, String signature) { - return simpleGetters.contains(methodName + ":" + signature); + public boolean isSimpleGetter(String className, String methodName, String signature) { + return simpleGetters.contains(className + ":" + methodName + ":" + signature); } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-08-04 06:37:49 UTC (rev 582) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-08-04 14:24:59 UTC (rev 583) @@ -174,7 +174,7 @@ Object[] parms = mc.getParms(); if (Arrays.equals(parms, parmConstants)) { Statistics statistics = Statistics.getStatistics(); - bugReporter.reportBug(new BugInstance(this, "RMC_REDUNDANT_METHOD_CALLS", statistics.isSimpleGetter(methodName, signature) ? LOW_PRIORITY : NORMAL_PRIORITY) + bugReporter.reportBug(new BugInstance(this, "RMC_REDUNDANT_METHOD_CALLS", statistics.isSimpleGetter(getClassConstantOperand(), methodName, signature) ? LOW_PRIORITY : 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. |