[Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect ClassEnvy.java,1.3,1.4 Cyclomati
Brought to you by:
dbrosius
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25068/src/com/mebigfatguy/fbcontrib/detect Modified Files: ClassEnvy.java CyclomaticComplexity.java DeclaredRuntimeException.java DubiousListCollection.java FinalParameters.java InefficientStringBuffering.java ListIndexedIterating.java LiteralStringComparison.java OverlyConcreteParameter.java ParallelLists.java PartiallyConstructedObjectAccess.java SyncCollectionIterators.java UnrelatedCollectionContents.java Log Message: finalize parameters, and then realized that the FinalParameters detector is fatally flawed, so hide it, for now.... ever? Index: DeclaredRuntimeException.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- DeclaredRuntimeException.java 20 Sep 2005 01:49:58 -0000 1.3 +++ DeclaredRuntimeException.java 1 Oct 2005 07:22:44 -0000 1.4 @@ -49,7 +49,7 @@ } } - public DeclaredRuntimeException(BugReporter bugReporter) { + public DeclaredRuntimeException(final BugReporter bugReporter) { this.bugReporter = bugReporter; } @@ -57,12 +57,12 @@ return super.clone(); } - public void visitClassContext(ClassContext classContext) { + public void visitClassContext(final ClassContext classContext) { if (runtimeExceptionClass != null) classContext.getJavaClass().accept(this); } - public void visitMethod(Method obj) { + public void visitMethod(final Method obj) { ExceptionTable et = obj.getExceptionTable(); if (et != null) { String[] exNames = et.getExceptionNames(); Index: ListIndexedIterating.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ListIndexedIterating.java 10 Sep 2005 04:12:41 -0000 1.1 +++ ListIndexedIterating.java 1 Oct 2005 07:22:44 -0000 1.2 @@ -50,7 +50,7 @@ private int loopReg; private boolean sawListSize; - public ListIndexedIterating(BugReporter bugReporter) { + public ListIndexedIterating(final BugReporter bugReporter) { this.bugReporter = bugReporter; stack = new OpcodeStack(); possibleForLoops = new HashSet<ForLoop>(); @@ -60,7 +60,7 @@ return super.clone(); } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { sawListSize = false; stack.resetForMethodEntry(this); @@ -76,14 +76,14 @@ } } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { if (stage == FIND_LOOP_STAGE) sawOpcodeLoop(seen); else sawOpcodeBug(seen); } - private void sawOpcodeLoop(int seen) { + private void sawOpcodeLoop(final int seen) { try { switch (state) { case SEEN_NOTHING: @@ -116,7 +116,7 @@ } } - private void sawOpcodeBug(int seen) { + private void sawOpcodeBug(final int seen) { try { Iterator<ForLoop> it = possibleForLoops.iterator(); while (it.hasNext()) { @@ -182,7 +182,7 @@ } } - private int getReg(int seen, int generalOp, int zeroOp) { + private int getReg(final int seen, final int generalOp, final int zeroOp) { if (seen == generalOp) return getRegisterOperand(); return seen - zeroOp; @@ -196,7 +196,7 @@ private int loopState; private boolean loopRegLoaded; - public ForLoop( int start, int end, int reg) { + public ForLoop( final int start, final int end, final int reg) { loopStart = start; loopEnd = end; loopReg = reg; @@ -216,7 +216,7 @@ return loopReg; } - public void setLoopState(int state) { + public void setLoopState(final int state) { loopState = state; } @@ -224,7 +224,7 @@ return loopState; } - public void setLoopRegLoaded(boolean loaded) { + public void setLoopRegLoaded(final boolean loaded) { loopRegLoaded = loaded; } Index: UnrelatedCollectionContents.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- UnrelatedCollectionContents.java 15 Sep 2005 02:49:52 -0000 1.6 +++ UnrelatedCollectionContents.java 1 Oct 2005 07:22:44 -0000 1.7 @@ -57,7 +57,7 @@ private Map<String, Set<SourceLineAnnotation>>memberSourceLineAnnotations; private Map<Integer, Set<SourceLineAnnotation>>localSourceLineAnnotations; - public UnrelatedCollectionContents(BugReporter bugReporter) { + public UnrelatedCollectionContents(final BugReporter bugReporter) { this.bugReporter = bugReporter; stack = new OpcodeStack(); } @@ -66,13 +66,13 @@ return super.clone(); } - public void visitClassContext(ClassContext classContext) { + public void visitClassContext(final ClassContext classContext) { memberCollections = new HashMap<String, Set<String>>(); memberSourceLineAnnotations = new HashMap<String, Set<SourceLineAnnotation>>(); super.visitClassContext(classContext); } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { localCollections = new HashMap<Integer, Set<String>>(); localScopeEnds = new HashMap<Integer, Set<Integer>>(); localSourceLineAnnotations = new HashMap<Integer, Set<SourceLineAnnotation>>(); @@ -80,7 +80,7 @@ super.visitCode(obj); } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { try { Set<Integer> regs = localScopeEnds.remove(getPC()); if (regs != null) { @@ -123,7 +123,7 @@ } } - private void checkAdd(OpcodeStack.Item colItm, OpcodeStack.Item addItm) + private void checkAdd(final OpcodeStack.Item colItm, final OpcodeStack.Item addItm) throws ClassNotFoundException { int reg = colItm.getRegisterNumber(); if (reg != -1) { @@ -172,7 +172,7 @@ } } - private void mergeItem(Set<String> supers, Set<SourceLineAnnotation> sla, OpcodeStack.Item addItm) + private void mergeItem(final Set<String> supers, final Set<SourceLineAnnotation> sla, final OpcodeStack.Item addItm) throws ClassNotFoundException { if (supers.size() == 0) @@ -201,7 +201,7 @@ } } - private void addNewItem(Set<String> supers, OpcodeStack.Item addItm) + private void addNewItem(final Set<String> supers, final OpcodeStack.Item addItm) throws ClassNotFoundException { if (addItm.getSignature().charAt(0) == '[') { @@ -231,7 +231,7 @@ } } - private static void intersection(Set<String> orig, Set<String> add) { + private static void intersection(final Set<String> orig, final Set<String> add) { Iterator<String> it = orig.iterator(); while (it.hasNext()) { if (!add.contains(it.next())) @@ -239,7 +239,7 @@ } } - private Integer getRegisterScopeEnd(int reg) { + private Integer getRegisterScopeEnd(final int reg) { LocalVariableTable lvt = getMethod().getLocalVariableTable(); if (lvt == null) return null; Index: SyncCollectionIterators.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SyncCollectionIterators.java 6 Sep 2005 03:03:51 -0000 1.2 +++ SyncCollectionIterators.java 1 Oct 2005 07:22:44 -0000 1.3 @@ -57,7 +57,7 @@ private Set<String> memberCollections = new HashSet<String>(); private Set<Integer> localCollections = new HashSet<Integer>(); - public SyncCollectionIterators(BugReporter bugReporter) { + public SyncCollectionIterators(final BugReporter bugReporter) { this.bugReporter = bugReporter; } @@ -65,19 +65,19 @@ return super.clone(); } - public void visitClassContext(ClassContext classContext) { + public void visitClassContext(final ClassContext classContext) { memberCollections.clear(); super.visitClassContext(classContext); } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { if (obj.getCode() != null) { state = SEEN_NOTHING; localCollections.clear(); super.visitCode(obj); } } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { switch (state) { case SEEN_NOTHING: if ((seen == INVOKESTATIC) && getClassConstantOperand().equals("java/util/Collections")) { Index: FinalParameters.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- FinalParameters.java 20 Sep 2005 01:49:58 -0000 1.2 +++ FinalParameters.java 1 Oct 2005 07:22:44 -0000 1.3 @@ -41,7 +41,7 @@ private boolean isStatic; private boolean isAbstract; - public FinalParameters(BugReporter bugReporter) { + public FinalParameters(final BugReporter bugReporter) { this.bugReporter = bugReporter; } @@ -49,17 +49,18 @@ return super.clone(); } - public void visitMethod(Method obj) { + public void visitMethod(final Method obj) { isStatic = (obj.getAccessFlags() & Constants.ACC_STATIC) != 0; isAbstract = (obj.getAccessFlags() & Constants.ACC_ABSTRACT) != 0; parmCount = Type.getArgumentTypes(obj.getSignature()).length; + super.visitMethod(obj); } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { if (isAbstract) return; - + changedParms = new HashSet<Integer>(); super.visitCode(obj); for (int i = 0; i < parmCount; i++) { @@ -81,7 +82,7 @@ } } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { int parm = getAStoreParameter(seen); if (parm >= 0) @@ -89,7 +90,7 @@ } } - private String getRegisterName(Code obj, int reg) { + private String getRegisterName(final Code obj, final int reg) { LocalVariableTable lvt = obj.getLocalVariableTable(); if (lvt != null) { LocalVariable lv = lvt.getLocalVariable(reg, 0); @@ -99,7 +100,7 @@ return String.valueOf(reg); } - private int getAStoreParameter(int seen) { + private int getAStoreParameter(final int seen) { int reg; if (seen == ASTORE) reg = getRegisterOperand(); Index: CyclomaticComplexity.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CyclomaticComplexity.java 16 Sep 2005 03:20:14 -0000 1.3 +++ CyclomaticComplexity.java 1 Oct 2005 07:22:44 -0000 1.4 @@ -43,7 +43,7 @@ private ClassContext classContext; private int reportLimit = 50; - public CyclomaticComplexity(BugReporter bugReporter) { + public CyclomaticComplexity(final BugReporter bugReporter) { this.bugReporter = bugReporter; Integer limit = Integer.getInteger(LIMIT_PROPERTY); if (limit != null) @@ -54,7 +54,7 @@ return super.clone(); } - public void visitClassContext(ClassContext context) { + public void visitClassContext(final ClassContext context) { classContext = context; classContext.getJavaClass().accept(this); } @@ -62,7 +62,7 @@ public void report() { } - public void visitMethod(Method obj) { + public void visitMethod(final Method obj) { try { if (obj.getCode() == null) return; Index: ClassEnvy.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ClassEnvy.java 17 Sep 2005 20:48:31 -0000 1.3 +++ ClassEnvy.java 1 Oct 2005 07:22:44 -0000 1.4 @@ -46,7 +46,7 @@ private int thisClsAccessCount; private double envyPercent = 0.90; - public ClassEnvy(BugReporter bugReporter) { + public ClassEnvy(final BugReporter bugReporter) { this.bugReporter = bugReporter; stack = new OpcodeStack(); String percent = System.getProperty(ENVY_PERCENT_PROPERTY); @@ -63,14 +63,14 @@ return super.clone(); } - public void visitClassContext(ClassContext classContext) { + public void visitClassContext(final ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); packageName = cls.getPackageName(); clsName = cls.getClassName(); super.visitClassContext(classContext); } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { stack.resetForMethodEntry(this); clsAccessCount = new HashMap<String, Integer>(); thisClsAccessCount = 0; @@ -104,7 +104,7 @@ } } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { try { if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE) @@ -131,7 +131,7 @@ } } - private boolean countClassAccess(int classAtStackIndex) { + private boolean countClassAccess(final int classAtStackIndex) { String calledClass = null; try { @@ -153,7 +153,7 @@ return true; } - private void countClassAccess(String calledClass) { + private void countClassAccess(final String calledClass) { if (calledClass.equals(clsName)) thisClsAccessCount++; else { @@ -170,7 +170,7 @@ } } - private boolean generalPurpose(String className) { + private boolean generalPurpose(final String className) { try { JavaClass cls = Repository.lookupClass(className); JavaClass[] infs = cls.getAllInterfaces(); @@ -204,14 +204,14 @@ return false; } - private String getPackageName(String className) { + private String getPackageName(final String className) { int dotPos = className.lastIndexOf("."); if (dotPos < 0) return ""; return className.substring(0, dotPos); } - private boolean similarPackages(String packName1, String packName2, int depth) { + private boolean similarPackages(final String packName1, final String packName2, int depth) { if (depth == 0) return true; Index: ParallelLists.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ParallelLists.java 25 Sep 2005 06:07:02 -0000 1.4 +++ ParallelLists.java 1 Oct 2005 07:22:44 -0000 1.5 @@ -42,7 +42,7 @@ private Set<String> listFields = new HashSet<String>(); private Map<Integer, String> indexToFieldMap = new HashMap<Integer, String>(); - public ParallelLists(BugReporter bugReporter) { + public ParallelLists(final BugReporter bugReporter) { this.bugReporter = bugReporter; } @@ -50,7 +50,7 @@ return super.clone(); } - public void visitClassContext(ClassContext classContext) { + public void visitClassContext(final ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); listFields.clear(); @@ -70,13 +70,13 @@ super.visitClassContext(classContext); } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { stack.resetForMethodEntry(this); indexToFieldMap.clear(); super.visitCode(obj); } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { try { if (seen == INVOKEINTERFACE) { String className = getClassConstantOperand(); @@ -101,7 +101,7 @@ } } - private int getIntOpRegister(int seen) { + private int getIntOpRegister(final int seen) { if ((seen == ISTORE) || (seen == IINC)) return getRegisterOperand(); return seen - ISTORE_0; Index: LiteralStringComparison.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- LiteralStringComparison.java 20 Sep 2005 01:49:58 -0000 1.2 +++ LiteralStringComparison.java 1 Oct 2005 07:22:44 -0000 1.3 @@ -30,7 +30,7 @@ private BugReporter bugReporter; private OpcodeStack stack; - public LiteralStringComparison(BugReporter bugReporter) { + public LiteralStringComparison(final BugReporter bugReporter) { this.bugReporter = bugReporter; stack = new OpcodeStack(); } @@ -39,12 +39,12 @@ return super.clone(); } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { stack.resetForMethodEntry(this); super.visitCode(obj); } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { try { if ((seen == INVOKEVIRTUAL) && "java/lang/String".equals(getClassConstantOperand())) { String calledMethodName = getNameConstantOperand(); Index: DubiousListCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- DubiousListCollection.java 22 Sep 2005 05:45:13 -0000 1.3 +++ DubiousListCollection.java 1 Oct 2005 07:22:44 -0000 1.4 @@ -62,7 +62,7 @@ private OpcodeStack stack = new OpcodeStack(); private Map<String, Integer> fieldsReported = new HashMap<String, Integer>(); - public DubiousListCollection(BugReporter bugReporter) { + public DubiousListCollection(final BugReporter bugReporter) { this.bugReporter = bugReporter; } @@ -85,12 +85,12 @@ } } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { stack.resetForMethodEntry(this); super.visitCode(obj); } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { try { if (seen == INVOKEINTERFACE) { String className = this.getClassConstantOperand(); @@ -128,7 +128,7 @@ } } - private FieldAnnotation getFieldFromStack(OpcodeStack stk, String signature) { + private FieldAnnotation getFieldFromStack(final OpcodeStack stk, final String signature) { int parmCount = Type.getArgumentTypes(signature).length; if (stk.getStackDepth() > parmCount) { OpcodeStack.Item itm = stk.getStackItem(parmCount); @@ -153,7 +153,7 @@ } } - private FieldAnnotation getFieldAnnotation(String fieldName) { + private FieldAnnotation getFieldAnnotation(final String fieldName) { JavaClass cls = getClassContext().getJavaClass(); Field[] fields = cls.getFields(); for (Field f : fields) { Index: PartiallyConstructedObjectAccess.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PartiallyConstructedObjectAccess.java 20 Sep 2005 02:28:42 -0000 1.1 +++ PartiallyConstructedObjectAccess.java 1 Oct 2005 07:22:44 -0000 1.2 @@ -36,7 +36,7 @@ private OpcodeStack stack; private boolean reportedCtor; - public PartiallyConstructedObjectAccess(BugReporter bugReporter) { + public PartiallyConstructedObjectAccess(final BugReporter bugReporter) { this.bugReporter = bugReporter; stack = new OpcodeStack(); } @@ -45,13 +45,13 @@ return super.clone(); } - public void visitClassContext(ClassContext classContext) { + public void visitClassContext(final ClassContext classContext) { JavaClass cls = classContext.getJavaClass(); if ((cls.getAccessFlags() & Constants.ACC_FINAL) == 0) super.visitClassContext(classContext); } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { stack.resetForMethodEntry(this); reportedCtor = false; if ("<init>".equals(getMethodName())) @@ -91,7 +91,7 @@ } } - private Method findMethod(JavaClass cls, String methodName, String methodSig) { + private Method findMethod(final JavaClass cls, final String methodName, final String methodSig) { Method[] methods = cls.getMethods(); for (Method m : methods) { if (methodName.equals(m.getName()) && methodSig.equals(m.getSignature())) { Index: InefficientStringBuffering.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- InefficientStringBuffering.java 3 Sep 2005 05:07:18 -0000 1.1 +++ InefficientStringBuffering.java 1 Oct 2005 07:22:44 -0000 1.2 @@ -32,7 +32,7 @@ private BugReporter bugReporter; private OpcodeStack opStack; - public InefficientStringBuffering(BugReporter bugReporter) { + public InefficientStringBuffering(final BugReporter bugReporter) { this.bugReporter = bugReporter; opStack = new OpcodeStack(); } @@ -41,13 +41,13 @@ return super.clone(); } - public void visit(Code c) { + public void visit(final Code c) { if (c.getCode() != null) { opStack.resetForMethodEntry(this); super.visit(c); } } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { try { if (seen == INVOKESPECIAL) { String calledClass = getClassConstantOperand(); Index: OverlyConcreteParameter.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- OverlyConcreteParameter.java 22 Sep 2005 02:04:37 -0000 1.16 +++ OverlyConcreteParameter.java 1 Oct 2005 07:22:44 -0000 1.17 @@ -51,7 +51,7 @@ private int parmCount; private boolean methodIsStatic; - public OverlyConcreteParameter(BugReporter bugReporter) { + public OverlyConcreteParameter(final BugReporter bugReporter) { this.bugReporter = bugReporter; try { objectClass = Repository.lookupClass("java.lang.Object"); @@ -65,7 +65,7 @@ return super.clone(); } - public void visitCode(Code obj) { + public void visitCode(final Code obj) { try { parameterDefiners.clear(); usedParameters.clear(); @@ -89,7 +89,7 @@ } } - public void sawOpcode(int seen) { + public void sawOpcode(final int seen) { if (parameterDefiners.size() == 0) return; @@ -215,7 +215,7 @@ return hasPossiblyOverlyConcreteParm; } - private Map<JavaClass, List<String>> getClassDefiners(JavaClass cls) + private Map<JavaClass, List<String>> getClassDefiners(final JavaClass cls) throws ClassNotFoundException { Map<JavaClass, List<String>> definers = new HashMap<JavaClass, List<String>>(); @@ -236,7 +236,7 @@ return definers; } - private List<String> getPublicMethodInfos(JavaClass cls) { + private List<String> getPublicMethodInfos(final JavaClass cls) { List<String> methodInfos = new ArrayList<String>(); Method[] methods = cls.getMethods(); for (Method m : methods) { @@ -248,7 +248,7 @@ return methodInfos; } - private void removeUselessDefiners(int reg) { + private void removeUselessDefiners(final int reg) { String methodSig = getSigConstantOperand(); String methodName = getNameConstantOperand(); String methodInfo = methodName + methodSig; @@ -275,7 +275,7 @@ } } - private void removeUselessDefiners(String parmSig, int reg) { + private void removeUselessDefiners(String parmSig, final int reg) { if (parmSig.startsWith("L")) { parmSig = parmSig.substring( 1, parmSig.length() - 1).replace('/', '.'); if ("java.lang.Object".equals(parmSig)) { |