Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [549] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/de
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-06-06 04:28:07
|
Revision: 549 Author: dbrosius Date: 2006-06-05 21:27:58 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=549&view=rev Log Message: ----------- add 'append' as a risky name content Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 04:13:16 UTC (rev 548) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 04:27:58 UTC (rev 549) @@ -30,6 +30,7 @@ static { riskyMethodNameContents.add("next"); riskyMethodNameContents.add("add"); + riskyMethodNameContents.add("append"); riskyMethodNameContents.add("put"); riskyMethodNameContents.add("remove"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-06 04:30:27
|
Revision: 550 Author: dbrosius Date: 2006-06-05 21:30:19 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=550&view=rev Log Message: ----------- add method name and signature to the bug report Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 04:27:58 UTC (rev 549) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 04:30:19 UTC (rev 550) @@ -110,7 +110,8 @@ bugReporter.reportBug(new BugInstance(this, "RMC_REDUNDANT_METHOD_CALLS", NORMAL_PRIORITY) .addClass(this) .addMethod(this) - .addSourceLine(this)); + .addSourceLine(this) + .addString(methodName + "[" + signature + "]")); } } if (reg >= 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-06 04:53:30
|
Revision: 551 Author: dbrosius Date: 2006-06-05 21:53:23 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=551&view=rev Log Message: ----------- clearer format msg Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 04:30:19 UTC (rev 550) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 04:53:23 UTC (rev 551) @@ -111,7 +111,7 @@ .addClass(this) .addMethod(this) .addSourceLine(this) - .addString(methodName + "[" + signature + "]")); + .addString(methodName + signature)); } } if (reg >= 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-06 04:55:53
|
Revision: 552 Author: dbrosius Date: 2006-06-05 21:55:47 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=552&view=rev Log Message: ----------- add 'read' and 'write' to risky method contents Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 04:53:23 UTC (rev 551) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 04:55:47 UTC (rev 552) @@ -33,6 +33,8 @@ riskyMethodNameContents.add("append"); riskyMethodNameContents.add("put"); riskyMethodNameContents.add("remove"); + riskyMethodNameContents.add("read"); + riskyMethodNameContents.add("write"); } private BugReporter bugReporter; private OpcodeStack stack = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-06 05:01:30
|
Revision: 553 Author: dbrosius Date: 2006-06-05 22:01:25 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=553&view=rev Log Message: ----------- add branch targets for TABLESWITCH and LOOKUPSWITCH Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 04:55:47 UTC (rev 552) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 05:01:25 UTC (rev 553) @@ -77,6 +77,12 @@ if (((seen >= IFEQ) && (seen <= GOTO)) || ((seen >= IFNULL) && (seen <= GOTO_W))) { branchTargets.add(Integer14.valueOf(getBranchTarget())); + } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) { + int[] offsets = getSwitchOffsets(); + int pc = getPC(); + for (int offset : offsets) { + branchTargets.add(Integer14.valueOf(offset + pc)); + } } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { localMethodCalls.remove(Integer14.valueOf(RegisterUtils.getAStoreReg(this, seen))); } else if (seen == PUTFIELD) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-06 16:02:27
|
Revision: 555 Author: dbrosius Date: 2006-06-06 09:02:16 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=555&view=rev Log Message: ----------- add javadoc, copyright Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 15:57:07 UTC (rev 554) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 16:02:16 UTC (rev 555) @@ -1,3 +1,21 @@ +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2006 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.fbcontrib.detect; import java.util.Arrays; @@ -42,10 +60,19 @@ private Map<String, MethodCall> fieldMethodCalls = null; private Set<Integer> branchTargets = null; + /** + * constructs a RMC detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ public RedundantMethodCalls(BugReporter bugReporter) { this.bugReporter = bugReporter; } + /** + * implements the visitor to create and clear the stack, method call maps, and branch targets + * + * @param classContext the context object of the currently visited class + */ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); @@ -60,6 +87,12 @@ branchTargets = null; } } + + /** + * implements the visitor to reset the stack, and method call maps for new method + * + * @param obj the context object of the currently parsed code block + */ public void visitCode(Code obj) { stack.resetForMethodEntry(this); localMethodCalls.clear(); @@ -67,6 +100,12 @@ super.visitCode(obj); } + /** + * implements the visitor to look for repetitive calls to the same method on the same object + * using the same constant parameters. These methods must return a value. + * + * @param seen the opcode of the currently parsed instruction + */ public void sawOpcode(int seen) { try { stack.mergeJumps(this); @@ -141,6 +180,12 @@ } } + /** + * returns true if the method name contains a pattern that is considered likely to be this modifying + * + * @param methodName the method name to check + * @return whether the method sounds like it modifies this + */ private boolean isRiskyName(String methodName) { methodName = methodName.toLowerCase(Locale.ENGLISH); for (String riskyName : riskyMethodNameContents) { @@ -150,6 +195,9 @@ return false; } + /** + * contains information about a method call + */ private static class MethodCall { private String methodName; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-06 16:04:46
|
Revision: 556 Author: dbrosius Date: 2006-06-06 09:04:36 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=556&view=rev Log Message: ----------- loosen permissions Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 16:02:16 UTC (rev 555) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 16:04:36 UTC (rev 556) @@ -198,27 +198,27 @@ /** * contains information about a method call */ - private static class MethodCall + static class MethodCall { private String methodName; private String methodSignature; private Object[] methodParms; - private MethodCall(String name, String signature, Object[] parms) { + public MethodCall(String name, String signature, Object[] parms) { methodName = name; methodSignature = signature; methodParms = parms; } - private String getName() { + public String getName() { return methodName; } - private String getSignature() { + public String getSignature() { return methodSignature; } - private Object[] getParms() { + public Object[] getParms() { return methodParms; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-06 21:00:40
|
Revision: 558 Author: dbrosius Date: 2006-06-06 13:30:34 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=558&view=rev Log Message: ----------- reset branchTargets on method entry, and enter catch block targets into branchTargets Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 16:08:04 UTC (rev 557) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 20:30:34 UTC (rev 558) @@ -26,6 +26,7 @@ import java.util.Set; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.CodeException; import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.Integer14; @@ -97,6 +98,11 @@ stack.resetForMethodEntry(this); localMethodCalls.clear(); fieldMethodCalls.clear(); + branchTargets.clear(); + CodeException[] codeExceptions = obj.getExceptionTable(); + for (CodeException codeEx : codeExceptions) { + branchTargets.add(codeEx.getHandlerPC()); + } super.visitCode(obj); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-07 04:45:20
|
Revision: 559 Author: dbrosius Date: 2006-06-06 21:45:14 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=559&view=rev Log Message: ----------- add ability for user to add risky method name parts, thru system property 'fbcontrib.RMC.riskynames' Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-06 20:30:34 UTC (rev 558) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-07 04:45:14 UTC (rev 559) @@ -45,6 +45,8 @@ */ public class RedundantMethodCalls extends BytecodeScanningDetector { + public static final String RMC_RISKY_USER_KEY = "fbcontrib.RMC.riskynames"; + private static Set<String> riskyMethodNameContents = new HashSet<String>(); static { riskyMethodNameContents.add("next"); @@ -54,6 +56,13 @@ riskyMethodNameContents.add("remove"); riskyMethodNameContents.add("read"); riskyMethodNameContents.add("write"); + + String userNameProp = System.getProperty(RMC_RISKY_USER_KEY); + if (userNameProp != null) { + String[] userNames = userNameProp.split("\\s*,\\s*"); + for (String name : userNames) + riskyMethodNameContents.add(name.toLowerCase()); + } } private BugReporter bugReporter; private OpcodeStack stack = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-06-08 02:47:39
|
Revision: 560 Author: dbrosius Date: 2006-06-07 19:47:32 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=560&view=rev Log Message: ----------- add push/pop as risky patterns Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-07 04:45:14 UTC (rev 559) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-06-08 02:47:32 UTC (rev 560) @@ -56,6 +56,8 @@ riskyMethodNameContents.add("remove"); riskyMethodNameContents.add("read"); riskyMethodNameContents.add("write"); + riskyMethodNameContents.add("push"); + riskyMethodNameContents.add("pop"); String userNameProp = System.getProperty(RMC_RISKY_USER_KEY); if (userNameProp != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-07-11 22:05:04
|
Revision: 575 Author: dbrosius Date: 2006-07-11 15:04:12 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=575&view=rev Log Message: ----------- add 'clone' to the list of methods not to report in RMC Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-07-07 18:32:44 UTC (rev 574) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-07-11 22:04:12 UTC (rev 575) @@ -58,6 +58,7 @@ riskyMethodNameContents.add("write"); riskyMethodNameContents.add("push"); riskyMethodNameContents.add("pop"); + riskyMethodNameContents.add("clone"); String userNameProp = System.getProperty(RMC_RISKY_USER_KEY); if (userNameProp != 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 06:37:53
|
Revision: 582 Author: dbrosius Date: 2006-08-03 23:37:49 -0700 (Thu, 03 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=582&view=rev Log Message: ----------- RMC uses the getter statistics to report gettors at a low priority Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 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:28:08 UTC (rev 581) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RedundantMethodCalls.java 2006-08-04 06:37:49 UTC (rev 582) @@ -29,6 +29,7 @@ import org.apache.bcel.classfile.CodeException; import org.apache.bcel.generic.Type; +import com.mebigfatguy.fbcontrib.collect.Statistics; import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -172,7 +173,8 @@ if (!signature.endsWith("V") && methodName.equals(mc.getName()) && signature.equals(mc.getSignature()) && !isRiskyName(methodName)) { Object[] parms = mc.getParms(); if (Arrays.equals(parms, parmConstants)) { - bugReporter.reportBug(new BugInstance(this, "RMC_REDUNDANT_METHOD_CALLS", NORMAL_PRIORITY) + Statistics statistics = Statistics.getStatistics(); + bugReporter.reportBug(new BugInstance(this, "RMC_REDUNDANT_METHOD_CALLS", statistics.isSimpleGetter(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. |