fb-contrib-commit Mailing List for fb-contrib (Page 34)
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...> - 2008-04-02 03:14:51
|
Revision: 1016 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1016&view=rev Author: dbrosius Date: 2008-04-01 20:14:57 -0700 (Tue, 01 Apr 2008) Log Message: ----------- fix deprecation Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2008-04-02 03:13:22 UTC (rev 1015) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2008-04-02 03:14:57 UTC (rev 1016) @@ -114,7 +114,7 @@ && (edgeType != EdgeTypes.UNKNOWN_EDGE)) { if ((edgeType == EdgeTypes.UNHANDLED_EXCEPTION_EDGE) || (edgeType == EdgeTypes.HANDLED_EXCEPTION_EDGE)) { - Integer nodeTarget = Integer14.valueOf(e.getTarget().getId()); + Integer nodeTarget = Integer14.valueOf(e.getTarget().getLabel()); if (!exceptionNodeTargets.contains(nodeTarget)) { exceptionNodeTargets.add(nodeTarget); branches++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-04-02 03:13:17
|
Revision: 1015 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1015&view=rev Author: dbrosius Date: 2008-04-01 20:13:22 -0700 (Tue, 01 Apr 2008) Log Message: ----------- upgrade to use findbugs 1.3.3 as build reference Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/lib/asm-3.0.jar trunk/fb-contrib/lib/bcel.jar trunk/fb-contrib/lib/findbugs-ant.jar trunk/fb-contrib/lib/findbugs.jar Added Paths: ----------- trunk/fb-contrib/lib/asm-tree-3.0.jar Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2008-03-24 01:44:54 UTC (rev 1014) +++ trunk/fb-contrib/build.xml 2008-04-02 03:13:22 UTC (rev 1015) @@ -151,7 +151,7 @@ <mkdir dir="${basedir}/plugin"/> <copy file="${basedir}/fb-contrib-${fb-contrib.version}.jar" todir="${basedir}/plugin"/> - <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${lib.dir}/findbugs-ant.jar;${lib.dir}/findbugs.jar;${lib.dir}/bcel.jar;${lib.dir}/dom4j-full.jar;${lib.dir}/asm-3.0.jar"/> + <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${lib.dir}/findbugs-ant.jar;${lib.dir}/findbugs.jar;${lib.dir}/bcel.jar;${lib.dir}/dom4j-full.jar;${lib.dir}/asm-3.0.jar;${lib.dir}/asm-tree-3.0.jar"/> <findbugs output="xml" home="${basedir}" Modified: trunk/fb-contrib/lib/asm-3.0.jar =================================================================== (Binary files differ) Added: trunk/fb-contrib/lib/asm-tree-3.0.jar =================================================================== (Binary files differ) Property changes on: trunk/fb-contrib/lib/asm-tree-3.0.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/fb-contrib/lib/bcel.jar =================================================================== (Binary files differ) Modified: trunk/fb-contrib/lib/findbugs-ant.jar =================================================================== (Binary files differ) Modified: trunk/fb-contrib/lib/findbugs.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-24 01:44:49
|
Revision: 1014 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1014&view=rev Author: dbrosius Date: 2008-03-23 18:44:54 -0700 (Sun, 23 Mar 2008) Log Message: ----------- remove xs semi Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java 2008-03-23 05:10:55 UTC (rev 1013) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java 2008-03-24 01:44:54 UTC (rev 1014) @@ -58,7 +58,7 @@ knownImmutables.add("Ljava/lang/Double;"); knownImmutables.add("Ljava/lang/Boolean;"); knownImmutables.add("Ljava/lang/Class;"); - }; + } private final BugReporter bugReporter; private Map<Integer, ParmUsage> possibleParmRegs; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-23 05:10:49
|
Revision: 1013 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1013&view=rev Author: dbrosius Date: 2008-03-22 22:10:55 -0700 (Sat, 22 Mar 2008) Log Message: ----------- need to remove registers from collection groups when that variable goes out of scope Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2008-03-20 05:39:32 UTC (rev 1012) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2008-03-23 05:10:55 UTC (rev 1013) @@ -29,6 +29,8 @@ import org.apache.bcel.Repository; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -85,6 +87,7 @@ private List<Set<Comparable<?>>> collectionGroups; private Map<Integer, Integer> groupToIterator; private Map<Integer, Loop> loops; + private Map<Integer, Set<Integer>> endOfScopes; /** * constructs a DWI detector given the reporter to report bugs on @@ -115,6 +118,7 @@ collectionGroups = null; groupToIterator = null; loops = null; + endOfScopes = null; } } @@ -129,6 +133,8 @@ collectionGroups.clear(); groupToIterator.clear(); loops.clear(); + buildVariableEndScopeMap(); + super.visitCode(obj); } @@ -278,6 +284,8 @@ OpcodeStack.Item itm = stack.getStackItem(0); itm.setUserValue(Integer14.valueOf(groupId)); } + + processEndOfScopes(Integer14.valueOf(getPC())); } } @@ -348,6 +356,42 @@ } } + private void buildVariableEndScopeMap() { + endOfScopes = new HashMap<Integer, Set<Integer>>(); + + LocalVariableTable lvt = getMethod().getLocalVariableTable(); + if (lvt != null) { + int len = lvt.getLength(); + for (int i = 0; i < len; i++) { + LocalVariable lv = lvt.getLocalVariable(i); + if (lv != null) { + Integer endPC = Integer14.valueOf(lv.getStartPC() + lv.getLength()); + Set<Integer> vars = endOfScopes.get(endPC); + if (vars == null) { + vars = new HashSet<Integer>(); + endOfScopes.put(endPC, vars); + } + vars.add(Integer14.valueOf(lv.getIndex())); + } + } + } + } + + private void processEndOfScopes(Integer pc) { + Set<Integer> endVars = endOfScopes.get(pc); + if (endVars != null) { + for (Integer v : endVars) { + Iterator<Set<Comparable<?>>> it = collectionGroups.iterator(); + while (it.hasNext()) { + Set<Comparable<?>> gv = it.next(); + if (gv.contains(v)) { + gv.remove(v); + } + } + } + } + } + static class Loop { public int loopStart; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-20 05:39:27
|
Revision: 1012 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1012&view=rev Author: dbrosius Date: 2008-03-19 22:39:32 -0700 (Wed, 19 Mar 2008) Log Message: ----------- only report WEM for methods with parms, as noparm instance methods are not obvious enough Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java 2008-03-19 21:52:53 UTC (rev 1011) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java 2008-03-20 05:39:32 UTC (rev 1012) @@ -93,7 +93,7 @@ @Override public void visitCode(Code obj) { Method method = getMethod(); - if (!method.isStatic() || !method.getSignature().startsWith("()")) { + if (!method.getSignature().startsWith("()")) { if (prescreen(getMethod())) { stack.resetForMethodEntry(this); super.visitCode(obj); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-19 21:52:47
|
Revision: 1011 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1011&view=rev Author: dbrosius Date: 2008-03-19 14:52:53 -0700 (Wed, 19 Mar 2008) Log Message: ----------- fix for [ 1919533 ] WEM: false positive Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java 2008-03-16 18:36:53 UTC (rev 1010) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java 2008-03-19 21:52:53 UTC (rev 1011) @@ -133,8 +133,10 @@ if (exCls.instanceOf(exceptionClass)) { String sig = getSigConstantOperand(); Type[] argTypes = Type.getArgumentTypes(sig); + int stringParms = 0; for (int t = 0; t < argTypes.length; t++) { if ("Ljava/lang/String;".equals(argTypes[t].getSignature())) { + stringParms++; int stackOffset = argTypes.length - t - 1; if (stack.getStackDepth() > stackOffset) { OpcodeStack.Item item = stack.getStackItem(stackOffset); @@ -143,7 +145,7 @@ } } } - allConstantStrings = true; + allConstantStrings = stringParms > 0; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-16 18:36:50
|
Revision: 1010 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1010&view=rev Author: dbrosius Date: 2008-03-16 11:36:53 -0700 (Sun, 16 Mar 2008) Log Message: ----------- remove boxing Modified Paths: -------------- trunk/fb-contrib/samples/LII_Sample.java Modified: trunk/fb-contrib/samples/LII_Sample.java =================================================================== --- trunk/fb-contrib/samples/LII_Sample.java 2008-03-16 18:24:54 UTC (rev 1009) +++ trunk/fb-contrib/samples/LII_Sample.java 2008-03-16 18:36:53 UTC (rev 1010) @@ -60,10 +60,10 @@ public void test7FP(List<Integer> editedIndexes, List<Integer> pageTokens, List<Integer> tokens) { - Integer index = pageTokens.size(); + int index = pageTokens.size(); for ( int i = 0; i < tokens.size(); i++ ) { - editedIndexes.add( index ); + editedIndexes.add( new Integer(index)); index++; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-16 18:24:52
|
Revision: 1009 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1009&view=rev Author: dbrosius Date: 2008-03-16 11:24:54 -0700 (Sun, 16 Mar 2008) Log Message: ----------- document JAO and WEM Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2008-03-16 17:35:14 UTC (rev 1008) +++ trunk/fb-contrib/htdocs/index.html 2008-03-16 18:24:54 UTC (rev 1009) @@ -48,9 +48,9 @@ <a href="bugdescriptions.html">Bug Descriptions</a> <hr/> - <img id="svn_image" src="flip1.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> + <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> Detectors added in svn<br/> - <div id="svn" style="display:none;"> + <div id="svn" style="display:block;"> <ul> <li><b>[CFS] Confusing Function Semantics</b><br/> Looks for methods that return a parameter after making what looks like @@ -62,12 +62,21 @@ Looks for implementation of clone where an assignment is made to a field of the source object. It is likely that that store should have occurred on the cloned object, as the clone operation is almost always considered read only.</li> + <li><b>[JAO] JUnit Assertion Oddities</b><br/> + Looks for junit test case methods that use assertions with odd parameters. Things such as, + passing a constant as the second (actual) parameter, not using the three parameter version of + asserts for doubles, or passing true or false as the first parameter instead of using assertTrue, + or assertFalse.</li> + <li><b>[WEM] Weak Exception Messaging</b><br/> + Looks for exceptions that are thrown with static strings as messages. Using static strings + doesn't differentiate one use of this method versus another, and so it may be difficult + to determine how this exception occurred without showing context.</li> </ul> </div> <hr/> - <img id="v3_4_0_image" src="flip2.gif" onClick="toggleBlock('v3_4_0', 'v3_4_0_image');" align="top"/> + <img id="v3_4_0_image" src="flip1.gif" onClick="toggleBlock('v3_4_0', 'v3_4_0_image');" align="top"/> Detectors add in v3.4.0<br/> - <div id="v3_4_0" style="display:block;"> + <div id="v3_4_0" style="display:none;"> <ul> <li><b>[SJVU] Suspicious JDK Version Use</b><br/> Looks for calls to classes and methods that do not exist in the JDK for which this class is This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-16 17:35:13
|
Revision: 1008 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1008&view=rev Author: dbrosius Date: 2008-03-16 10:35:14 -0700 (Sun, 16 Mar 2008) Log Message: ----------- avoid index out of bounds exceptions Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java 2008-03-16 02:45:28 UTC (rev 1007) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java 2008-03-16 17:35:14 UTC (rev 1008) @@ -169,7 +169,7 @@ String calledRet = Type.getReturnType(calledSig).getSignature(); if ("V".equals(calledRet)) { int calledObjOffset = Type.getArgumentTypes(calledSig).length; - if (stack.getStackDepth() >= calledObjOffset) { + if (stack.getStackDepth() > calledObjOffset) { OpcodeStack.Item item = stack.getStackItem(calledObjOffset); int reg = item.getRegisterNumber(); ParmUsage pu = possibleParmRegs.get(Integer14.valueOf(reg)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-16 02:45:22
|
Revision: 1007 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1007&view=rev Author: dbrosius Date: 2008-03-15 19:45:28 -0700 (Sat, 15 Mar 2008) Log Message: ----------- don't report WEM when in static no arg methods Modified Paths: -------------- trunk/fb-contrib/samples/WEM_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java Modified: trunk/fb-contrib/samples/WEM_Sample.java =================================================================== --- trunk/fb-contrib/samples/WEM_Sample.java 2008-03-16 01:52:58 UTC (rev 1006) +++ trunk/fb-contrib/samples/WEM_Sample.java 2008-03-16 02:45:28 UTC (rev 1007) @@ -12,5 +12,10 @@ if (s.length() == 1) throw new IllegalArgumentException("You stink -->" + s); } + + public static void ok() + { + throw new RuntimeException("Wow"); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java 2008-03-16 01:52:58 UTC (rev 1006) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java 2008-03-16 02:45:28 UTC (rev 1007) @@ -92,9 +92,12 @@ */ @Override public void visitCode(Code obj) { - if (prescreen(getMethod())) { - stack.resetForMethodEntry(this); - super.visitCode(obj); + Method method = getMethod(); + if (!method.isStatic() || !method.getSignature().startsWith("()")) { + if (prescreen(getMethod())) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-16 01:52:55
|
Revision: 1006 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1006&view=rev Author: dbrosius Date: 2008-03-15 18:52:58 -0700 (Sat, 15 Mar 2008) Log Message: ----------- Initial checkin, WEM detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Added Paths: ----------- trunk/fb-contrib/samples/WEM_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2008-03-15 06:17:22 UTC (rev 1005) +++ trunk/fb-contrib/etc/findbugs.xml 2008-03-16 01:52:58 UTC (rev 1006) @@ -312,6 +312,10 @@ speed="fast" reports="SCA_SUSPICIOUS_CLONE_ALGORITHM" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.WeakExceptionMessaging" + speed="fast" + reports="WEM_WEAK_EXCEPTION_MESSAGING" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -416,4 +420,5 @@ <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE" category="STYLE" experimental="true" /> <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT" category="STYLE" experimental="true" /> <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2008-03-15 06:17:22 UTC (rev 1005) +++ trunk/fb-contrib/etc/messages.xml 2008-03-16 01:52:58 UTC (rev 1006) @@ -852,9 +852,22 @@ <![CDATA[ <p>looks for implementations of clone where an assignment is made to a field of the source object. It is likely that that store should have occurred on the cloned object, as - the clone operation is almost always considered read only.</p>]]> + the clone operation is almost always considered read only.</p> + <p>It is a fast detector</p> + ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.WeakExceptionMessaging"> + <Details> + <![CDATA[ + <p>looks for exceptions that are thrown with static strings as messages. Using static strings + doesn't differentiate one use of this method versus another, and so it may be difficult + to determine how this exception occurred without showing context.<p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -2206,6 +2219,19 @@ </Details> </BugPattern> + <BugPattern type="WEM_WEAK_EXCEPTION_MESSAGING"> + <ShortDescription>method throws exception with static message string</ShortDescription> + <LongDescription>method {1} throws exception with static message string</LongDescription> + <Details> + <![CDATA[ + <p>This method creates and throws an exception using a static string as the exceptions message. + Without any specific context of this particular exception invocation, such as the value of parameters, + key member variables, or local variables, it may be difficult to infer how this exception occurred. Consider + adding context to the exception message.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2278,4 +2304,5 @@ <BugCode abbrev="CFS">Confusing Function Semantics</BugCode> <BugCode abbrev="JAO">JUnit Assertion Oddities</BugCode> <BugCode abbrev="SCA">Suspicious Clone Algorithm</BugCode> + <BugCode abbrev="WEM">Weak Exception Messaging</BugCode> </MessageCollection> \ No newline at end of file Added: trunk/fb-contrib/samples/WEM_Sample.java =================================================================== --- trunk/fb-contrib/samples/WEM_Sample.java (rev 0) +++ trunk/fb-contrib/samples/WEM_Sample.java 2008-03-16 01:52:58 UTC (rev 1006) @@ -0,0 +1,16 @@ + +public class WEM_Sample +{ + public void badException (String s) + { + if (s.length() == 1) + throw new IllegalArgumentException("You stink"); + } + + public void goodException (String s) + { + if (s.length() == 1) + throw new IllegalArgumentException("You stink -->" + s); + } + +} Property changes on: trunk/fb-contrib/samples/WEM_Sample.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java 2008-03-16 01:52:58 UTC (rev 1006) @@ -0,0 +1,158 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2008 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 org.apache.bcel.Constants; +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.ConstantString; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; + +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; + +public class WeakExceptionMessaging extends BytecodeScanningDetector { + + private static JavaClass exceptionClass; + static { + try { + exceptionClass = Repository.lookupClass("java/lang/Exception"); + } catch (ClassNotFoundException cnfe) { + exceptionClass = null; + } + } + + private BugReporter bugReporter; + private OpcodeStack stack; + + /** + * constructs a WEM detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public WeakExceptionMessaging(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * overrides the visitor to initialize and tear down the opcode stack + * + * @Param classContext the context object of the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + if (exceptionClass != null) { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } + } finally { + stack = null; + } + } + + /** + * looks for methods that contain a ATHROW opcodes + * + * @param method the context object of the current method + * @return if the class uses throws + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.ATHROW)); + } + + /** + * overrides the visitor to prescreen the method to look for throws calls + * and only forward onto bytecode scanning if there + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + if (prescreen(getMethod())) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } + } + + /** + * overrides the visitor to look for throws instructions using exceptions with + * static messages + * + * @param seen the opcode of the currently visited instruction + */ + @Override + public void sawOpcode(int seen) { + boolean allConstantStrings = false; + boolean sawConstant = false; + try { + if (seen == ATHROW) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if (item.getUserValue() != null) { + bugReporter.reportBug(new BugInstance(this, "WEM_WEAK_EXCEPTION_MESSAGING", LOW_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } else if (seen == LDC) { + if (getConstantRefOperand() instanceof ConstantString) + sawConstant = true; + } else if (seen == INVOKESPECIAL) { + if ("<init>".equals(getNameConstantOperand())) { + String clsName = getClassConstantOperand(); + if (clsName.indexOf("Exception") >= 0) { + JavaClass exCls = Repository.lookupClass(clsName); + if (exCls.instanceOf(exceptionClass)) { + String sig = getSigConstantOperand(); + Type[] argTypes = Type.getArgumentTypes(sig); + for (int t = 0; t < argTypes.length; t++) { + if ("Ljava/lang/String;".equals(argTypes[t].getSignature())) { + int stackOffset = argTypes.length - t - 1; + if (stack.getStackDepth() > stackOffset) { + OpcodeStack.Item item = stack.getStackItem(stackOffset); + if (item.getUserValue() == null) + return; + } + } + } + allConstantStrings = true; + } + } + } + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } finally { + stack.sawOpcode(this, seen); + if ((sawConstant || allConstantStrings) && (stack.getStackDepth() > 0)) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(Boolean.TRUE); + } + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: 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...> - 2008-03-15 06:17:16
|
Revision: 1005 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1005&view=rev Author: dbrosius Date: 2008-03-14 23:17:22 -0700 (Fri, 14 Mar 2008) Log Message: ----------- fix for [ 1914317 ] FalsePositive UAA_USE_ADD_ALL, postpose the reporting of UAA until you finish the loop that it occurs in, this way you can check for duplicate adds, conditional adds in ADDITION to the candidate. Modified Paths: -------------- trunk/fb-contrib/samples/UAA_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/samples/UAA_Sample.java =================================================================== --- trunk/fb-contrib/samples/UAA_Sample.java 2008-03-15 04:59:43 UTC (rev 1004) +++ trunk/fb-contrib/samples/UAA_Sample.java 2008-03-15 06:17:22 UTC (rev 1005) @@ -80,7 +80,7 @@ } } - public void testAddWithCheck(List<String> src, List<String> dst) + public void testFPAddWithCheck(List<String> src, List<String> dst) { for (String s : src) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2008-03-15 04:59:43 UTC (rev 1004) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2008-03-15 06:17:22 UTC (rev 1005) @@ -19,6 +19,7 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import org.apache.bcel.Repository; @@ -124,6 +125,22 @@ boolean sawLoad = false; try { + int pc = getPC(); + Iterator<LoopInfo> it = loops.values().iterator(); + while (it.hasNext()) { + LoopInfo loop = it.next(); + if ((loop.getEndPC()-3) <= pc) { + int loopPC = loop.getAddPC(); + if (loopPC > 0) { + bugReporter.reportBug(new BugInstance(this, "UAA_USE_ADD_ALL", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this, loopPC)); + } + it.remove(); + } + } + if (seen == INVOKEINTERFACE) { String methodName = getNameConstantOperand(); String signature = getSigConstantOperand(); @@ -167,12 +184,13 @@ uValue = (Comparable<?>)valueItem.getUserValue(); if (uValue != null) { LoopInfo loop = loops.get(uValue); - if ((loop != null) && loop.isInLoop(getPC(), false)) { - if (this.getCodeByte(getNextPC()) == POP) { - bugReporter.reportBug(new BugInstance(this, "UAA_USE_ADD_ALL", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + if (loop != null) { + if (loop.inConditionalRange(pc)) + loop.foundAdd(-1); + else if (loop.isInLoop(pc, false)) { + if (this.getCodeByte(getNextPC()) == POP) { + loop.foundAdd(pc); + } } } } @@ -183,11 +201,13 @@ uValue = (Comparable<?>)valueItem.getUserValue(); if (uValue != null) { LoopInfo loop = loops.get(uValue); - if ((loop != null) && loop.isInLoop(getPC(), false)) { - bugReporter.reportBug(new BugInstance(this, "UAA_USE_ADD_ALL", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + if (loop != null) { + if (loop.inConditionalRange(pc)) + loop.foundAdd(-1); + else if (loop.isInLoop(pc, false)) + if (this.getCodeByte(getNextPC()) == POP) { + loop.foundAdd(pc); + } } } } @@ -214,11 +234,11 @@ brOffset <<= 8; brOffset |= (0x0FF & code[gotoPos+2]); gotoPos += brOffset; - if (gotoPos < getPC()) { + if (gotoPos < pc) { OpcodeStack.Item itm = stack.getStackItem(0); uValue = (Comparable<?>)itm.getUserValue(); if (uValue != null) { - loops.put(uValue, new LoopInfo(getPC(), getBranchTarget())); + loops.put(uValue, new LoopInfo(pc, getBranchTarget())); } loopFound = true; } @@ -226,9 +246,9 @@ if (!loopFound) { - LoopInfo loop = findLoop(getPC(), true); + LoopInfo loop = findLoop(pc, true); if (loop != null) { - loop.addConditionalRange(getPC(), getBranchTarget()); + loop.addConditionalRange(pc, getBranchTarget()); } } } @@ -249,9 +269,9 @@ } } } else if (((seen > IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL)) { - LoopInfo loop = findLoop(getPC(), true); + LoopInfo loop = findLoop(pc, true); if (loop != null) { - loop.addConditionalRange(getPC(), getBranchOffset() > 0 ? getBranchTarget() : loop.end); + loop.addConditionalRange(pc, getBranchOffset() > 0 ? getBranchTarget() : loop.end); } } else if (seen == CHECKCAST) { if (stack.getStackDepth() > 0) { @@ -352,12 +372,14 @@ { private int start; private int end; + private int addPC; private Map<Integer, Integer> conditionalRanges = new HashMap<Integer, Integer>(); public LoopInfo(int loopStart, int loopEnd) { start = loopStart; end = loopEnd; + addPC = 0; } public void addConditionalRange(int condStart, int condEnd) @@ -365,6 +387,16 @@ conditionalRanges.put(Integer14.valueOf(condStart), Integer14.valueOf(condEnd)); } + public boolean inConditionalRange(int pc) { + for (Map.Entry<Integer, Integer> entry : conditionalRanges.entrySet()) + { + if ((pc >= entry.getKey().intValue()) && pc <= entry.getValue().intValue()) + return true; + } + + return false; + } + public boolean isInLoop(int pc, boolean ignoreConditionals) { if ((pc < start) || (pc > end)) @@ -373,13 +405,26 @@ if (ignoreConditionals) return true; - for (Map.Entry<Integer, Integer> entry : conditionalRanges.entrySet()) - { - if ((pc >= entry.getKey().intValue()) && pc <= entry.getValue().intValue()) - return false; - } - - return true; + return !inConditionalRange(pc); } + + public void foundAdd(int pc) { + if (addPC == 0) + addPC = pc; + else + addPC = -1; + } + + public int getStartPC() { + return start; + } + + public int getEndPC() { + return end; + } + + public int getAddPC() { + return addPC; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-15 04:59:38
|
Revision: 1004 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1004&view=rev Author: dbrosius Date: 2008-03-14 21:59:43 -0700 (Fri, 14 Mar 2008) Log Message: ----------- test case for [ 1914317 ] FalsePositive UAA_USE_ADD_ALL Modified Paths: -------------- trunk/fb-contrib/samples/UAA_Sample.java Modified: trunk/fb-contrib/samples/UAA_Sample.java =================================================================== --- trunk/fb-contrib/samples/UAA_Sample.java 2008-03-15 04:46:51 UTC (rev 1003) +++ trunk/fb-contrib/samples/UAA_Sample.java 2008-03-15 04:59:43 UTC (rev 1004) @@ -1,3 +1,4 @@ +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -40,6 +41,19 @@ return out; } + + public void fpPrematureLoopEnd(List<String> ss) + { + for (String s : ss) + { + out.add(s); + if (s.length() == 0) + { + continue; + } + out.add(s); + } + } public void testMemberSet() { for (String s : in) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-15 04:46:46
|
Revision: 1003 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1003&view=rev Author: dbrosius Date: 2008-03-14 21:46:51 -0700 (Fri, 14 Mar 2008) Log Message: ----------- Fix for [ 1914320 ] FalsePositive Bloated Assignment Scope Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2008-03-15 04:22:17 UTC (rev 1002) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2008-03-15 04:46:51 UTC (rev 1003) @@ -50,6 +50,7 @@ private ScopeBlock rootScopeBlock; private Set<Integer> catchHandlers; private Set<Integer> switchTargets; + private List<Integer> monitorSyncPCs; private boolean dontReport; private boolean sawDup; private boolean sawNull; @@ -74,11 +75,13 @@ ignoreRegs = new HashSet<Integer>(); catchHandlers = new HashSet<Integer>(); switchTargets = new HashSet<Integer>(); + monitorSyncPCs = new ArrayList<Integer>(); super.visitClassContext(classContext); } finally { ignoreRegs = null; catchHandlers = null; switchTargets = null; + monitorSyncPCs = null; } } @@ -147,6 +150,8 @@ int pc = getPC(); if (catchHandlers.contains(Integer14.valueOf(pc))) ignoreRegs.add(iReg); + else if (monitorSyncPCs.size() > 0) + ignoreRegs.add(iReg); else if (sawNull) ignoreRegs.add(iReg); @@ -173,6 +178,8 @@ int pc = getPC(); if (catchHandlers.contains(Integer14.valueOf(pc))) ignoreRegs.add(iReg); + else if (monitorSyncPCs.size() > 0) + ignoreRegs.add(iReg); else if (sawNull) ignoreRegs.add(iReg); @@ -270,7 +277,12 @@ if ("wasNull".equals(getNameConstantOperand()) && "()Z".equals(getSigConstantOperand())) dontReport = true; - } + } else if (seen == MONITORENTER) { + monitorSyncPCs.add(Integer14.valueOf(getPC())); + } else if (seen == MONITOREXIT) { + if (monitorSyncPCs.size() > 0) + monitorSyncPCs.remove(monitorSyncPCs.size() - 1); + } sawDup = (seen == DUP); sawNull = (seen == ACONST_NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-15 04:22:11
|
Revision: 1002 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1002&view=rev Author: dbrosius Date: 2008-03-14 21:22:17 -0700 (Fri, 14 Mar 2008) Log Message: ----------- sample test case for bug [ 1914320 ] FalsePositive Bloated Assignment Scope Modified Paths: -------------- trunk/fb-contrib/samples/BAS_Sample.java Modified: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java 2008-03-15 04:15:29 UTC (rev 1001) +++ trunk/fb-contrib/samples/BAS_Sample.java 2008-03-15 04:22:17 UTC (rev 1002) @@ -1,4 +1,5 @@ import java.util.List; +import java.util.Set; public class BAS_Sample { @@ -87,5 +88,21 @@ return null; } + + public void testFPSync(Set<String> a, Set<String> b) + { + String c, d; + + synchronized(this) + { + c = a.iterator().next(); + d = b.iterator().next(); + } + + if (d.length() > 0) + { + d = c; + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-15 04:15:24
|
Revision: 1001 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1001&view=rev Author: dbrosius Date: 2008-03-14 21:15:29 -0700 (Fri, 14 Mar 2008) Log Message: ----------- Fix for [ 1914319 ] FalsePositive MRC_Method_Returns_Constant, If the return is from stringbuffer/builder.toString and the constant is "", then that is suspect, because OpcodeStack doesn't seem to handle it correctly. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2008-03-15 03:59:59 UTC (rev 1000) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2008-03-15 04:15:29 UTC (rev 1001) @@ -94,6 +94,7 @@ */ @Override public void sawOpcode(int seen) { + boolean sawSBToString = false; try { if (!methodSuspect) return; @@ -101,11 +102,16 @@ if ((seen >= IRETURN) && (seen <= ARETURN)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); + Object constant = item.getConstant(); if (constant == null) { methodSuspect = false; return; } + if ((item.getUserValue() != null) && ("".equals(constant))) { + methodSuspect = false; + return; + } if ((returnConstant != null) && (!returnConstant.equals(constant))) { methodSuspect = false; return; @@ -117,9 +123,18 @@ if (stack.getStackDepth() > 0) { methodSuspect = false; //Trinaries confuse us to much, if the code has a trinary well - oh well } + } else if (seen == INVOKEVIRTUAL) { + String clsName = getClassConstantOperand(); + if (clsName.startsWith("java/lang/StringB")) { + sawSBToString = "toString".equals(getNameConstantOperand()); + } } } finally { stack.sawOpcode(this, seen); + if (sawSBToString && (stack.getStackDepth() > 0)) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(Boolean.TRUE); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-15 03:59:55
|
Revision: 1000 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1000&view=rev Author: dbrosius Date: 2008-03-14 20:59:59 -0700 (Fri, 14 Mar 2008) Log Message: ----------- test case that supports Bug 1914319 Modified Paths: -------------- trunk/fb-contrib/samples/MRC_Sample.java Modified: trunk/fb-contrib/samples/MRC_Sample.java =================================================================== --- trunk/fb-contrib/samples/MRC_Sample.java 2008-03-14 05:34:06 UTC (rev 999) +++ trunk/fb-contrib/samples/MRC_Sample.java 2008-03-15 03:59:59 UTC (rev 1000) @@ -36,4 +36,18 @@ return "Hello"; } } + + + private String fpStringBuilder() + { + StringBuilder sb = new StringBuilder(); + fooIt(sb); + + return sb.toString(); + } + + private void fooIt(StringBuilder sb) + { + sb.append("Foo"); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-14 05:34:01
|
Revision: 999 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=999&view=rev Author: dbrosius Date: 2008-03-13 22:34:06 -0700 (Thu, 13 Mar 2008) Log Message: ----------- Fix for [ 1913557 ] FalsePositive BAS, IINC needs to count as a store and a load Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2008-03-14 04:58:39 UTC (rev 998) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2008-03-14 05:34:06 UTC (rev 999) @@ -160,6 +160,32 @@ else ignoreRegs.add(iReg); } + } else if (seen == IINC) { + int reg = getRegisterOperand(); + Integer iReg = Integer14.valueOf(reg); + if (!ignoreRegs.contains(iReg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) + sb.addLoad(reg, getPC()); + else + ignoreRegs.add(iReg); + } + int pc = getPC(); + if (catchHandlers.contains(Integer14.valueOf(pc))) + ignoreRegs.add(iReg); + else if (sawNull) + ignoreRegs.add(iReg); + + if (!ignoreRegs.contains(iReg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); + if (sb != null) { + sb.addStore(reg, pc); + if (sawDup) + sb.addLoad(reg, pc); + } + else + ignoreRegs.add(iReg); + } } else if ((seen == ALOAD) || (seen == ILOAD) || (seen == LLOAD) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-14 04:58:34
|
Revision: 998 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=998&view=rev Author: dbrosius Date: 2008-03-13 21:58:39 -0700 (Thu, 13 Mar 2008) Log Message: ----------- fix for [ 1913611 ] FalsePositve SCRV Suspicious Comparator Return Values, assume that trinaries are indeterminate Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java 2008-03-14 04:38:15 UTC (rev 997) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java 2008-03-14 04:58:39 UTC (rev 998) @@ -133,6 +133,9 @@ } } else indeterminate = true; + } else if ((seen == GOTO) || (seen == GOTO_W)) { + if (stack.getStackDepth() > 0) + indeterminate = true; } } finally { stack.sawOpcode(this, seen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-14 04:38:10
|
Revision: 997 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=997&view=rev Author: dbrosius Date: 2008-03-13 21:38:15 -0700 (Thu, 13 Mar 2008) Log Message: ----------- add false positive Modified Paths: -------------- trunk/fb-contrib/samples/SC_Sample.java Modified: trunk/fb-contrib/samples/SC_Sample.java =================================================================== --- trunk/fb-contrib/samples/SC_Sample.java 2008-03-12 05:19:56 UTC (rev 996) +++ trunk/fb-contrib/samples/SC_Sample.java 2008-03-14 04:38:15 UTC (rev 997) @@ -25,4 +25,14 @@ return 1; } } + + class FPComparator implements Comparable<FPComparator> + { + int i = 0; + + public int compareTo(FPComparator that) + { + return i < that.i ? -1 : (i == that.i) ? 0 : 1; + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-12 05:19:56
|
Revision: 996 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=996&view=rev Author: dbrosius Date: 2008-03-11 22:19:56 -0700 (Tue, 11 Mar 2008) Log Message: ----------- gram mar Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2008-03-12 05:16:00 UTC (rev 995) +++ trunk/fb-contrib/etc/messages.xml 2008-03-12 05:19:56 UTC (rev 996) @@ -850,7 +850,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousCloneAlgorithm"> <Details> <![CDATA[ - <p>looks for implementation of clone where an assignment is made to a field of the + <p>looks for implementations of clone where an assignment is made to a field of the source object. It is likely that that store should have occurred on the cloned object, as the clone operation is almost always considered read only.</p>]]> </Details> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-12 05:19:41
|
Revision: 995 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=995&view=rev Author: dbrosius Date: 2008-03-11 22:16:00 -0700 (Tue, 11 Mar 2008) Log Message: ----------- document SCA Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2008-03-09 04:04:07 UTC (rev 994) +++ trunk/fb-contrib/htdocs/index.html 2008-03-12 05:16:00 UTC (rev 995) @@ -58,6 +58,10 @@ method as it isn't obvious that the 'original' object is modified. If the point of this method is to modify the parameter, it is probably better just to have the method be a void method, to avoid confusion.</li> + <li><b>[SCA] Suspicious Clone Algorithm</b><br/> + Looks for implementation of clone where an assignment is made to a field of the + source object. It is likely that that store should have occurred on the cloned object, as + the clone operation is almost always considered read only.</li> </ul> </div> <hr/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-09 04:04:04
|
Revision: 994 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=994&view=rev Author: dbrosius Date: 2008-03-08 20:04:07 -0800 (Sat, 08 Mar 2008) Log Message: ----------- only report at a LOW_PRIORITY when the inheritance classes don't appear to belong to the caller. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java 2008-03-09 04:03:15 UTC (rev 993) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java 2008-03-09 04:04:07 UTC (rev 994) @@ -25,6 +25,7 @@ import org.apache.bcel.classfile.Code; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; +import com.mebigfatguy.fbcontrib.utils.SignatureUtils; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -156,7 +157,16 @@ } } if (matchCount > 1) { - bugReporter.reportBug(new BugInstance(bsd, "ITC_INHERITANCE_TYPE_CHECKING", NORMAL_PRIORITY) + String clsName = bsd.getClassName(); + int priority = NORMAL_PRIORITY; + for (String type : instanceOfTypes) { + if (!SignatureUtils.similarPackages(clsName, type, 2)) { + priority = LOW_PRIORITY; + break; + } + } + + bugReporter.reportBug(new BugInstance(bsd, "ITC_INHERITANCE_TYPE_CHECKING", priority) .addClass(bsd) .addMethod(bsd) .addSourceLine(bsd, firstPC)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-09 04:03:10
|
Revision: 993 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=993&view=rev Author: dbrosius Date: 2008-03-08 20:03:15 -0800 (Sat, 08 Mar 2008) Log Message: ----------- allow for arguments that have paths specified with / Modified Paths: -------------- trunk/fb-contrib/samples/ITC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java Modified: trunk/fb-contrib/samples/ITC_Sample.java =================================================================== --- trunk/fb-contrib/samples/ITC_Sample.java 2008-03-09 03:46:50 UTC (rev 992) +++ trunk/fb-contrib/samples/ITC_Sample.java 2008-03-09 04:03:15 UTC (rev 993) @@ -5,8 +5,19 @@ public class ITC_Sample { - public String test(List<String> l) + class A { + + } + + class B extends A + {} + + class C extends A + {} + + public String testOthers(List<String> l) + { if (l instanceof ArrayList) return (String)((ArrayList)l).remove(0); else if (l instanceof LinkedList) @@ -16,4 +27,14 @@ else return null; } + + public String testMine(A a) + { + if (a instanceof B) + return "Yes"; + else if (a instanceof C) + return "No"; + else + return "Unknown"; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2008-03-09 03:46:50 UTC (rev 992) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2008-03-09 04:03:15 UTC (rev 993) @@ -47,10 +47,13 @@ * * @return if they are similar */ - public static boolean similarPackages(final String packName1, final String packName2, int depth) { + public static boolean similarPackages(String packName1, String packName2, int depth) { if (depth == 0) return true; + packName1 = packName1.replace('/', '.'); + packName2 = packName2.replace('/', '.'); + int dot1 = packName1.indexOf('.'); int dot2 = packName2.indexOf('.'); if (dot1 < 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-03-09 03:46:47
|
Revision: 992 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=992&view=rev Author: dbrosius Date: 2008-03-08 19:46:50 -0800 (Sat, 08 Mar 2008) Log Message: ----------- Fix for 1909543: Check the result of add for a following POP and only report if the POP is seen. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2008-03-09 03:42:54 UTC (rev 991) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java 2008-03-09 03:46:50 UTC (rev 992) @@ -168,10 +168,12 @@ if (uValue != null) { LoopInfo loop = loops.get(uValue); if ((loop != null) && loop.isInLoop(getPC(), false)) { - bugReporter.reportBug(new BugInstance(this, "UAA_USE_ADD_ALL", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + if (this.getCodeByte(getNextPC()) == POP) { + bugReporter.reportBug(new BugInstance(this, "UAA_USE_ADD_ALL", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |