fb-contrib-commit Mailing List for fb-contrib (Page 46)
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...> - 2006-12-10 05:06:06
|
Revision: 716 http://svn.sourceforge.net/fb-contrib/?rev=716&view=rev Author: dbrosius Date: 2006-12-09 21:05:56 -0800 (Sat, 09 Dec 2006) Log Message: ----------- document SCII Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-12-10 05:04:14 UTC (rev 715) +++ trunk/fb-contrib/htdocs/index.html 2006-12-10 05:05:56 UTC (rev 716) @@ -58,6 +58,10 @@ (a negative number, 0, and a positive number).</li> <li><b>[SPP] Sillyness Pot Pourri</b><br/> Looks for various small problems that don't fall into any particular category.</li> + <li><b>[SCII] Spoiled Child Interface Implementor</b><br/> + Looks for classes that implement interfaces by relying on methods being + implemented in superclasses, even though the superclass knows nothing about + the interface being implemented by the child.</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...> - 2006-12-10 05:04:17
|
Revision: 715 http://svn.sourceforge.net/fb-contrib/?rev=715&view=rev Author: dbrosius Date: 2006-12-09 21:04:14 -0800 (Sat, 09 Dec 2006) Log Message: ----------- initial checkin - SCII detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-12-10 04:13:12 UTC (rev 714) +++ trunk/fb-contrib/etc/findbugs.xml 2006-12-10 05:04:14 UTC (rev 715) @@ -262,6 +262,10 @@ speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" + speed="fast" + reports="SCI_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -335,4 +339,5 @@ <BugPattern abbrev="SPP" type="SPP_USE_ISNAN" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="SPP" type="SPP_USE_BIGDECIMAL_STRING_CTOR" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-12-10 04:13:12 UTC (rev 714) +++ trunk/fb-contrib/etc/messages.xml 2006-12-10 05:04:14 UTC (rev 715) @@ -702,6 +702,16 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor"> + <Details> + <![CDATA[ + <p>looks for classes that implement interfaces by relying on methods being + implemented in superclasses, even tho the superclass knows nothing about + the interface being implemented by the child.</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1618,6 +1628,20 @@ </Details> </BugPattern> + <BugPattern type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR"> + <ShortDescription>Class implements interface by relying on unknowing superclass methods</ShortDescription> + <LongDescription>Class {0} implements interface by relying on unknowing superclass methods</LongDescription> + <Details> + <![CDATA[ + <p>This class declares that it implements an interface, but does so by relying on methods supplied + by superclasses, even though those superclasses know nothing about the interface in question. If you wish + to have the child not implement all the methods of the interface, it would probably be better to declare + the superclass as implementing the interface, and if that class does not provide all the methods, then declare + that superclass abstract.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1678,5 +1702,5 @@ <BugCode abbrev="SCRV">Suspicious Comparator Return Values</BugCode> <BugCode abbrev="SPP">Sillyness Pot Pourri</BugCode> <BugCode abbrev="BAS">Bloated Assignment Scope</BugCode> - + <BugCode abbrev="SCII">Spoiled Child Interface Implementor</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...> - 2006-12-10 04:13:14
|
Revision: 714 http://svn.sourceforge.net/fb-contrib/?rev=714&view=rev Author: dbrosius Date: 2006-12-09 20:13:12 -0800 (Sat, 09 Dec 2006) Log Message: ----------- add copyright 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 2006-12-09 00:00:18 UTC (rev 713) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-10 04:13:12 UTC (rev 714) @@ -1,3 +1,21 @@ +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2006 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.fbcontrib.detect; import java.util.ArrayList; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-09 00:00:40
|
Revision: 713 http://svn.sourceforge.net/fb-contrib/?rev=713&view=rev Author: dbrosius Date: 2006-12-08 16:00:18 -0800 (Fri, 08 Dec 2006) Log Message: ----------- fix it better Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-12-08 23:50:08 UTC (rev 712) +++ trunk/fb-contrib/htdocs/index.html 2006-12-09 00:00:18 UTC (rev 713) @@ -63,7 +63,7 @@ <hr/> <img id="v3_0_0_image" src="flip1.gif" onClick="toggleBlock('v3_0_0', 'v3_0_0_image');" align="top"/> Detectors added in v3.0.0<br/> - <div id="svn" style="display:none;"> + <div id="v3_0_0" style="display:none;"> <ul> <li><b>[LEST] Lost Exception Stack Trace</b><br/> Looks for methods that catch exceptions, and rethrow another exception without encapsulating This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-08 23:50:16
|
Revision: 712 http://svn.sourceforge.net/fb-contrib/?rev=712&view=rev Author: dbrosius Date: 2006-12-08 15:50:08 -0800 (Fri, 08 Dec 2006) Log Message: ----------- fix expansion of v3_0_0 Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2006-12-08 16:11:06 UTC (rev 711) +++ trunk/fb-contrib/htdocs/index.html 2006-12-08 23:50:08 UTC (rev 712) @@ -61,7 +61,7 @@ </ul> </div> <hr/> - <img id="v3_0_0_image" src="flip1.gif" onClick="toggleBlock('v3_0_0', 'svn_image');" align="top"/> + <img id="v3_0_0_image" src="flip1.gif" onClick="toggleBlock('v3_0_0', 'v3_0_0_image');" align="top"/> Detectors added in v3.0.0<br/> <div id="svn" style="display:none;"> <ul> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-08 16:12:03
|
Revision: 711 http://svn.sourceforge.net/fb-contrib/?rev=711&view=rev Author: dbrosius Date: 2006-12-08 08:11:06 -0800 (Fri, 08 Dec 2006) Log Message: ----------- don't push up scope blocks, believing that the block is a complex conditional guard if the block in question already has children 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 2006-12-04 05:34:26 UTC (rev 710) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-08 16:11:06 UTC (rev 711) @@ -141,10 +141,10 @@ } } else { ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); - if ((sb != null) && (!sb.isLoop)) { + if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) { sb.pushUpLoadStores(); - sb.startLocation = getPC(); - sb.finishLocation = target; + sb.setStart(getPC()); + sb.setFinish(target); } else { sb = new ScopeBlock(getPC(), target); rootScopeBlock.addChild(sb); @@ -255,7 +255,26 @@ public int getFinish() { return finishLocation; } + + /** + * sets the start pc of the block + * @param start the start pc + */ + public void setStart(int start) { + startLocation = start; + } + + /** + * sets the finish pc of the block + * @param finish the finish pc + */ + public void setFinish(int finish) { + finishLocation = finish; + } + public boolean hasChildren() { + return children != null; + } /** * sets that this block is a loop */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-04 05:34:27
|
Revision: 710 http://svn.sourceforge.net/fb-contrib/?rev=710&view=rev Author: dbrosius Date: 2006-12-03 21:34:26 -0800 (Sun, 03 Dec 2006) Log Message: ----------- if a compound if test is found, update the scope block range 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 2006-12-04 04:46:31 UTC (rev 709) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 05:34:26 UTC (rev 710) @@ -143,6 +143,8 @@ ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); if ((sb != null) && (!sb.isLoop)) { sb.pushUpLoadStores(); + sb.startLocation = getPC(); + sb.finishLocation = target; } else { sb = new ScopeBlock(getPC(), target); rootScopeBlock.addChild(sb); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-04 04:46:36
|
Revision: 709 http://svn.sourceforge.net/fb-contrib/?rev=709&view=rev Author: dbrosius Date: 2006-12-03 20:46:31 -0800 (Sun, 03 Dec 2006) Log Message: ----------- fix case where if statement immediately follows a loop. 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 2006-12-04 02:38:36 UTC (rev 708) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 04:46:31 UTC (rev 709) @@ -141,7 +141,7 @@ } } else { ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); - if (sb != null) { + if ((sb != null) && (!sb.isLoop)) { sb.pushUpLoadStores(); } else { sb = new ScopeBlock(getPC(), target); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-04 02:38:41
|
Revision: 708 http://svn.sourceforge.net/fb-contrib/?rev=708&view=rev Author: dbrosius Date: 2006-12-03 18:38:36 -0800 (Sun, 03 Dec 2006) Log Message: ----------- reenable BAS for now Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-12-04 02:30:27 UTC (rev 707) +++ trunk/fb-contrib/etc/findbugs.xml 2006-12-04 02:38:36 UTC (rev 708) @@ -260,8 +260,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" - reports="BAS_BLOATED_ASSIGNMENT_SCOPE" - hidden="true" /> + reports="BAS_BLOATED_ASSIGNMENT_SCOPE" /> <!-- BugPattern --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-04 02:30:27
|
Revision: 707 http://svn.sourceforge.net/fb-contrib/?rev=707&view=rev Author: dbrosius Date: 2006-12-03 18:30:27 -0800 (Sun, 03 Dec 2006) Log Message: ----------- fix findScopeBlock 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 2006-12-04 00:45:50 UTC (rev 706) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 02:30:27 UTC (rev 707) @@ -168,9 +168,9 @@ if ((pc > sb.getStart()) && (pc < sb.getFinish())) { if (sb.children != null) { for (ScopeBlock child : sb.children) { - sb = findScopeBlock(child, pc); - if (sb != null) - return sb; + ScopeBlock foundSb = findScopeBlock(child, pc); + if (foundSb != null) + return foundSb; } } return sb; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-04 00:45:56
|
Revision: 706 http://svn.sourceforge.net/fb-contrib/?rev=706&view=rev Author: dbrosius Date: 2006-12-03 16:45:50 -0800 (Sun, 03 Dec 2006) Log Message: ----------- forward branching gotos not associated with elseifs, are treated as loops 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 2006-12-03 17:25:11 UTC (rev 705) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-04 00:45:50 UTC (rev 706) @@ -134,6 +134,10 @@ if (sb != null) { sb = new ScopeBlock(getPC(), target); rootScopeBlock.addChild(sb); + } else { + sb = new ScopeBlock(getPC(), target); + sb.setLoop(); + rootScopeBlock.addChild(sb); } } else { ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-03 17:25:15
|
Revision: 705 http://svn.sourceforge.net/fb-contrib/?rev=705&view=rev Author: dbrosius Date: 2006-12-03 09:25:11 -0800 (Sun, 03 Dec 2006) Log Message: ----------- hide detector for now Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-12-03 17:17:52 UTC (rev 704) +++ trunk/fb-contrib/etc/findbugs.xml 2006-12-03 17:25:11 UTC (rev 705) @@ -260,7 +260,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" - reports="BAS_BLOATED_ASSIGNMENT_SCOPE" /> + reports="BAS_BLOATED_ASSIGNMENT_SCOPE" + hidden="true" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-03 17:18:05
|
Revision: 704 http://svn.sourceforge.net/fb-contrib/?rev=704&view=rev Author: dbrosius Date: 2006-12-03 09:17:52 -0800 (Sun, 03 Dec 2006) Log Message: ----------- handle elseif's correctly 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 2006-12-03 16:49:37 UTC (rev 703) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 17:17:52 UTC (rev 704) @@ -129,16 +129,21 @@ } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) { int target = getBranchTarget(); if (target > getPC()) { - if ((seen == GOTO) || (seen == GOTO_W)) - return; - - ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); - if (sb != null) { - sb.pushUpLoadStores(); - } else { - sb = new ScopeBlock(getPC(), target); - rootScopeBlock.addChild(sb); - } + if ((seen == GOTO) || (seen == GOTO_W)) { + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), getNextPC()); + if (sb != null) { + sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } + } else { + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); + if (sb != null) { + sb.pushUpLoadStores(); + } else { + sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } + } } else { ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); if (sb != null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-03 16:49:48
|
Revision: 703 http://svn.sourceforge.net/fb-contrib/?rev=703&view=rev Author: dbrosius Date: 2006-12-03 08:49:37 -0800 (Sun, 03 Dec 2006) Log Message: ----------- forward branching GOTO or GOTO_W's shouldn't be considered scope definitions 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 2006-12-03 10:42:28 UTC (rev 702) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 16:49:37 UTC (rev 703) @@ -129,6 +129,9 @@ } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) { int target = getBranchTarget(); if (target > getPC()) { + if ((seen == GOTO) || (seen == GOTO_W)) + return; + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); if (sb != null) { sb.pushUpLoadStores(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-03 10:42:29
|
Revision: 702 http://svn.sourceforge.net/fb-contrib/?rev=702&view=rev Author: dbrosius Date: 2006-12-03 02:42:28 -0800 (Sun, 03 Dec 2006) Log Message: ----------- if a block starts and ends after another block, THAT is when it is part of a compound condition, in which case combine the two blocks, and push the load and stores up to the parent 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 2006-12-03 10:21:49 UTC (rev 701) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 10:42:28 UTC (rev 702) @@ -129,7 +129,7 @@ } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) { int target = getBranchTarget(); if (target > getPC()) { - ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, target); + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); if (sb != null) { sb.pushUpLoadStores(); } else { @@ -174,14 +174,14 @@ * * @return the scope block found or null */ - private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int target) { - if (sb.finishLocation == target) + private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) { + if ((sb.startLocation < start) && (sb.finishLocation <= target)) return sb; if (sb.children != null) { for (ScopeBlock child : sb.children) { - ScopeBlock targetBlock = findScopeBlockWithTarget(child, target); + ScopeBlock targetBlock = findScopeBlockWithTarget(child, start, target); if (targetBlock != null) return targetBlock; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-03 10:21:51
|
Revision: 701 http://svn.sourceforge.net/fb-contrib/?rev=701&view=rev Author: dbrosius Date: 2006-12-03 02:21:49 -0800 (Sun, 03 Dec 2006) Log Message: ----------- remove unused 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 2006-12-03 10:21:09 UTC (rev 700) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 10:21:49 UTC (rev 701) @@ -25,7 +25,6 @@ public class BloatedAssignmentScope extends BytecodeScanningDetector { BugReporter bugReporter; - private Map<Integer, Integer> regToLocationMap; private Set<Integer> ignoreRegs; private ScopeBlock rootScopeBlock; @@ -46,11 +45,9 @@ @Override public void visitClassContext(ClassContext classContext) { try { - regToLocationMap = new HashMap<Integer, Integer>(); ignoreRegs = new HashSet<Integer>(); super.visitClassContext(classContext); } finally { - regToLocationMap = null; ignoreRegs = null; } } @@ -64,7 +61,6 @@ public void visitCode(Code obj) { try { - regToLocationMap.clear(); ignoreRegs.clear(); Method method = getMethod(); if (!method.isStatic()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-03 10:21:19
|
Revision: 700 http://svn.sourceforge.net/fb-contrib/?rev=700&view=rev Author: dbrosius Date: 2006-12-03 02:21:09 -0800 (Sun, 03 Dec 2006) Log Message: ----------- if a scope block target is the same as another block it must be a compound conditional, so merge the blocks, and move already recorded load stores to the parent 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 2006-12-03 09:52:26 UTC (rev 699) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 10:21:09 UTC (rev 700) @@ -133,8 +133,13 @@ } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) { int target = getBranchTarget(); if (target > getPC()) { - ScopeBlock sb = new ScopeBlock(getPC(), target); - rootScopeBlock.addChild(sb); + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, target); + if (sb != null) { + sb.pushUpLoadStores(); + } else { + sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } } else { ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); if (sb != null) @@ -164,11 +169,36 @@ } return null; } + + /** + * returns an existing scope block that has the same target as the one looked for + * + * @param sb the scope block to start with + * @param target the target to look for + * + * @return the scope block found or null + */ + private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int target) { + if (sb.finishLocation == target) + return sb; + if (sb.children != null) + { + for (ScopeBlock child : sb.children) { + ScopeBlock targetBlock = findScopeBlockWithTarget(child, target); + if (targetBlock != null) + return targetBlock; + } + } + + return null; + } + /** holds the description of a scope { } block, be it a for, if, while block */ private class ScopeBlock { + private ScopeBlock parent; private int startLocation; private int finishLocation; private boolean isLoop; @@ -182,6 +212,7 @@ * @param finish the end of the block */ public ScopeBlock(int start, int finish) { + parent = null; startLocation = start; finishLocation = finish; isLoop = false; @@ -254,6 +285,8 @@ * @param child the scope block to add to the tree */ public void addChild(ScopeBlock newChild) { + newChild.parent = this; + if (children != null) { for (ScopeBlock child : children) { if ((newChild.startLocation > child.startLocation) && (newChild.finishLocation < child.finishLocation)) { @@ -339,5 +372,27 @@ return false; } + + /** + * push all loads and stores to this block up to the parent + */ + public void pushUpLoadStores() { + if (parent != null) { + if (loads != null) { + if (parent.loads != null) + parent.loads.putAll(loads); + else + parent.loads = loads; + } + if (stores != null) { + if (parent.stores != null) + parent.stores.putAll(stores); + else + parent.stores = stores; + } + loads = null; + stores = null; + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-12-03 09:52:28
|
Revision: 699 http://svn.sourceforge.net/fb-contrib/?rev=699&view=rev Author: dbrosius Date: 2006-12-03 01:52:26 -0800 (Sun, 03 Dec 2006) Log Message: ----------- BAS starts to hobble along Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-11-30 06:05:35 UTC (rev 698) +++ trunk/fb-contrib/etc/findbugs.xml 2006-12-03 09:52:26 UTC (rev 699) @@ -257,7 +257,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri" speed="fast" reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR"/> - + + <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" + speed="fast" + reports="BAS_BLOATED_ASSIGNMENT_SCOPE" /> <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -330,4 +333,5 @@ <BugPattern abbrev="SPP" type="SPP_STUTTERED_ASSIGNMENT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="SPP" type="SPP_USE_ISNAN" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="SPP" type="SPP_USE_BIGDECIMAL_STRING_CTOR" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-11-30 06:05:35 UTC (rev 698) +++ trunk/fb-contrib/etc/messages.xml 2006-12-03 09:52:26 UTC (rev 699) @@ -693,6 +693,15 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope"> + <Details> + <![CDATA[ + <p>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> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1596,6 +1605,19 @@ ]]> </Details> </BugPattern> + + <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> + <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> + <LongDescription>Method {1} assigns a variable in a larger scope then is needed</LongDescription> + <Details> + <![CDATA[ + <p>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.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1655,5 +1677,6 @@ <BugCode abbrev="PIS">Possible Incomplete Serialization</BugCode> <BugCode abbrev="SCRV">Suspicious Comparator Return Values</BugCode> <BugCode abbrev="SPP">Sillyness Pot Pourri</BugCode> + <BugCode abbrev="BAS">Bloated Assignment Scope</BugCode> </MessageCollection> \ No newline at end of file Modified: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java 2006-11-30 06:05:35 UTC (rev 698) +++ trunk/fb-contrib/samples/BAS_Sample.java 2006-12-03 09:52:26 UTC (rev 699) @@ -20,5 +20,30 @@ } return s; } + + public String testFP2Scopes(String s) + { + Object o = new Object(); + if (s.equals("Boo")) + s = o.toString(); + else if (s.equals("Hoo")) + s = o.toString(); + + return s; + } + + public String test2InnerScopes(String s) + { + Object o = new Object(); + if (s != null) + { + if (s.equals("Boo")) + s = o.toString(); + else if (s.equals("Hoo")) + s = o.toString(); + } + + return s; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-11-30 06:05:35 UTC (rev 698) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-12-03 09:52:26 UTC (rev 699) @@ -1,12 +1,18 @@ package com.mebigfatguy.fbcontrib.detect; +import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; +import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.ba.ClassContext; @@ -18,19 +24,20 @@ */ public class BloatedAssignmentScope extends BytecodeScanningDetector { - private BugReporter bugReporter; + BugReporter bugReporter; private Map<Integer, Integer> regToLocationMap; - private Map<Integer, Integer> scopeBlockMap; + private Set<Integer> ignoreRegs; + private ScopeBlock rootScopeBlock; /** - * constructs a BLT detector given the reporter to report bugs on + * constructs a BAS detector given the reporter to report bugs on * @param bugReporter the sync of bug reports */ public BloatedAssignmentScope(BugReporter bugReporter) { this.bugReporter = bugReporter; } - + /** * implements the visitor to create and the clear the register to location map * @@ -40,11 +47,11 @@ public void visitClassContext(ClassContext classContext) { try { regToLocationMap = new HashMap<Integer, Integer>(); - scopeBlockMap = new HashMap<Integer, Integer>(); + ignoreRegs = new HashSet<Integer>(); super.visitClassContext(classContext); } finally { regToLocationMap = null; - scopeBlockMap = null; + ignoreRegs = null; } } @@ -55,23 +62,282 @@ */ @Override public void visitCode(Code obj) { - regToLocationMap.clear(); - scopeBlockMap.clear(); - super.visitCode(obj); + try { + + regToLocationMap.clear(); + ignoreRegs.clear(); + Method method = getMethod(); + if (!method.isStatic()) + ignoreRegs.add(Integer.valueOf(0)); + + int[] parmRegs = RegisterUtils.getParameterRegisters(method); + for (int parm : parmRegs) { + ignoreRegs.add(Integer.valueOf(parm)); + } + + rootScopeBlock = new ScopeBlock(0, obj.getLength()); + super.visitCode(obj); + + rootScopeBlock.findBugs(); + + } finally { + rootScopeBlock = null; + } } - + /** - * implements the visitor to look for variables assigned out side of the scope + * implements the visitor to look for variables assigned below the scope * in which they are used. * * @param seen the opcode of the currently parsed instruction */ @Override public void sawOpcode(int seen) { - if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { - int reg = RegisterUtils.getAStoreReg(this, seen); - } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { - int reg = RegisterUtils.getALoadReg(this, seen); + if ((seen == ASTORE) + || (seen == ISTORE) + || (seen == LSTORE) + || (seen == FSTORE) + || (seen == DSTORE) + || ((seen >= ASTORE_0) && (seen <= ASTORE_3)) + || ((seen >= ISTORE_0) && (seen <= ISTORE_3)) + || ((seen >= LSTORE_0) && (seen <= LSTORE_1)) + || ((seen >= FSTORE_0) && (seen <= FSTORE_1)) + || ((seen >= DSTORE_0) && (seen <= DSTORE_1))) { + int reg = RegisterUtils.getStoreReg(this, seen); + if (!ignoreRegs.contains(Integer.valueOf(reg))) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) + sb.addStore(reg, getPC()); + else + ignoreRegs.add(Integer.valueOf(reg)); + } + + } else if ((seen == ALOAD) + || (seen == ILOAD) + || (seen == LLOAD) + || (seen == FLOAD) + || (seen == DLOAD) + || ((seen >= ALOAD_0) && (seen <= ALOAD_3)) + || ((seen >= ILOAD_0) && (seen <= ILOAD_3)) + || ((seen >= LLOAD_0) && (seen <= LLOAD_1)) + || ((seen >= FLOAD_0) && (seen <= FLOAD_1)) + || ((seen >= DLOAD_0) && (seen <= DLOAD_1))) { + int reg = RegisterUtils.getLoadReg(this, seen); + if (!ignoreRegs.contains(Integer.valueOf(reg))) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) + sb.addLoad(reg, getPC()); + else + ignoreRegs.add(Integer.valueOf(reg)); + } + } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == GOTO_W)) { + int target = getBranchTarget(); + if (target > getPC()) { + ScopeBlock sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } else { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) + sb.setLoop(); + } } } + + /** + * returns the scope block in which this register was assigned, by traversing the scope block tree + * + * @param sb the scope block to start searching in + * @param pc the current program counter + * @return the scope block or null if not found + */ + private ScopeBlock findScopeBlock(ScopeBlock sb, int pc) { + + if ((pc > sb.getStart()) && (pc < sb.getFinish())) { + if (sb.children != null) { + for (ScopeBlock child : sb.children) { + sb = findScopeBlock(child, pc); + if (sb != null) + return sb; + } + } + return sb; + } + return null; + } + + /** holds the description of a scope { } block, be it a for, if, while block + */ + private class ScopeBlock + { + private int startLocation; + private int finishLocation; + private boolean isLoop; + private Map<Integer, Integer> loads; + private Map<Integer, Integer> stores; + private List<ScopeBlock> children; + + /** construts a new scope block + * + * @param start the beginning of the block + * @param finish the end of the block + */ + public ScopeBlock(int start, int finish) { + startLocation = start; + finishLocation = finish; + isLoop = false; + loads = null; + stores = null; + children = null; + } + + /** + * returns a string representation of the scope block + * + * @returns a string representation + */ + public String toString() { + return "Start=" + startLocation + " Finish=" + finishLocation + " Loop=" + isLoop + " Loads=" + loads + " Stores=" + stores; + } + + /** returns the start of the block + * + * @return the start of the block + */ + public int getStart() { + return startLocation; + } + + /** returns the end of the block + * + * @return the end of the block + */ + public int getFinish() { + return finishLocation; + } + + /** + * sets that this block is a loop + */ + public void setLoop() { + isLoop = true; + } + + /** + * adds the register as a store in this scope block + * + * @param reg the register that was stored + * @param pc the instruction that did the store + */ + public void addStore(int reg, int pc) { + if (stores == null) + stores = new HashMap<Integer, Integer>(); + + stores.put(Integer.valueOf(reg), Integer.valueOf(pc)); + } + + /** + * adds the register as a load in this scope block + * + * @param reg the register that was loaded + * @param pc the instruction that did the load + */ + public void addLoad(int reg, int pc) { + if (loads == null) + loads = new HashMap<Integer, Integer>(); + + loads.put(Integer.valueOf(reg), Integer.valueOf(pc)); + } + + /** + * adds a scope block to this subtree by finding the correct place in the hierarchy to store it + * + * @param child the scope block to add to the tree + */ + public void addChild(ScopeBlock newChild) { + if (children != null) { + for (ScopeBlock child : children) { + if ((newChild.startLocation > child.startLocation) && (newChild.finishLocation < child.finishLocation)) { + child.addChild(newChild); + return; + } + } + int pos = 0; + for (ScopeBlock child : children) { + if (newChild.startLocation < child.startLocation) { + children.add(pos, newChild); + return; + } + pos++; + } + children.add(newChild); + return; + } + children = new ArrayList<ScopeBlock>(); + children.add(newChild); + } + + /** + * report stores that occur at scopes higher than associated loads that are not involved with loops + */ + public void findBugs() { + if (isLoop) + return; + + if (stores != null) { + if (loads != null) + stores.keySet().removeAll(loads.keySet()); + + if (children != null) { + for (Map.Entry<Integer, Integer> entry : stores.entrySet()) { + int childUseCount = 0; + boolean inLoop = false; + for (ScopeBlock child : children) { + if (child.usesReg(entry.getKey())) { + if (child.isLoop) { + inLoop = true; + break; + } + childUseCount++; + } + } + if ((!inLoop) && (childUseCount == 1)) { + bugReporter.reportBug(new BugInstance(BloatedAssignmentScope.this, "BAS_BLOATED_ASSIGNMENT_SCOPE", NORMAL_PRIORITY) + .addClass(BloatedAssignmentScope.this) + .addMethod(BloatedAssignmentScope.this) + .addSourceLine(BloatedAssignmentScope.this, entry.getValue())); + } + } + } + } + + if (children != null) { + for (ScopeBlock child : children) { + child.findBugs(); + } + } + } + + /** + * returns whether this block either loads or stores into the register in question + * + * @param reg the register to look for loads or stores + * + * @return whether the block uses the register + */ + public boolean usesReg(Integer reg) { + if ((loads != null) && (loads.containsKey(reg))) + return true; + if ((stores != null) && (stores.containsKey(reg))) + return true; + + if (children != null) { + for (ScopeBlock child : children) { + if (child.usesReg(reg)) + return true; + } + } + + return false; + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-11-30 06:05:35
|
Revision: 698 http://svn.sourceforge.net/fb-contrib/?rev=698&view=rev Author: dbrosius Date: 2006-11-29 22:05:35 -0800 (Wed, 29 Nov 2006) Log Message: ----------- initial checkin BAS Added Paths: ----------- trunk/fb-contrib/samples/BAS_Sample.java Added: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java (rev 0) +++ trunk/fb-contrib/samples/BAS_Sample.java 2006-11-30 06:05:35 UTC (rev 698) @@ -0,0 +1,24 @@ + +public class BAS_Sample +{ + public void testIfScope(String s) + { + Object o = new Object(); + if (s.equals("Foo")) + { + s = o.toString(); + } + } + + public String testFPForScope(String s) + { + Object o = new Object(); + while (s.length() > 0) + { + o = s.substring(0, 1); + s = s.substring(1); + } + return s; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-11-30 06:05:11
|
Revision: 697 http://svn.sourceforge.net/fb-contrib/?rev=697&view=rev Author: dbrosius Date: 2006-11-29 22:05:11 -0800 (Wed, 29 Nov 2006) Log Message: ----------- initial checkin BAS Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2006-11-30 06:05:11 UTC (rev 697) @@ -0,0 +1,77 @@ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.classfile.Code; + +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; + +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for variable assignments at a scope larger than its use. In this case, + * the assignment can be pushed down into the smaller scope to reduce the performance + * impact of that assignment. + */ +public class BloatedAssignmentScope extends BytecodeScanningDetector +{ + private BugReporter bugReporter; + private Map<Integer, Integer> regToLocationMap; + private Map<Integer, Integer> scopeBlockMap; + + /** + * constructs a BLT detector given the reporter to report bugs on + + * @param bugReporter the sync of bug reports + */ + public BloatedAssignmentScope(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to create and the clear the register to location map + * + * @param classContext the context object of the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + regToLocationMap = new HashMap<Integer, Integer>(); + scopeBlockMap = new HashMap<Integer, Integer>(); + super.visitClassContext(classContext); + } finally { + regToLocationMap = null; + scopeBlockMap = null; + } + } + + /** + * implements the visitor to reset the register to location map + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + regToLocationMap.clear(); + scopeBlockMap.clear(); + super.visitCode(obj); + } + + /** + * implements the visitor to look for variables assigned out side of the scope + * in which they are used. + * + * @param seen the opcode of the currently parsed instruction + */ + @Override + public void sawOpcode(int seen) { + if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { + int reg = RegisterUtils.getAStoreReg(this, seen); + } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { + int reg = RegisterUtils.getALoadReg(this, seen); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-11-23 20:08:59
|
Revision: 696 http://svn.sourceforge.net/fb-contrib/?rev=696&view=rev Author: dbrosius Date: 2006-11-23 12:08:54 -0800 (Thu, 23 Nov 2006) Log Message: ----------- add checks for BigDecimal(2.1) to SPP Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-11-23 19:15:03 UTC (rev 695) +++ trunk/fb-contrib/etc/findbugs.xml 2006-11-23 20:08:54 UTC (rev 696) @@ -256,7 +256,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri" speed="fast" - reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN"/> + reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR"/> <!-- BugPattern --> @@ -329,4 +329,5 @@ <BugPattern abbrev="SPP" type="SPP_USE_MATH_CONSTANT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="SPP" type="SPP_STUTTERED_ASSIGNMENT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="SPP" type="SPP_USE_ISNAN" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SPP" type="SPP_USE_BIGDECIMAL_STRING_CTOR" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-11-23 19:15:03 UTC (rev 695) +++ trunk/fb-contrib/etc/messages.xml 2006-11-23 20:08:54 UTC (rev 696) @@ -1585,6 +1585,17 @@ </Details> </BugPattern> + <BugPattern type="SPP_USE_BIGDECIMAL_STRING_CTOR"> + <ShortDescription>Method passes double value to BigDecimal Constructor</ShortDescription> + <LongDescription>Method {1} passes double value to BigDecimal Constructor</LongDescription> + <Details> + <![CDATA[ + <p>This method calls the BigDecimal constructor that takes a double, and passes a literal double constant value. Since + the use of BigDecimal is to get better precision than double, by passing a double, you only get the precision of double number + space. To take advantage of the BigDecimal space, pass the number as a string. </p> + ]]> + </Details> + </BugPattern> <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2006-11-23 19:15:03 UTC (rev 695) +++ trunk/fb-contrib/samples/SPP_Sample.java 2006-11-23 20:08:54 UTC (rev 696) @@ -1,3 +1,4 @@ +import java.math.BigDecimal; import java.util.BitSet; public class SPP_Sample @@ -37,4 +38,9 @@ if (d == Double.NaN) System.out.println("It's a nan"); } + + public void testBigDecimal() + { + BigDecimal d = new BigDecimal(2.1); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-23 19:15:03 UTC (rev 695) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-23 20:08:54 UTC (rev 696) @@ -180,6 +180,18 @@ } } } + } else if ("java/math/BigDecimal".equals(className)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + Object constant = item.getConstant(); + if (constant instanceof Double) + { + bugReporter.reportBug(new BugInstance(this, "SPP_USE_BIGDECIMAL_STRING_CTOR", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-11-23 19:15:06
|
Revision: 695 http://svn.sourceforge.net/fb-contrib/?rev=695&view=rev Author: dbrosius Date: 2006-11-23 11:15:03 -0800 (Thu, 23 Nov 2006) Log Message: ----------- add checking nan by doing == Double.NaN Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-11-20 01:31:22 UTC (rev 694) +++ trunk/fb-contrib/etc/findbugs.xml 2006-11-23 19:15:03 UTC (rev 695) @@ -256,7 +256,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri" speed="fast" - reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT"/> + reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN"/> <!-- BugPattern --> @@ -328,5 +328,5 @@ <BugPattern abbrev="SPP" type="SPP_NO_CHAR_SB_CTOR" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="SPP" type="SPP_USE_MATH_CONSTANT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="SPP" type="SPP_STUTTERED_ASSIGNMENT" category="CORRECTNESS" experimental="true" /> - + <BugPattern abbrev="SPP" type="SPP_USE_ISNAN" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-11-20 01:31:22 UTC (rev 694) +++ trunk/fb-contrib/etc/messages.xml 2006-11-23 19:15:03 UTC (rev 695) @@ -1574,6 +1574,17 @@ </Details> </BugPattern> + <BugPattern type="SPP_USE_ISNAN"> + <ShortDescription>Method compares a double to Double.NAN</ShortDescription> + <LongDescription>Method {1} compares a double to Double.NAN</LongDescription> + <Details> + <![CDATA[ + <p>This method compares a douhle to the constant Double.NaN. You should use + Double.isNaN(d) if a primitive; or d.isNaN() if a boxed double, instead.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2006-11-20 01:31:22 UTC (rev 694) +++ trunk/fb-contrib/samples/SPP_Sample.java 2006-11-23 19:15:03 UTC (rev 695) @@ -31,4 +31,10 @@ { String a = a = s; } + + public void testNAN(double d) + { + if (d == Double.NaN) + System.out.println("It's a nan"); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-20 01:31:22 UTC (rev 694) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-23 19:15:03 UTC (rev 695) @@ -93,6 +93,20 @@ .addSourceLine(this)); } } + } else if (seen == DCMPL) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item item = stack.getStackItem(0); + Double d1 = (Double)item.getConstant(); + item = stack.getStackItem(1); + Double d2 = (Double)item.getConstant(); + + if (((d1 != null) && d1.isNaN()) || ((d2 != null) && d2.isNaN())) { + bugReporter.reportBug(new BugInstance(this, "SPP_USE_ISNAN", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } else if (((seen >= ASTORE_0) && (seen < ASTORE_3)) || (seen == ASTORE)) { reg = RegisterUtils.getAStoreReg(this, seen); if (seen == lastOpcode) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-11-20 01:31:31
|
Revision: 694 http://svn.sourceforge.net/fb-contrib/?rev=694&view=rev Author: dbrosius Date: 2006-11-19 17:31:22 -0800 (Sun, 19 Nov 2006) Log Message: ----------- add assignment stutter checking to SPP Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-11-19 05:52:18 UTC (rev 693) +++ trunk/fb-contrib/etc/findbugs.xml 2006-11-20 01:31:22 UTC (rev 694) @@ -256,7 +256,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri" speed="fast" - reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT"/> + reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT"/> <!-- BugPattern --> @@ -327,5 +327,6 @@ <BugPattern abbrev="SPP" type="SPP_INTERN_ON_CONSTANT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="SPP" type="SPP_NO_CHAR_SB_CTOR" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="SPP" type="SPP_USE_MATH_CONSTANT" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SPP" type="SPP_STUTTERED_ASSIGNMENT" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-11-19 05:52:18 UTC (rev 693) +++ trunk/fb-contrib/etc/messages.xml 2006-11-20 01:31:22 UTC (rev 694) @@ -1562,6 +1562,18 @@ </Details> </BugPattern> + <BugPattern type="SPP_STUTTERED_ASSIGNMENT"> + <ShortDescription>Method assigns a value to a local twice in a row</ShortDescription> + <LongDescription>Method {1} assigns a value to a local twice in a row</LongDescription> + <Details> + <![CDATA[ + <p>This method assigns a value twice in a row in a stuttered way such as + <code>a = a = 5;</code> This is most probably a cut and paste error where the duplicate + assignment can be removed.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2006-11-19 05:52:18 UTC (rev 693) +++ trunk/fb-contrib/samples/SPP_Sample.java 2006-11-20 01:31:22 UTC (rev 694) @@ -26,4 +26,9 @@ { return pi * radius * radius; } + + public void testStutter(String s) + { + String a = a = s; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-19 05:52:18 UTC (rev 693) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-20 01:31:22 UTC (rev 694) @@ -21,6 +21,8 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.ConstantDouble; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; + import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -35,6 +37,7 @@ private BugReporter bugReporter; private OpcodeStack stack; private int lastOpcode; + private int lastReg; /** * constructs a SPP detector given the reporter to report bugs on @@ -61,6 +64,7 @@ public void visitCode(Code obj) { stack.resetForMethodEntry(this); lastOpcode = -1; + lastReg = -1; super.visitCode(obj); } @@ -70,6 +74,7 @@ * @param seen the opcode of the currently parsed instruction */ public void sawOpcode(int seen) { + int reg = -1; try { stack.mergeJumps(this); @@ -88,6 +93,16 @@ .addSourceLine(this)); } } + } else if (((seen >= ASTORE_0) && (seen < ASTORE_3)) || (seen == ASTORE)) { + reg = RegisterUtils.getAStoreReg(this, seen); + if (seen == lastOpcode) { + if (reg == lastReg) { + bugReporter.reportBug(new BugInstance(this, "SPP_STUTTERED_ASSIGNMENT", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } else if (seen == INVOKEVIRTUAL) { String className = getClassConstantOperand(); String methodName = getNameConstantOperand(); @@ -157,6 +172,7 @@ } finally { stack.sawOpcode(this, seen); lastOpcode = seen; + lastReg = reg; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-11-19 05:52:20
|
Revision: 693 http://svn.sourceforge.net/fb-contrib/?rev=693&view=rev Author: dbrosius Date: 2006-11-18 21:52:18 -0800 (Sat, 18 Nov 2006) Log Message: ----------- add 'create' as risky to PRMC Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2006-11-19 05:42:56 UTC (rev 692) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2006-11-19 05:52:18 UTC (rev 693) @@ -62,6 +62,7 @@ static { riskyMethodNameContents.add("next"); riskyMethodNameContents.add("add"); + riskyMethodNameContents.add("create"); riskyMethodNameContents.add("append"); riskyMethodNameContents.add("put"); riskyMethodNameContents.add("remove"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-11-19 05:42:57
|
Revision: 692 http://svn.sourceforge.net/fb-contrib/?rev=692&view=rev Author: dbrosius Date: 2006-11-18 21:42:56 -0800 (Sat, 18 Nov 2006) Log Message: ----------- try to make SPP for StringBuffer(int) with char less prone to false +, and reenable Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-11-19 05:18:32 UTC (rev 691) +++ trunk/fb-contrib/etc/messages.xml 2006-11-19 05:42:56 UTC (rev 692) @@ -1539,12 +1539,12 @@ </BugPattern> <BugPattern type="SPP_NO_CHAR_SB_CTOR"> - <ShortDescription>Method passes character to StringBuffer or StringBuilder integer constructor</ShortDescription> - <LongDescription>Method {1} passes character to StringBuffer or StringBuilder integer constructor</LongDescription> + <ShortDescription>Method appears to pass character to StringBuffer or StringBuilder integer constructor</ShortDescription> + <LongDescription>Method {1} appears to pass character to StringBuffer or StringBuilder integer constructor</LongDescription> <Details> <![CDATA[ <p>This method constructs a StringBuffer or a StringBuilder using the constructor that takes an integer, but - passes a character instead. It is probable that the author assumed that character would be appended to the + appears to pass a character instead. It is probable that the author assumed that character would be appended to the StringBuffer/Builder, but instead the integer value of the character is used as an initial size for the buffer. </p> ]]> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-19 05:18:32 UTC (rev 691) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2006-11-19 05:42:56 UTC (rev 692) @@ -131,10 +131,23 @@ String signature = getSigConstantOperand(); if ("(I)V".equals(signature)) { if (lastOpcode == BIPUSH) { - //bugReporter.reportBug(new BugInstance(this, "SPP_NO_CHAR_SB_CTOR", NORMAL_PRIORITY) - // .addClass(this) - // .addMethod(this) - // .addSourceLine(this)); + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + Object o = item.getConstant(); + if (o instanceof Integer) { + int parm = ((Integer) o).intValue(); + if ((parm > 32) + && (parm < 127) + && (parm != 64) + && ((parm % 10) != 0) + && ((parm % 5) != 0)) { + bugReporter.reportBug(new BugInstance(this, "SPP_NO_CHAR_SB_CTOR", LOW_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |