fb-contrib-commit Mailing List for fb-contrib (Page 21)
Brought to you by:
dbrosius
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(56) |
Oct
(60) |
Nov
(58) |
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(66) |
Feb
(55) |
Mar
(85) |
Apr
(115) |
May
(35) |
Jun
(28) |
Jul
(3) |
Aug
(48) |
Sep
(37) |
Oct
(22) |
Nov
(14) |
Dec
(66) |
2007 |
Jan
(45) |
Feb
(63) |
Mar
(10) |
Apr
(1) |
May
(1) |
Jun
(12) |
Jul
|
Aug
|
Sep
(25) |
Oct
(21) |
Nov
(39) |
Dec
|
2008 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(5) |
May
(2) |
Jun
(32) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2009 |
Jan
(10) |
Feb
(31) |
Mar
(32) |
Apr
(35) |
May
(25) |
Jun
|
Jul
(31) |
Aug
(10) |
Sep
(95) |
Oct
(35) |
Nov
(10) |
Dec
(34) |
2010 |
Jan
(90) |
Feb
(4) |
Mar
(7) |
Apr
(20) |
May
(20) |
Jun
(13) |
Jul
(7) |
Aug
(18) |
Sep
(25) |
Oct
(4) |
Nov
(16) |
Dec
(2) |
2011 |
Jan
(1) |
Feb
|
Mar
(11) |
Apr
(3) |
May
(2) |
Jun
(26) |
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(14) |
Nov
(3) |
Dec
(4) |
2013 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(4) |
May
|
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(3) |
2014 |
Jan
(4) |
Feb
(2) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(2) |
Nov
(7) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(3) |
2018 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(5) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dbr...@us...> - 2009-09-29 03:59:47
|
Revision: 1341 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1341&view=rev Author: dbrosius Date: 2009-09-29 03:59:41 +0000 (Tue, 29 Sep 2009) Log Message: ----------- em Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-09-29 03:13:52 UTC (rev 1340) +++ trunk/fb-contrib/etc/messages.xml 2009-09-29 03:59:41 UTC (rev 1341) @@ -111,7 +111,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy"> <Details> <![CDATA[ - <p><b>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</b></p> + <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> <p> Looks for methods that use a high percentage of methods from another class over it's own methods. When this is the case, it is often better to implement this method in that other class, by refactoring the class to accept parameters it needs from the source class. @@ -702,7 +702,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope"> <Details> <![CDATA[ - <p><b>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</b> + <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em> Looks for assignments to variables in a scope larger than it's use. As long as the evaluation of the assignment does not have side effects, the assignment can be moved into the inner scope where it is used.</p> <p>It is a fast detector.</p> @@ -1143,7 +1143,7 @@ <LongDescription>method {1} excessively uses methods of another class</LongDescription> <Details> <![CDATA[ - <p><b>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</b></p> + <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> <p>This method makes extensive use of methods from another class over methods of it's own class. Typically this means that the functionality that is accomplished by this method most likely belongs with the class that is being used so liberally. Consider refactoring this @@ -2016,7 +2016,7 @@ <LongDescription>Method {1} uses non standard math constant</LongDescription> <Details> <![CDATA[ - <p>This method defines its own version of <b>PI</b> or <b>e</b> and the value is not as precise as the + <p>This method defines its own version of <em>PI</em> or <em>e</em> and the value is not as precise as the one defined in the constants Math.PI or Math.E. Use these constants instead.</p> ]]> </Details> @@ -2229,7 +2229,7 @@ <LongDescription>Method {1} assigns a variable in a larger scope then is needed</LongDescription> <Details> <![CDATA[ - <p><b>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</b> + <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em> This method assigns a value to a variable in an outer scope compared to where the variable is actually used. Assuming this evaluation does not have side effects, the assignment can be moved into the inner scope (if block) so that its execution time isn't taken up if the if guard is false. Care should be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-29 03:14:03
|
Revision: 1340 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1340&view=rev Author: dbrosius Date: 2009-09-29 03:13:52 +0000 (Tue, 29 Sep 2009) Log Message: ----------- final could still be derived, so don't do final 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 03:01:21 UTC (rev 1339) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-29 03:13:52 UTC (rev 1340) @@ -73,7 +73,7 @@ public void visitCode(Code obj) { try { Method m = getMethod(); - if (m.isStatic() || m.isFinal() || m.isPrivate() || "<init>".equals(m.getName())) { + if (m.isStatic() || m.isPrivate() || "<init>".equals(m.getName())) { 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. |
From: <dbr...@us...> - 2009-09-29 03:01:41
|
Revision: 1339 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1339&view=rev Author: dbrosius Date: 2009-09-29 03:01:21 +0000 (Tue, 29 Sep 2009) Log Message: ----------- more tests Modified Paths: -------------- trunk/fb-contrib/samples/PDP_Sample.java Modified: trunk/fb-contrib/samples/PDP_Sample.java =================================================================== --- trunk/fb-contrib/samples/PDP_Sample.java 2009-09-29 01:39:13 UTC (rev 1338) +++ trunk/fb-contrib/samples/PDP_Sample.java 2009-09-29 03:01:21 UTC (rev 1339) @@ -36,4 +36,13 @@ { al = (ArrayList<String>) l; } + + public void testMultiCasts(String key, Object o) { + if (key.equals("Foo")) { + double d = ((Double) o).doubleValue(); + } + else if (key.equals("Boo")) { + float f = ((Float) o).floatValue(); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-29 01:39:21
|
Revision: 1338 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1338&view=rev Author: dbrosius Date: 2009-09-29 01:39:13 +0000 (Tue, 29 Sep 2009) Log Message: ----------- don't report parms that are cast to multiple different types even tho this is suspect 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 01:34:18 UTC (rev 1337) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-29 01:39:13 UTC (rev 1338) @@ -19,6 +19,7 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.BitSet; +import java.util.HashMap; import java.util.Map; import org.apache.bcel.Constants; @@ -49,9 +50,11 @@ BugReporter bugReporter; Map<Integer, String> parmSigs; + Map<Integer, BugInfo> bugs; int loadedReg; String parmSig; int state; + String castClass; /** * constructs a PDP detector given the reporter to report bugs on @@ -68,13 +71,21 @@ */ @Override public void visitCode(Code obj) { - Method m = getMethod(); - if (m.isStatic() || m.isFinal() || m.isPrivate() || "<init>".equals(m.getName())) { - parmSigs = SignatureUtils.getParameterSignatures(m); - if ((parmSigs.size() > 0) && prescreen(m)) { - state = SAW_NOTHING; - super.visitCode(obj); + try { + Method m = getMethod(); + if (m.isStatic() || m.isFinal() || m.isPrivate() || "<init>".equals(m.getName())) { + parmSigs = SignatureUtils.getParameterSignatures(m); + if ((parmSigs.size() > 0) && prescreen(m)) { + state = SAW_NOTHING; + bugs = new HashMap<Integer, BugInfo>(); + super.visitCode(obj); + for (BugInfo bi : bugs.values()) { + bugReporter.reportBug(bi.bug); + } + } } + } finally { + bugs = null; } } @@ -111,7 +122,7 @@ case SAW_LOAD: if (seen == CHECKCAST) { - String castClass = getClassConstantOperand(); + castClass = getClassConstantOperand(); if (!castClass.equals(parmSig)) { state = SAW_CHECKCAST; return; @@ -137,15 +148,36 @@ parmName = "(" + loadedReg + ")"; } - bugReporter.reportBug(new BugInstance(this, "PDP_POORLY_DEFINED_PARAMETER", NORMAL_PRIORITY) + BugInstance bug = new BugInstance(this, "PDP_POORLY_DEFINED_PARAMETER", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this) - .addString(parmName)); + .addString(parmName); + Integer lr = Integer14.valueOf(loadedReg); + BugInfo bi = bugs.get(lr); + if (bi == null) { + bugs.put(lr, new BugInfo(castClass, bug)); + } else { + //If there are casts to multiple different types, don't report it altho suspect + if (!bi.castClass.equals(castClass)) { + bugs.remove(lr); + } + } + } state = SAW_NOTHING; break; } } + + private static class BugInfo { + String castClass; + BugInstance bug; + + BugInfo(String cast, BugInstance bi) { + castClass = cast; + bug = bi; + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-29 01:34:28
|
Revision: 1337 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1337&view=rev Author: dbrosius Date: 2009-09-29 01:34:18 +0000 (Tue, 29 Sep 2009) Log Message: ----------- ws is not permitted at end Modified Paths: -------------- trunk/fb-contrib/etc/bugrank.txt Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2009-09-29 01:19:10 UTC (rev 1336) +++ trunk/fb-contrib/etc/bugrank.txt 2009-09-29 01:34:18 UTC (rev 1337) @@ -122,5 +122,4 @@ 0 BugPattern ITU_INAPPROPRIATE_TOSTRING_USE 0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING 0 BugPattern OC_OVERZEALOUS_CASTING -0 BugPattern PDP_POORLY_DEFINED_PARAMETER - +0 BugPattern PDP_POORLY_DEFINED_PARAMETER \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-29 01:19:19
|
Revision: 1336 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1336&view=rev Author: dbrosius Date: 2009-09-29 01:19:10 +0000 (Tue, 29 Sep 2009) Log Message: ----------- add final methods to the ones to be checked by PDP 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-27 04:28:17 UTC (rev 1335) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-29 01:19:10 UTC (rev 1336) @@ -69,7 +69,7 @@ @Override public void visitCode(Code obj) { Method m = getMethod(); - if (m.isStatic() || m.isPrivate() || "<init>".equals(m.getName())) { + if (m.isStatic() || m.isFinal() || m.isPrivate() || "<init>".equals(m.getName())) { 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. |
From: <dbr...@us...> - 2009-09-27 04:28:23
|
Revision: 1335 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1335&view=rev Author: dbrosius Date: 2009-09-27 04:28:17 +0000 (Sun, 27 Sep 2009) Log Message: ----------- add other messages Modified Paths: -------------- trunk/fb-contrib/etc/bugrank.txt Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2009-09-26 22:27:54 UTC (rev 1334) +++ trunk/fb-contrib/etc/bugrank.txt 2009-09-27 04:28:17 UTC (rev 1335) @@ -120,3 +120,7 @@ 0 BugPattern TBP_TRISTATE_BOOLEAN_PATTERN 0 BugPattern SUA_SUSPICIOUS_UNINITIALIZED_ARRAY 0 BugPattern ITU_INAPPROPRIATE_TOSTRING_USE +0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING +0 BugPattern OC_OVERZEALOUS_CASTING +0 BugPattern PDP_POORLY_DEFINED_PARAMETER + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 22:28:05
|
Revision: 1334 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1334&view=rev Author: dbrosius Date: 2009-09-26 22:27:54 +0000 (Sat, 26 Sep 2009) Log Message: ----------- use engrish Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-09-26 22:15:43 UTC (rev 1333) +++ trunk/fb-contrib/etc/messages.xml 2009-09-26 22:27:54 UTC (rev 1334) @@ -1557,7 +1557,7 @@ <LongDescription>method {1} uses 1 element array to simulate call by reference</LongDescription> <Details> <![CDATA[ - <p>This method uses a one element array to wrap an object that is to be past to a method as an argument + <p>This method uses a one element array to wrap an object that is to be passed to a method as an argument to simulate call by pointer ala C++. It is better to define a proper return class type that holds all the relevant information retrieved from the called method.</p> ]]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 22:15:57
|
Revision: 1333 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1333&view=rev Author: dbrosius Date: 2009-09-26 22:15:43 +0000 (Sat, 26 Sep 2009) Log Message: ----------- warnings Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2009-09-26 22:14:09 UTC (rev 1332) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2009-09-26 22:15:43 UTC (rev 1333) @@ -28,7 +28,6 @@ { private int numMethodCalls; - @SuppressWarnings("unused") public CollectStatistics(BugReporter bugReporter) { Statistics.getStatistics().clear(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 22:14:18
|
Revision: 1332 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1332&view=rev Author: dbrosius Date: 2009-09-26 22:14:09 +0000 (Sat, 26 Sep 2009) Log Message: ----------- javadoc fix 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-26 22:12:55 UTC (rev 1331) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-26 22:14:09 UTC (rev 1332) @@ -82,7 +82,6 @@ /** * looks for methods that contain a checkcast instruction * - * @param code the context object of the current code block * @param method the context object of the current method * @return if the class does checkcast instructions */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 22:13:09
|
Revision: 1331 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1331&view=rev Author: dbrosius Date: 2009-09-26 22:12:55 +0000 (Sat, 26 Sep 2009) Log Message: ----------- javadoc fix Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java 2009-09-26 22:11:53 UTC (rev 1330) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java 2009-09-26 22:12:55 UTC (rev 1331) @@ -74,7 +74,6 @@ /** * looks for methods that contain a checkcast instruction * - * @param code the context object of the current code block * @param method the context object of the current method * @return if the class does checkcast instructions */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 22:12:00
|
Revision: 1330 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1330&view=rev Author: dbrosius Date: 2009-09-26 22:11:53 +0000 (Sat, 26 Sep 2009) Log Message: ----------- javadoc fix Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java 2009-09-26 20:07:36 UTC (rev 1329) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java 2009-09-26 22:11:53 UTC (rev 1330) @@ -48,7 +48,7 @@ /** * constructs a IKNC detector given the reporter to report bugs on - * @param bugReporter the sync of bug reports + * @param reporter the sync of bug reports */ public InconsistentKeyNameCasing(BugReporter reporter) { bugReporter = reporter; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 20:07:44
|
Revision: 1329 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1329&view=rev Author: dbrosius Date: 2009-09-26 20:07:36 +0000 (Sat, 26 Sep 2009) Log Message: ----------- add PDP Detector Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-26 20:07:17 UTC (rev 1328) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-26 20:07:36 UTC (rev 1329) @@ -160,7 +160,7 @@ for (Type t : parms) { String signature = t.getSignature(); parmSigs.put(Integer14.valueOf(slot), signature); - slot += ("L".equals(signature) || "D".equals(signature)) ? 2 : 1; + slot += ("J".equals(signature) || "D".equals(signature)) ? 2 : 1; } return parmSigs; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 20:07:26
|
Revision: 1328 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1328&view=rev Author: dbrosius Date: 2009-09-26 20:07:17 +0000 (Sat, 26 Sep 2009) Log Message: ----------- add PDP Detector Modified Paths: -------------- trunk/fb-contrib/samples/PDP_Sample.java Modified: trunk/fb-contrib/samples/PDP_Sample.java =================================================================== --- trunk/fb-contrib/samples/PDP_Sample.java 2009-09-26 20:06:57 UTC (rev 1327) +++ trunk/fb-contrib/samples/PDP_Sample.java 2009-09-26 20:07:17 UTC (rev 1328) @@ -5,24 +5,24 @@ { ArrayList<String> al; - public void testQuestionableCast(List<String> l) + public PDP_Sample(List<String> l) { al = (ArrayList<String>) l; } - public void testFPCodeChecksType(List<String> l) + private void testFPCodeChecksType(List<String> l) { if (l instanceof ArrayList) al = (ArrayList<String>) l; } - public void testFPNonParm(String s) + private void testFPNonParm(String s) { List<String> l = new ArrayList<String>(); al = (ArrayList<String>) l; } - public void testDoubleInSig(double d, List<String> l) + private void testDoubleInSig(double d, List<String> l) { al = (ArrayList<String>) l; } @@ -31,4 +31,9 @@ { ArrayList<String> aal = (ArrayList<String>) l; } + + public void testFPDerivableMethod(List<String> l) + { + al = (ArrayList<String>) l; + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 20:07:08
|
Revision: 1327 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1327&view=rev Author: dbrosius Date: 2009-09-26 20:06:57 +0000 (Sat, 26 Sep 2009) Log Message: ----------- add PDP Detector Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-09-26 20:06:42 UTC (rev 1326) +++ trunk/fb-contrib/etc/messages.xml 2009-09-26 20:06:57 UTC (rev 1327) @@ -1023,6 +1023,18 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.PoorlyDefinedParameter"> + <Details> + <![CDATA[ + <p>looks for non derivable methods that declare parameters and then cast those + parameters to more specific types in the method. This is misleading and dangerous + as you are not documenting through parameter types what is necessary for these + parameters to function correctly.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -2656,6 +2668,18 @@ </Details> </BugPattern> + <BugPattern type="PDP_POORLY_DEFINED_PARAMETER"> + <ShortDescription>method defines parameters more abstractly than needed to function properly</ShortDescription> + <LongDescription>method {1} defines parameters more abstractly than needed to function properly</LongDescription> + <Details> + <![CDATA[ + <p>This method defines parameters at a more abstract level than is actually needed to function correctly, + as the code casts these parameters to more concrete types. Since this method is not derivable, you should + just define the parameters with the type that is needed. + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2742,4 +2766,5 @@ <BugCode abbrev="ITU">Inappropriate ToString Use</BugCode> <BugCode abbrev="IKNC">Inconsistent Key Name Casing</BugCode> <BugCode abbrev="OC">Overzealous Casting</BugCode> + <BugCode abbrev="PDP">Poorly Defined Parameter</BugCode> </MessageCollection> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 20:06:48
|
Revision: 1326 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1326&view=rev Author: dbrosius Date: 2009-09-26 20:06:42 +0000 (Sat, 26 Sep 2009) Log Message: ----------- add PDP Detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2009-09-26 20:06:16 UTC (rev 1325) +++ trunk/fb-contrib/etc/findbugs.xml 2009-09-26 20:06:42 UTC (rev 1326) @@ -369,6 +369,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.OverzealousCasting" speed="fast" reports="OC_OVERZEALOUS_CASTING" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.PoorlyDefinedParameter" + speed="fast" + reports="PDP_POORLY_DEFINED_PARAMETER" /> <!-- BugPattern --> @@ -496,4 +500,5 @@ <BugPattern abbrev="ITU" type="ITU_INAPPROPRIATE_TOSTRING_USE" category="CORRECTNESS" /> <BugPattern abbrev="IKNC" type="IKNC_INCONSISTENT_HTTP_PARAM_CASING" category="STYLE" experimental="true" /> <BugPattern abbrev="OC" type="OC_OVERZEALOUS_CASTING" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="PDP" type="PDP_POORLY_DEFINED_PARAMETER" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 20:06:22
|
Revision: 1325 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1325&view=rev Author: dbrosius Date: 2009-09-26 20:06:16 +0000 (Sat, 26 Sep 2009) Log Message: ----------- PDP seems to be working 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-26 19:34:46 UTC (rev 1324) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-26 20:06:16 UTC (rev 1325) @@ -23,6 +23,8 @@ import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; import org.apache.bcel.classfile.Method; import com.mebigfatguy.fbcontrib.utils.Integer14; @@ -67,11 +69,12 @@ @Override public void visitCode(Code obj) { Method m = getMethod(); - - parmSigs = SignatureUtils.getParameterSignatures(m); - if ((parmSigs.size() > 0) && prescreen(m)) { - state = SAW_NOTHING; - super.visitCode(obj); + if (m.isStatic() || m.isPrivate() || "<init>".equals(m.getName())) { + parmSigs = SignatureUtils.getParameterSignatures(m); + if ((parmSigs.size() > 0) && prescreen(m)) { + state = SAW_NOTHING; + super.visitCode(obj); + } } } @@ -101,6 +104,7 @@ loadedReg = RegisterUtils.getALoadReg(this, seen); parmSig = parmSigs.get(Integer14.valueOf(loadedReg)); if (parmSig != null) { + parmSig = parmSig.substring(1, parmSig.length() - 1); state = SAW_LOAD; } } @@ -113,19 +117,32 @@ state = SAW_CHECKCAST; return; } + } else if (seen == INSTANCEOF) { + // probably an if guard... assume the code is reasonable + parmSigs.remove(Integer14.valueOf(loadedReg)); } state = SAW_NOTHING; break; case SAW_CHECKCAST: if ((seen == PUTFIELD) || (seen == ASTORE) || ((seen >= ASTORE_0) && seen <= ASTORE_3)) { + String parmName = null; + LocalVariableTable lvt = getMethod().getLocalVariableTable(); + if (lvt != null) { + LocalVariable lv = lvt.getLocalVariable(loadedReg, 1); + if (lv != null) { + parmName = lv.getName(); + } + } + if (parmName == null) { + parmName = "(" + loadedReg + ")"; + } + bugReporter.reportBug(new BugInstance(this, "PDP_POORLY_DEFINED_PARAMETER", NORMAL_PRIORITY) .addClass(this) .addMethod(this) - .addSourceLine(this)); - } else { - // probably an if guard... assume the code is reasonable - parmSigs.remove(loadedReg); + .addSourceLine(this) + .addString(parmName)); } state = SAW_NOTHING; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 19:34:53
|
Revision: 1324 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1324&view=rev Author: dbrosius Date: 2009-09-26 19:34:46 +0000 (Sat, 26 Sep 2009) Log Message: ----------- flesh more impl out -- not done yet 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-26 19:34:06 UTC (rev 1323) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-26 19:34:46 UTC (rev 1324) @@ -25,12 +25,13 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; +import com.mebigfatguy.fbcontrib.utils.Integer14; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import com.mebigfatguy.fbcontrib.utils.SignatureUtils; +import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.OpcodeStack; -import edu.umd.cs.findbugs.ba.ClassContext; /** * looks for non derivable method that declare parameters and then cast those @@ -40,9 +41,15 @@ */ public class PoorlyDefinedParameter extends BytecodeScanningDetector { + private static final int SAW_NOTHING = 0; + private static final int SAW_LOAD = 1; + private static final int SAW_CHECKCAST = 2; + BugReporter bugReporter; - OpcodeStack stack; Map<Integer, String> parmSigs; + int loadedReg; + String parmSig; + int state; /** * constructs a PDP detector given the reporter to report bugs on @@ -53,20 +60,6 @@ } /** - * implements the visitor to create the opcode stack - * @param classContext the context object of the currently parsed class - */ - @Override - public void visitClassContext(ClassContext classContext) { - try { - stack = new OpcodeStack(); - super.visitClassContext(classContext); - } finally { - stack = null; - } - } - - /** * implements the visitor to see if the method has parameters * * @param obj the context object of the currently parsed code block @@ -77,19 +70,11 @@ parmSigs = SignatureUtils.getParameterSignatures(m); if ((parmSigs.size() > 0) && prescreen(m)) { + state = SAW_NOTHING; super.visitCode(obj); } } - /** - * implements the visitor to look for check casts of parameters to - * more specific types - */ - @Override - public void sawOpcode(int seen) - { - - } /** * looks for methods that contain a checkcast instruction @@ -102,4 +87,49 @@ BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return (bytecodeSet != null) && (bytecodeSet.get(Constants.CHECKCAST)); } + + /** + * implements the visitor to look for check casts of parameters to + * more specific types + */ + @Override + public void sawOpcode(int seen) + { + switch (state) { + case SAW_NOTHING: + if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { + loadedReg = RegisterUtils.getALoadReg(this, seen); + parmSig = parmSigs.get(Integer14.valueOf(loadedReg)); + if (parmSig != null) { + state = SAW_LOAD; + } + } + break; + + case SAW_LOAD: + if (seen == CHECKCAST) { + String castClass = getClassConstantOperand(); + if (!castClass.equals(parmSig)) { + state = SAW_CHECKCAST; + return; + } + } + state = SAW_NOTHING; + break; + + case SAW_CHECKCAST: + if ((seen == PUTFIELD) || (seen == ASTORE) || ((seen >= ASTORE_0) && seen <= ASTORE_3)) { + bugReporter.reportBug(new BugInstance(this, "PDP_POORLY_DEFINED_PARAMETER", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } else { + // probably an if guard... assume the code is reasonable + parmSigs.remove(loadedReg); + } + + state = SAW_NOTHING; + break; + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 19:34:14
|
Revision: 1323 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1323&view=rev Author: dbrosius Date: 2009-09-26 19:34:06 +0000 (Sat, 26 Sep 2009) Log Message: ----------- stub in sample for PDP Added Paths: ----------- trunk/fb-contrib/samples/PDP_Sample.java Added: trunk/fb-contrib/samples/PDP_Sample.java =================================================================== --- trunk/fb-contrib/samples/PDP_Sample.java (rev 0) +++ trunk/fb-contrib/samples/PDP_Sample.java 2009-09-26 19:34:06 UTC (rev 1323) @@ -0,0 +1,34 @@ +import java.util.ArrayList; +import java.util.List; + +public class PDP_Sample +{ + ArrayList<String> al; + + public void testQuestionableCast(List<String> l) + { + al = (ArrayList<String>) l; + } + + public void testFPCodeChecksType(List<String> l) + { + if (l instanceof ArrayList) + al = (ArrayList<String>) l; + } + + public void testFPNonParm(String s) + { + List<String> l = new ArrayList<String>(); + al = (ArrayList<String>) l; + } + + public void testDoubleInSig(double d, List<String> l) + { + al = (ArrayList<String>) l; + } + + public static void testStatic( long lng, List<String> l) + { + ArrayList<String> aal = (ArrayList<String>) l; + } +} \ No newline at end of file Property changes on: trunk/fb-contrib/samples/PDP_Sample.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 19:17:03
|
Revision: 1322 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1322&view=rev Author: dbrosius Date: 2009-09-26 19:16:50 +0000 (Sat, 26 Sep 2009) Log Message: ----------- stub in PDP -- not impled Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-26 19:16:50 UTC (rev 1322) @@ -0,0 +1,105 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2009 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.BitSet; +import java.util.Map; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; + +import com.mebigfatguy.fbcontrib.utils.SignatureUtils; + +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for non derivable method that declare parameters and then cast those + * parameters to more specific types in the method. This is misleading and dangerous + * as you are not documenting through parameter types what is necessary for these + * parameters to function correctly. + */ +public class PoorlyDefinedParameter extends BytecodeScanningDetector +{ + BugReporter bugReporter; + OpcodeStack stack; + Map<Integer, String> parmSigs; + + /** + * constructs a PDP detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public PoorlyDefinedParameter(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to create the opcode stack + * @param classContext the context object of the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + stack = null; + } + } + + /** + * implements the visitor to see if the method has parameters + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + Method m = getMethod(); + + parmSigs = SignatureUtils.getParameterSignatures(m); + if ((parmSigs.size() > 0) && prescreen(m)) { + super.visitCode(obj); + } + } + + /** + * implements the visitor to look for check casts of parameters to + * more specific types + */ + @Override + public void sawOpcode(int seen) + { + + } + + /** + * looks for methods that contain a checkcast instruction + * + * @param code the context object of the current code block + * @param method the context object of the current method + * @return if the class does checkcast instructions + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.CHECKCAST)); + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 19:14:50
|
Revision: 1321 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1321&view=rev Author: dbrosius Date: 2009-09-26 19:14:42 +0000 (Sat, 26 Sep 2009) Log Message: ----------- add @Override Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java 2009-09-26 19:09:28 UTC (rev 1320) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java 2009-09-26 19:14:42 UTC (rev 1321) @@ -63,6 +63,7 @@ * and to see if there is a local variable table * @param obj the context object of the currently parsed code block */ + @Override public void visitCode(Code obj) { state = SAW_NOTHING; lvt = obj.getLocalVariableTable(); @@ -87,6 +88,7 @@ * types of the objects are different. * @param seen the opcode of the currently parsed instruction */ + @Override public void sawOpcode(int seen) { switch (state) { case SAW_NOTHING: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 19:09:42
|
Revision: 1320 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1320&view=rev Author: dbrosius Date: 2009-09-26 19:09:28 +0000 (Sat, 26 Sep 2009) Log Message: ----------- make it static Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-26 19:07:24 UTC (rev 1319) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-26 19:09:28 UTC (rev 1320) @@ -151,7 +151,7 @@ * @param m the method for which you want the parameters * @return a map of parameter types (expect empty slots when doubles/longs are used */ - public Map<Integer, String> getParameterSignatures(Method m) { + public static Map<Integer, String> getParameterSignatures(Method m) { Type[] parms = m.getArgumentTypes(); Map<Integer, String> parmSigs = new LinkedHashMap<Integer, String>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 19:07:35
|
Revision: 1319 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1319&view=rev Author: dbrosius Date: 2009-09-26 19:07:24 +0000 (Sat, 26 Sep 2009) Log Message: ----------- switch getParameterSignatures to return a map Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-26 19:05:22 UTC (rev 1318) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-26 19:07:24 UTC (rev 1319) @@ -18,8 +18,8 @@ */ package com.mebigfatguy.fbcontrib.utils; -import java.util.ArrayList; -import java.util.List; +import java.util.LinkedHashMap; +import java.util.Map; import org.apache.bcel.Constants; import org.apache.bcel.classfile.JavaClass; @@ -146,22 +146,20 @@ } /** - * returns a List that represents the type of the parameter in slot x + * returns a Map that represents the type of the parameter in slot x * * @param m the method for which you want the parameters - * @return a list of parameter types (expect empty slots when doubles/longs are used + * @return a map of parameter types (expect empty slots when doubles/longs are used */ - public List<String> getParameterSignatures(Method m) { + public Map<Integer, String> getParameterSignatures(Method m) { Type[] parms = m.getArgumentTypes(); - List<String> parmSigs = new ArrayList<String>(); + Map<Integer, String> parmSigs = new LinkedHashMap<Integer, String>(); int slot = m.isStatic() ? 0 : 1; for (Type t : parms) { String signature = t.getSignature(); - while (parmSigs.size() <= slot) - parmSigs.add(null); - parmSigs.set(slot, signature); + parmSigs.put(Integer14.valueOf(slot), signature); slot += ("L".equals(signature) || "D".equals(signature)) ? 2 : 1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 19:05:33
|
Revision: 1318 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1318&view=rev Author: dbrosius Date: 2009-09-26 19:05:22 +0000 (Sat, 26 Sep 2009) Log Message: ----------- add getParameterSignatures Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-26 18:48:14 UTC (rev 1317) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2009-09-26 19:05:22 UTC (rev 1318) @@ -18,9 +18,13 @@ */ package com.mebigfatguy.fbcontrib.utils; +import java.util.ArrayList; +import java.util.List; + import org.apache.bcel.Constants; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; public class SignatureUtils { @@ -141,4 +145,27 @@ return null; } + /** + * returns a List that represents the type of the parameter in slot x + * + * @param m the method for which you want the parameters + * @return a list of parameter types (expect empty slots when doubles/longs are used + */ + public List<String> getParameterSignatures(Method m) { + Type[] parms = m.getArgumentTypes(); + + List<String> parmSigs = new ArrayList<String>(); + + int slot = m.isStatic() ? 0 : 1; + for (Type t : parms) { + String signature = t.getSignature(); + while (parmSigs.size() <= slot) + parmSigs.add(null); + parmSigs.set(slot, signature); + slot += ("L".equals(signature) || "D".equals(signature)) ? 2 : 1; + } + + return parmSigs; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-26 18:48:30
|
Revision: 1317 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1317&view=rev Author: dbrosius Date: 2009-09-26 18:48:14 +0000 (Sat, 26 Sep 2009) Log Message: ----------- oi Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java 2009-09-26 05:18:56 UTC (rev 1316) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java 2009-09-26 18:48:14 UTC (rev 1317) @@ -22,7 +22,6 @@ import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.LocalVariableTable; import org.apache.bcel.classfile.Method; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |