[Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect AbstractOverriddenMethod.java,1.
Brought to you by:
dbrosius
|
From: Dave B. <dbr...@us...> - 2006-03-22 06:51:49
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12363/src/com/mebigfatguy/fbcontrib/detect Modified Files: AbstractOverriddenMethod.java Log Message: try to report source lines, and short circuit once you find a bug Index: AbstractOverriddenMethod.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- AbstractOverriddenMethod.java 11 Mar 2006 06:35:25 -0000 1.3 +++ AbstractOverriddenMethod.java 22 Mar 2006 06:51:46 -0000 1.4 @@ -18,6 +18,7 @@ */ package com.mebigfatguy.fbcontrib.detect; +import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; @@ -33,6 +34,7 @@ */ public class AbstractOverriddenMethod extends PreorderVisitor implements Detector, StatelessDetector { private BugReporter bugReporter; + private ClassContext clsContext; private JavaClass[] superClasses; /** @@ -59,6 +61,7 @@ */ public void visitClassContext(ClassContext classContext) { try { + clsContext = classContext; JavaClass cls = classContext.getJavaClass(); superClasses = cls.getSuperClasses(); cls.accept(this); @@ -79,20 +82,25 @@ String methodName = obj.getName(); String methodSig = obj.getSignature(); - for (JavaClass cls : superClasses) { + outer: 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) + BugInstance bug = new BugInstance(this, "AOM_ABSTRACT_OVERRIDDEN_METHOD", NORMAL_PRIORITY) .addClass(this) - .addMethod(this)); + .addMethod(this); + + Code code = obj.getCode(); + if (code != null) + bug.addSourceLineRange(clsContext, this, 0, code.getLength()-1); + bugReporter.reportBug(bug); + + break outer; } } - } - + } } /** |