[Fb-contrib-commit] SF.net SVN: fb-contrib:[1345] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2009-09-30 05:57:24
|
Revision: 1345 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1345&view=rev Author: dbrosius Date: 2009-09-30 05:57:16 +0000 (Wed, 30 Sep 2009) Log Message: ----------- report PDP on final methods of classes directly derived from Object, as well. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-29 04:31:13 UTC (rev 1344) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-30 05:57:16 UTC (rev 1345) @@ -35,6 +35,7 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.ba.ClassContext; /** * looks for non derivable method that declare parameters and then cast those @@ -55,6 +56,7 @@ String parmSig; int state; String castClass; + boolean derivedFromObject; /** * constructs a PDP detector given the reporter to report bugs on @@ -65,6 +67,16 @@ } /** + * implements the visitor to see if this class is directly derived from Object + * + * @param classContext the context object of the currently parsed class + */ + public void visitClassContext(ClassContext classContext) { + derivedFromObject = "java.lang.Object".equals(classContext.getJavaClass().getSuperclassName()); + super.visitClassContext(classContext); + } + + /** * implements the visitor to see if the method has parameters * * @param obj the context object of the currently parsed code block @@ -73,7 +85,7 @@ public void visitCode(Code obj) { try { Method m = getMethod(); - if (m.isStatic() || m.isPrivate() || "<init>".equals(m.getName())) { + if (m.isStatic() || m.isPrivate() || "<init>".equals(m.getName()) || (m.isFinal() && derivedFromObject)) { parmSigs = SignatureUtils.getParameterSignatures(m); if ((parmSigs.size() > 0) && prescreen(m)) { state = SAW_NOTHING; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |