fb-contrib-commit Mailing List for fb-contrib (Page 4)
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...> - 2014-02-17 21:23:02
|
Revision: 1765 http://sourceforge.net/p/fb-contrib/code/1765 Author: dbrosius Date: 2014-02-17 21:22:53 +0000 (Mon, 17 Feb 2014) Log Message: ----------- merge from git, prepare for 5.0.3 release Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/ABC_Sample.java trunk/fb-contrib/samples/ACEM_Sample.java trunk/fb-contrib/samples/AFBR_Sample.java trunk/fb-contrib/samples/AIOB_Sample.java trunk/fb-contrib/samples/AOM_Sample.java trunk/fb-contrib/samples/AWCBR_Sample.java trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/samples/BED_Sample.java trunk/fb-contrib/samples/BSB_Sample.java trunk/fb-contrib/samples/CAAL_Sample.java trunk/fb-contrib/samples/CAO_Sample.java trunk/fb-contrib/samples/CBX_Sample.java trunk/fb-contrib/samples/CCNE_Sample.java trunk/fb-contrib/samples/CEBE_EqualsToEqualsSample.java trunk/fb-contrib/samples/CE_Sample.java trunk/fb-contrib/samples/CFS_Sample.java trunk/fb-contrib/samples/CHBH_HashcodeToHashcodeSample.java trunk/fb-contrib/samples/CLI_Sample.java trunk/fb-contrib/samples/CNC_Sample.java trunk/fb-contrib/samples/COM_Sample.java trunk/fb-contrib/samples/CSBTS_StringToStringSample.java trunk/fb-contrib/samples/CU_Sample.java trunk/fb-contrib/samples/CVAA_Sample.java trunk/fb-contrib/samples/DDC_Sample.java trunk/fb-contrib/samples/DLC_Sample.java trunk/fb-contrib/samples/DRE_Sample.java trunk/fb-contrib/samples/DSOC_Sample.java trunk/fb-contrib/samples/DTEP_Sample.java trunk/fb-contrib/samples/DWI_Sample.java trunk/fb-contrib/samples/EXS_Sample.java trunk/fb-contrib/samples/FCBL_Sample.java trunk/fb-contrib/samples/FPL_Sample.java trunk/fb-contrib/samples/FP_Sample.java trunk/fb-contrib/samples/ICA_Sample.java trunk/fb-contrib/samples/IICU_Sample.java trunk/fb-contrib/samples/IKNC_Sample.java trunk/fb-contrib/samples/IPU_Sample.java trunk/fb-contrib/samples/ISB_Sample.java trunk/fb-contrib/samples/ITC_Sample.java trunk/fb-contrib/samples/ITU_Sample.java trunk/fb-contrib/samples/JAO_Sample.java trunk/fb-contrib/samples/JVR_Sample.java trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/samples/LGO_Sample.java trunk/fb-contrib/samples/LII_Sample.java trunk/fb-contrib/samples/LO_Sample.java trunk/fb-contrib/samples/LSC_Sample.java trunk/fb-contrib/samples/LSYC_Sample.java trunk/fb-contrib/samples/MAC_Sample.java trunk/fb-contrib/samples/MDM_Sample.java trunk/fb-contrib/samples/MOM_Sample.java trunk/fb-contrib/samples/MRC_Sample.java trunk/fb-contrib/samples/MTA_Sample.java trunk/fb-contrib/samples/NAB_Sample.java trunk/fb-contrib/samples/NCMU_Sample.java trunk/fb-contrib/samples/NCS_Sample.java trunk/fb-contrib/samples/NFF_Sample.java trunk/fb-contrib/samples/NIR_Sample.java trunk/fb-contrib/samples/NMCS_Sample.java trunk/fb-contrib/samples/NOS_Sample.java trunk/fb-contrib/samples/NPMC_Sample.java trunk/fb-contrib/samples/NRTL_Sample.java trunk/fb-contrib/samples/NSE_Sample.java trunk/fb-contrib/samples/OCP_Sample.java trunk/fb-contrib/samples/OC_Sample.java trunk/fb-contrib/samples/ODN_Sample.java trunk/fb-contrib/samples/PCAIL_Sample.java trunk/fb-contrib/samples/PCOA_Sample.java trunk/fb-contrib/samples/PDP_Sample.java trunk/fb-contrib/samples/PIS_Sample.java trunk/fb-contrib/samples/PL_Sample.java trunk/fb-contrib/samples/PMB_Sample.java trunk/fb-contrib/samples/PME_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/samples/PSC_Sample.java trunk/fb-contrib/samples/PUS_Sample.java trunk/fb-contrib/samples/ROOM_Sample.java trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/samples/SACM_Sample.java trunk/fb-contrib/samples/SCA_Sample.java trunk/fb-contrib/samples/SCII_Sample.java trunk/fb-contrib/samples/SCI_Sample.java trunk/fb-contrib/samples/SCRV_Sample.java trunk/fb-contrib/samples/SCR_Sample.java trunk/fb-contrib/samples/SCSS_Sample.java trunk/fb-contrib/samples/SC_Sample.java trunk/fb-contrib/samples/SEC_Sample.java trunk/fb-contrib/samples/SGSU_Sample.java trunk/fb-contrib/samples/SG_Sample.java trunk/fb-contrib/samples/SIL_Sample.java trunk/fb-contrib/samples/SJVU_Sample.java trunk/fb-contrib/samples/SMA_Sample.java trunk/fb-contrib/samples/SMII_Sample.java trunk/fb-contrib/samples/SNG_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/STB_Sample.java trunk/fb-contrib/samples/STS_Sample.java trunk/fb-contrib/samples/SUA_Sample.java trunk/fb-contrib/samples/SWCO_Sample.java trunk/fb-contrib/samples/TBP_Sample.java trunk/fb-contrib/samples/TR_Sample.java trunk/fb-contrib/samples/UAA_Sample.java trunk/fb-contrib/samples/UCC_Sample.java trunk/fb-contrib/samples/UCPM_Sample.java trunk/fb-contrib/samples/UEC_Sample.java trunk/fb-contrib/samples/UMTP_Sample.java trunk/fb-contrib/samples/UNNC_Sample.java trunk/fb-contrib/samples/URV_Sample.java trunk/fb-contrib/samples/USBR_Sample.java trunk/fb-contrib/samples/USS_Sample.java trunk/fb-contrib/samples/UTA_Sample.java trunk/fb-contrib/samples/UVA_Sample.java trunk/fb-contrib/samples/WEM_Sample.java trunk/fb-contrib/samples/WOC_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java Added Paths: ----------- trunk/fb-contrib/samples/UP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java Removed Paths: ------------- trunk/fb-contrib/META-INF/ Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/.classpath 2014-02-17 21:22:53 UTC (rev 1765) @@ -5,18 +5,18 @@ <classpathentry excluding="lib/" kind="src" path="samples"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> - <classpathentry kind="lib" path="lib/annotations-2.0.2.jar"/> <classpathentry kind="lib" path="lib/asm-tree-3.3.1.jar"/> <classpathentry kind="lib" path="lib/backport-util-concurrent-3.1.jar"/> <classpathentry kind="lib" path="lib/bcel-2.0.2.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/> - <classpathentry kind="lib" path="lib/commons-lang3-3.1.jar"/> <classpathentry kind="lib" path="lib/javax.servlet-api-3.1.0.jar"/> - <classpathentry kind="lib" path="lib/javax.servlet.jsp-api-2.2.1.jar"/> <classpathentry kind="lib" path="lib/junit-4.11.jar"/> <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/> <classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/> <classpathentry kind="lib" path="lib/findbugs-2.0.3.jar"/> <classpathentry kind="lib" path="lib/guava-15.0.jar"/> + <classpathentry kind="lib" path="lib/annotations-2.0.3.jar"/> + <classpathentry kind="lib" path="lib/commons-lang3-3.2.jar"/> + <classpathentry kind="lib" path="lib/javax.servlet.jsp-api-2.3.1.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/build.xml 2014-02-17 21:22:53 UTC (rev 1765) @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="5.0.2" /> + <property name="fb-contrib.version" value="5.0.3" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -49,7 +49,7 @@ <echo message=""/> <echo message=" this project uses yank (https://github.com/mebigfatguy/yank) for dependency management"/> <echo message=" download yank.jar and place in ant/lib directory"/> - <echo message=" http://search.maven.org/#artifactdetails%7Ccom.mebigfatguy.yank%7Cyank%7C0.4.2%7Cjar"/> + <echo message=" http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.mebigfatguy.yank%22"/> <antcall target="install"/> </target> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/etc/findbugs.xml 2014-02-17 21:22:53 UTC (rev 1765) @@ -31,7 +31,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -106,7 +106,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.JDBCVendorReliance" speed="fast" reports="JVR_JDBC_VENDOR_RELIANCE" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat" speed="fast" reports="PMB_POSSIBLE_MEMORY_BLOAT" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat" speed="fast" reports="PMB_POSSIBLE_MEMORY_BLOAT,PMB_INSTANCE_BASED_THREAD_LOCAL" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LocalSynchronizedCollection" speed="moderate" reports="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" /> @@ -146,7 +146,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING" /> + 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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -248,7 +248,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument" speed="fast" reports="ICA_INVALID_CONSTANT_ARRAY" /> - <!-- COMMENT OUT FOR POINT RELEASE + <!-- COMMENT OUT FOR POINT RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> @@ -257,8 +257,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PoorMansEnum" speed="fast" reports="PME_POOR_MANS_ENUM" /> - COMMENT OUT FOR POINT RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnusedParameter" speed="fast" reports="UP_UNUSED_PARAMETER" /> + COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -308,6 +310,7 @@ <BugPattern abbrev="SWCO" type="SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT" category="CORRECTNESS" /> <BugPattern abbrev="JVR" type="JVR_JDBC_VENDOR_RELIANCE" category="CORRECTNESS" /> <BugPattern abbrev="PMB" type="PMB_POSSIBLE_MEMORY_BLOAT" category="CORRECTNESS" /> + <BugPattern abbrev="PMB" type="PMB_INSTANCE_BASED_THREAD_LOCAL" category="CORRECTNESS" /> <BugPattern abbrev="LSYC" type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" category="CORRECTNESS" /> <BugPattern abbrev="FCBL" type="FCBL_FIELD_COULD_BE_LOCAL" category="CORRECTNESS" /> <BugPattern abbrev="NRTL" type="NRTL_NON_RECYCLEABLE_TAG_LIB" category="CORRECTNESS"/> @@ -362,6 +365,7 @@ <BugPattern abbrev="SPP" type="SPP_DOUBLE_APPENDED_LITERALS" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_NULL_BEFORE_INSTANCEOF" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_NON_USEFUL_TOSTRING" category="STYLE" /> + <BugPattern abbrev="SPP" type="SPP_TOSTRING_ON_STRING" category="CORRECTNESS" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> @@ -455,4 +459,5 @@ <BugPattern abbrev="ICA" type="ICA_INVALID_CONSTANT_ARGUMENT" category="CORRECTNESS" /> <BugPattern abbrev="CNC" type="CNC_COLLECTION_NAMING_CONFUSION" category="STYLE" /> <BugPattern abbrev="PME" type="PME_POOR_MANS_ENUM" category="STYLE" /> + <BugPattern abbrev="UP" type="UP_UNUSED_PARAMETER" category="STYLE" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/etc/messages.xml 2014-02-17 21:22:53 UTC (rev 1765) @@ -1352,7 +1352,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.CollectionNamingConfusion"> <Details> <![CDATA[ - <p>Looks for fields or local variables that are collections but which names have a different type + <p>Looks for fields or local variables that are collections but the names have a different type of collection in the name. This is confusing, and is probably a left over from a type change, such as </p> <p>List<String> mySet;</p> @@ -1371,6 +1371,16 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.UnusedParameter"> + <Details> + <![CDATA[ + <p>Looks for private or static methods that have parameters that aren't used. These parameters + can be removed.</p> + <p>It is fast detector</p> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> @@ -1409,7 +1419,7 @@ <Details> <![CDATA[ <p>This method concatenates the output of a toString() call into a StringBuffer/Builder. - It is simpler just pass the object you want to append to the to append call, as that form + It is simpler just to pass the object you want to append to the append call, as that form does not suffer the potential for NullPointerExceptions, and is easier to read.</p> ]]> </Details> @@ -2004,6 +2014,21 @@ ]]> </Details> </BugPattern> + + <BugPattern type="PMB_INSTANCE_BASED_THREAD_LOCAL"> + <ShortDescription>Field is an instance based ThreadLocal variable</ShortDescription> + <LongDescription>Field {1} is an instance based ThreadLocal variable</LongDescription> + <Details> + <![CDATA[ + <p>This ThreadLocal field is defined as being instance based (not static). As all + ThreadLocal variables describe permanent reachability roots so far as the garbage + collector is concerned, these variables will never be reclaimed (so long as the Thread lives). + Since this ThreadLocal is instanced, you potentially will be creating many non reclaimable + variables, even after the owning instance has been reclaimed. It is almost a certainty that + you want to use static based ThreadLocal variables.</p> + ]]> + </Details> + </BugPattern> <BugPattern type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION"> <ShortDescription>Method creates local variable-based synchronized collection</ShortDescription> @@ -2685,6 +2710,16 @@ ]]> </Details> </BugPattern> + + <BugPattern type="SPP_TOSTRING_ON_STRING"> + <ShortDescription>Method calls toString() on a String</ShortDescription> + <LongDescription>Method {1} calls toString() on a String</LongDescription> + <Details> + <![CDATA[ + <p>This methods calls toString on a String. Just use the object itself if you want a String.</p> + ]]> + </Details> + </BugPattern> <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> @@ -3813,7 +3848,7 @@ <Details> <![CDATA[ <p>This class defines a field or local collection variable with a name that contains a different type - of collection in it's name. This is confusing to the reader, and likely caused by a previous refactor of + of collection in its name. This is confusing to the reader, and likely caused by a previous refactor of type, without changing the name.</p> ]]> </Details> @@ -3825,11 +3860,24 @@ <Details> <![CDATA[ <p>This field, although defined as a simple variable (int, String, etc) only has a set of constant values - assigned to it. This appears to be used like an enum value, and should probably be defined as such. + assigned to it. Thus it appears to be used like an enum value, and should probably be defined as such. </p> ]]> </Details> </BugPattern> + + <BugPattern type="UP_UNUSED_PARAMETER"> + <ShortDescription>Static or private method has unused parameters</ShortDescription> + <LongDescription>Static or private method {1} has unused parameters</LongDescription> + <Details> + <![CDATA[ + <p>This method defines parameters that are never used. As this method is either static of private, + and can't be derived from, it is safe to remove these parameters and simplify your method. + You should consider, while unlikely, that this method may be used reflectively, and thus you will + want to change that call as well. + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -3947,4 +3995,5 @@ <BugCode abbrev="ICA">Invalid Constant Argument</BugCode> <BugCode abbrev="CNC">Collection Naming Confusion</BugCode> <BugCode abbrev="PME">Poor Mans Enum</BugCode> + <BugCode abbrev="UP">Unused Parameter</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/htdocs/index.shtml 2014-02-17 21:22:53 UTC (rev 1765) @@ -68,14 +68,14 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 5.0.2 available for download - <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.0.2.jar/download">here</a>.</p> + <p style="font-weight: bold;">The latest version of fb-contrib is 5.0.3 available for download + <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.0.3.jar/download">here</a>.</p> </div> <hr/> - <img id="git_image" src="flip1.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> + <img id="git_image" src="flip2.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> Detectors added in git<br/> - <div id="git" style="display:none;"> + <div id="git" style="display:block;"> <ul> <li><b>[STB] Stacked Try Blocks</b><br/> Looks for two or more try catch blocks that are consecutive and catch the @@ -106,12 +106,16 @@ Looks for simple fields that only store one of several constant values. This usually is an indication that this field should really be an enum type. </li> + <li><b>[UP] Unused Parameter</b><br/> + Looks for private or static methods that have parameters that aren't used. These parameters + can be removed. + </li> </ul> </div> <hr/> - <img id="v5_0_0_image" src="flip2.gif" onClick="toggleBlock('v5_0_0', 'v5_0_0_image');" align="top"/> + <img id="v5_0_0_image" src="flip1.gif" onClick="toggleBlock('v5_0_0', 'v5_0_0_image');" align="top"/> Detectors added in v5.0.0<br/> - <div id="v5_0_0" style="display:block;"> + <div id="v5_0_0" style="display:none;"> <li><b>[CVAA] ContraVariant Array Assignment</b><br/> Looks for contravariant array assignments. Since arrays are mutable data structures, their use must be restricted to covariant or invariant usage.<br/> Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/htdocs/repository.html 2014-02-17 21:22:53 UTC (rev 1765) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>5.0.2</td></tr> + <tr><td><b>Version:</b></td><td>5.0.3</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/pom.xml 2014-02-17 21:22:53 UTC (rev 1765) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>5.0.2</version> + <version>5.0.3</version> <parent> <groupId>org.sonatype.oss</groupId> Modified: trunk/fb-contrib/samples/ABC_Sample.java =================================================================== --- trunk/fb-contrib/samples/ABC_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/ABC_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -6,46 +6,36 @@ import java.util.Set; import java.util.TreeMap; +public class ABC_Sample { + public Map<String[], String> testMaps(String[] key, String value) { + Map<String[], String> m = new HashMap<String[], String>(); + m.put(key, value); + return m; + } + public Set<String[]> testSets(String[] values) { + Set<String[]> s = new HashSet<String[]>(); + s.add(values); + return s; + } -public class ABC_Sample -{ - public Map<String[], String> testMaps(String[] key, String value) - { - Map<String[], String> m = new HashMap<String[], String>(); - m.put(key, value); - return m; - } - - public Set<String[]> testSets(String[] values) - { - Set<String[]> s = new HashSet<String[]>(); - s.add(values); - return s; - } - - public boolean testLists(List<String[]> l, String[] value) - { - return l.contains(value); - } - - public static class UseComparator - { - private Map<byte[], byte[]> testComp; - - public UseComparator() - { - testComp = new TreeMap<byte[], byte[]>( new Comparator<byte[]>() - { - public int compare(byte[] b1, byte[] b2) - { - return b1.length - b2.length; - } - }); - } - - public void testc() { - testComp.put(new byte[5], new byte[3]); - } - } + public boolean testLists(List<String[]> l, String[] value) { + return l.contains(value); + } + + public static class UseComparator { + private Map<byte[], byte[]> testComp; + + public UseComparator() { + testComp = new TreeMap<byte[], byte[]>(new Comparator<byte[]>() { + public int compare(byte[] b1, byte[] b2) { + return b1.length - b2.length; + } + }); + } + + public void testc() { + testComp.put(new byte[5], new byte[3]); + } + } } Modified: trunk/fb-contrib/samples/ACEM_Sample.java =================================================================== --- trunk/fb-contrib/samples/ACEM_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/ACEM_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,13 +1,9 @@ +public abstract class ACEM_Sample { + public void test() { + } -public abstract class ACEM_Sample -{ - public void test() - { - } - - public int test1() - { - throw new UnsupportedOperationException("Not implemented"); - } + public int test1() { + throw new UnsupportedOperationException("Not implemented"); + } } \ No newline at end of file Modified: trunk/fb-contrib/samples/AFBR_Sample.java =================================================================== --- trunk/fb-contrib/samples/AFBR_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/AFBR_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -3,80 +3,55 @@ import java.io.InputStream; @SuppressWarnings("all") -public class AFBR_Sample -{ - public int test1(boolean b) - { - try - { - int i = 0; - } - finally - { - if (b) - return 0; - int j = 0; - } - return 2; - } - - public int test2() - { - try - { - return 0; - } - finally - { - throw new NullPointerException(); - } - } - - public int test3() throws Exception - { - try - { - return 0; - } - finally - { - throw new Exception(); - } - } - - public int test4() - { - try - { - throw new Exception(); - } - catch (Exception e) - { - return 1; - } - finally - { - return 0; - } - } - - public int test5() throws IOException - { - InputStream is = null; - try - { - is = new FileInputStream("test"); - return 1; - } - catch (IOException ioe) - { - System.out.println("error"); - } - finally - { - if (is != null) - is.close(); - } - return 0; - } +public class AFBR_Sample { + public int test1(boolean b) { + try { + int i = 0; + } finally { + if (b) + return 0; + int j = 0; + } + return 2; + } + + public int test2() { + try { + return 0; + } finally { + throw new NullPointerException(); + } + } + + public int test3() throws Exception { + try { + return 0; + } finally { + throw new Exception(); + } + } + + public int test4() { + try { + throw new Exception(); + } catch (Exception e) { + return 1; + } finally { + return 0; + } + } + + public int test5() throws IOException { + InputStream is = null; + try { + is = new FileInputStream("test"); + return 1; + } catch (IOException ioe) { + System.out.println("error"); + } finally { + if (is != null) + is.close(); + } + return 0; + } } \ No newline at end of file Modified: trunk/fb-contrib/samples/AIOB_Sample.java =================================================================== --- trunk/fb-contrib/samples/AIOB_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/AIOB_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,62 +1,58 @@ import java.util.List; - -public class AIOB_Sample -{ +public class AIOB_Sample { int[] fa = new int[4]; int[] fb; - - public void testOutOfBounds() - { + + public void testOutOfBounds() { int[] a = new int[4]; - + a[4] = 2; fa[4] = 2; } - - public void testUnallocated() - { + + public void testUnallocated() { int[] b = null; - + b[4] = 4; fb[4] = 4; } - + public int[] fpPlusPlusNotRecognized(List<String> l) { int size = 0; - + for (String s : l) { size++; } - + int[] data = new int[size]; - + data[0] = 0; return data; } - + public void fpPostAllocate() { double[] da = null; - + for (int i = 0; i < 10; i++) { if ((i & 1) == 1) { da[0] = 0.0; } - + if (da == null) da = new double[10]; } } - + public void fpPlusEquals(List<String> ss) { int size = 0; - + for (String s : ss) { size += s.length(); } - + int[] a = new int[size]; - + a[0] = 1; } } Modified: trunk/fb-contrib/samples/AOM_Sample.java =================================================================== --- trunk/fb-contrib/samples/AOM_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/AOM_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,19 +1,17 @@ +class AOM_Super { + public void test1() { + test2(); + System.out.println("test"); + } -class AOM_Super -{ - public void test1() { - test2(); - System.out.println("test"); - } - - private void test2() { - System.out.println("test"); - } + private void test2() { + System.out.println("test"); + } } -public abstract class AOM_Sample extends AOM_Super -{ - @Override - public abstract void test1(); - public abstract void test2(); +public abstract class AOM_Sample extends AOM_Super { + @Override + public abstract void test1(); + + public abstract void test2(); } Modified: trunk/fb-contrib/samples/AWCBR_Sample.java =================================================================== --- trunk/fb-contrib/samples/AWCBR_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/AWCBR_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,33 +1,27 @@ +public class AWCBR_Sample { + public void m(int[] v) { + v[0]++; + } -public class AWCBR_Sample -{ - public void m(int[] v) - { - v[0]++; - } - - public int testuninitedalloc(int i) - { - int[] data = new int[1]; - data[0] = i; - m(data); - i = data[0]; - return i; - } - - public int testinitedalloc(int i) - { - int[] data = new int[] { i }; - m(data); - i = data[0]; - return i; - } - - public int testNoCall(int i) - { - //while silly don't report this, as there is no arg usage - int[] data = new int[] { i }; - i = data[0]; - return i; - } + public int testuninitedalloc(int i) { + int[] data = new int[1]; + data[0] = i; + m(data); + i = data[0]; + return i; + } + + public int testinitedalloc(int i) { + int[] data = new int[] { i }; + m(data); + i = data[0]; + return i; + } + + public int testNoCall(int i) { + // while silly don't report this, as there is no arg usage + int[] data = new int[] { i }; + i = data[0]; + return i; + } } Modified: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/BAS_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -8,177 +8,165 @@ import java.util.Set; @SuppressWarnings("all") -public class BAS_Sample -{ - private final Map<String, String> m = new HashMap<String, String>(); +public class BAS_Sample { + private final Map<String, String> m = new HashMap<String, String>(); - public void testIfScope(String s) - { - Object o = new Object(); - if (s.equals("Foo")) - { - s = o.toString(); - } - } + 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; - } + public String testFPForScope(String s) { + Object o = new Object(); + while (s.length() > 0) { + o = s.substring(0, 1); + s = s.substring(1); + } + return s; + } - public String testFP2Scopes(String s) - { - Object o = new Object(); - if (s.equals("Boo")) - { + public String testFP2Scopes(String s) { + Object o = new Object(); + if (s.equals("Boo")) { s = o.toString(); - } - else if (s.equals("Hoo")) - { + } else if (s.equals("Hoo")) { s = o.toString(); } - return s; - } + return s; + } - public String test2InnerScopes(String s) - { - Object o = new Object(); - if (s != null) - { - if (s.equals("Boo")) - { + public String test2InnerScopes(String s) { + Object o = new Object(); + if (s != null) { + if (s.equals("Boo")) { s = o.toString(); - } - else if (s.equals("Hoo")) - { + } else if (s.equals("Hoo")) { s = o.toString(); } - } + } - return s; - } + return s; + } - public String testFPLoopCond(List<String> in) - { - StringBuilder sb = new StringBuilder(); - for (String s : in) - { - sb.append(s); - } - return sb.toString(); - } + public String testFPLoopCond(List<String> in) { + StringBuilder sb = new StringBuilder(); + for (String s : in) { + sb.append(s); + } + return sb.toString(); + } - public List<String> getList() - { - return null; - } + public List<String> getList() { + return null; + } - public String testSwitch(int a) - { - String v = "Test"; + public String testSwitch(int a) { + String v = "Test"; - switch (a) - { - case 1: - v = "Testa"; - break; + switch (a) { + case 1: + v = "Testa"; + break; - case 2: - v = "Tesseract"; - break; + case 2: + v = "Tesseract"; + break; - case 3: - v = "Testy"; - break; + case 3: + v = "Testy"; + break; - default: - v = "Rossa"; - break; - } + default: + v = "Rossa"; + break; + } - return null; - } + return null; + } - public void testFPSync(Set<String> a, Set<String> b) - { - String c, d; + public void testFPSync(Set<String> a, Set<String> b) { + String c, d; - synchronized(this) - { - c = a.iterator().next(); - d = b.iterator().next(); - } + synchronized (this) { + c = a.iterator().next(); + d = b.iterator().next(); + } - if (d.length() > 0) - { - d = c; - } - } + if (d.length() > 0) { + d = c; + } + } - public int testFPObjChange(Calendar c, boolean b) - { - int hour = c.get(Calendar.HOUR_OF_DAY); - c.set(2000, Calendar.JANUARY, 1); + public int testFPObjChange(Calendar c, boolean b) { + int hour = c.get(Calendar.HOUR_OF_DAY); + c.set(2000, Calendar.JANUARY, 1); - if (b) - { - return hour; - } + if (b) { + return hour; + } - return 0; - } + return 0; + } - public void testFPSrcOverwrite(int src, boolean b) - { - int d = src; - src = 0; + public void tstFPRefChange(Holder h1, Holder h2, boolean b) { - if (b) - { - System.out.println(d); - } - } + int h = h1.member; + h1 = h2; - public void testFPRiskies1(boolean b) { - long start = System.currentTimeMillis(); + if (b) { + System.out.println(h); + } + } - if (b) { - long delta = System.currentTimeMillis() - start; - System.out.println(delta); - } - } + public void testFPSrcOverwrite(int src, boolean b) { + int d = src; + src = 0; - public String testFPIteratorNext(Collection<String> c, boolean b) { - Iterator<String> it = c.iterator(); + if (b) { + System.out.println(d); + } + } - String s = it.next(); + public void testFPRiskies1(boolean b) { + long start = System.currentTimeMillis(); - if (b) { - if (s == null) { - return "yay"; - } - } + if (b) { + long delta = System.currentTimeMillis() - start; + System.out.println(delta); + } + } - return it.next(); - } - - public List<String> testFPSynchronized(String s, String p) { - List<String> l = new ArrayList<String>(); - String x = s; - synchronized(s) { - if (p != null) { - l.add(p); - return l; - } - } - - return null; - } + public String testFPIteratorNext(Collection<String> c, boolean b) { + Iterator<String> it = c.iterator(); + + String s = it.next(); + + if (b) { + if (s == null) { + return "yay"; + } + } + + return it.next(); + } + + public List<String> testFPSynchronized(String s, String p) { + List<String> l = new ArrayList<String>(); + String x = s; + synchronized (s) { + if (p != null) { + l.add(p); + return l; + } + } + + return null; + } + + static class Holder { + int member; + } } Modified: trunk/fb-contrib/samples/BED_Sample.java =================================================================== --- trunk/fb-contrib/samples/BED_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/BED_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -10,62 +10,49 @@ import javax.naming.directory.DirContext; import javax.naming.directory.InitialDirContext; - @SuppressWarnings("all") -public class BED_Sample -{ - IOException ioe; +public class BED_Sample { + IOException ioe; - public BED_Sample() throws IOException - { + public BED_Sample() throws IOException { - } + } - public BED_Sample(String name) throws NamingException - { - Hashtable<String, String> env = new Hashtable<String, String>(); - env.put("name", name); - DirContext context = new InitialDirContext(env); - } + public BED_Sample(String name) throws NamingException { + Hashtable<String, String> env = new Hashtable<String, String>(); + env.put("name", name); + DirContext context = new InitialDirContext(env); + } - private void badThrow() throws SQLException - { + private void badThrow() throws SQLException { - } + } - public static void badStatic() throws DataFormatException - { + public static void badStatic() throws DataFormatException { - } - - public final void badFinal() throws ClassNotFoundException - { - - } + } - public static void doIt() throws SQLException, IOException - { - InputStream is = new FileInputStream("c:\\temp.txt"); - } + public final void badFinal() throws ClassNotFoundException { - public static void fp() throws Exception - { - InputStream is = new FileInputStream("c:\\temp.txt"); - } + } - private void fpThrowField(boolean b) throws IOException - { - if (b) - { - throw ioe; - } - else - { - IOException e = ioe; - throw ioe; - } - } + public static void doIt() throws SQLException, IOException { + InputStream is = new FileInputStream("c:\\temp.txt"); + } + public static void fp() throws Exception { + InputStream is = new FileInputStream("c:\\temp.txt"); + } + + private void fpThrowField(boolean b) throws IOException { + if (b) { + throw ioe; + } else { + IOException e = ioe; + throw ioe; + } + } + public Object iAmCreatingAnObject() { return new Object() { private byte[] iHaveToThrowAnException() throws IOException { Modified: trunk/fb-contrib/samples/BSB_Sample.java =================================================================== --- trunk/fb-contrib/samples/BSB_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/BSB_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -6,67 +6,56 @@ import java.util.Set; @SuppressWarnings("all") -public class BSB_Sample -{ - private Object lock = new Object(); - private Set<String> info = new HashSet<String>(); - private Map<String, Object> synchMap = Collections.synchronizedMap(new HashMap<String, Object>()); +public class BSB_Sample { + private Object lock = new Object(); + private Set<String> info = new HashSet<String>(); + private Map<String, Object> synchMap = Collections.synchronizedMap(new HashMap<String, Object>()); - public void testFieldBeginBloated(int i, int j) - { - synchronized(lock) - { - StringBuffer sb = new StringBuffer(); - sb.append("Test"); - sb.append(i); - info.add(sb.toString()); - } - } - - public void testLocalBeginBloated(int j) - { - Set<String> i = getInfo(); - synchronized(i) - { - StringBuffer sb = new StringBuffer(); - sb.append("Test"); - sb.append(j); - i.add(sb.toString()); - } - } - - public void testAliasedLocalBeginBloated(int j) - { - Set<String> i = getInfo(); - synchronized(info) - { - StringBuffer sb = new StringBuffer(); - sb.append("Test"); - sb.append(j); - i.add(sb.toString()); - } - } - - public void testBranchCutDown(int j) - { - Set<String> i = getInfo(); - synchronized(i) - { - StringBuffer sb = new StringBuffer(); - if (sb.length() > 0) - { - sb.append("Test"); - sb.append(j); - i.add(sb.toString()); - } - } - } - - public Set<String> getInfo() - { - return info; - } - + public void testFieldBeginBloated(int i, int j) { + synchronized (lock) { + StringBuffer sb = new StringBuffer(); + sb.append("Test"); + sb.append(i); + info.add(sb.toString()); + } + } + + public void testLocalBeginBloated(int j) { + Set<String> i = getInfo(); + synchronized (i) { + StringBuffer sb = new StringBuffer(); + sb.append("Test"); + sb.append(j); + i.add(sb.toString()); + } + } + + public void testAliasedLocalBeginBloated(int j) { + Set<String> i = getInfo(); + synchronized (info) { + StringBuffer sb = new StringBuffer(); + sb.append("Test"); + sb.append(j); + i.add(sb.toString()); + } + } + + public void testBranchCutDown(int j) { + Set<String> i = getInfo(); + synchronized (i) { + StringBuffer sb = new StringBuffer(); + if (sb.length() > 0) { + sb.append("Test"); + sb.append(j); + i.add(sb.toString()); + } + } + } + + public Set<String> getInfo() { + return info; + } + public void accessSyncMap() { Set keySet = synchMap.keySet(); synchronized (synchMap) { Modified: trunk/fb-contrib/samples/CAAL_Sample.java =================================================================== --- trunk/fb-contrib/samples/CAAL_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CAAL_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,7 +1,6 @@ import java.util.Arrays; import java.util.List; - public class CAAL_Sample { public void testCAAL(int[] v) { Modified: trunk/fb-contrib/samples/CAO_Sample.java =================================================================== --- trunk/fb-contrib/samples/CAO_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CAO_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,52 +1,42 @@ +public class CAO_Sample { + public void testci(Character c) { + System.out.println("Character"); + } -public class CAO_Sample -{ - public void testci(Character c) - { - System.out.println("Character"); - } - - public void testci(int i) - { - System.out.println("int"); - } - - public void testcj(Character c) - { - System.out.println("Character"); - } - - public void testcj(long l) - { - System.out.println("long"); - } + public void testci(int i) { + System.out.println("int"); + } - public void testcd(Character c) - { - System.out.println("Character"); - } - - public void testcd(double d) - { - System.out.println("double"); - } + public void testcj(Character c) { + System.out.println("Character"); + } - public void testcf(Character c) - { - System.out.println("Character"); - } - - public void testcf(float f) - { - System.out.println("float"); - } - public static void main(String[] args) - { - CAO_Sample s = new CAO_Sample(); - s.testci('a'); - s.testcj('a'); - s.testcd('a'); - s.testcf('a'); - } + public void testcj(long l) { + System.out.println("long"); + } + + public void testcd(Character c) { + System.out.println("Character"); + } + + public void testcd(double d) { + System.out.println("double"); + } + + public void testcf(Character c) { + System.out.println("Character"); + } + + public void testcf(float f) { + System.out.println("float"); + } + + public static void main(String[] args) { + CAO_Sample s = new CAO_Sample(); + s.testci('a'); + s.testcj('a'); + s.testcd('a'); + s.testcf('a'); + } } \ No newline at end of file Modified: trunk/fb-contrib/samples/CBX_Sample.java =================================================================== --- trunk/fb-contrib/samples/CBX_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CBX_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,12 +1,9 @@ - -public class CBX_Sample -{ - public String testBuildXML(int val, String info) - { - StringBuffer sb = new StringBuffer(); - sb.append("<sample>"); - sb.append("<test name='" + val + "'>" + info + "</test>"); - sb.append("</sample>"); - return sb.toString(); - } +public class CBX_Sample { + public String testBuildXML(int val, String info) { + StringBuffer sb = new StringBuffer(); + sb.append("<sample>"); + sb.append("<test name='" + val + "'>" + info + "</test>"); + sb.append("</sample>"); + return sb.toString(); + } } Modified: trunk/fb-contrib/samples/CCNE_Sample.java =================================================================== --- trunk/fb-contrib/samples/CCNE_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CCNE_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -2,8 +2,7 @@ public void compareClassEquals() { Object o = new CCNE_Sample(); Object p = new CCNE_Sample(); - System.out.println(o.getClass().getName() - .equals(p.getClass().getName())); + System.out.println(o.getClass().getName().equals(p.getClass().getName())); } public void fpCompareAgainstString(String name) { Modified: trunk/fb-contrib/samples/CEBE_EqualsToEqualsSample.java =================================================================== --- trunk/fb-contrib/samples/CEBE_EqualsToEqualsSample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CEBE_EqualsToEqualsSample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -2,30 +2,29 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; public class CEBE_EqualsToEqualsSample { - public final String name; - public final int age; + public final String name; + public final int age; - CEBE_EqualsToEqualsSample(String name, int age) { - this.name = name; - this.age = age; - } + CEBE_EqualsToEqualsSample(String name, int age) { + this.name = name; + this.age = age; + } - @Override - public int hashCode() { - return new HashCodeBuilder().append(name).append(age).toHashCode(); - } + @Override + public int hashCode() { + return new HashCodeBuilder().append(name).append(age).toHashCode(); + } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CEBE_EqualsToEqualsSample other = (CEBE_EqualsToEqualsSample) obj; - return new EqualsBuilder().append(this.name, other.name) - .append(this.age, other.age).equals(obj); - } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CEBE_EqualsToEqualsSample other = (CEBE_EqualsToEqualsSample) obj; + return new EqualsBuilder().append(this.name, other.name).append(this.age, other.age).equals(obj); + } } Modified: trunk/fb-contrib/samples/CE_Sample.java =================================================================== --- trunk/fb-contrib/samples/CE_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CE_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,37 +1,37 @@ +public class CE_Sample { + public void test() { + Envy e = new Envy(); + e.a(); + e.b(); + test2(); + e.c(); + e.d(); + e.e(); + e.f(); + } -public class CE_Sample -{ - public void test() - { - Envy e = new Envy(); - e.a(); - e.b(); - test2(); - e.c(); - e.d(); - e.e(); - e.f(); - } - - public void test2() - { - - } + public void test2() { + + } } -class Envy -{ - public void a() {} - - public void b() {} - - public void c() {} - - public void d() {} - - public void e() {} - - public void f() {} +class Envy { + public void a() { + } + + public void b() { + } + + public void c() { + } + + public void d() { + } + + public void e() { + } + + public void f() { + } } - Modified: trunk/fb-contrib/samples/CFS_Sample.java =================================================================== --- trunk/fb-contrib/samples/CFS_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CFS_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,19 +1,16 @@ import java.util.Date; -public class CFS_Sample -{ - @SuppressWarnings("deprecation") - public Date getNextDate(Date d) - { - d.setHours(0); - return d; - } - - @SuppressWarnings("deprecation") - public Date getNextDateFP(Date d) - { - d = (Date)d.clone(); - d.setHours(0); - return d; - } +public class CFS_Sample { + @SuppressWarnings("deprecation") + public Date getNextDate(Date d) { + d.setHours(0); + return d; + } + + @SuppressWarnings("deprecation") + public Date getNextDateFP(Date d) { + d = (Date) d.clone(); + d.setHours(0); + return d; + } } Modified: trunk/fb-contrib/samples/CHBH_HashcodeToHashcodeSample.java =================================================================== --- trunk/fb-contrib/samples/CHBH_HashcodeToHashcodeSample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CHBH_HashcodeToHashcodeSample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -2,29 +2,28 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; public class CHBH_HashcodeToHashcodeSample { - public final String name; - public final int age; + public final String name; + public final int age; - CHBH_HashcodeToHashcodeSample(String name, int age) { - this.name = name; - this.age = age; - } + CHBH_HashcodeToHashcodeSample(String name, int age) { + this.name = name; + this.age = age; + } - @Override - public int hashCode() { - return new HashCodeBuilder().append(name).append(age).hashCode(); - } + @Override + public int hashCode() { + return new HashCodeBuilder().append(name).append(age).hashCode(); + } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CHBH_HashcodeToHashcodeSample other = (CHBH_HashcodeToHashcodeSample) obj; - return new EqualsBuilder().append(this.name, other.name) - .append(this.age, other.age).isEquals(); - } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CHBH_HashcodeToHashcodeSample other = (CHBH_HashcodeToHashcodeSample) obj; + return new EqualsBuilder().append(this.name, other.name).append(this.age, other.age).isEquals(); + } } Modified: trunk/fb-contrib/samples/CLI_Sample.java =================================================================== --- trunk/fb-contrib/samples/CLI_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CLI_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,44 +1,37 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; +@SuppressWarnings("all") +public class CLI_Sample { + public String test1(String[] sa) { + String result = ""; + for (String element : sa) + result += sa[0]; + return result; + } -@SuppressWarnings("all") -public class CLI_Sample -{ - public String test1(String[] sa) - { - String result = ""; - for (String element : sa) - result += sa[0]; - return result; - } - - public String test2(String[] sa) - { - String name = sa[0]; - String address = sa[1]; - String ss = sa[2]; - return name + address + ss; - } - - public String testFPSplit(String s) { - String[] parts = s.split(","); - String a = parts[0]; - String b = parts[1]; - String c = parts[2]; - return c + b + a; - } - - class FPHander implements InvocationHandler - { - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable - { - if (args[2] == null) - { + public String test2(String[] sa) { + String name = sa[0]; + String address = sa[1]; + String ss = sa[2]; + return name + address + ss; + } + + public String testFPSplit(String s) { + String[] parts = s.split(","); + String a = parts[0]; + String b = parts[1]; + String c = parts[2]; + return c + b + a; + } + + class FPHander implements InvocationHandler { + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if (args[2] == null) { return null; } - + return String.valueOf(args[0]) + String.valueOf(args[1]); } - } + } } Modified: trunk/fb-contrib/samples/CNC_Sample.java =================================================================== --- trunk/fb-contrib/samples/CNC_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CNC_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -2,13 +2,12 @@ import java.util.Map; import java.util.Set; - public class CNC_Sample { Map<String, String> argList; Set<Integer> targetMap; List<Double> bernoulliSet; - + public void testCNC(Map<String, String> argSet, Set<String> nameList, List<String> nameMap) { - + } } Modified: trunk/fb-contrib/samples/COM_Sample.java =================================================================== --- trunk/fb-contrib/samples/COM_Sample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/COM_Sample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -1,85 +1,73 @@ import java.util.HashSet; import java.util.Set; -public class COM_Sample -{ +public class COM_Sample { - public void test1() - { - } + public void test1() { + } - public String test2(int i) - { - return String.valueOf(i); - } + public String test2(int i) { + return String.valueOf(i); + } - public Set<String> test3(String a, String b, String c) - { - Set<String> ss = new HashSet<String>(); - ss.add(a); - ss.add(b); - ss.add(c); - return ss; - } + public Set<String> test3(String a, String b, String c) { + Set<String> ss = new HashSet<String>(); + ss.add(a); + ss.add(b); + ss.add(c); + return ss; + } - public static class Derived extends COM_Sample - { - @Override - public void test1() - { - } + public static class Derived extends COM_Sample { + @Override + public void test1() { + } - @Override - public Set<String> test3(String a, String b, String c) - { - Set<String> ss = new HashSet<String>(); - ss.add(a); - ss.add(b); - ss.add(c); - return ss; - } + @Override + public Set<String> test3(String a, String b, String c) { + Set<String> ss = new HashSet<String>(); + ss.add(a); + ss.add(b); + ss.add(c); + return ss; + } - @Override - public String test2(int i) - { - return String.valueOf(i); - } - } + @Override + public String test2(int i) { + return String.valueOf(i); + } + } } -interface Inf -{ - void m1(); - void m2(); +interface Inf { + void m1(); + + void m2(); } -abstract class c1 implements Inf -{ - public void m1() {} +abstract class c1 implements Inf { + public void m1() { + } } -abstract class c2 extends c1 -{ - public void m2() {} +abstract class c2 extends c1 { + public void m2() { + } } -abstract class s1 -{ - public static final String FOO = "foo"; +abstract class s1 { + public static final String FOO = "foo"; - public String getFoo() - { - return FOO; - } + public String getFoo() { + return FOO; + } } -abstract class s2 extends s1 -{ - public static final String FOO = "foo2"; +abstract class s2 extends s1 { + public static final String FOO = "foo2"; - @Override - public String getFoo() - { - return FOO; - } + @Override + public String getFoo() { + return FOO; + } } Modified: trunk/fb-contrib/samples/CSBTS_StringToStringSample.java =================================================================== --- trunk/fb-contrib/samples/CSBTS_StringToStringSample.java 2014-01-15 20:53:03 UTC (rev 1764) +++ trunk/fb-contrib/samples/CSBTS_StringToStringSample.java 2014-02-17 21:22:53 UTC (rev 1765) @@ -18,8 +18,7 @@ // string representation for derived types // return ToStringBuilder.reflectionToString(this); // Use for final classes most efficient solution - return new ToStringBuilder(this).append("name", name) - .append("age", age).toString(); + return new ToStringBuilder(this).append("name", name).append("age", age).toString(); } } @@ -46,11 +45,7 @@ ... [truncated message content] |
From: <dbr...@us...> - 2014-01-15 20:53:06
|
Revision: 1764 http://sourceforge.net/p/fb-contrib/code/1764 Author: dbrosius Date: 2014-01-15 20:53:03 +0000 (Wed, 15 Jan 2014) Log Message: ----------- sync from github for 5.0.2 Modified Paths: -------------- trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2014-01-15 20:32:40 UTC (rev 1763) +++ trunk/fb-contrib/htdocs/index.shtml 2014-01-15 20:53:03 UTC (rev 1764) @@ -68,8 +68,8 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 5.0.1 available for download - <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.0.1.jar/download">here</a>.</p> + <p style="font-weight: bold;">The latest version of fb-contrib is 5.0.2 available for download + <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.0.2.jar/download">here</a>.</p> </div> <hr/> Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2014-01-15 20:32:40 UTC (rev 1763) +++ trunk/fb-contrib/htdocs/repository.html 2014-01-15 20:53:03 UTC (rev 1764) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>5.0.1</td></tr> + <tr><td><b>Version:</b></td><td>5.0.2</td></tr> </table> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2014-01-15 20:32:43
|
Revision: 1763 http://sourceforge.net/p/fb-contrib/code/1763 Author: dbrosius Date: 2014-01-15 20:32:40 +0000 (Wed, 15 Jan 2014) Log Message: ----------- Version 5.0.2 Added Paths: ----------- tags/v5_0_2/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2014-01-15 20:27:32
|
Revision: 1762 http://sourceforge.net/p/fb-contrib/code/1762 Author: dbrosius Date: 2014-01-15 20:27:28 +0000 (Wed, 15 Jan 2014) Log Message: ----------- Merge from Github for release 5.0.2 Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorMansEnum.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java 2014-01-15 20:27:28 UTC (rev 1762) @@ -0,0 +1,117 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2014 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 org.apache.bcel.Repository; +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; +import org.apache.bcel.classfile.Method; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.Detector; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.visitclass.PreorderVisitor; + +/** looks for fields and local variables that have Map, Set, List in their names + * but the variable is a collection of a different basic type. + */ +public class CollectionNamingConfusion extends PreorderVisitor implements Detector { + + private static JavaClass MAP_CLASS; + private static JavaClass SET_CLASS; + private static JavaClass LIST_CLASS; + + static { + try { + MAP_CLASS = Repository.lookupClass("java/util/Map"); + SET_CLASS = Repository.lookupClass("java/util/Set"); + LIST_CLASS = Repository.lookupClass("java/util/List"); + } catch (ClassNotFoundException cnfe) { + MAP_CLASS = null; + SET_CLASS = null; + LIST_CLASS = null; + } + } + private BugReporter bugReporter; + + public CollectionNamingConfusion(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + public void visitClassContext(ClassContext classContext) { + if (MAP_CLASS != null) { + classContext.getJavaClass().accept(this); + } + } + + @Override + public void visitField(Field obj) { + if (checkConfusedName(obj.getName(), obj.getSignature())) { + bugReporter.reportBug(new BugInstance(this, "CNC_COLLECTION_NAMING_CONFUSION", NORMAL_PRIORITY) + .addClass(this) + .addField(this) + .addString(obj.getName())); + } + } + + @Override + public void visitMethod(Method obj) { + LocalVariableTable lvt = obj.getLocalVariableTable(); + if (lvt != null ) { + LocalVariable[] lvs = lvt.getLocalVariableTable(); + for (LocalVariable lv : lvs) { + if (checkConfusedName(lv.getName(), lv.getSignature())) { + bugReporter.reportBug(new BugInstance(this, "CNC_COLLECTION_NAMING_CONFUSION", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addString(lv.getName())); + } + } + } + } + + private boolean checkConfusedName(String name, String signature) { + try { + name = name.toLowerCase(); + if (name.endsWith("map") || (name.endsWith("set") && !name.endsWith("toset")) || name.endsWith("list")) { + if (signature.startsWith("Ljava/util/")) { + String clsName = signature.substring(1, signature.length() - 1); + JavaClass cls = Repository.lookupClass(clsName); + if (cls.implementationOf(MAP_CLASS) && !name.endsWith("map")) { + return true; + } else if (cls.implementationOf(SET_CLASS) && !name.endsWith("set")) { + return true; + } else if (cls.implementationOf(LIST_CLASS) && !name.endsWith("list")) { + return true; + } + } + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } + + return false; + } + + public void report() { + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorMansEnum.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorMansEnum.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorMansEnum.java 2014-01-15 20:27:28 UTC (rev 1762) @@ -0,0 +1,135 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2014 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.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.JavaClass; + +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.SourceLineAnnotation; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.ba.XFactory; + +/** + * looks for simple fields that only store one of several constant values. This usually is an + * indication that this field should really be an enum type. + */ +public class PoorMansEnum extends BytecodeScanningDetector { + + private BugReporter bugReporter; + private Map<String, Set<Object>> fieldValues; + private Map<String, Field> nameToField; + private Map<String, SourceLineAnnotation> firstFieldUse; + private OpcodeStack stack; + + public PoorMansEnum(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + @Override + public void visitClassContext(ClassContext classContext) { + try { + fieldValues = new HashMap<String, Set<Object>>(); + nameToField = new HashMap<String, Field>(); + JavaClass cls = classContext.getJavaClass(); + for (Field f : cls.getFields()) { + if (f.isPrivate() && !f.isSynthetic()) { + fieldValues.put(f.getName(), null); + nameToField.put(f.getName(), f); + } + } + if (!fieldValues.isEmpty()) { + stack = new OpcodeStack(); + firstFieldUse = new HashMap<String, SourceLineAnnotation>(); + super.visitClassContext(classContext); + + for (Map.Entry<String, Set<Object>> fieldInfo : fieldValues.entrySet()) { + Set<Object> values = fieldInfo.getValue(); + if (values != null) { + if (values.size() >= 3) { + String fieldName = fieldInfo.getKey(); + bugReporter.reportBug(new BugInstance(this, "PME_POOR_MANS_ENUM", NORMAL_PRIORITY) + .addClass(this) + .addField(XFactory.createXField(cls, nameToField.get(fieldName))) + .addSourceLine(firstFieldUse.get(fieldName))); + } + } + } + } + } finally { + fieldValues = null; + nameToField = null; + firstFieldUse = null; + stack = null; + } + } + + @Override + public void visitCode(Code obj) { + if (!fieldValues.isEmpty()) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } + } + + @Override + public void sawOpcode(int seen) { + try { + stack.precomputation(this); + if (fieldValues.isEmpty()) { + return; + } + + if (seen == PUTFIELD) { + String fieldName = getNameConstantOperand(); + if (fieldValues.containsKey(fieldName)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + Object cons = item.getConstant(); + if (cons == null) { + fieldValues.remove(fieldName); + nameToField.remove(fieldName); + firstFieldUse.remove(fieldName); + } else { + Set<Object> values = fieldValues.get(fieldName); + if (values == null) { + values = new HashSet<Object>(); + fieldValues.put(fieldName, values); + if (firstFieldUse.get(fieldName) == null) + firstFieldUse.put(fieldName, SourceLineAnnotation.fromVisitedInstruction(this)); + } + values.add(cons); + } + } + } + } + } finally { + stack.sawOpcode(this, seen); + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorMansEnum.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2014-01-15 20:25:09
|
Revision: 1761 http://sourceforge.net/p/fb-contrib/code/1761 Author: dbrosius Date: 2014-01-15 20:25:00 +0000 (Wed, 15 Jan 2014) Log Message: ----------- Merge from Github for release 5.0.2 Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/mbfg_menu.shtml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/CU_Sample.java trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/samples/OCP_Sample.java trunk/fb-contrib/samples/OC_Sample.java trunk/fb-contrib/samples/SG_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/WOC_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CompareClassNameEquals.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImproperPropertiesUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonCollectionMethodUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonFunctionalField.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleUnsuspectedSerialization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SQLInLoop.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SluggishGui.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpuriousThreadStates.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousClusteredSessionSupport.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousWaitOnConcurrentObject.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/TailRecursion.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/TristateBooleanPattern.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseVarArgs.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/samples/CNC_Sample.java trunk/fb-contrib/samples/PME_Sample.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/.classpath 2014-01-15 20:25:00 UTC (rev 1761) @@ -11,11 +11,12 @@ <classpathentry kind="lib" path="lib/bcel-2.0.2.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/> <classpathentry kind="lib" path="lib/commons-lang3-3.1.jar"/> - <classpathentry kind="lib" path="lib/findbugs-2.0.2.jar"/> <classpathentry kind="lib" path="lib/javax.servlet-api-3.1.0.jar"/> <classpathentry kind="lib" path="lib/javax.servlet.jsp-api-2.2.1.jar"/> <classpathentry kind="lib" path="lib/junit-4.11.jar"/> <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/> <classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/> + <classpathentry kind="lib" path="lib/findbugs-2.0.3.jar"/> + <classpathentry kind="lib" path="lib/guava-15.0.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/build.xml 2014-01-15 20:25:00 UTC (rev 1761) @@ -2,6 +2,7 @@ <project name="fb-contrib" default="info"> + <property file="user.properties" /> <property file="build.properties" /> <property file="version.properties" /> @@ -17,7 +18,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="5.0.1" /> + <property name="fb-contrib.version" value="5.0.2" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -70,6 +71,7 @@ <pathelement location="${lib.dir}/commons-lang3-${commons-lang3.version}.jar" /> <pathelement location="${lib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> <pathelement location="${lib.dir}/slf4j-api-${slf4j-api.version}.jar" /> + <pathelement location="${lib.dir}/guava-${guava.version}.jar" /> </path> <mkdir dir="${classes.dir}/com" /> <mkdir dir="${classes.dir}/com/mebigfatguy" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/etc/findbugs.xml 2014-01-15 20:25:00 UTC (rev 1761) @@ -15,7 +15,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -31,7 +31,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -146,7 +146,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF" /> + 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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -248,10 +248,15 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument" speed="fast" reports="ICA_INVALID_CONSTANT_ARRAY" /> - <!-- COMMENT OUT FOR POINT RELEASE + <!-- COMMENT OUT FOR POINT RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.CollectionNamingConfusion" speed="fast" reports="CNC_COLLECTION_NAMING_CONFUSION" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.PoorMansEnum" speed="fast" reports="PME_POOR_MANS_ENUM" /> + COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -356,6 +361,7 @@ <BugPattern abbrev="SPP" type="SPP_USE_GET0" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_DOUBLE_APPENDED_LITERALS" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_NULL_BEFORE_INSTANCEOF" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_NON_USEFUL_TOSTRING" category="STYLE" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> @@ -447,4 +453,6 @@ <BugPattern abbrev="AIOB" type="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS" category="CORRECTNESS" /> <BugPattern abbrev="AIOB" type="AIOB_ARRAY_STORE_TO_NULL_REFERENCE" category="CORRECTNESS" /> <BugPattern abbrev="ICA" type="ICA_INVALID_CONSTANT_ARGUMENT" category="CORRECTNESS" /> + <BugPattern abbrev="CNC" type="CNC_COLLECTION_NAMING_CONFUSION" category="STYLE" /> + <BugPattern abbrev="PME" type="PME_POOR_MANS_ENUM" category="STYLE" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/etc/messages.xml 2014-01-15 20:25:00 UTC (rev 1761) @@ -1348,6 +1348,29 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.CollectionNamingConfusion"> + <Details> + <![CDATA[ + <p>Looks for fields or local variables that are collections but which names have a different type + of collection in the name. This is confusing, and is probably a left over from a type change, such as + </p> + <p>List<String> mySet;</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.PoorMansEnum"> + <Details> + <![CDATA[ + <p>Looks for fields defined with simple types, (int, String, etc) that are used like an enum. Specifically fields that are + only assigned a set of constant values. This variable probably should be redefined as an enum. + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> @@ -2650,6 +2673,18 @@ ]]> </Details> </BugPattern> + + <BugPattern type="SPP_NON_USEFUL_TOSTRING"> + <ShortDescription>Method calls toString() on an instance of a class that hasn't overridden toString()</ShortDescription> + <LongDescription>Method {1} calls toString() on an instance of a class that hasn't overridden toString()</LongDescription> + <Details> + <![CDATA[ + <p>This method calls toString() on an object that hasn't overridden the toString() method, and thus relies on + the version found in java.lang.Object. This string is just a raw display of the object's class and location, and + provides no information about the information of use. You should implement toString in this class. + ]]> + </Details> + </BugPattern> <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> @@ -3771,6 +3806,30 @@ ]]> </Details> </BugPattern> + + <BugPattern type="CNC_COLLECTION_NAMING_CONFUSION"> + <ShortDescription>Collection variable is named with a different type of collection in the name</ShortDescription> + <LongDescription>Collection variable {2} is named with a different type of collection in the name</LongDescription> + <Details> + <![CDATA[ + <p>This class defines a field or local collection variable with a name that contains a different type + of collection in it's name. This is confusing to the reader, and likely caused by a previous refactor of + type, without changing the name.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="PME_POOR_MANS_ENUM"> + <ShortDescription>Simple field is used like an enum</ShortDescription> + <LongDescription>Simple field {1} is used like an enum</LongDescription> + <Details> + <![CDATA[ + <p>This field, although defined as a simple variable (int, String, etc) only has a set of constant values + assigned to it. This appears to be used like an enum value, and should probably be defined as such. + </p> + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -3886,4 +3945,6 @@ <BugCode abbrev="NPMC">Non Productive Method Call</BugCode> <BugCode abbrev="AIOB">Array Index Out of Bounds</BugCode> <BugCode abbrev="ICA">Invalid Constant Argument</BugCode> + <BugCode abbrev="CNC">Collection Naming Confusion</BugCode> + <BugCode abbrev="PME">Poor Mans Enum</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/htdocs/index.shtml 2014-01-15 20:25:00 UTC (rev 1761) @@ -98,6 +98,14 @@ </li> </ul> </li> + <li><b>[CNC] Collection Naming Confusion</b><br/> + Looks for fields and local variables that have Map, Set, List in their names + but the variable is a collection of a different basic type. + </li> + <li><b>[PME] Poor Mans Enum</b><br/> + Looks for simple fields that only store one of several constant values. This usually is an indication + that this field should really be an enum type. + </li> </ul> </div> <hr/> Modified: trunk/fb-contrib/htdocs/mbfg_menu.shtml =================================================================== --- trunk/fb-contrib/htdocs/mbfg_menu.shtml 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/htdocs/mbfg_menu.shtml 2014-01-15 20:25:00 UTC (rev 1761) @@ -12,7 +12,7 @@ <li><a href="http://schemalizer.sf.net">Schemalizer</a></li> <li><a href="http://tomailer.sf.net">ToMailer</a></li> <li><a href="http://jd4a.sf.net">JavaDoc for Android</a></li> - <il><a href="http://damus.sf.net">Damus</a></li> + <li><a href="http://damus.sf.net">Damus</a></li> <li><a href="http://www.heartofgoldfarm.com">Heart of Gold Farm</a></li> </ul> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/pom.xml 2014-01-15 20:25:00 UTC (rev 1761) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>5.0.1</version> + <version>5.0.2</version> <parent> <groupId>org.sonatype.oss</groupId> @@ -103,7 +103,7 @@ <dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>findbugs</artifactId> - <version>2.0.1</version> + <version>2.0.3</version> <scope>provided</scope> </dependency> </dependencies> Added: trunk/fb-contrib/samples/CNC_Sample.java =================================================================== --- trunk/fb-contrib/samples/CNC_Sample.java (rev 0) +++ trunk/fb-contrib/samples/CNC_Sample.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -0,0 +1,14 @@ +import java.util.List; +import java.util.Map; +import java.util.Set; + + +public class CNC_Sample { + Map<String, String> argList; + Set<Integer> targetMap; + List<Double> bernoulliSet; + + public void testCNC(Map<String, String> argSet, Set<String> nameList, List<String> nameMap) { + + } +} Property changes on: trunk/fb-contrib/samples/CNC_Sample.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/samples/CU_Sample.java =================================================================== --- trunk/fb-contrib/samples/CU_Sample.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/samples/CU_Sample.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -37,4 +37,10 @@ public void run() { } } + + class FPActuallyThrow implements Cloneable { + public FPActuallyThrow clone() throws CloneNotSupportedException { + throw new CloneNotSupportedException("Silly"); + } + } } Modified: trunk/fb-contrib/samples/LEST_Sample.java =================================================================== --- trunk/fb-contrib/samples/LEST_Sample.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/samples/LEST_Sample.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,9 +1,13 @@ +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import com.google.common.base.Throwables; + @SuppressWarnings("all") public class LEST_Sample { @@ -159,6 +163,18 @@ throw new Exception("message"); } } + + public void fpThrowables() + { + try + { + InputStream is = new FileInputStream("foo"); + } + catch (IOException e) + { + throw Throwables.propagate(e); + } + } private Exception wrap(Exception e) { return new Exception(e); Modified: trunk/fb-contrib/samples/OCP_Sample.java =================================================================== --- trunk/fb-contrib/samples/OCP_Sample.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/samples/OCP_Sample.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -10,15 +10,15 @@ import java.util.Iterator; import java.util.LinkedList; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + @SuppressWarnings("all") public class OCP_Sample extends Z implements ActionListener, Serializable { Modified: trunk/fb-contrib/samples/OC_Sample.java =================================================================== --- trunk/fb-contrib/samples/OC_Sample.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/samples/OC_Sample.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,5 +1,5 @@ +import java.util.ArrayList; import java.util.Collection; -import java.util.ArrayList; @SuppressWarnings("all") public class OC_Sample Added: trunk/fb-contrib/samples/PME_Sample.java =================================================================== --- trunk/fb-contrib/samples/PME_Sample.java (rev 0) +++ trunk/fb-contrib/samples/PME_Sample.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -0,0 +1,32 @@ + +public class PME_Sample { + + private int v; + private String s; + private String fps; + private boolean fpb; + + public void foo() { + v = 1; + s = "Fee"; + fps = "Hello"; + fpb = true; + } + + public void foo2() { + v =- 2; + s = "Fi"; + fps = "Hi"; + fpb = false; + } + + public void foo3() { + v = 3; + s = "Fo"; + fps = "Chow"; + } + + public void foo4(String x) { + fps = x; + } +} Property changes on: trunk/fb-contrib/samples/PME_Sample.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/samples/SG_Sample.java =================================================================== --- trunk/fb-contrib/samples/SG_Sample.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/samples/SG_Sample.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -5,11 +5,11 @@ import java.io.ByteArrayInputStream; import java.io.FileReader; +import org.w3c.dom.Document; + import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.w3c.dom.Document; - @SuppressWarnings("all") public class SG_Sample implements ActionListener, WindowListener { Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/samples/SPP_Sample.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -384,4 +384,11 @@ } return Math.random() > 0.5; } + + public void testToString() { + SPP_Sample s = new SPP_Sample(); + System.out.println(s.toString()); + /* only report it once */ + System.out.println(s.toString()); + } } Modified: trunk/fb-contrib/samples/WOC_Sample.java =================================================================== --- trunk/fb-contrib/samples/WOC_Sample.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/samples/WOC_Sample.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -15,6 +15,8 @@ private final Set<String> memberSet = new HashSet<String>(); private Set<String> fpSet; private final List<String> fpList = new ArrayList<String>(); + private List<String> fp1 = new ArrayList<String>(); + private List<String> fp2 = new ArrayList<String>(); public void testWOCSimple() { Set<String> s = new HashSet<String>(); @@ -64,7 +66,7 @@ } } - public Set<String> testFPTrinary(boolean b) { + public Set<String> testFPTernary(boolean b) { Set<String> s = new HashSet<String>(); s.add("foo"); s.add("bar"); @@ -104,6 +106,19 @@ return result; } + + public List<String> fpWOCTernary(boolean a, boolean b) { + + if (a) + { + return b ? fp1 : fp2; + } + + List<String> used1 = new ArrayList<String>(); + List<String> used2 = new ArrayList<String>(); + + return b ? used1 : used2; + } public static class FpContains { private List<String> fpSet; Modified: trunk/fb-contrib/samples/samples.fbp =================================================================== --- trunk/fb-contrib/samples/samples.fbp 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/samples/samples.fbp 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,15 +1,16 @@ <Project projectName="sample"> - <Jar>./././.</Jar> - <AuxClasspathEntry>../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/commons-collections-3.2.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/commons-lang3-3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.servlet.jsp-api-2.2.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/junit-4.11.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/log4j-1.2.17-sources.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/log4j-1.2.17.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/slf4j-api-1.7.5.jar</AuxClasspathEntry> - <SrcDir>./././.</SrcDir> + <Jar>././././.</Jar> + <AuxClasspathEntry>./../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/commons-collections-3.2.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/commons-lang3-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/javax.servlet.jsp-api-2.2.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/junit-4.11.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/log4j-1.2.17-sources.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/log4j-1.2.17.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/slf4j-api-1.7.5.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/guava-15.0.jar</AuxClasspathEntry> + <SrcDir>././././.</SrcDir> <SuppressionFilter> <LastVersion value="-1" relOp="NEQ"/> </SuppressionFilter> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,6 +28,7 @@ { private int numMethodCalls; + @SuppressWarnings("unused") public CollectStatistics(BugReporter bugReporter) { Statistics.getStatistics().clear(); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -42,6 +42,7 @@ private OpcodeStack stack = new OpcodeStack(); private PrintWriter pw = null; + @SuppressWarnings("unused") public OCSDebugger(BugReporter bugReporter) { } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,7 +1,7 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Bhaskar Maddala - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Bhaskar Maddala + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2013-12-11 03:45:55 UTC (rev 1760) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2014-01-15 20:25:00 UTC (rev 1761) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2013 Dave Brosius + * Copyright (C) 2005-2014 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -50,10 +50,10 @@ */ @CustomUserValue public class BloatedAssignmentScope extends BytecodeScanningDetector { - private static final Set<String> dangerousAssignmentClassSources = new HashSet<String>(7); - private static final Set<String> dangerousAssignmentMethodSources = new HashSet<String>(4); + private static final Set<String> dangerousAssignmentClassSources = new HashSet<String>(7); + private static final Set<String> dangerousAssignmentMethodSources = new HashSet<String>(4); - static { + static { dangerousAssignmentClassSources.add("java/io/BufferedInputStream"); dangerousAssignmentClassSources.add("java/io/DataInputStream"); dangerousAssignmentClassSources.add("java/io/InputStream"); @@ -67,587 +67,603 @@ dangerousAssignmentMethodSources.add("java/util/GregorianCalendar.get(I)I"); dangerousAssignmentMethodSources.add("java/util/Iterator.next()Ljava/lang/Object;"); dangerousAssignmentMethodSources.add("java/util/regex/Matcher.start()I"); - } + } - BugReporter bugReporter; - private OpcodeStack stack; - private BitSet ignoreRegs; - private ScopeBlock rootScopeBlock; - private BitSet catchHandlers; - private BitSet switchTargets; - private List<Integer> monitorSyncPCs; - private boolean dontReport; - private boolean sawDup; - private boolean sawNull; + BugReporter bugReporter; + private OpcodeStack stack; + private BitSet ignoreRegs; + private ScopeBlock rootScopeBlock; + private BitSet tryBlocks; + private BitSet catchHandlers; + private BitSet switchTargets; + private List<Integer> monitorSyncPCs; + private boolean dontReport; + private boolean sawDup; + private boolean sawNull; - /** - * 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; - } + /** + * 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 - * - * @param classContext - * the context object of the currently parsed class - */ - @Override - public void visitClassContext(ClassContext classContext) { - try { - ignoreRegs = new BitSet(); - catchHandlers = new BitSet(); - switchTargets = new BitSet(); - monitorSyncPCs = new ArrayList<Integer>(5); - stack = new OpcodeStack(); - super.visitClassContext(classContext); - } finally { - ignoreRegs = null; - catchHandlers = null; - switchTargets = null; - monitorSyncPCs = null; - stack = null; - } - } + /** + * 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 { + ignoreRegs = new BitSet(); + tryBlocks = new BitSet(); + catchHandlers = new BitSet(); + switchTargets = new BitSet(); + monitorSyncPCs = new ArrayList<Integer>(5); + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + ignoreRegs = null; + tryBlocks = null; + catchHandlers = null; + switchTargets = null; + monitorSyncPCs = null; + stack = 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) { - try { + /** + * 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) { + try { - ignoreRegs.clear(); - Method method = getMethod(); - if (!method.isStatic()) { - ignoreRegs.set(0); - } + ignoreRegs.clear(); + Method method = getMethod(); + if (!method.isStatic()) { + ignoreRegs.set(0); + } - int[] parmRegs = RegisterUtils.getParameterRegisters(method); - for (int parm : parmRegs) { - ignoreRegs.set(parm); - } + int[] parmRegs = RegisterUtils.getParameterRegisters(method); + for (int parm : parmRegs) { + ignoreRegs.set(parm); + } - rootScopeBlock = new ScopeBlock(0, obj.getLength()); - catchHandlers.clear(); - CodeException[] exceptions = obj.getExceptionTable(); - if (exceptions != null) { - for (CodeException ex : exceptions) { - catchHandlers.set(ex.getHandlerPC()); - } - } + rootScopeBlock = new ScopeBlock(0, obj.getLength()); + tryBlocks.clear(); + catchHandlers.clear(); + CodeException[] exceptions = obj.getExceptionTable(); + if (exceptions != null) { + for (CodeException ex : exceptions) { + tryBlocks.set(ex.getStartPC()); + catchHandlers.set(ex.getHandlerPC()); + } + } - switchTargets.clear(); - stack.resetForMethodEntry(this); - dontReport = false; - sawDup = false; - sawNull = false; - super.visitCode(obj); + switchTargets.clear(); + stack.resetForMethodEntry(this); + dontReport = false; + sawDup = false; + sawNull = false; + super.visitCode(obj); - if (!dontReport) { - rootScopeBlock.findBugs(new HashSet<Integer>()); - } + if (!dontReport) { + rootScopeBlock.findBugs(new HashSet<Integer>()); + } - } finally { - rootScopeBlock = null; - } - } + } finally { + rootScopeBlock = null; + } + } - /** - * 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) { - UserObject uo = null; - try { - stack.precomputation(this); - - 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_3)) - || ((seen >= FSTORE_0) && (seen <= FSTORE_1)) - || ((seen >= DSTORE_0) && (seen <= DSTORE_1))) { - int reg = RegisterUtils.getStoreReg(this, seen); - int pc = getPC(); + /** + * 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) { + UserObject uo = null; + try { + stack.precomputation(this); - if (catchHandlers.get(pc)) { - ignoreRegs.set(reg); - } else if (monitorSyncPCs.size() > 0) { - ignoreRegs.set(reg); - } else if (sawNull) { - ignoreRegs.set(reg); - } + int pc = getPC(); + if (tryBlocks.get(pc)) { + ScopeBlock sb = new ScopeBlock(getPC(), findCatchHandlerFor(pc)); + sb.setTry(); + rootScopeBlock.addChild(sb); + } - if (!ignoreRegs.get(reg)) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); - if (sb != null) { - UserObject assoc = null; - if (stack.getStackDepth() > 0) { - assoc = (UserObject) stack.getStackItem(0) - .getUserValue(); - } + 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_3)) || ((seen >= FSTORE_0) && (seen <= FSTORE_1)) + || ((seen >= DSTORE_0) && (seen <= DSTORE_1))) { + int reg = RegisterUtils.getStoreReg(this, seen); - if ((assoc != null) && assoc.isRisky) { - ignoreRegs.set(reg); - } else { - sb.addStore(reg, pc, assoc); - if (sawDup) { - sb.addLoad(reg, pc); - } - } - } else { - ignoreRegs.set(reg); - } - } - } else if (seen == IINC) { - int reg = getRegisterOperand(); - if (!ignoreRegs.get(reg)) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); - if (sb != null) { - sb.addLoad(reg, getPC()); - } else { - ignoreRegs.set(reg); - } - } - int pc = getPC(); - if (catchHandlers.get(pc)) { - ignoreRegs.set(reg); - } else if (monitorSyncPCs.size() > 0) { - ignoreRegs.set(reg); - } else if (sawNull) { - ignoreRegs.set(reg); - } + if (catchHandlers.get(pc)) { + ignoreRegs.set(reg); + } else if (monitorSyncPCs.size() > 0) { + ignoreRegs.set(reg); + } else if (sawNull) { + ignoreRegs.set(reg); + } - if (!ignoreRegs.get(reg)) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); - if (sb != null) { - sb.addStore(reg, pc, null); - if (sawDup) { - sb.addLoad(reg, pc); - } - } else { - ignoreRegs.set(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_3)) - || ((seen >= FLOAD_0) && (seen <= FLOAD_1)) - || ((seen >= DLOAD_0) && (seen <= DLOAD_1))) { - int reg = RegisterUtils.getLoadReg(this, seen); - if (!ignoreRegs.get(reg)) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); - if (sb != null) { - sb.addLoad(reg, getPC()); - } else { - ignoreRegs.set(reg); - } - } - } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == IFNULL) - || (seen == IFNONNULL) || (seen == GOTO_W)) { - int target = getBranchTarget(); - if (target > getPC()) { - if ((seen == GOTO) || (seen == GOTO_W)) { - int nextPC = getNextPC(); - if (!switchTargets.get(nextPC)) { - ScopeBlock sb = findScopeBlockWithTarget( - rootScopeBlock, getPC(), nextPC); - if (sb == null) { - sb = new ScopeBlock(getPC(), target); - sb.setLoop(); - sb.setGoto(); - rootScopeBlock.addChild(sb); - } else { - sb = new ScopeBlock(getPC(), target); - sb.setGoto(); - rootScopeBlock.addChild(sb); - } - } - } else { - ScopeBlock sb = findScopeBlockWithTarget( - rootScopeBlock, getPC(), target); - if ((sb != null) && (!sb.isLoop) && !sb.hasChildren()) { - if (sb.isGoto()) { - ScopeBlock parent = sb.getParent(); - sb.pushUpLoadStores(); - if (parent != null) { - parent.removeChild(sb); - } - sb = new ScopeBlock(getPC(), target); - rootScopeBlock.addChild(sb); - } else { - sb.pushUpLoadStores(); - sb.setStart(getPC()); - sb.setFinish(target); - } - } else { - sb = new ScopeBlock(getPC(), target); - rootScopeBlock.addChild(sb); - } - } - } else { - ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); - if (sb != null) { - ScopeBlock parentSB = sb.getParent(); - while (parentSB != null) { - if (parentSB.getStart() >= target) { - sb = parentSB; - parentSB = parentSB.getParent(); - } else { - break; - } - } - sb.setLoop(); - } - } - } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) { - int pc = getPC(); - int[] offsets = getSwitchOffsets(); - List<Integer> targets = new ArrayList<Integer>(offsets.length); - for (int offset : offsets) { - targets.add(Integer.valueOf(offset + pc)); - } - Integer defOffset = Integer.valueOf(getDefaultSwitchOffset() - + pc); - if (!targets.contains(defOffset)) { - targets.add(defOffset); - } - Collections.sort(targets); + if (!ignoreRegs.get(reg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); + if (sb != null) { + UserObject assoc = null; + if (stack.getStackDepth() > 0) { + assoc = (UserObject) stack.getStackItem(0).getUserValue(); + } - Integer lastTarget = targets.get(0); - for (int i = 1; i < targets.size(); i++) { - Integer nextTarget = targets.get(i); - ScopeBlock sb = new ScopeBlock(lastTarget.intValue(), - nextTarget.intValue()); - rootScopeBlock.addChild(sb); - lastTarget = nextTarget; - } - for (Integer target : targets) { - switchTargets.set(target.intValue()); - } - } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) { - if ("wasNull".equals(getNameConstantOperand()) - && "()Z".equals(getSigConstantOperand())) { - dontReport = true; - } + if ((assoc != null) && assoc.isRisky) { + ignoreRegs.set(reg); + } else { + sb.addStore(reg, pc, assoc); + if (sawDup) { + sb.addLoad(reg, pc); + } + } + } else { + ignoreRegs.set(reg); + } + } + } else if (seen == IINC) { + int reg = getRegisterOperand(); + if (!ignoreRegs.get(reg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) { + sb.addLoad(reg, getPC()); + } else { + ignoreRegs.set(reg); + } + } + if (catchHandlers.get(pc)) { + ignoreRegs.set(reg); + } else if (monitorSyncPCs.size() > 0) { + ignoreRegs.set(reg); + } else if (sawNull) { + ignoreRegs.set(reg); + } - uo = new UserObject(); - uo.isRisky = isRiskyMethodCall(); - uo.caller = getCallingObject(); + if (!ignoreRegs.get(reg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, pc); + if (sb != null) { + sb.addStore(reg, pc, null); + if (sawDup) { + sb.addLoad(reg, pc); + } + } else { + ignoreRegs.set(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_3)) || ((seen >= FLOAD_0) && (seen <= FLOAD_1)) + || ((seen >= DLOAD_0) && (seen <= DLOAD_1))) { + int reg = RegisterUtils.getLoadReg(this, seen); + if (!ignoreRegs.get(reg)) { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) { + sb.addLoad(reg, getPC()); + } else { + ignoreRegs.set(reg); + } + } + } else if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL) || (seen == GOTO_W)) { + int target = getBranchTarget(); + if (target > getPC()) { + if ((seen == GOTO) || (seen == GOTO_W)) { + int nextPC = getNextPC(); + if (!switchTargets.get(nextPC)) { + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), nextPC); + if (sb == null) { + sb = new ScopeBlock(getPC(), target); + sb.setLoop(); + sb.setGoto(); + rootScopeBlock.addChild(sb); + } else { + sb = new ScopeBlock(getPC(), target); + sb.setGoto(); + rootScopeBlock.addChild(sb); + } + } + } else { + ScopeBlock sb = findScopeBlockWithTarget(rootScopeBlock, getPC(), target); + if ((sb != null) && (!sb.isLoop()) && !sb.isCase() && !sb.hasChildren()) { + if (sb.isGoto()) { + ScopeBlock parent = sb.getParent(); + sb.pushUpLoadStores(); + if (parent != null) { + parent.removeChild(sb); + } + sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } else { + sb.pushUpLoadStores(); + sb.setStart(getPC()); + sb.setFinish(target); + } + } else { + sb = new ScopeBlock(getPC(), target); + rootScopeBlock.addChild(sb); + } + } + } else { + ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); + if (sb != null) { + ScopeBlock parentSB = sb.getParent(); + while (parentSB != null) { + if (parentSB.getStart() >= target) { + sb = parentSB; + parentSB = parentSB.getParent(); + } else { + break; + } + } + sb.setLoop(); + } + } + } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) { + int[] offsets = getSwitchOffsets(); + List<Integer> targets = new ArrayList<Integer>(offsets.length); + for (int offset : offsets) { + targets.add(Integer.valueOf(offset + pc)); + } + Integer defOffset = Integer.valueOf(getDefaultSwitchOffset() + pc); + if (!targets.contains(defOffset)) { + targets.add(defOffset); + } + Collections.sort(targets); - if (uo.caller != null) { - ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC()); - if (sb != null) { - sb.removeByAssoc(uo.caller); - } - } - } else if ((seen == INVOKESTATIC) || (seen == INVOKESPECIAL)) { - uo = new UserObject(); - uo.isRisky = isRiskyMethodCall(); - } else if (seen == MONITORENTER) { - monitorSyncPCs.add(Integer.valueOf(getPC())); + Integer lastTarget = targets.get(0); + for (int i = 1; i < targets.size(); i++) { + Integer nextTarget = targets.get(i); + ... [truncated message content] |
From: <dbr...@us...> - 2013-12-11 03:45:59
|
Revision: 1760 http://sourceforge.net/p/fb-contrib/code/1760 Author: dbrosius Date: 2013-12-11 03:45:55 +0000 (Wed, 11 Dec 2013) Log Message: ----------- Move latest to 5.0.1 Modified Paths: -------------- trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2013-12-11 03:23:38 UTC (rev 1759) +++ trunk/fb-contrib/htdocs/index.shtml 2013-12-11 03:45:55 UTC (rev 1760) @@ -68,8 +68,8 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 5.0.0 available for download - <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.0.0.jar/download">here</a>.</p> + <p style="font-weight: bold;">The latest version of fb-contrib is 5.0.1 available for download + <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.0.1.jar/download">here</a>.</p> </div> <hr/> Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2013-12-11 03:23:38 UTC (rev 1759) +++ trunk/fb-contrib/htdocs/repository.html 2013-12-11 03:45:55 UTC (rev 1760) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>5.0.0</td></tr> + <tr><td><b>Version:</b></td><td>5.0.1</td></tr> </table> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-12-11 03:23:41
|
Revision: 1759 http://sourceforge.net/p/fb-contrib/code/1759 Author: dbrosius Date: 2013-12-11 03:23:38 +0000 (Wed, 11 Dec 2013) Log Message: ----------- Version 5.0.1 Added Paths: ----------- tags/v5_0_1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-12-11 03:20:31
|
Revision: 1758 http://sourceforge.net/p/fb-contrib/code/1758 Author: dbrosius Date: 2013-12-11 03:20:25 +0000 (Wed, 11 Dec 2013) Log Message: ----------- prepare for the 5.0.1 release Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.properties trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/FCBL_Sample.java trunk/fb-contrib/samples/JAO_Sample.java trunk/fb-contrib/samples/LO_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java Added Paths: ----------- trunk/fb-contrib/yank.xls Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2013-11-17 21:58:00 UTC (rev 1757) +++ trunk/fb-contrib/.classpath 2013-12-11 03:20:25 UTC (rev 1758) @@ -4,15 +4,18 @@ <classpathentry kind="src" path="src"/> <classpathentry excluding="lib/" kind="src" path="samples"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="lib" path="samples/lib/jsp-api-2.2.1.jar"/> - <classpathentry kind="lib" path="samples/lib/junit-4.10.jar" sourcepath="/home/dave/.m2/repository/junit/junit/4.10/junit-4.10-sources.jar"/> - <classpathentry kind="lib" path="samples/lib/log4j-1.2.16.jar"/> - <classpathentry kind="lib" path="samples/lib/servlet-api-3.0.1.jar"/> - <classpathentry kind="lib" path="samples/lib/commons-lang3-3.1.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> - <classpathentry kind="lib" path="samples/lib/commons-collections-3.2.1.jar"/> - <classpathentry kind="lib" path="samples/lib/backport-util-concurrent-3.1.jar" sourcepath="/home/dave/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1-sources.jar"/> - <classpathentry kind="lib" path="samples/lib/slf4j-api-1.7.5.jar"/> - <classpathentry kind="lib" path="samples/lib/junit.jar"/> + <classpathentry kind="lib" path="lib/annotations-2.0.2.jar"/> + <classpathentry kind="lib" path="lib/asm-tree-3.3.1.jar"/> + <classpathentry kind="lib" path="lib/backport-util-concurrent-3.1.jar"/> + <classpathentry kind="lib" path="lib/bcel-2.0.2.jar"/> + <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/> + <classpathentry kind="lib" path="lib/commons-lang3-3.1.jar"/> + <classpathentry kind="lib" path="lib/findbugs-2.0.2.jar"/> + <classpathentry kind="lib" path="lib/javax.servlet-api-3.1.0.jar"/> + <classpathentry kind="lib" path="lib/javax.servlet.jsp-api-2.2.1.jar"/> + <classpathentry kind="lib" path="lib/junit-4.11.jar"/> + <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/> + <classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.properties =================================================================== --- trunk/fb-contrib/build.properties 2013-11-17 21:58:00 UTC (rev 1757) +++ trunk/fb-contrib/build.properties 2013-12-11 03:20:25 UTC (rev 1758) @@ -7,3 +7,5 @@ etc/,\ samples/ output.. = classes/ + +proxy.server = Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2013-11-17 21:58:00 UTC (rev 1757) +++ trunk/fb-contrib/build.xml 2013-12-11 03:20:25 UTC (rev 1758) @@ -1,15 +1,15 @@ <!-- fb-contrib Ant build script. Dave Brosius --> -<project name="fb-contrib" default="install"> +<project name="fb-contrib" default="info"> - <property file="build.properties" /> + <property file="build.properties" /> + <property file="version.properties" /> <property name="src.dir" value="${basedir}/src" /> <property name="classes.dir" value="${basedir}/classes" /> <property name="lib.dir" value="${basedir}/lib" /> <property name="etc.dir" value="${basedir}/etc" /> <property name="samples.dir" value="${basedir}/samples" /> - <property name="sampleslib.dir" value="${samples.dir}/lib" /> <property name="javadoc.dir" value="${basedir}/javadoc" /> <property name="htdocs.dir" value="${basedir}/htdocs" /> <property name="javac.source" value="1.5" /> @@ -17,79 +17,10 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="5.0.0" /> + <property name="fb-contrib.version" value="5.0.1" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> - - <property name="findbugs.version" value="2.0.1" /> - <property name="findbugs-bcel.version" value="2.0.1" /> - <property name="annotations.version" value="2.0.1" /> - <property name="asm-tree.version" value="3.3.1" /> - - <property name="findbugs-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/findbugs/${findbugs.version}/findbugs-${findbugs.version}.jar" /> - <property name="findbugs-bcel-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/bcel/${findbugs-bcel.version}/bcel-${findbugs-bcel.version}.jar" /> - <property name="annotations-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/annotations/${annotations.version}/annotations-${annotations.version}.jar" /> - <property name="asm-tree-url" value="http://repo1.maven.org/maven2/asm/asm-tree/${asm-tree.version}/asm-tree-${asm-tree.version}.jar" /> - - <!-- properties for samples lib dependencies --> - <property name="commons-lang3.version" value="3.1" /> - <property name="jsp-api.version" value="2.2.1" /> - <property name="junit.version" value="4.10" /> - <property name="log4j.version" value="1.2.16" /> - <property name="servlet-api.version" value="3.0.1" /> - <property name="backport-util-concurrent.version" value="3.1" /> - <property name="commons-collections.version" value="3.2.1" /> - <property name="slf4j.version" value="1.7.5" /> - - <property name="commons-lang3-url" value="http://repo1.maven.org/maven2/org/apache/commons/commons-lang3/${commons-lang3.version}/commons-lang3-${commons-lang3.version}.jar" /> - <property name="jsp-api-url" value="http://repo1.maven.org/maven2/javax/servlet/jsp/javax.servlet.jsp-api/${jsp-api.version}/javax.servlet.jsp-api-${jsp-api.version}.jar" /> - <property name="junit-url" value="http://repo1.maven.org/maven2/junit/junit/${junit.version}/junit-${junit.version}.jar" /> - <property name="log4j-url" value="http://repo1.maven.org/maven2/log4j/log4j/${log4j.version}/log4j-${log4j.version}.jar" /> - <property name="servlet-api-url" value="http://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/${servlet-api.version}/javax.servlet-api-${servlet-api.version}.jar" /> - <property name="backport-util-concurrent-url" value="http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/${backport-util-concurrent.version}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> - <property name="commons-collections-url" value="http://repo1.maven.org/maven2/commons-collections/commons-collections/${commons-collections.version}/commons-collections-${commons-collections.version}.jar" /> - <property name="slf4j-api-url" value="http://repo1.maven.org/maven2/org/slf4j/slf4j-api/${slf4j.version}/slf4j-api-${slf4j.version}.jar" /> - - <target name="check"> - <available file="${dest}/${name}-${version}.jar" property="jar-exists" /> - </target> - - <target name="_pull" depends="check" unless="jar-exists"> - <get src="${url}" dest="${dest}/${name}-${version}.jar" verbose="true" ignoreerrors="true" /> - </target> - - <macrodef name="pull"> - <attribute name="url" /> - <attribute name="dest" /> - <attribute name="name" /> - <attribute name="version" /> - - <sequential> - <antcall target="_pull"> - <param name="url" value="@{url}" /> - <param name="dest" value="@{dest}" /> - <param name="name" value="@{name}" /> - <param name="version" value="@{version}" /> - </antcall> - </sequential> - </macrodef> - - <target name="pullall"> - <pull url="${findbugs-url}" dest="${lib.dir}" name="findbugs" version="${findbugs.version}" /> - <pull url="${findbugs-bcel-url}" dest="${lib.dir}" name="findbugs-bcel" version="${findbugs-bcel.version}" /> - <pull url="${annotations-url}" dest="${lib.dir}" name="annotations" version="${annotations.version}" /> - <pull url="${asm-tree-url}" dest="${lib.dir}" name="asm-tree" version="${asm-tree.version}" /> - <pull url="${commons-lang3-url}" dest="${sampleslib.dir}" name="commons-lang3" version="${commons-lang3.version}" /> - <pull url="${jsp-api-url}" dest="${sampleslib.dir}" name="jsp-api" version="${jsp-api.version}" /> - <pull url="${junit-url}" dest="${sampleslib.dir}" name="junit" version="${junit.version}" /> - <pull url="${log4j-url}" dest="${sampleslib.dir}" name="log4j" version="${log4j.version}" /> - <pull url="${servlet-api-url}" dest="${sampleslib.dir}" name="servlet-api" version="${servlet-api.version}" /> - <pull url="${backport-util-concurrent-url}" dest="${sampleslib.dir}" name="backport-util-concurrent" version="${backport-util-concurrent.version}" /> - <pull url="${commons-collections-url}" dest="${sampleslib.dir}" name="commons-collections" version="${commons-collections.version}" /> - <pull url="${slf4j-api-url}" dest="${sampleslib.dir}" name="slf4j-api" version="${slf4j.version}" /> - </target> - <target name="clean" description="removes all generated collateral"> <delete dir="${classes.dir}" /> <delete dir="${javadoc.dir}" /> @@ -103,27 +34,42 @@ </delete> <delete dir="${basedir}/plugin" /> </target> + + <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank"> + <mkdir dir="${lib.dir}" /> + <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true"> + <server url="http://repo1.maven.org/maven2" /> + <generateVersions propertyFileName="${basedir}/version.properties" /> + </yank:yank> + </target> + + <target name="info"> + <echo message="fb-contrib - a findbugs plugin"/> + <echo message=""/> + <echo message=" this project uses yank (https://github.com/mebigfatguy/yank) for dependency management"/> + <echo message=" download yank.jar and place in ant/lib directory"/> + <echo message=" http://search.maven.org/#artifactdetails%7Ccom.mebigfatguy.yank%7Cyank%7C0.4.2%7Cjar"/> + <antcall target="install"/> + </target> - <target name="-init" description="prepares repository for a build"> + <target name="-init" depends="yank" description="prepares repository for a build"> <mkdir dir="${lib.dir}" /> - <mkdir dir="${sampleslib.dir}" /> <mkdir dir="${classes.dir}" /> <mkdir dir="${javadoc.dir}" /> <path id="fb-contrib.classpath"> <pathelement location="${lib.dir}/findbugs-${findbugs.version}.jar" /> - <pathelement location="${lib.dir}/findbugs-bcel-${findbugs-bcel.version}.jar" /> + <pathelement location="${lib.dir}/bcel-${bcel.version}.jar" /> <pathelement location="${lib.dir}/annotations-${annotations.version}.jar" /> <pathelement location="${lib.dir}/asm-tree-${asm-tree.version}.jar" /> </path> <path id="fb-contrib.samples.classpath"> - <pathelement location="${sampleslib.dir}/jsp-api-${jsp-api.version}.jar" /> - <pathelement location="${sampleslib.dir}/junit-${junit.version}.jar" /> - <pathelement location="${sampleslib.dir}/servlet-api-${servlet-api.version}.jar" /> - <pathelement location="${sampleslib.dir}/log4j-${log4j.version}.jar" /> - <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar" /> - <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar" /> - <pathelement location="${sampleslib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> - <pathelement location="${sampleslib.dir}/slf4j-api-${slf4j.version}.jar" /> + <pathelement location="${lib.dir}/javax.servlet.jsp-api-${javax.servlet.jsp-api.version}.jar" /> + <pathelement location="${lib.dir}/junit-${junit.version}.jar" /> + <pathelement location="${lib.dir}/javax.servlet-api-${javax.servlet-api.version}.jar" /> + <pathelement location="${lib.dir}/log4j-${log4j.version}.jar" /> + <pathelement location="${lib.dir}/commons-lang3-${commons-lang3.version}.jar" /> + <pathelement location="${lib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> + <pathelement location="${lib.dir}/slf4j-api-${slf4j-api.version}.jar" /> </path> <mkdir dir="${classes.dir}/com" /> <mkdir dir="${classes.dir}/com/mebigfatguy" /> @@ -140,7 +86,7 @@ </xmlvalidate> </target> - <target name="compile" depends="-init, pullall" description="compiles java files"> + <target name="compile" depends="-init" description="compiles java files"> <javac srcdir="${src.dir}" destdir="${classes.dir}" source="${javac.source}" target="${javac.target}" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> <classpath refid="fb-contrib.classpath" /> </javac> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-11-17 21:58:00 UTC (rev 1757) +++ trunk/fb-contrib/etc/findbugs.xml 2013-12-11 03:20:25 UTC (rev 1758) @@ -31,7 +31,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -177,7 +177,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousClusteredSessionSupport" speed="fast" reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE,LO_INVALID_FORMATTING_ANCHOR,LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE,LO_INVALID_FORMATTING_ANCHOR,LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS,LO_EXCEPTION_WITH_LOGGER_PARMS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse" speed="fast" reports="IICU_INCORRECT_INTERNAL_CLASS_USE" /> @@ -248,12 +248,12 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument" speed="fast" reports="ICA_INVALID_CONSTANT_ARRAY" /> - <!-- + <!-- COMMENT OUT FOR POINT RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> - --> - + COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -385,6 +385,7 @@ <BugPattern abbrev="LO" type="LO_STUTTERED_MESSAGE" category="STYLE" /> <BugPattern abbrev="LO" type="LO_INVALID_FORMATTING_ANCHOR" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS" category="CORRECTNESS" /> + <BugPattern abbrev="LO" type="LO_EXCEPTION_WITH_LOGGER_PARMS" category="CORRECTNESS" /> <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" /> <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2013-11-17 21:58:00 UTC (rev 1757) +++ trunk/fb-contrib/etc/messages.xml 2013-12-11 03:20:25 UTC (rev 1758) @@ -6,11 +6,9 @@ <ShortDescription>fb-contrib plugin</ShortDescription> <Details> <![CDATA[ - <p> - This plugin contains FindBugs detectors from the fb-contrib project - </p> + <p>This plugin contains FindBugs detectors from the fb-contrib project</p> ]]> - </Details> + </Details> </Plugin> <!-- Detectors --> @@ -20,61 +18,61 @@ <![CDATA[ <p>Collects statistics for other detectors</p> ]]> - </Details> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering"> <Details> <![CDATA[ - <p> Looks for appending strings inside of calls to StringBuffer or StringBuilder append.</p> - <p> <pre> + <p>Looks for appending strings inside of calls to StringBuffer or StringBuilder append.</p> + <pre> StringBuffer sb = new StringBuffer(); sb.append(a + b); return sb.toString(); - </pre></p> + </pre> <p>It is a fast detector</p> ]]> - </Details> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.SyncCollectionIterators"> <Details> <![CDATA[ - <p> Looks for use of iterators on synchronized collections built from the java.util.Collections class.</p> - <p> As the collection in question was built through Collections.synchronizedXXX, an assumption - is made that this collection must be multithreaded safe. However, iterator access is used, + <p>Looks for use of iterators on synchronized collections built from the java.util.Collections class</p> + <p>As the collection in question was built through Collections.synchronizedXXX, an assumption + is made that this collection must be multithreaded safe. However, iterator access is used, which is explicitly unsafe. When iterators are to be used, synchronization should be done manually.</p> <p>It is a slow detector</p> ]]> - </Details> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.CyclomaticComplexity"> <Details> <![CDATA[ - <p> Calculates the McCabe Cyclomatic Complexity measure and reports methods that have an + <p>Calculates the McCabe Cyclomatic Complexity measure and reports methods that have an excessive value. This report value can be set with system property 'fb-contrib.cc.limit'.</p> <p>It is a slow detector</p> ]]> - </Details> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyConcreteParameter"> <Details> <![CDATA[ - <p> Looks for parameters that are defined by classes, but where the method only use methods defined by an + <p>Looks for parameters that are defined by classes, but where the method only use methods defined by an implemented interface or super class of that class. Relying on concrete classes in public signatures causes cohesion, and makes low impact changes more difficult.</p> <p>It is a slow detector</p> ]]> - </Details> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.ListIndexedIterating"> <Details> <![CDATA[ - <p> Looks for for loops that iterate over a java.util.List using an integer index, and get, - rather than using an Iterator. An iterator may perform better depending on List implementation, + <p>Looks for for loops that iterate over a java.util.List using an integer index, and get, + rather than using an Iterator. An iterator may perform better depending on List implementation, but more importantly will allow the code to be converted to other collection types.</p> <p>It is a moderately fast detector</p> ]]> @@ -84,7 +82,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents"> <Details> <![CDATA[ - <p> Looks for collections or arrays that hold objects that are unrelated through class or + <p>Looks for collections or arrays that hold objects that are unrelated through class or interface inheritance other than java.lang.Object. Doing so makes for brittle code, relying either on positional correspondence for type, or a reliance on instanceof to determine type. A better design usually can be had by creating a separate class, @@ -98,7 +96,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException"> <Details> <![CDATA[ - <p> Looks for methods that declare Runtime exceptions in their throws clause. While doing + <p>Looks for methods that declare Runtime exceptions in their throws clause. While doing so is not illegal, it may represent a misunderstanding as to the exception in question. If a RuntimeException is declared, it implies that this exception type is expected to happen, which if true should be handled in code, and not propagated. </p> @@ -111,7 +109,7 @@ <Details> <![CDATA[ <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> - <p> Looks for methods that use a high percentage of methods from another class over its own + <p>Looks for methods that use a high percentage of methods from another class over its own methods. When this is the case, it is often better to implement this method in that other class, by refactoring the class to accept parameters it needs from the source class. The reporting percentage can be set with system property 'fb-contrib.ce.percent'.</p> @@ -123,7 +121,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison"> <Details> <![CDATA[ - <p> Looks for methods that compare strings against literal strings, where the literal string + <p>Looks for methods that compare strings against literal strings, where the literal string is passed as the parameter. If the .equals or .compareTo is called on the literal itself, passing the variable as the parameter, you avoid the possibility of a NullPointerException.</p> <p>It is a fast detector</p> @@ -134,7 +132,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PartiallyConstructedObjectAccess"> <Details> <![CDATA[ - <p> Looks for constructors of non final classes that make method calls to non final methods. + <p>Looks for constructors of non final classes that make method calls to non final methods. As these methods could be overridden, the overridden method will be accessing an object that is only partially constructed, perhaps causing problems.</p> <p>It is a fast detector</p> @@ -145,7 +143,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DubiousListCollection"> <Details> <![CDATA[ - <p> Looks for fields that are implementations of java.util.List, but that are used in a set-like fashion. + <p>Looks for fields that are implementations of java.util.List, but that are used in a set-like fashion. Since lookup type operations are performed using a linear search for Lists, the performance for large Lists will be poor. Consideration should be made as to whether these fields should be sets. In the case that order is important, consider using LinkedHashSet.</p> @@ -157,7 +155,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ParallelLists"> <Details> <![CDATA[ - <p> Looks for classes that maintain two or more lists or arrays associated one-for-one through the same index + <p>Looks for classes that maintain two or more lists or arrays associated one-for-one through the same index to hold two or more pieces of related information. It would be better to create a new class that holds all of these pieces of information, and place instances of this class in one list. Or if the two list are related in key/value fashion, then a map.</p> @@ -180,7 +178,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractClassEmptyMethods"> <Details> <![CDATA[ - <p> Looks for abstract classes that define empty methods or methods that simply throw an + <p>Looks for abstract classes that define empty methods or methods that simply throw an exception. Since this is an abstract class, it may be cleaner to simple define this method as abstract, so that correct subclass behaviour is enforced.</p> <p>It is a fast detector</p> @@ -191,7 +189,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ManualArrayCopy"> <Details> <![CDATA[ - <p> Looks for methods that copy data from one array to another using a loop. It is + <p>Looks for methods that copy data from one array to another using a loop. It is better performing to use System.arraycopy to do such copying as this is a native method.</p> <p>It is a fast detector</p> ]]> @@ -201,7 +199,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.FloatingPointLoops"> <Details> <![CDATA[ - <p> Looks for methods that use floating point indexes for loops. Since floating point + <p>Looks for methods that use floating point indexes for loops. Since floating point math is inprecise, rounding errors will occur each time through the loop causing hard to find problems. It is usually better to use integer indexing, and calculating the correct floating point value from the index.</p> @@ -213,7 +211,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonCollectionMethodUse"> <Details> <![CDATA[ - <p> Looks for method calls to collection classes where the method is not defined by the Collections + <p>Looks for method calls to collection classes where the method is not defined by the Collections interface, and an equivalent method exists in the interface. Examples include:<br> <table border="1"> <tr><th>Old Method</th><th>New Method</th></tr> @@ -237,15 +235,15 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingAutoboxedOverloading"> <Details> <![CDATA[ - <p> Looks for methods that have the same signature, except where one uses a + <p>Looks for methods that have the same signature, except where one uses a Character parameter, and the other uses an int, long, float, double parameter. Since autoboxing is available in 1.5 one might assume that <pre> - test('a') + test('a') </pre> would map to <pre> - public void test(Character c) + public void test(Character c) </pre> but instead maps to one that takes an int, long, float or double. </p> @@ -257,11 +255,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.AbnormalFinallyBlockReturn"> <Details> <![CDATA[ - <p> Looks for methods that have finally blocks that return values - or throw exceptions. This code will swallow normal program flow and - hide real program logic. - </p> - <p>It is a fast detector</p> + <p>Looks for methods that have finally blocks that return values + or throw exceptions. This code will swallow normal program flow and + hide real program logic.</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -269,11 +266,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.StaticMethodInstanceInvocation"> <Details> <![CDATA[ - <p> Looks for methods that make static method calls using an instance reference. + <p>Looks for methods that make static method calls using an instance reference. For documentation purposes, it is better to call the method using the class name. - This may represent a change in definition that should be noticed. - </p> - <p>It is a fast detector</p> + This may represent a change in definition that should be noticed.</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -281,7 +277,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SpuriousThreadStates"> <Details> <![CDATA[ - <p> Looks for methods that call wait, notify or notifyAll on an instance of a + <p>Looks for methods that call wait, notify or notifyAll on an instance of a java.lang.Thread. Since the internal workings of the threads is to synchronize on the thread itself, introducing client calls will confuse the thread state of the object in question, and will cause spurious thread state changes, either waking threads up @@ -294,7 +290,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessAutoboxing"> <Details> <![CDATA[ - <p> Looks for methods that pass a primitive wrapper class object to the + <p>Looks for methods that pass a primitive wrapper class object to the same class' Constructor. Patterns found are: <ul> <li>new Boolean(Boolean)</li> @@ -310,7 +306,7 @@ <p>It also looks for calls to BoxedClass.valueOf(x) where X is already a Boxed class</p> <p>It also looks for calls to BoxedClass.valueOf(myString).boxedValue(), when instead it is simpler to use BoxedClass.parseBoxed(myString)</p> - <p>It is a fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -372,7 +368,7 @@ <Details> <![CDATA[ <p>Looks for methods that build XML based strings by concatenation strings - and custom values together. Doing so makes brittle code, that is difficult to + and custom values together. Doing so makes brittle code, that is difficult to modify, validate and understand. It is cleaner to create external XML files that are transformed at runtime, using parameters set through Transformer.setParameter. <p>It is a fast detector</p> @@ -432,7 +428,7 @@ <![CDATA[ <p>Looks for methods that implement AWT or Swing listeners and perform time consuming operations. Doing these operations in the GUI thread will cause the - interface to appear sluggish and non-responsive to the user. It is better to + interface to appear sluggish and non-responsive to the user. It is better to use a separate thread to do the time consuming work so that the user has a better experience.</p> <p>It is a fast detector</p> @@ -443,7 +439,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessInstanceRetrieval"> <Details> <![CDATA[ - <p>Looks for methods that call a method to retrieve a reference to an object, + <p>Looks for methods that call a method to retrieve a reference to an object, to use to load a constant. It is simpler and more performant to access the static variable directly from the class itself.</p> <p>It is a fast detector</p> @@ -454,7 +450,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DateComparison"> <Details> <![CDATA[ - <p> Looks for inefficient comparison of Date objects using two comparisons when one would do.</p> + <p>Looks for inefficient comparison of Date objects using two comparisons when one would do.</p> <p>It is a fast detector</p> ]]> </Details> @@ -463,7 +459,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousWaitOnConcurrentObject"> <Details> <![CDATA[ - <p>Looks for calls to the wait method on mutexes defined in the java.util.concurrent + <p>Looks for calls to the wait method on mutexes defined in the java.util.concurrent package where it is likely that await was intended.</p> <p>It is a fast detector</p> ]]> @@ -483,8 +479,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat"> <Details> <![CDATA[ - <p>Looks for classes that maintain collections or StringBuffer/StringBuilders in - static member variables, and that do not appear to provide a way to clear or remove + <p>Looks for classes that maintain collections or StringBuffer/StringBuilders in + static member variables, and that do not appear to provide a way to clear or remove items from these members. Such class fields are likely causes of memory bloat.</p> <p>It is a fast detector</p> ]]> @@ -494,9 +490,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.LocalSynchronizedCollection"> <Details> <![CDATA[ - <p>Looks for allocations of synchronized collections that are stored in local - variables, and never stored in fields or returned from methods. As local variables - are by definition thread safe, using synchronized collections in this context + <p>Looks for allocations of synchronized collections that are stored in local + variables, and never stored in fields or returned from methods. As local variables + are by definition thread safe, using synchronized collections in this context makes no sense.</p> <p>It is a moderately fast detector</p> ]]> @@ -506,8 +502,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.FieldCouldBeLocal"> <Details> <![CDATA[ - <p>Looks for classes that define fields that are used in a locals only fashion, - specifically private fields that are accessed first in each method with a + <p>Looks for classes that define fields that are used in a locals only fashion, + specifically private fields that are accessed first in each method with a store vs. a load.</p> <p>It is a slow detector</p> ]]> @@ -530,7 +526,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonRecycleableTaglibs"> <Details> <![CDATA[ - <p>Looks for tag libraries that are not recycleable because backing members + <p>Looks for tag libraries that are not recycleable because backing members of taglib attributes are set in areas besides the setter method for the attribute.</p> <p>It is a fast detector</p> ]]> @@ -540,9 +536,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance"> <Details> <![CDATA[ - <p>Looks for violation of Section 508, Accessibility for People with disabilities Act. - </p> - <p>It is a fast detector</p> + <p>Looks for violation of Section 508, Accessibility for People with disabilities Act.</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -570,7 +565,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessMemberCollectionSynchronization"> <Details> <![CDATA[ - <p>Looks for classes that define private synchronized collections as static or instance + <p>Looks for classes that define private synchronized collections as static or instance members, that are only altered in a static initializer or constructor. Since the multithreaded use of this collection is read-only, the use of synchronization is unnecessary.</p> <p>It is a moderately fast detector</p> @@ -581,7 +576,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.InheritanceTypeChecking"> <Details> <![CDATA[ - <p>Looks for if/else blocks where a series of them use instanceof on the same + <p>Looks for if/else blocks where a series of them use instanceof on the same variable to determine what to do. If these classes are related by inheritance, this often is better handled through calling a single overridden method.</p> <p>It is a moderately fast detector</p> @@ -635,7 +630,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UseCharacterParameterizedMethod"> <Details> <![CDATA[ - <p>Looks for methods that pass single character string constants as parameters to + <p>Looks for methods that pass single character string constants as parameters to methods that alternatively have an overridden method that accepts a character instead. It is easier for the method to handle a single character than a String.</p> <p>It is a fast detector.</p> @@ -669,9 +664,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleIncompleteSerialization"> <Details> <![CDATA[ - <p>Looks for classes that don't handle serialization of parent class member fields - when the class in question is serializable but is derived from a non serializable - classes.</p> + <p>Looks for classes that don't handle serialization of parent class member fields + when the class in question is serializable but is derived from a non serializable + classes.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -681,7 +676,7 @@ <Details> <![CDATA[ <p>Looks for class that implement Comparator or Comparable, and whose compare or compareTo - methods return constant values only, but that don't represent the three possible choice + methods return constant values only, but that don't represent the three possible choice (a negative number, 0, and a positive number).</p> <p>It is a fast detector.</p> ]]> @@ -700,8 +695,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope"> <Details> <![CDATA[ - <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em> - Looks for assignments to variables in a scope larger than its use. As long as the evaluation of the assignment + <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> + <p>Looks for assignments to variables in a scope larger than its use. As long as the evaluation of the assignment does not have side effects, the assignment can be moved into the inner scope where it is used.</p> <p>It is a fast detector.</p> ]]> @@ -711,7 +706,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor"> <Details> <![CDATA[ - <p>Looks for classes that implement interfaces by relying on methods being + <p>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.</p> <p>It is a fast detector.</p> @@ -757,7 +752,7 @@ <Details> <![CDATA[ <p>Looks for loops that transfer the contents of one collection to another. These collection sources might - be local variables or member fields, including sets, maps key/values, lists, or arrays. It is simpler to + be local variables or member fields, including sets, maps key/values, lists, or arrays. It is simpler to just use the addAll method of the collection class. In the case where the source is an array, you can use Arrays.asList(array), and use that as the source to addAll.</p> <p>It is a fast detector.</p> @@ -769,7 +764,7 @@ <Details> <![CDATA[ <p>Looks for private or static methods that only return one constant value. Since there is no - chance for derived classes overriding this behavior, the return of a constant value + chance for derived classes overriding this behavior, the return of a constant value seems dubious.</p> <p>It is a fast detector</p> ]]> @@ -780,7 +775,7 @@ <Details> <![CDATA[ <p>Looks for classes that implement the Serializable interface and implement the - standard readObject and writeObject methods by simply deferring to the Stream + standard readObject and writeObject methods by simply deferring to the Stream parameter's defaultReadObject or defaultWriteObject and nothing else. As this is the built in behavior, these methods are not needed.</p> <p>It is a fast detector</p> @@ -818,12 +813,11 @@ <Details> <![CDATA[ <p>Looks for methods that return a parameter after modifying that parameter. - Doing this will confuse the user of this method, as it will be assumed that the + Doing this will confuse the user of this method, as it will be assumed that the passed in argument is different than the output, or at least won't be changed. If the purpose of this method is just to modify the parameter, this method should probably be changed to have a void return type. If you must return a variable, perhaps - a clone of the parameter should be returned. - </p> + a clone of the parameter should be returned.</p> <p>It is a fast detector</p> ]]> </Details> @@ -838,7 +832,7 @@ <li>Passing a constant as the second (actual) parameter</li> <li>not using the three parameter version of asserts for doubles</li> <li>Passing true or false as the first parameter instead of using assertTrue, or assertFalse</li> - <li>Using the assert keyword</li> + <li>Using the assert keyword</li> </ul> </p> <p>It is a fast detector</p> @@ -911,7 +905,7 @@ <p>Looks for sets or keySets of maps that contain other collections. As typically collections calculate their hashCode, equals and compareTo methods by iterating the collection and evaluating the same function on each item in the collection, this can be costly from a performance point of view.</p> - <p>In addition, using a set, or keySet of a map, infers that you will be looking for items based on + <p>In addition, using a set, or keySet of a map, infers that you will be looking for items based on the value of a collection, which seems dubious at best.</p> <p>Finally, as collections are often modified, this may cause problems if the collection is modified, thus changing hashCodes, etc, while the collection is in the set.</p> @@ -925,7 +919,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BogusExceptionDeclaration"> <Details> <![CDATA[ - <p>Looks for constructors, static methods and private methods that declare that they throw + <p>Looks for constructors, static methods and private methods that declare that they throw checked exceptions that the actual code never throws. Since these methods can't be overridden, there is no reason to add these exceptions to the method declaration.</p> <p>It is a moderately fast detector</p> @@ -948,7 +942,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DeprecatedTypesafeEnumPattern"> <Details> <![CDATA[ - <p>Looks for classes that appear to implement the old style type safe enum pattern + <p>Looks for classes that appear to implement the old style type safe enum pattern that was used before Java added Enum support to the language. Since this class is compiled with Java 1.5 or later, it would be simpler to just use Java enums.</p> <p>It is a fast detector</p> @@ -975,18 +969,18 @@ dubious. It would be better to just define a new enumeration with three values, and return that.</p> <p>It is a fast detector</p> - ]]> + ]]> </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousUninitializedArray"> <Details> <![CDATA[ - <p>Looks for methods that return arrays that are allocated but not initialized - in this method. While it's possible that the calling method will do the work of - initializing the array, it is not a usual pattern, and it is suspected that this array - was just forgotten to be initialized.</p> - <p>It is a fast detector</p> + <p>Looks for methods that return arrays that are allocated but not initialized + in this method. While it's possible that the calling method will do the work of + initializing the array, it is not a usual pattern, and it is suspected that this array + was just forgotten to be initialized.</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -994,10 +988,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.InappropriateToStringUse"> <Details> <![CDATA[ - <p>Looks for methods that perform algorithmic operations on Strings that are returned - from a toString() method. As toString should only be used for debug/trace purposes, it - shouldn't be used for algorithm use.</p> - <p>It is a fast detector</p> + <p>Looks for methods that perform algorithmic operations on Strings that are returned + from a toString() method. As toString should only be used for debug/trace purposes, it + shouldn't be used for algorithm use.</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -1005,9 +999,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.InconsistentKeyNameCasing"> <Details> <![CDATA[ - <p>Looks for methods that use the same name with different casing to access objects in HttpRequest parameters - and attributes. As these parameter names are case sensitive this will lead to confusion.</p> - <p>It is a fast detector</p> + <p>Looks for methods that use the same name with different casing to access objects in HttpRequest parameters + and attributes. As these parameter names are case sensitive this will lead to confusion.</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -1019,7 +1013,7 @@ to a class or interface higher up in the inheritance chain. You only need to cast to that class or interface.</p> <p>It is a fast detector</p> - ]]> + ]]> </Details> </Detector> @@ -1050,18 +1044,18 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment"> <Details> <![CDATA[ - <p>Finds contravariant array assignments. Since arrays are mutable data structures, their use + <p>Finds contravariant array assignments. Since arrays are mutable data structures, their use must be restricted to covariant or invariant usage.</p> - + <pre> - class A {} - class B extends A {} - - B[] b = new B[2]; - A[] a = b; - a[0] = new A(); // results in ArrayStoreException (Runtime) + class A {} + class B extends A {} + + B[] b = new B[2]; + A[] a = b; + a[0] = new A(); // results in ArrayStoreException (Runtime) </pre> - <p>It is a fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -1069,8 +1063,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField"> <Details> <![CDATA[ - <p>Looks for fields in serializable classes that are defined as both final and - transient. As a transient field is not initialized when streamed, and is not + <p>Looks for fields in serializable classes that are defined as both final and + transient. As a transient field is not initialized when streamed, and is not initialized in a constructor, it will remain null because it is defined final.</p> <p>It is a fast detector</p> ]]> @@ -1079,94 +1073,93 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousNullGuard"> <Details> - <![CDATA[ - <p>Looks for code that checks to see if a field or local variable is not null, - before entering a code block either an if, or while statement, and then reassigns that - field or local variable. It is likely that guard should have been to see if that + <![CDATA[ + <p>Looks for code that checks to see if a field or local variable is not null, + before entering a code block either an if, or while statement, and then reassigns that + field or local variable. It is likely that guard should have been to see if that field or local variable is null, not, not null.</p> - <p>It is a fast detector</p> - ]]> - </Details> + <p>It is a fast detector</p> + ]]> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.MoreDumbMethods"> <Details> - <![CDATA[ - <p>This detector looks for calls to more pointless or deprecated methods.</p> - <p>It is a fast detector</p> - ]]> - </Details> + <![CDATA[ + <p>This detector looks for calls to more pointless or deprecated methods.</p> + <p>It is a fast detector</p> + ]]> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionOnObjectMethods"> <Details> - <![CDATA[ - <p>This detector looks for reflective calls on methods that are found in the class java.lang.Object. - As these methods are always available, there is no reason to use reflection to call them. - </p> - <p>It is a fast detector</p> - ]]> - </Details> + <![CDATA[ + <p>This detector looks for reflective calls on methods that are found in the class java.lang.Object. + As these methods are always available, there is no reason to use reflection to call them.</p> + <p>It is a fast detector</p> + ]]> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.ImproperPropertiesUse"> <Details> - <![CDATA[ - <p>This detector looks for java.util.Properties use where values other than String - are placed in the properties object. As the Properties object was intended to be a - String to String only collection, putting other types in the Properties object is - incorrect, and takes advantage of a poor design decision by the original Properties class - designers to derive from Hashtable, rather than using aggregation.</p> - <p>It is a fast detector</p> - ]]> - </Details> + <![CDATA[ + <p>This detector looks for java.util.Properties use where values other than String + are placed in the properties object. As the Properties object was intended to be a + String to String only collection, putting other types in the Properties object is + incorrect, and takes advantage of a poor design decision by the original Properties class + designers to derive from Hashtable, rather than using aggregation.</p> + <p>It is a fast detector</p> + ]]> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleConstantAllocationInLoop"> <Details> - <![CDATA[ - <p>This detector looks for allocations of objects using the default constructor in a loop, where - the object allocated is never assigned to any object that is used outside the loop. - It is possible that this allocation can be done outside the loop to avoid excessive garbage.</p> - <p>It is a fast detector</p> - ]]> - </Details> + <![CDATA[ + <p>This detector looks for allocations of objects using the default constructor in a loop, where + the object allocated is never assigned to any object that is used outside the loop. + It is possible that this allocation can be done outside the loop to avoid excessive garbage.</p> + <p>It is a fast detector</p> + ]]> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.WriteOnlyCollection"> <Details> - <![CDATA[ + <![CDATA[ <p>This detector looks for allocations and initializations of Java collections, but that are never - read from or accessed to gain information. This represents a collection of no use, and most probably - can be removed. It is similar to a dead local store.</p> - <p>It is a fast detector</p> - ]]> - </Details> + read from or accessed to gain information. This represents a collection of no use, and most probably + can be removed. It is similar to a dead local store.</p> + <p>It is a fast detector</p> + ]]> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.UseVarArgs"> <Details> - <![CDATA[ - <p>This detector looks for definitions of methods that have an array as the last parameter. + <![CDATA[ + <p>This detector looks for definitions of methods that have an array as the last parameter. Since this class is compiled with Java 1.5 or better, it would be more flexible for clients of this method to define this parameter as a vararg parameter.</p> - <p>It is a fast detector</p> - ]]> - </Details> + <p>It is a fast detector</p> + ]]> + </Details> </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleUnsuspectedSerialization"> <Details> - <![CDATA[ - <p>This detector looks for code that serializes objects that are non-static inner - classes of other classes. Since there is a reference to the containing class, this class will be serialized as well. - It is often the case that this is not what is wanted, and will cause much more data to be serialized - than is necessary.</p> - <p>It is a fast detector</p> - ]]> - </Details> + <![CDATA[ + <p>This detector looks for code that serializes objects that are non-static inner + classes of other classes. Since there is a reference to the containing class, this class will be serialized as well. + It is often the case that this is not what is wanted, and will cause much more data to be serialized + than is necessary.</p> + <p>It is a fast detector</p> + ]]> + </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.SideEffectConstructor"> <Details> <![CDATA[ @@ -1177,7 +1170,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousGetterSetterUse"> <Details> <![CDATA[ @@ -1191,182 +1184,175 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects"> <Details> <![CDATA[ <p>This detector looks for creation of java.awt.Graphics object that do not have the - .dispose() method called on them when finished. These objects will be cleaned up by + .dispose() method called on them when finished. These objects will be cleaned up by the Garbage collector, bug given the likelyhood that large numbers of these objects can - be created in a short period of time, it is better to dispose them as soon as possible - </p> + be created in a short period of time, it is better to dispose them as soon as possible.</p> <p>It is a fast detector</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks"> <Details> <![CDATA[ - <p>This detector looks for two or more try catch blocks that are consecutive - and catch the same kind of exception, and each catch block mandatorily throws - the same exception. These two catch blocks can and should be made into one + <p>This detector looks for two or more try catch blocks that are consecutive + and catch the same kind of exception, and each catch block mandatorily throws + the same exception. These two catch blocks can and should be made into one catch block to simply the code.</p> <p>It is a fast detector</p> ]]> </Details> </Detector> - <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsEqualsBuilderToEquals"> - <Details> - <![CDATA[ - <p>This detector looks for uses for Commons-lang EqualsBuilder where the - result of equals() is returned instead of calling the method isEquals().</p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsHashcodeBuilderToHashcode"> - <Details> - <![CDATA[ - <p>This detector looks for uses for Commons-lang HashCodeBuilder where the - result of hashCode() is returned instead of calling the method toHashCode().</p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsStringBuilderToString"> - <Details> - <![CDATA[ - <p>This detector looks for uses for Commons-lang ToStringBuilder where the - result of toString() is returned without an intermediate invocation of toString().</p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.CompareClassNameEquals"> - <Details> - <![CDATA[ - <p> In a JVM, two classes are the same class (and consequently the same type) if - they are loaded by the same class loader, and they have the same fully - qualified name [JVMSpec 1999]. - - Comparing class name ignores the class loader. - </p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.BackportReusePublicIdentifiers"> - <Details> - <![CDATA[ - <p> Detects use of Backport Utils concurrent classes. Updated/Efficient version of these - classes are available in versions of the JDK 5.0 and higher, and these - classes should only be used if you are targeting JDK 1.4 and lower. - </p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability"> - <Details> - <![CDATA[ - <p> Looks for classes that implement clone() that do not specialize the return value, and do - not swallow CloneNotSupportedException. Not doing so makes the clone method not as simple to use, - and should be harmless to do so. - </p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList"> - <Details> - <![CDATA[ - <p> Looks for calls to Arrays.asList where the parameter is a primitive array. - This does not produce a list that holds the primitive boxed values, but a list of - one item, the array itself. - </p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections"> - <Details> - <![CDATA[ - <p> Looks for methods that create collections using the default constructor, - even though the number of elements that will be placed in the collection is known - apriori, and thus could be pre-allocated. Not doing so just causes more intermediate - reallocations which is unnecessary. - </p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.UnboundMethodTemplateParameter"> - <Details> - <![CDATA[ - <p> Looks for methods that declare method level template parameter(s) that are not bound to any of the - method's parameters, and thus is not adding any validation/type safety to the method, and is - just confusing. - </p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall"> - <Details> - <![CDATA[ - <p> Looks for common methods that are non mutating where the return value is ignored. As these methods - do not change the object they are called on, calling this methods is pointless. They can be removed. - </p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds"> - <Details> - <![CDATA[ - <p>Looks for questionable load/stores to array elements.<ul> - <li> - Looks for accesses to array elements using literal values that are known to be outside the bounds of the array. - This mistake will cause an ArrayIndexOutOfBoundsException to occur at runtime.</li> - <li> - Looks for stores to array elements where the array itself appears to have not been allocated. - </li> - </ul> - </p> - <p>It is a fast detector</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument"> - <Details> - <![CDATA[ - <p>Looks for method calls that take a parameter value that does not match one of the expected - values for that parameter. It is likely this parameter value should really be an enum, but predates - the additio... [truncated message content] |
From: <dbr...@us...> - 2013-11-17 21:58:03
|
Revision: 1757 http://sourceforge.net/p/fb-contrib/code/1757 Author: dbrosius Date: 2013-11-17 21:58:00 +0000 (Sun, 17 Nov 2013) Log Message: ----------- sync from git Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-11-17 21:50:52 UTC (rev 1756) +++ trunk/fb-contrib/etc/findbugs.xml 2013-11-17 21:58:00 UTC (rev 1757) @@ -15,6 +15,24 @@ <!-- Detectors --> +<!-- COMMENT OUT FOR RELEASE + + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> + + COMMENT OUT FOR RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering" speed="fast" reports="ISB_INEFFICIENT_STRING_BUFFERING,ISB_EMPTY_STRING_APPENDING,ISB_TOSTRING_APPENDING" /> @@ -130,8 +148,6 @@ <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" /> @@ -231,6 +247,12 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" /> <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument" speed="fast" reports="ICA_INVALID_CONSTANT_ARRAY" /> + + <!-- + <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> + --> <!-- BugPattern --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-11-17 21:50:54
|
Revision: 1756 http://sourceforge.net/p/fb-contrib/code/1756 Author: dbrosius Date: 2013-11-17 21:50:52 +0000 (Sun, 17 Nov 2013) Log Message: ----------- Version 5.0.0 Added Paths: ----------- tags/v5_0_0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-11-17 21:48:08
|
Revision: 1755 http://sourceforge.net/p/fb-contrib/code/1755 Author: dbrosius Date: 2013-11-17 21:48:02 +0000 (Sun, 17 Nov 2013) Log Message: ----------- prepare for the 5.0.0 release Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/AIOB_Sample.java trunk/fb-contrib/samples/JAO_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CompareClassNameEquals.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImproperPropertiesUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleUnsuspectedSerialization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpuriousThreadStates.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousClusteredSessionSupport.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousWaitOnConcurrentObject.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/TailRecursion.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/TristateBooleanPattern.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java Added Paths: ----------- trunk/fb-contrib/samples/ICA_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2013-10-20 02:34:16 UTC (rev 1754) +++ trunk/fb-contrib/.classpath 2013-11-17 21:48:02 UTC (rev 1755) @@ -11,7 +11,7 @@ <classpathentry kind="lib" path="samples/lib/commons-lang3-3.1.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> <classpathentry kind="lib" path="samples/lib/commons-collections-3.2.1.jar"/> - <classpathentry kind="lib" path="samples/lib/backport-util-concurrent-3.1.jar"/> + <classpathentry kind="lib" path="samples/lib/backport-util-concurrent-3.1.jar" sourcepath="/home/dave/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1-sources.jar"/> <classpathentry kind="lib" path="samples/lib/slf4j-api-1.7.5.jar"/> <classpathentry kind="lib" path="samples/lib/junit.jar"/> <classpathentry kind="output" path="classes"/> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2013-10-20 02:34:16 UTC (rev 1754) +++ trunk/fb-contrib/build.xml 2013-11-17 21:48:02 UTC (rev 1755) @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="4.8.5" /> + <property name="fb-contrib.version" value="5.0.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-10-20 02:34:16 UTC (rev 1754) +++ trunk/fb-contrib/etc/findbugs.xml 2013-11-17 21:48:02 UTC (rev 1755) @@ -130,6 +130,8 @@ <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" /> @@ -222,7 +224,14 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_MISMATCHED_RETURN,CU_CLONE_USABILITY_THROWS" /> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.UnboundMethodTemplateParameter" speed="fast" reports="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument" speed="fast" reports="ICA_INVALID_CONSTANT_ARRAY" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -414,4 +423,5 @@ <BugPattern abbrev="NPMC" type="NPMC_NON_PRODUCTIVE_METHOD_CALL" category="CORRECTNESS" /> <BugPattern abbrev="AIOB" type="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS" category="CORRECTNESS" /> <BugPattern abbrev="AIOB" type="AIOB_ARRAY_STORE_TO_NULL_REFERENCE" category="CORRECTNESS" /> + <BugPattern abbrev="ICA" type="ICA_INVALID_CONSTANT_ARGUMENT" category="CORRECTNESS" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2013-10-20 02:34:16 UTC (rev 1754) +++ trunk/fb-contrib/etc/messages.xml 2013-11-17 21:48:02 UTC (rev 1755) @@ -40,8 +40,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SyncCollectionIterators"> <Details> <![CDATA[ - <p> Looks for use of iterators on synchronized collections built from the java.util.Collections class</p> - <p> As the collection in question was built thru Collections.synchronizedXXX, an assumption + <p> Looks for use of iterators on synchronized collections built from the java.util.Collections class.</p> + <p> As the collection in question was built through Collections.synchronizedXXX, an assumption is made that this collection must be multithreaded safe. However, iterator access is used, which is explicitly unsafe. When iterators are to be used, synchronization should be done manually.</p> <p>It is a slow detector</p> @@ -84,10 +84,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents"> <Details> <![CDATA[ - <p> Looks for collections or arrays that hold objects that are unrelated thru class or + <p> Looks for collections or arrays that hold objects that are unrelated through class or interface inheritance other than java.lang.Object. Doing so makes for brittle code, relying either on positional correspondence for type, or a reliance on instanceof to - determine type. A better design usually can be had by creating a seperate class, + determine type. A better design usually can be had by creating a separate class, which defines the different types required, and add an instance of that class to the collection, or array.</p> <p>It is a fast detector</p> @@ -111,7 +111,7 @@ <Details> <![CDATA[ <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> - <p> Looks for methods that use a high percentage of methods from another class over it's own + <p> Looks for methods that use a high percentage of methods from another class over its own methods. When this is the case, it is often better to implement this method in that other class, by refactoring the class to accept parameters it needs from the source class. The reporting percentage can be set with system property 'fb-contrib.ce.percent'.</p> @@ -145,7 +145,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DubiousListCollection"> <Details> <![CDATA[ - <p> looks for fields that are implementations of java.util.List, but that are used in a set-like fashion. + <p> Looks for fields that are implementations of java.util.List, but that are used in a set-like fashion. Since lookup type operations are performed using a linear search for Lists, the performance for large Lists will be poor. Consideration should be made as to whether these fields should be sets. In the case that order is important, consider using LinkedHashSet.</p> @@ -170,7 +170,7 @@ <Details> <![CDATA[ <p>Looks for methods that correctly do not write to a parameter. To help document this, and to perhaps - help the jvm optimize the invocation of this method, you should consider defining these parameters + help the JVM optimize the invocation of this method, you should consider defining these parameters as final.</p> <p>It is a slow detector</p> ]]> @@ -247,7 +247,7 @@ <pre> public void test(Character c) </pre> - but instead maps to one that takes an int long, float or double. + but instead maps to one that takes an int, long, float or double. </p> <p>It is a fast detector</p> ]]> @@ -285,7 +285,7 @@ java.lang.Thread. Since the internal workings of the threads is to synchronize on the thread itself, introducing client calls will confuse the thread state of the object in question, and will cause spurious thread state changes, either waking threads up - when not intended, or removing the the thread from the runnable state.</p> + when not intended, or removing the thread from the runnable state.</p> <p>It is a fast detector</p> ]]> </Details> @@ -308,7 +308,7 @@ </ul> </p> <p>It also looks for calls to BoxedClass.valueOf(x) where X is already a Boxed class</p> - <p>It also looks for calls to BoxedClass.valueOf(myString).boxedValue(), When instead it is + <p>It also looks for calls to BoxedClass.valueOf(myString).boxedValue(), when instead it is simpler to use BoxedClass.parseBoxed(myString)</p> <p>It is a fast detector</p> ]]> @@ -319,7 +319,7 @@ <Details> <![CDATA[ <p>Looks for methods that store the return result in a local variable and - then immediately returns that local variable. It is simpler to just return + then immediately return that local variable. It is simpler to just return the method (or assignment) result directly.</p> <p>It is a fast detector</p> ]]> @@ -329,7 +329,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.CopiedOverriddenMethod"> <Details> <![CDATA[ - <p>Looks for methods that are direct copies of the implementation in the super class</p> + <p>Looks for methods that are direct copies of the implementation in the super class.</p> <p>It is a fast detector</p> ]]> </Details> @@ -371,9 +371,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML"> <Details> <![CDATA[ - <p>Looks for methods that build xml based strings by concatenation strings + <p>Looks for methods that build XML based strings by concatenation strings and custom values together. Doing so makes brittle code, that is difficult to - modify, validate and understand. It is cleaner to create external xml files that are + modify, validate and understand. It is cleaner to create external XML files that are transformed at runtime, using parameters set through Transformer.setParameter. <p>It is a fast detector</p> ]]> @@ -395,7 +395,7 @@ <Details> <![CDATA[ <p>Looks for methods that access arrays or classes that implement java.util.List - using a constant integer for the index. This is often a typo intented to be a loop + using a constant integer for the index. This is often a typo intended to be a loop variable, but if specific indices mean certain things, perhaps a first class object would be a better choice for a container.</p> <p>It is a fast detector</p> @@ -430,8 +430,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SluggishGui"> <Details> <![CDATA[ - <p>Looks for methods that implement awt or swing listeners and perform time - consuming operations. Doing these operations in the gui thread will cause the + <p>Looks for methods that implement AWT or Swing listeners and perform time + consuming operations. Doing these operations in the GUI thread will cause the interface to appear sluggish and non-responsive to the user. It is better to use a separate thread to do the time consuming work so that the user has a better experience.</p> @@ -473,7 +473,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.JDBCVendorReliance"> <Details> <![CDATA[ - <p>Looks for uses of jdbc vendor specific classes and methods making the database + <p>Looks for uses of JDBC vendor specific classes and methods making the database access code non portable.</p> <p>It is a fast detector</p> ]]> @@ -550,7 +550,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UseEnumCollections"> <Details> <![CDATA[ - <p>Looks for use of sets and maps using enums. It is more efficient to use EnumSet or EnumMap</p> + <p>Looks for use of sets and maps using enums. It is more efficient to use EnumSet or EnumMap.</p> <p>It is a fast detector</p> ]]> </Details> @@ -559,7 +559,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SQLInLoop"> <Details> <![CDATA[ - <p>Looks for the execution of sql queries inside a loop. This pattern tends to be inefficient, + <p>Looks for the execution of SQL queries inside a loop. This pattern tends to be inefficient, and often can be improved upon, by collecting all the keys needed for the query and issuing just one query using an in clause with all the keys for all the queries previously needed in the loop.</p> <p>It is a fast detector</p> @@ -594,7 +594,7 @@ <![CDATA[ <p>Looks for creation of arrays in methods using constant values. These arrays will need to be recreated each time the method is called. These arrays should probably - be defined as static fields, instead</p> + be defined as static fields, instead.</p> <p>It is a fast detector</p> ]]> </Details> @@ -659,7 +659,7 @@ <![CDATA[ <p>Looks for methods that are defined to return Object, and return different types of objects based on different code paths. If this method is not based on a interface or - superclass, it is suggested to change the return type to a type that would accomodate + superclass, it is suggested to change the return type to a type that would accommodate all kinds of return types.</p> <p>It is a fast detector.</p> ]]> @@ -701,7 +701,7 @@ <Details> <![CDATA[ <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em> - Looks for assignments to variables in a scope larger than it's use. As long as the evaluation of the assignment + Looks for assignments to variables in a scope larger than its use. As long as the evaluation of the assignment does not have side effects, the assignment can be moved into the inner scope where it is used.</p> <p>It is a fast detector.</p> ]]> @@ -747,7 +747,7 @@ <![CDATA[ <p>Looks for calls to classes and methods that do not exist in the JDK for which this class is compiled. This can happen if you specify the -source and -target options of the javac compiler, and - specify a target that is less than the jdk version of the javac compiler.</p> + specify a target that is less than the JDK version of the javac compiler.</p> <p>It is a slow detector.</p> ]]> </Details> @@ -756,7 +756,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UseAddAll"> <Details> <![CDATA[ - <p>Looks for loops that transfers the contents of one collection to another. These collection sources might + <p>Looks for loops that transfer the contents of one collection to another. These collection sources might be local variables or member fields, including sets, maps key/values, lists, or arrays. It is simpler to just use the addAll method of the collection class. In the case where the source is an array, you can use Arrays.asList(array), and use that as the source to addAll.</p> @@ -807,7 +807,7 @@ concerning are methods constrained by interface or super class contracts not to throw checked exceptions but appear owned by the same author. Next are methods constrained by interface or super class contracts and throw other - types of checked exceptions. Most egregious are method not constrained by any interface + types of checked exceptions. Most egregious are methods not constrained by any interface or superclass contract.</p> <p>It is a moderately fast detector</p> ]]> @@ -882,7 +882,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities"> <Details> <![CDATA[ - <p>Looks for odd patterns of use of Logger classes from either log4j, slf4j or commons logging.</p> + <p>Looks for odd patterns of use of Logger classes from either log4j, SLF4j or commons logging.</p> <p>It is a fast detector</p> ]]> </Details> @@ -891,8 +891,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse"> <Details> <![CDATA[ - <p>Looks for classes that rely on internal classes in the various apis or libraries. As these - classes are not officially released from the api vendor, they are subject to change or removal, and thus, + <p>Looks for classes that rely on internal classes in the various APIs or libraries. As these + classes are not officially released from the API vendor, they are subject to change or removal, and thus, should not be counted on.</p> Packages that shouldn't be used are: <ul> @@ -913,10 +913,10 @@ on each item in the collection, this can be costly from a performance point of view.</p> <p>In addition, using a set, or keySet of a map, infers that you will be looking for items based on the value of a collection, which seems dubious at best.</p> - <p>Finally, as collections are often modified, This may cause problems if the collection is modified, + <p>Finally, as collections are often modified, this may cause problems if the collection is modified, thus changing hashCodes, etc, while the collection is in the set.</p> <p>If you wish to keep a collection of collections, the outer collection should probably be a list - to avoid these problems</p> + to avoid these problems.</p> <p>It is a moderately fast detector</p> ]]> </Details> @@ -937,9 +937,9 @@ <Details> <![CDATA[ <p>Looks for allocations of objects, and then immediately checking to see if the - object is null, or non null. As the new operator is guaranteed to eiher succeed, or throw + object is null, or non null. As the new operator is guaranteed to either succeed, or throw an exception, this null check is useless, and denotes a misunderstanding as to how - the jvm works. You can remove this guard.</p> + the JVM works. You can remove this guard.</p> <p>It is a fast detector</p> ]]> </Details> @@ -949,8 +949,8 @@ <Details> <![CDATA[ <p>Looks for classes that appear to implement the old style type safe enum pattern - that was used before java added Enum support to the language. Since this class is - compiled with java 1.5 or later, it would be simpler to just use java enums</p> + that was used before Java added Enum support to the language. Since this class is + compiled with Java 1.5 or later, it would be simpler to just use Java enums.</p> <p>It is a fast detector</p> ]]> </Details> @@ -984,7 +984,7 @@ <![CDATA[ <p>Looks for methods that return arrays that are allocated but not initialized in this method. While it's possible that the calling method will do the work of - initializing the array, it is not a usual pattern, and it suspected that this array + initializing the array, it is not a usual pattern, and it is suspected that this array was just forgotten to be initialized.</p> <p>It is a fast detector</p> ]]> @@ -1051,7 +1051,7 @@ <Details> <![CDATA[ <p>Finds contravariant array assignments. Since arrays are mutable data structures, their use - must be restricted to covariant or invariant usage</p> + must be restricted to covariant or invariant usage.</p> <pre> class A {} @@ -1083,7 +1083,7 @@ <p>Looks for code that checks to see if a field or local variable is not null, before entering a code block either an if, or while statement, and then reassigns that field or local variable. It is likely that guard should have been to see if that - field or local variable is null, not, not null</p> + field or local variable is null, not, not null.</p> <p>It is a fast detector</p> ]]> </Details> @@ -1136,7 +1136,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.WriteOnlyCollection"> <Details> <![CDATA[ - <p>This detector looks for allocations and initializations of java collections, but that are never + <p>This detector looks for allocations and initializations of Java collections, but that are never read from or accessed to gain information. This represents a collection of no use, and most probably can be removed. It is similar to a dead local store.</p> <p>It is a fast detector</p> @@ -1148,8 +1148,8 @@ <Details> <![CDATA[ <p>This detector looks for definitions of methods that have an array as the last parameter. - Since this class is compiled with java 1.5 or better, it would be more flexible for clients of this - method to define this parameter as a vararg parameter</p> + Since this class is compiled with Java 1.5 or better, it would be more flexible for clients of this + method to define this parameter as a vararg parameter.</p> <p>It is a fast detector</p> ]]> </Details> @@ -1181,7 +1181,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousGetterSetterUse"> <Details> <![CDATA[ - <p>This detector looks for java bean getter-setter use where the value of a property is set + <p>This detector looks for Java bean getter-setter use where the value of a property is set with the value retrieved from the same bean's correllary getter, like this:</p> <pre> person.setAge(person.getAge()); @@ -1250,7 +1250,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.CompareClassNameEquals"> <Details> <![CDATA[ - <p> In a JVM, Two classes are the same class (and consequently the same type) if + <p> In a JVM, two classes are the same class (and consequently the same type) if they are loaded by the same class loader, and they have the same fully qualified name [JVMSpec 1999]. @@ -1350,6 +1350,19 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument"> + <Details> + <![CDATA[ + <p>Looks for method calls that take a parameter value that does not match one of the expected + values for that parameter. It is likely this parameter value should really be an enum, but predates + the addition of enums to java. Passing an invalid value will likely cause problems in the execution of + the method. + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> </Detector> @@ -1434,8 +1447,8 @@ <LongDescription>Method {1} uses integer based for loops to iterate over a List</LongDescription> <Details> <![CDATA[ - <p>This method uses an integer based for loop to iterator over a java.util.List, by calling - List.get(i) each time thru the loop. The integer is not used for other reasons. It is better + <p>This method uses an integer based for loop to iterate over a java.util.List, by calling + List.get(i) each time through the loop. The integer is not used for other reasons. It is better to use an Iterator instead, as depending on List implementation, iterators can perform better, and they also allow for exchanging of other collection types without issue.</p> ]]> @@ -1459,10 +1472,10 @@ <LongDescription>Method {1} declares RuntimeException in throws clause</LongDescription> <Details> <![CDATA[ - <p>This method declares a RuntimeException derived class in it's throws clause. + <p>This method declares a RuntimeException derived class in its throws clause. This may indicate a misunderstanding as to how unchecked exceptions are handled. If is felt that a RuntimeException is so prevalent that it should be declared, it - is probably a better idea to prevent the occurance in code.</p> + is probably a better idea to prevent the occurrence in code.</p> ]]> </Details> </BugPattern> @@ -1473,7 +1486,7 @@ <Details> <![CDATA[ <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> - <p>This method makes extensive use of methods from another class over methods of it's own + <p>This method makes extensive use of methods from another class over methods of its own class. Typically this means that the functionality that is accomplished by this method most likely belongs with the class that is being used so liberally. Consider refactoring this method to be contained in that class, and to accept all the parameters needed in the method signature.</p> @@ -1498,7 +1511,7 @@ <LongDescription>Constructor {1} makes call to non-final method</LongDescription> <Details> <![CDATA[ - <p>This constructor makes a call to a non-final method. Since this method can be overriden, a subclasses + <p>This constructor makes a call to a non-final method. Since this method can be overridden, a subclasses implementation will be executing against an object that has not been initialized at the subclass level. You should mark all methods called from the constructor as final to avoid this problem.</p> ]]> @@ -1537,7 +1550,7 @@ <Details> <![CDATA[ <p>This method correctly does not write to a parameter. To help document this, and to perhaps - help the jvm optimize the invocation of this method, you should consider defining these parameters + help the JVM optimize the invocation of this method, you should consider defining these parameters as final.</p> ]]> </Details> @@ -1636,7 +1649,7 @@ <![CDATA[ <p>This method invokes the methods wait, notify or notifyAll on a Thread instance. Doing so will confuse the internal thread state behaviour causing spurious thread - wakeups/sleeps because the internal mechanism also uses the thread instance for it's + wakeups/sleeps because the internal mechanism also uses the thread instance for its notifications. </p> ]]> @@ -1732,7 +1745,7 @@ <Details> <![CDATA[ <p>This method constructs a Boxed Primitive from a primitive only to call the primitiveValue() method to - cast the value to another primitive typee. It is simpler to just use casting</p> + cast the value to another primitive type. It is simpler to just use casting</p> <pre> primitive i = new BoxedPrimitive(1.0).primitiveValue(); or @@ -1779,11 +1792,11 @@ </BugPattern> <BugPattern type="COM_COPIED_OVERRIDDEN_METHOD"> - <ShortDescription>Method is implemented with an exact copy of it's superclass's method</ShortDescription> - <LongDescription>Method {1} is implemented with an exact copy of it's superclass's method</LongDescription> + <ShortDescription>Method is implemented with an exact copy of its superclass's method</ShortDescription> + <LongDescription>Method {1} is implemented with an exact copy of its superclass's method</LongDescription> <Details> <![CDATA[ - <p>This method is implemented using an exact copy of it's super class method's + <p>This method is implemented using an exact copy of its super class method's implementation, which usually means that this method can just be removed. </p> ]]> @@ -1829,14 +1842,14 @@ </BugPattern> <BugPattern type="CBX_CUSTOM_BUILT_XML"> - <ShortDescription>Method builds xml strings through adhoc concatenation</ShortDescription> - <LongDescription>Method {1} builds xml strings through adhoc concatenation</LongDescription> + <ShortDescription>Method builds XML strings through adhoc concatenation</ShortDescription> + <LongDescription>Method {1} builds XML strings through adhoc concatenation</LongDescription> <Details> <![CDATA[ - <p>This method generates an xml based string by concatenating together various - xml fragments, and variable values. Doing so makes the code difficult to read, modify - and validate. It is much more clean to built xml structures in external files that are - read in and transformed into the final product, thru modification by Transformer.setParameter. + <p>This method generates an XML based string by concatenating together various + XML fragments, and variable values. Doing so makes the code difficult to read, modify + and validate. It is much more clean to built XML structures in external files that are + read in and transformed into the final product, through modification by Transformer.setParameter. </p> ]]> </Details> @@ -1895,12 +1908,12 @@ </BugPattern> <BugPattern type="SG_SLUGGISH_GUI"> - <ShortDescription>Method performs time consuming operation in gui thread</ShortDescription> - <LongDescription>Method {1} performs time consuming operation in gui thread</LongDescription> + <ShortDescription>Method performs time consuming operation in GUI thread</ShortDescription> + <LongDescription>Method {1} performs time consuming operation in GUI thread</LongDescription> <Details> <![CDATA[ - <p>This method implements an awt or swing listener and performs time - consuming operations. Doing these operations in the gui thread will cause the + <p>This method implements an AWT or Swing listener and performs time + consuming operations. Doing these operations in the GUI thread will cause the interface to appear sluggish and non-responsive to the user. Consider using a separate thread to do the time consuming work so that the user has a better experience.</p> @@ -1926,7 +1939,7 @@ <Details> <![CDATA[ <p>This method compares dates with two comparisons, rather than using the reverse comparison. - So This pattern + So this pattern <pre> if ((date1.equals( date2 )) || (date1.after( date2 ))) </pre> @@ -1967,11 +1980,11 @@ </BugPattern> <BugPattern type="JVR_JDBC_VENDOR_RELIANCE"> - <ShortDescription>Method uses jdbc vendor specific classes and methods</ShortDescription> - <LongDescription>Method {1} uses jdbc vendor specific classes and methods</LongDescription> + <ShortDescription>Method uses JDBC vendor specific classes and methods</ShortDescription> + <LongDescription>Method {1} uses JDBC vendor specific classes and methods</LongDescription> <Details> <![CDATA[ - <p>This method uses jdbc vendor specific classes and method to perform database work. + <p>This method uses JDBC vendor specific classes and method to perform database work. This makes the code specific to this vendor, and unable to run on other databases.</p> ]]> </Details> @@ -2042,7 +2055,7 @@ <LongDescription>Tag library {0} is not recycleable</LongDescription> <Details> <![CDATA[ - <p>This Tag library class implements an attribute who's associated backing store field + <p>This tag library class implements an attribute who's associated backing store field is modified at another point in the tag library. In order for a taglibrary to be recycleable, only the container is allowed to change this attribute, through the use of the setXXX method of the taglib. By modifying the value programmatically, the @@ -2052,13 +2065,13 @@ </BugPattern> <BugPattern type="S508C_NULL_LAYOUT"> - <ShortDescription>Gui uses absolute layout</ShortDescription> - <LongDescription>Gui {0} uses absolute layout</LongDescription> + <ShortDescription>GUI uses absolute layout</ShortDescription> + <LongDescription>GUI {0} uses absolute layout</LongDescription> <Details> <![CDATA[ <p>This class passes null to setLayout, which specifies that components are to be laid out using absolute coordinates. This makes making changes for - font sizes, etc, difficult as items will not reposition + font sizes, etc, difficult as items will not reposition. </p> ]]> </Details> @@ -2094,9 +2107,9 @@ <LongDescription>Class {0} extends JComponent but does not implement Accessible interface</LongDescription> <Details> <![CDATA[ - <p>This class extends the JComponent gui control but does not implement the Accessibility interface. + <p>This class extends the JComponent GUI control but does not implement the Accessibility interface. This makes this control unable to be processed by screen readers, etc, for people with reading/vision - difficulties</p> + difficulties.</p> ]]> </Details> </BugPattern> @@ -2143,17 +2156,17 @@ <Details> <![CDATA[ <p>This class uses an ordinary set or map collection and uses an enum class as the key type. - It is better performant to use the jdk 1.5 EnumSet or EnumMap classes.</p> + It is better performant to use the JDK 1.5 EnumSet or EnumMap classes.</p> ]]> </Details> </BugPattern> <BugPattern type="SIL_SQL_IN_LOOP"> - <ShortDescription>Method executes sql queries inside of loops</ShortDescription> - <LongDescription>Method {1} executes sql queries inside of loops</LongDescription> + <ShortDescription>Method executes SQL queries inside of loops</ShortDescription> + <LongDescription>Method {1} executes SQL queries inside of loops</LongDescription> <Details> <![CDATA[ - <p>This method executes sql queries inside of a loop. This pattern is often inefficient + <p>This method executes SQL queries inside of a loop. This pattern is often inefficient as the number of queries may mushroom in fencepost cases. It is probably more performant to loop over the input and collect the key data needed for the query for all items, and issue one query using an in clause, or similar construct, and then loop over this result @@ -2222,7 +2235,7 @@ <p>This method manually loops over a collection, pulling each element out and storing it in an array to build an array from the collection. It is easier, and clearer to use the built in collections method toArray. Given a collection 'mycollection' of type T, use - mycollection.toArray(new T[mycollection.size()]); + mycollection.toArray(new T[mycollection.size()]);</p> ]]> </Details> </BugPattern> @@ -2311,7 +2324,7 @@ because this class does not take the responsibility of writing these fields out either using Serializable's writeObject method, or Externalizable's writeExternal method. Therefore when this class is read from a stream, the superclass fields - will only be initialized to the values specified in it's default constructor. + will only be initialized to the values specified in its default constructor. If possible, change the superclass to implement Serializable, or implement Serializable or Externalizable methods in the child class.</p> ]]> @@ -2347,7 +2360,7 @@ <Details> <![CDATA[ <p>This method calls intern on a constant string. As constant strings are already interned, this call - is superfluous</p> + is superfluous.</p> ]]> </Details> </BugPattern> @@ -2393,7 +2406,7 @@ <LongDescription>Method {1} compares a double to Double.NAN</LongDescription> <Details> <![CDATA[ - <p>This method compares a douhle or float to the constant Double.NaN or Float.NaN. You should use + <p>This method compares a double or float to the constant Double.NaN or Float.NaN. You should use Double.isNaN(d) or Float.isNaN(f) if a primitive; or d.isNaN() or f.isNaN() if a boxed double, instead.</p> ]]> </Details> @@ -2416,7 +2429,7 @@ <LongDescription>Method {1} passes empty string to StringBuffer of StringBuilder constructor</LongDescription> <Details> <![CDATA[ - <p>This method calls the StringBuffer of StringBuilder constructor passing in a constant empty string (""). + <p>This method calls the StringBuffer or StringBuilder constructor passing in a constant empty string (""). This is the same as calling the default constructor, but makes the code work harder. Consider passing in a default size instead. ]]> @@ -2440,12 +2453,14 @@ <LongDescription>Method {1} uses invalid C++ style null check on Boolean</LongDescription> <Details> <![CDATA[ - <p>This method attempts to check for null by just refering to the variable name + <p>This method attempts to check for null by just referring to the variable name as would be done in C++. This ordinarily would be considered a compile error, except the variable in question is a Boolean, which does an auto unbox to boolean.</p> <pre> if (b && b.booleanValue()) + </pre> should be + <pre> if ((b != null) && b.booleanValue()) </pre> ]]> @@ -2470,7 +2485,7 @@ <Details> <![CDATA[ <p>This method tests the value of a boolean and using a ternary operator to return either true or false. - The ternary operator is completely unecessary, just use the original boolean value.</p> + The ternary operator is completely unnecessary, just use the original boolean value.</p> ]]> </Details> </BugPattern> @@ -2494,8 +2509,8 @@ </BugPattern> <BugPattern type="SPP_USE_STRINGBUILDER_LENGTH"> - <ShortDescription>Method converts StringBuffer or Builder to String just to get it's length</ShortDescription> - <LongDescription>Method {1} converts StringBuffer or Builder to String just to get it's length</LongDescription> + <ShortDescription>Method converts StringBuffer or Builder to String just to get its length</ShortDescription> + <LongDescription>Method {1} converts StringBuffer or Builder to String just to get its length</LongDescription> <Details> <![CDATA[ <p>This method calls the toString method on a StringBuffer or StringBuilder only to call length() on the resulting @@ -2512,7 +2527,7 @@ <![CDATA[ <p>This method passes a non calendar object to the java.util.Calendar.after or java.util.Calendar.before methods. Even though these methods take an Object as a parameter type, only Calendar type objects are supported, otherwise - false is returned</p> + false is returned.</p> ]]> </Details> </BugPattern> @@ -2522,7 +2537,7 @@ <LongDescription>Method {1} calls keySet() just to call contains, use containsKey instead</LongDescription> <Details> <![CDATA[ - <p>This method calls mySet.keySet().contains("foo") when mySet.containsKey("foo") is simpler</p> + <p>This method calls mySet.keySet().contains("foo") when mySet.containsKey("foo") is simpler.</p> ]]> </Details> </BugPattern> @@ -2533,7 +2548,7 @@ <Details> <![CDATA[ <p>This method calls the size() method on a collection and compares the result to zero to see if the collection - is empty. For better code clarity, it is better to just use col.isEmpty() or !col.isEmpty()</p> + is empty. For better code clarity, it is better to just use col.isEmpty() or !col.isEmpty().</p> ]]> </Details> </BugPattern> @@ -2607,8 +2622,8 @@ <Details> <![CDATA[ This method calls trim() on a String without assigning the new string to another variable. - It then calls length() or equals on this trimmed string. If trimming the string was important - for determining it's length of it's equality, it should be trimmed when you actually go to use it. + It then calls length() or equals() on this trimmed string. If trimming the string was important + for determining its length or its equality, it should be trimmed when you actually go to use it. It would make more sense to first trim the String, store the trimmed value in a variable, and then continue to test and use that trimmed string. ]]> @@ -2710,7 +2725,7 @@ <LongDescription>Method {1} modifies collection element while iterating</LongDescription> <Details> <![CDATA[ - <p>This method modifies the contents of a collection using the collection api methods, while + <p>This method modifies the contents of a collection using the collection API methods, while at the same time iterating across the collection. Doing this will invalidate the iterator, and further use of it, will cause ConcurrentModificationExceptions to be thrown. </p> @@ -2723,7 +2738,7 @@ <LongDescription>Method {1} builds String array using String Tokenizing</LongDescription> <Details> <![CDATA[ - <p>This method uses a StringTokenizer to split up a String and then walks thru the + <p>This method uses a StringTokenizer to split up a String and then walks through the separated elements and builds an array from these enumerated values. It is simpler and easier to use the String.split method.</p> <p>PLEASE NOTE: String.split will return an array of 1 element when passed the @@ -2743,7 +2758,7 @@ <LongDescription>Method {1} uses rt.jar class or method that does not exist for the version the class is compiled for</LongDescription> <Details> <![CDATA[ - <p>This method calls a method that does not exist, on a class that does not exist in the jdk that + <p>This method calls a method that does not exist, on a class that does not exist in the JDK that this class has been compiled for. This can happen if you compile the class specifying the -source and -target options, and use a version that is before the version of the compiler's JDK.</p> ]]> @@ -2758,7 +2773,7 @@ <p>This method uses a simple for loop to copy the contents of a set, list, map key/value, array or other collection to another collection. It is simpler and more straight forward to just call the addAll method of the destination collection passing in the source collection. In the case that the source is an array, you can use Array.asList method to massage the array - into a collection</p> + into a collection.</p> ]]> </Details> </BugPattern> @@ -2769,7 +2784,7 @@ <Details> <![CDATA[ <p>This private or static method only returns one constant value. As this method is private or static, - it's behavior can't be overridden, and thus the return of a constant value seems dubious. + its behavior can't be overridden, and thus the return of a constant value seems dubious. Either the method should be changed to return no value, or perhaps another return value was expected to be returned in another code path in this method.</p> ]]> @@ -2805,7 +2820,7 @@ <![CDATA[ <p>This method is not constrained by an interface or superclass, but converts a caught checked exception to unchecked exception and thrown. It would be more appropriate just throw the checked exception, adding - the exception to the throws clause of the method. + the exception to the throws clause of the method.</p> ]]> </Details> </BugPattern> @@ -2898,11 +2913,11 @@ </BugPattern> <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED"> - <ShortDescription>Method uses java asserts rather than a junit assertion</ShortDescription> - <LongDescription>Method {1} uses java asserts rather than a junit assertion</LongDescription> + <ShortDescription>Method uses Java asserts rather than a junit assertion</ShortDescription> + <LongDescription>Method {1} uses Java asserts rather than a junit assertion</LongDescription> <Details> <![CDATA[ - <p>This method uses a java assert to assure that a certain state is in effect. As this is + <p>This method uses a Java assert to assure that a certain state is in effect. As this is a junit test it makes more sense to either check this condition with a junit assert, or allow a following exception to occur.</p> ]]> @@ -3015,7 +3030,7 @@ <Details> <![CDATA[ This method attempts to use an SLF4J logger to log a parameterized expression using formatting anchors. - However, slf4j uses simple non numbered anchors such as {}, rather than anchors with digits in them as the + However, SLF4j uses simple non numbered anchors such as {}, rather than anchors with digits in them as the code uses. Thus no parameter replacement will occur. ]]> </Details> @@ -3026,19 +3041,19 @@ <LongDescription>Method {1} passes an incorrect number of parameters to an SLF4J logging statement</LongDescription> <Details> <![CDATA[ - This method passes the wrong number of parameters to a slf4j logging method (error, warn, info, debug) based on the number of anchors {} in the + This method passes the wrong number of parameters to a SLF4j logging method (error, warn, info, debug) based on the number of anchors {} in the format string. An additional exception argument is allowed if found. ]]> </Details> </BugPattern> <BugPattern type="IICU_INCORRECT_INTERNAL_CLASS_USE"> - <ShortDescription>Class relies on internal api classes</ShortDescription> - <LongDescription>Class {0} relies on internal api classes</LongDescription> + <ShortDescription>Class relies on internal API classes</ShortDescription> + <LongDescription>Class {0} relies on internal API classes</LongDescription> <Details> <![CDATA[ - <p>This class makes use of internal api classes. As these - classes are not documented, nor externally released as part of the api, they are subject + <p>This class makes use of internal API classes. As these + classes are not documented, nor externally released as part of the API, they are subject to change or removal. You should not be using these classes.</p> Packages that shouldn't be used are: <ul> @@ -3089,7 +3104,7 @@ <![CDATA[ <p>This method allocations an object with new, and then checks that the object is null or non null. As the new operator is guaranteed to either succeed or throw an exception, - this null check is unnecessary and can be removed. + this null check is unnecessary and can be removed.</p> ]]> </Details> </BugPattern> @@ -3100,7 +3115,7 @@ <Details> <![CDATA[ <p>This class appears to implement the old style type safe enum pattern that was used in place of - real enums. Since this class is compiled with java 1.5 or better, it would be simpler and more + real enums. Since this class is compiled with Java 1.5 or better, it would be simpler and more easy to understand if it was just switched over to an enum.</p> ]]> </Details> @@ -3152,7 +3167,7 @@ <Details> <![CDATA[ <p>This method calls algorithmic operations on a String that was returned from a toString() method. - As these methods are for debugging/logging purposes, it shouldn't be the basis of core logic in your code. + As these methods are for debugging/logging purposes, it shouldn't be the basis of core logic in your code.</p> ]]> </Details> </BugPattern> @@ -3162,8 +3177,8 @@ <LongDescription>Method {1} uses the same HttpSession attribute name but with different casing</LongDescription> <Details> <![CDATA[ - <p>This method sets or gets an HttpSession attribute with a parmeter name that was used in other locations - but with a different casing. As HttpSession attribute are case sensitive, this will be very confusing. + <p>This method sets or gets an HttpSession attribute with a parameter name that was used in other locations + but with a different casing. As HttpSession attribute are case sensitive, this will be very confusing.</p> ]]> </Details> </BugPattern> @@ -3174,7 +3189,7 @@ <Details> <![CDATA[ <p>This method fetches an HttpServletRequest parameter with a parameter name that was used in other locations - but with a different casing. As HttpServletRequest parameters are case sensitive, this will be very confusing. + but with a different casing. As HttpServletRequest parameters are case sensitive, this will be very confusing.</p> ]]> </Details> </BugPattern> @@ -3186,7 +3201,7 @@ <![CDATA[ <p>This method casts the right hand side of an expression to a class that is more specific than the variable on the left hand side of the assignment. The cast only has to be as specific as what the variable - that is on the left. Using a more specific type on the right hand side just increases cohesion. + that is on the left. Using a more specific type on the right hand side just increases cohesion.</p> ]]> </Details> </BugPattern> @@ -3198,7 +3213,7 @@ <![CDATA[ <p>This method defines parameters at a more abstract level than is actually needed to function correctly, as the code casts these parameters to more concrete types. Since this method is not derivable, you should - just define the parameters with the type that is needed. + just define the parameters with the type that is needed.</p> ]]> </Details> </BugPattern> @@ -3223,7 +3238,7 @@ <Details> <![CDATA[ <p>This method contains a contravariant array assignment. Since arrays are mutable data structures, their use - must be restricted to covariant or invariant usage</p> + must be restricted to covariant or invariant usage.</p> <pre> class A {} @@ -3242,7 +3257,7 @@ <Details> <![CDATA[ <p>This method contains a contravariant array element assignment. Since arrays are mutable - data structures, their use must be restricted to covariant or invariant usage</p> + data structures, their use must be restricted to covariant or invariant usage.</p> <pre> class A {} @@ -3408,7 +3423,7 @@ <LongDescription>Method {1} calls Condition.signal() rather than Condition.signalAll()</LongDescription> <Details> <![CDATA[ - <p><code>Condition.signalAll()</code> is prefered over <code>Condition.signal()</code>. Calling <code>signal()</code> only wakes up one thread, meaning that the thread woken up might not be the one waiting for the condition that the caller just satisfied.</p> + <p><code>Condition.signalAll()</code> is preferred over <code>Condition.signal()</code>. Calling <code>signal()</code> only wakes up one thread, meaning that the thread woken up might not be the one waiting for the condition that the caller just satisfied.</p> ]]> </Details> </BugPattern> @@ -3450,7 +3465,7 @@ <![CDATA[ <p>This method uses reflection to call a method that is defined in java.lang.Object. As these methods are always available, it is not necessary to call these methods with - reflection. + reflection.</p> ]]> </Details> </BugPattern> @@ -3461,10 +3476,10 @@ <Details> <![CDATA[ <p>This method places non-String objects into a Properties object. As the Properties object - is intented to be a String to String map, putting non String objects is wrong, and takes advantage + is intended to be a String to String map, putting non String objects is wrong, and takes advantage of a design flaw in the Properties class by deriving from Hashtable instead of using aggregation. If you want a collection that holds other types of objects, use a Hashtable, or better still newer collections - like HashMap or TreeMap. + like HashMap or TreeMap.</p> ]]> </Details> </BugPattern> @@ -3476,7 +3491,7 @@ <![CDATA[ <p>This method uses the inherited method from Hashtable put(String key, Object value) in a Properties object. Since the Properties object was intended to be only a String to String - map, use of the derived put method is discouraged. Use the Properties.setProperty method instead. + map, use of the derived put method is discouraged. Use the Properties.setProperty method instead.</p> ]]> </Details> </BugPattern> @@ -3490,7 +3505,7 @@ only uses it in a quasi-static way. It is never assigned to anything that lives outside the loop, and could potentially be allocated once outside the loop. Often this can be achieved by calling a clear() like method in the loop, to reset the state of the object - in the loop. + in the loop.</p> ]]> </Details> </BugPattern> @@ -3502,7 +3517,7 @@ <![CDATA[ <p>This method creates and initializes a collection but then never access this collection to gain information, or fetch items from the collection. It is likely that this collection - is left over from a past effort, and can be removed. + is left over from a past effort, and can be removed.</p> ]]> </Details> </BugPattern> @@ -3514,7 +3529,7 @@ <![CDATA[ <p>This class creates and initializes a collection as a field but then never access this collection to gain information, or fetch items from the collection. It is likely that this collection - is left over from a past effort, and can be removed. + is left over from a past effort, and can be removed.</p> ]]> </Details> </BugPattern> @@ -3526,7 +3541,7 @@ <![CDATA[ <p>This method defines a parameter list that ends with an array. As this class is compiled with Java 1.5 or better, this parameter could be defined as a vararg parameter instead, which can be - more convienent for client developers to use. This is not a bug, per se, just an improvement. + more convenient for client developers to use. This is not a bug, per se, just an improvement.</p> ]]> </Details> </BugPattern> @@ -3540,7 +3555,7 @@ reference to the containing class, this outer class will be serialized as well. This is often not intentional, and will make the amount of data that is serialized much more than is needed. If the outer classes is not desired to be serialized, either make the inner class s... [truncated message content] |
From: <dbr...@us...> - 2013-10-20 02:34:18
|
Revision: 1754 http://sourceforge.net/p/fb-contrib/code/1754 Author: dbrosius Date: 2013-10-20 02:34:16 +0000 (Sun, 20 Oct 2013) Log Message: ----------- Version 4.8.5 Added Paths: ----------- tags/v4_8_5/trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-10-20 02:31:15
|
Revision: 1753 http://sourceforge.net/p/fb-contrib/code/1753 Author: dbrosius Date: 2013-10-20 02:31:11 +0000 (Sun, 20 Oct 2013) Log Message: ----------- Final v4.8.5 changes Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-10-19 23:52:01 UTC (rev 1752) +++ trunk/fb-contrib/etc/findbugs.xml 2013-10-20 02:31:11 UTC (rev 1753) @@ -16,25 +16,7 @@ <!-- Detectors --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> - -<!-- PERMANENTLY DISABLED - <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> ---> -<!-- COMMENT OUT FOR RELEASE --> - - <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" /> - - <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> - - <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> - - <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> - - <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> - -<!-- COMMENT OUT FOR RELEASE --> - <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering" speed="fast" reports="ISB_INEFFICIENT_STRING_BUFFERING,ISB_EMPTY_STRING_APPENDING,ISB_TOSTRING_APPENDING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SyncCollectionIterators" speed="slow" reports="SCI_SYNCHRONIZED_COLLECTION_ITERATORS" /> @@ -148,8 +130,6 @@ <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" /> @@ -242,19 +222,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_MISMATCHED_RETURN,CU_CLONE_USABILITY_THROWS" /> -<!-- For 5.0.0 - - <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" /> - - <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> - - <Detector class="com.mebigfatguy.fbcontrib.detect.UnboundMethodTemplateParameter" speed="fast" reports="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" /> - - <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" /> - - <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> - ---> + <!-- 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...> - 2013-10-19 23:52:04
|
Revision: 1752 http://sourceforge.net/p/fb-contrib/code/1752 Author: dbrosius Date: 2013-10-19 23:52:01 +0000 (Sat, 19 Oct 2013) Log Message: ----------- Version 4.8.5 Added Paths: ----------- tags/v4_8_5/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-10-19 23:44:11
|
Revision: 1751 http://sourceforge.net/p/fb-contrib/code/1751 Author: dbrosius Date: 2013-10-19 23:44:05 +0000 (Sat, 19 Oct 2013) Log Message: ----------- version 4.8.5 Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.xml trunk/fb-contrib/etc/bcel.license trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/AIOB_Sample.java trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/samples/BED_Sample.java trunk/fb-contrib/samples/CLI_Sample.java trunk/fb-contrib/samples/FP_Sample.java trunk/fb-contrib/samples/LO_Sample.java trunk/fb-contrib/samples/PCAIL_Sample.java trunk/fb-contrib/samples/PMB_Sample.java trunk/fb-contrib/samples/PSC_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/SUA_Sample.java trunk/fb-contrib/samples/WOC_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonFunctionalField.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java Added Paths: ----------- trunk/fb-contrib/samples/SCRV_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/.classpath 2013-10-19 23:44:05 UTC (rev 1751) @@ -4,14 +4,15 @@ <classpathentry kind="src" path="src"/> <classpathentry excluding="lib/" kind="src" path="samples"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="lib" path="samples/lib/jsp-api-2.2.1.jar"/> - <classpathentry kind="lib" path="samples/lib/junit-4.10.jar"/> + <classpathentry kind="lib" path="samples/lib/junit-4.10.jar" sourcepath="/home/dave/.m2/repository/junit/junit/4.10/junit-4.10-sources.jar"/> <classpathentry kind="lib" path="samples/lib/log4j-1.2.16.jar"/> <classpathentry kind="lib" path="samples/lib/servlet-api-3.0.1.jar"/> <classpathentry kind="lib" path="samples/lib/commons-lang3-3.1.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> <classpathentry kind="lib" path="samples/lib/commons-collections-3.2.1.jar"/> <classpathentry kind="lib" path="samples/lib/backport-util-concurrent-3.1.jar"/> + <classpathentry kind="lib" path="samples/lib/slf4j-api-1.7.5.jar"/> + <classpathentry kind="lib" path="samples/lib/junit.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/build.xml 2013-10-19 23:44:05 UTC (rev 1751) @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="4.8.4" /> + <property name="fb-contrib.version" value="4.8.5" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -40,6 +40,7 @@ <property name="servlet-api.version" value="3.0.1" /> <property name="backport-util-concurrent.version" value="3.1" /> <property name="commons-collections.version" value="3.2.1" /> + <property name="slf4j.version" value="1.7.5" /> <property name="commons-lang3-url" value="http://repo1.maven.org/maven2/org/apache/commons/commons-lang3/${commons-lang3.version}/commons-lang3-${commons-lang3.version}.jar" /> <property name="jsp-api-url" value="http://repo1.maven.org/maven2/javax/servlet/jsp/javax.servlet.jsp-api/${jsp-api.version}/javax.servlet.jsp-api-${jsp-api.version}.jar" /> @@ -48,6 +49,7 @@ <property name="servlet-api-url" value="http://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/${servlet-api.version}/javax.servlet-api-${servlet-api.version}.jar" /> <property name="backport-util-concurrent-url" value="http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/${backport-util-concurrent.version}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> <property name="commons-collections-url" value="http://repo1.maven.org/maven2/commons-collections/commons-collections/${commons-collections.version}/commons-collections-${commons-collections.version}.jar" /> + <property name="slf4j-api-url" value="http://repo1.maven.org/maven2/org/slf4j/slf4j-api/${slf4j.version}/slf4j-api-${slf4j.version}.jar" /> <target name="check"> <available file="${dest}/${name}-${version}.jar" property="jar-exists" /> @@ -85,6 +87,7 @@ <pull url="${servlet-api-url}" dest="${sampleslib.dir}" name="servlet-api" version="${servlet-api.version}" /> <pull url="${backport-util-concurrent-url}" dest="${sampleslib.dir}" name="backport-util-concurrent" version="${backport-util-concurrent.version}" /> <pull url="${commons-collections-url}" dest="${sampleslib.dir}" name="commons-collections" version="${commons-collections.version}" /> + <pull url="${slf4j-api-url}" dest="${sampleslib.dir}" name="slf4j-api" version="${slf4j.version}" /> </target> <target name="clean" description="removes all generated collateral"> @@ -119,7 +122,8 @@ <pathelement location="${sampleslib.dir}/log4j-${log4j.version}.jar" /> <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar" /> <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar" /> - <pathelement location="${sampleslib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> + <pathelement location="${sampleslib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> + <pathelement location="${sampleslib.dir}/slf4j-api-${slf4j.version}.jar" /> </path> <mkdir dir="${classes.dir}/com" /> <mkdir dir="${classes.dir}/com/mebigfatguy" /> @@ -182,7 +186,7 @@ <attribute name="Bundle-Vendor" value="FB-Contrib Project" /> <attribute name="Require-Bundle" value="edu.umd.cs.findbugs.plugin.eclipse" /> <attribute name="Bundle-ActivationPolicy" value="lazy" /> - <attribute name="Export-Package" value="com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect" /> + <attribute name="Export-Package" value="com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect, com.mebigfatguy.fbcontrib.debug" /> </manifest> </jar> </target> Modified: trunk/fb-contrib/etc/bcel.license =================================================================== --- trunk/fb-contrib/etc/bcel.license 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/etc/bcel.license 2013-10-19 23:44:05 UTC (rev 1751) @@ -187,7 +187,7 @@ * same "printed page" as the copyright notice for easier * identification within third-party archives. * - * Copyright [yyyy] [name of copyright owner] + * Copyright [2013] [Aoache BCEL] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/etc/findbugs.xml 2013-10-19 23:44:05 UTC (rev 1751) @@ -16,7 +16,25 @@ <!-- Detectors --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> + +<!-- PERMANENTLY DISABLED + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> +--> +<!-- COMMENT OUT FOR RELEASE --> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> + +<!-- COMMENT OUT FOR RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering" speed="fast" reports="ISB_INEFFICIENT_STRING_BUFFERING,ISB_EMPTY_STRING_APPENDING,ISB_TOSTRING_APPENDING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SyncCollectionIterators" speed="slow" reports="SCI_SYNCHRONIZED_COLLECTION_ITERATORS" /> @@ -30,9 +48,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents" speed="fast" reports="UCC_UNRELATED_COLLECTION_CONTENTS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" speed="fast" reports="DRE_DECLARED_RUNTIME_EXCEPTION" /> -<!-- COMMENT OUT FOR RELEASE - <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" /> - COMMENT OUT FOR RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PartiallyConstructedObjectAccess" speed="fast" reports="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" /> @@ -73,9 +89,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractOverriddenMethod" speed="fast" reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML" speed="fast" reports="CBX_CUSTOM_BUILT_XML" /> -<!-- COMMENT OUT FOR RELEASE - <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> - COMMENT OUT FOR RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.ConstantListIndex" speed="fast" reports="CLI_CONSTANT_LIST_INDEX" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SloppyClassReflection" speed="fast" reports="SCR_SLOPPY_CLASS_REFLECTION" /> @@ -132,10 +146,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS" /> -<!-- COMMENT OUT FOR RELEASE + 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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" /> @@ -165,7 +179,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousClusteredSessionSupport" speed="fast" reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE,LO_INVALID_FORMATTING_ANCHOR,LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse" speed="fast" reports="IICU_INCORRECT_INTERNAL_CLASS_USE" /> @@ -176,9 +190,6 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryNewNullCheck" speed="fast" reports="UNNC_UNNECESSARY_NEW_NULL_CHECK" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeprecatedTypesafeEnumPattern" speed="fast" reports="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" /> -<!-- COMMENT OUT FOR RELEASE - <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> - COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.TristateBooleanPattern" speed="fast" reports="TBP_TRISTATE_BOOLEAN_PATTERN" /> @@ -193,9 +204,6 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PoorlyDefinedParameter" speed="fast" reports="PDP_POORLY_DEFINED_PARAMETER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NonSymmetricEquals" speed="fast" reports="NSE_NON_SYMMETRIC_EQUALS" /> -<!-- COMMENT OUT FOR RELEASE - <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> - COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField" speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" /> @@ -221,9 +229,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousGetterSetterUse" speed="fast" reports="SGSU_SUSPICIOUS_GETTER_SETTER_USE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects" speed="fast" reports="LGO_LINGERING_GRAPHICS_OBJECT" /> -<!-- COMMENT OUT FOR RELEASE - <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> - COMMENT OUT FOR RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsEqualsBuilderToEquals" speed="fast" reports="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsHashcodeBuilderToHashcode" speed="fast" reports="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE" /> @@ -235,7 +241,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BackportReusePublicIdentifiers" speed="fast" reports="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_MISMATCHED_RETURN,CU_CLONE_USABILITY_THROWS" /> -<!-- COMMENT OUT FOR RELEASE + +<!-- For 5.0.0 + <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> @@ -245,6 +253,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> + --> <!-- BugPattern --> @@ -347,6 +356,7 @@ <BugPattern abbrev="SPP" type="SPP_STRINGBUILDER_IS_MUTABLE" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_USE_GET0" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_DOUBLE_APPENDED_LITERALS" category="PERFORMANCE" /> + <BugPattern abbrev="SPP" type="SPP_NULL_BEFORE_INSTANCEOF" category="CORRECTNESS" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> @@ -370,10 +380,12 @@ <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" /> <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" /> <BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" /> - <BugPattern abbrev="LO" type="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE" category="CORRECTNESS" /> + <BugPattern abbrev="LO" type="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_CLASS" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_PARAMETER" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_STUTTERED_MESSAGE" category="STYLE" /> + <BugPattern abbrev="LO" type="LO_INVALID_FORMATTING_ANCHOR" category="CORRECTNESS" /> + <BugPattern abbrev="LO" type="LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS" category="CORRECTNESS" /> <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" /> <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/etc/messages.xml 2013-10-19 23:44:05 UTC (rev 1751) @@ -62,8 +62,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyConcreteParameter"> <Details> <![CDATA[ - <p> Looks for parameters that are defined by classes, but only use methods defined by an - implemented interface or super class. Relying on concrete classes in public signatures causes cohesion, + <p> Looks for parameters that are defined by classes, but where the method only use methods defined by an + implemented interface or super class of that class. Relying on concrete classes in public signatures causes cohesion, and makes low impact changes more difficult.</p> <p>It is a slow detector</p> ]]> @@ -1350,6 +1350,9 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> + <Details></Details> + </Detector> <!-- BugPattern --> @@ -1601,11 +1604,11 @@ </BugPattern> <BugPattern type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN"> - <ShortDescription>Class has abnormal exit from finally block</ShortDescription> - <LongDescription>Class {0} has abnormal exit from finally block</LongDescription> + <ShortDescription>Method has abnormal exit from finally block</ShortDescription> + <LongDescription>Method {1} has abnormal exit from finally block</LongDescription> <Details> <![CDATA[ - <p>This class returns or throws exceptions from a finally block. This will + <p>This method returns or throws exceptions from a finally block. This will mask real program logic in the try block, and short-circuit normal method termination. </p> ]]> @@ -2646,6 +2649,17 @@ ]]> </Details> </BugPattern> + + <BugPattern type="SPP_NULL_BEFORE_INSTANCEOF"> + <ShortDescription>Method checks a reference for null before calling instanceof</ShortDescription> + <LongDescription>Method {1} checks a reference for null before calling instanceof</LongDescription> + <Details> + <![CDATA[ + This method checks a reference for null just before seeing if the reference is an instanceof some class. + Since instanceof will return false for null references, the null check is not needed. + ]]> + </Details> + </BugPattern> <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> @@ -2994,6 +3008,29 @@ ]]> </Details> </BugPattern> + + <BugPattern type="LO_INVALID_FORMATTING_ANCHOR"> + <ShortDescription>Method attempts to log using numbered formatting anchors</ShortDescription> + <LongDescription>Method {1} attempts to log using numbered formatting anchors</LongDescription> + <Details> + <![CDATA[ + This method attempts to use an SLF4J logger to log a parameterized expression using formatting anchors. + However, slf4j uses simple non numbered anchors such as {}, rather than anchors with digits in them as the + code uses. Thus no parameter replacement will occur. + ]]> + </Details> + </BugPattern> + + <BugPattern type="LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS"> + <ShortDescription>Method passes an incorrect number of parameters to an SLF4J logging statement</ShortDescription> + <LongDescription>Method {1} passes an incorrect number of parameters to an SLF4J logging statement</LongDescription> + <Details> + <![CDATA[ + This method passes the wrong number of parameters to a slf4j logging method (error, warn, info, debug) based on the number of anchors {} in the + format string. An additional exception argument is allowed if found. + ]]> + </Details> + </BugPattern> <BugPattern type="IICU_INCORRECT_INTERNAL_CLASS_USE"> <ShortDescription>Class relies on internal api classes</ShortDescription> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/htdocs/index.shtml 2013-10-19 23:44:05 UTC (rev 1751) @@ -68,8 +68,8 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 4.8.2 available for download - <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-4.8.2.jar/download">here</a>.</p> + <p style="font-weight: bold;">The latest version of fb-contrib is 4.8.5 available for download + <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-4.8.5.jar/download">here</a>.</p> </div> <hr/> Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/htdocs/repository.html 2013-10-19 23:44:05 UTC (rev 1751) @@ -22,11 +22,11 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>4.8.2</td></tr> + <tr><td><b>Version:</b></td><td>4.8.5</td></tr> </table> </div> -<p>fb-contrib is also now available at <a href="http://search.maven.org">search.maven.org</a></p> +<p>fb-contrib is also now available at <a href="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.mebigfatguy.fb-contrib%22">search.maven.org</a></p> </div> </body> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/pom.xml 2013-10-19 23:44:05 UTC (rev 1751) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>4.8.4</version> + <version>4.8.5</version> <parent> <groupId>org.sonatype.oss</groupId> @@ -44,6 +44,15 @@ </properties> <timezone>+1</timezone> </contributor> + <contributor> + <name>Trevor Pounds</name> + </contributor> + <contributor> + <name>Ronald Blaschke</name> + </contributor> + <contributor> + <name>Zenichi Amano</name> + </contributor> </contributors> <licenses> Modified: trunk/fb-contrib/samples/AIOB_Sample.java =================================================================== --- trunk/fb-contrib/samples/AIOB_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/AIOB_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -1,4 +1,6 @@ +import java.util.List; + public class AIOB_Sample { int[] fa = new int[4]; @@ -19,4 +21,17 @@ b[4] = 4; fb[4] = 4; } + + public int[] fpPlusPlusNotRecognized(List<String> l) { + int size = 0; + + for (String s : l) { + size++; + } + + int[] data = new int[size]; + + data[0] = 0; + return data; + } } Modified: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/BAS_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -1,3 +1,4 @@ +import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.HashMap; @@ -166,6 +167,18 @@ } return it.next(); - } + + public List<String> testFPSynchronized(String s, String p) { + List<String> l = new ArrayList<String>(); + String x = s; + synchronized(s) { + if (p != null) { + l.add(p); + return l; + } + } + + return null; + } } Modified: trunk/fb-contrib/samples/BED_Sample.java =================================================================== --- trunk/fb-contrib/samples/BED_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/BED_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -37,6 +37,11 @@ { } + + public final void badFinal() throws ClassNotFoundException + { + + } public static void doIt() throws SQLException, IOException { Modified: trunk/fb-contrib/samples/CLI_Sample.java =================================================================== --- trunk/fb-contrib/samples/CLI_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/CLI_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -1,4 +1,7 @@ +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + @SuppressWarnings("all") public class CLI_Sample { @@ -25,4 +28,17 @@ String c = parts[2]; return c + b + a; } + + class FPHander implements InvocationHandler + { + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable + { + if (args[2] == null) + { + return null; + } + + return String.valueOf(args[0]) + String.valueOf(args[1]); + } + } } Modified: trunk/fb-contrib/samples/FP_Sample.java =================================================================== --- trunk/fb-contrib/samples/FP_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/FP_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -7,7 +7,7 @@ System.out.println(a); } - public void test2(String a) { + public void test2(String a){ a = "hello"; System.out.println(a); } @@ -20,4 +20,8 @@ b = a; return a + b + c; } + + public void testLongDouble(int a, long b, double d, char c) { + } + } \ No newline at end of file Modified: trunk/fb-contrib/samples/LO_Sample.java =================================================================== --- trunk/fb-contrib/samples/LO_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/LO_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -6,7 +6,7 @@ import java.io.InputStream; import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggerFactory; +import org.slf4j.LoggerFactory; @SuppressWarnings("all") @@ -14,6 +14,7 @@ { private static Logger l1 = Logger.getLogger(String.class); private static Logger l2 = Logger.getLogger("com.foo.LO_Sample"); + private static final org.slf4j.Logger l3 = LoggerFactory.getLogger(LO_Sample.class); public LO_Sample(Logger l3) { @@ -37,6 +38,26 @@ is.close(); } } + + public void testInvalidSLF4jParm() + { + l3.error("This is a problem {0}", "hello"); + } + + public void testWrongNumberOfParms() + { + l3.error("This is a problem {}", "hello", "hello"); + l3.error("This is a problem {} and this {}", "hello"); + l3.error("This is a problem {} and this {} and this {}", "hello", "world"); + l3.error("This is a problem {} and this {} and this {} and this {}", "hello", "hello", "hello"); + } + + public void testFPWrongNumberOfParms() + { + l3.error("This is a problem {}", "hello", new IOException("Yikes")); + l3.error("This is a problem {} and this {} and this {} and this {}", "hello", "hello", "hello", "hello", new RuntimeException("yikes")); + l3.error("This is a problem {} and this {}", "hello", new RuntimeException("yikes")); + } public class Inner { Modified: trunk/fb-contrib/samples/PCAIL_Sample.java =================================================================== --- trunk/fb-contrib/samples/PCAIL_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/PCAIL_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -127,6 +127,27 @@ } } + public List<String> fpPreUse() + { + List<String> l = null; + + while (true) + { + if (l != null) + { + return l; + } + + l = new ArrayList<String>(); + l.add("Foo"); + + for (String s : l) + { + System.out.println(s); + } + } + } + private PCAIL_Sample builder() { return this; Modified: trunk/fb-contrib/samples/PMB_Sample.java =================================================================== --- trunk/fb-contrib/samples/PMB_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/PMB_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -7,7 +7,7 @@ { private static Set<String> bl_data = new HashSet<String>(); private static List<String> data = new ArrayList<String>(); - + private static Set<String> inner_data = new HashSet<String>(); public void add(String s) { bl_data.add(s); @@ -18,4 +18,14 @@ { data.remove(s); } + + public void fpInnerDoesRemove() { + inner_data.add("Hello"); + Runnable r = new Runnable() { + public void run() { + inner_data.remove("Hello"); + } + }; + r.run(); + } } Modified: trunk/fb-contrib/samples/PSC_Sample.java =================================================================== --- trunk/fb-contrib/samples/PSC_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/PSC_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -19,6 +19,13 @@ names.add(s.toString()); } } + + public void testPSCMaps(Map<String, String> input) { + Map<String, String> output = new HashMap<String, String>(); + for (Map.Entry<String, String> entry : input.entrySet()) { + output.put(entry.getKey().intern(), entry.getValue()); + } + } public void testPSCEnumerated() { Set<String> commonWords = new HashSet<String>(); @@ -40,6 +47,14 @@ commonWords.add("they"); commonWords.add("them"); } + + public List<String> testAddAllToCtor(List<String> l) { + List<String> ll = new ArrayList<String>(); + ll.addAll(l); + + ll.add("FooBar"); + return ll; + } public void fpDontHaveCollectionForSizing(Iterator<Long> it) { Deque<Long> ad = new ArrayDeque<Long>(); @@ -56,6 +71,17 @@ } } } + + public List<String> fpAddSubCollection(Map<String, Set<String>> s) + { + List<String> l = new ArrayList<String>(); + for (Map.Entry<String, Set<String>> entry : s.entrySet()) + { + l.add(entry.getKey()); + l.addAll(entry.getValue()); + } + return l; + } public void fpSwitchInLoop(Set<Integer> source) { List<Integer> dest = new ArrayList<Integer>(); @@ -90,6 +116,32 @@ } return l; - } + + public List<Exception> fpPSCInCatchBlock(List<String> src) { + List<Exception> exceptions = new ArrayList<Exception>(); + + for (String s : src) { + try { + s = s.substring(1000, 1001); + + } catch (IndexOutOfBoundsException e) { + exceptions.add(e); + } + } + + List<Exception> exceptions2 = new ArrayList<Exception>(); + + for (String s : src) { + try { + s = s.substring(1000, 1001); + if (s == null) + return null; + } catch (IndexOutOfBoundsException e) { + exceptions2.add(e); + } + } + + return exceptions; + } } Added: trunk/fb-contrib/samples/SCRV_Sample.java =================================================================== --- trunk/fb-contrib/samples/SCRV_Sample.java (rev 0) +++ trunk/fb-contrib/samples/SCRV_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -0,0 +1,45 @@ +import java.util.Comparator; + +public class SCRV_Sample +{ + public static final int T1 = 0; + public static final int T2 = 1; + + int t = 0; + class SampleComparator implements Comparator<SCRV_Sample> + { + public int compare(SCRV_Sample arg0, SCRV_Sample arg1) { + if (arg0.t == arg1.t) + return 0; + + return -1; + } + } + + class SampleComparable implements Comparable<SCRV_Sample> + { + public int compareTo(SCRV_Sample arg0) { + if (t == arg0.t) + return 0; + + 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; + } + } + + class FPThrowsComparator implements Comparator<SCRV_Sample> + { + public int compare(SCRV_Sample arg0, SCRV_Sample arg1) { + throw new UnsupportedOperationException(); + } + } +} Property changes on: trunk/fb-contrib/samples/SCRV_Sample.java ___________________________________________________________________ Added: svn:eol-stype ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/SPP_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -22,6 +22,7 @@ private static final double pi = 3.14; private static final double e = 2.72; public static final String FALSE_POSITIVE = "INTERN_OK_HERE".intern(); + private static final String LIT = "lit"; static enum Flap { Smack, Jack }; @@ -118,6 +119,13 @@ sb.append("Hello").append(s).append("there"); } + public String testFPDoubleAppendListeralStatic() + { + StringBuilder sb = new StringBuilder(); + sb.append("literal").append(LIT).append("literal"); + return sb.toString(); + } + public boolean testFPUselessTrinary(boolean a, boolean b) { @@ -348,4 +356,32 @@ public String testListFirst(List<String> l) { return l.iterator().next(); } + + public boolean nullAndInstanceOf(Object o) { + if ((o != null) && (o instanceof String)) + { + return true; + } + return false; + } + + public boolean nullAndInstanceOf(double d1, double d2, double d3, Object o) { + if ((o != null) && (o instanceof String)) + { + return true; + } + return false; + } + + public boolean fpNullAndInstanceOf(Object o) { + if (o != null) + { + if (o instanceof String) + { + return true; + } + return false; + } + return Math.random() > 0.5; + } } Modified: trunk/fb-contrib/samples/SUA_Sample.java =================================================================== --- trunk/fb-contrib/samples/SUA_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/SUA_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -74,4 +74,14 @@ System.arraycopy(src, 0, dst, 0, src.length); return dst; } + + public double[] fpSFBug65tipOff() { + String[] elems = "1,2.0,3".split(","); + double[] result = new double[elems.length]; + for (int i = 0; i < elems.length; i++) + { + result[i] = 0.0; + } + return result; + } } \ No newline at end of file Modified: trunk/fb-contrib/samples/WOC_Sample.java =================================================================== --- trunk/fb-contrib/samples/WOC_Sample.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/WOC_Sample.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -11,106 +11,111 @@ import java.util.Set; import java.util.Vector; +public class WOC_Sample { + private final Set<String> memberSet = new HashSet<String>(); + private Set<String> fpSet; + private final List<String> fpList = new ArrayList<String>(); -public class WOC_Sample -{ - private final Set<String> memberSet = new HashSet<String>(); - private Set<String> fpSet; - private final List<String> fpList = new ArrayList<String>(); + public void testWOCSimple() { + Set<String> s = new HashSet<String>(); + s.add("Foo"); + memberSet.add("fee"); + if (fpSet.retainAll(new HashSet<String>())) { + System.out.println("woops"); + } + } - public void testWOCSimple() - { - Set<String> s = new HashSet<String>(); - s.add("Foo"); - memberSet.add("fee"); - if (fpSet.retainAll(new HashSet<String>())) { - System.out.println("woops"); - } - } + public Map<String, String> testFPWOCReturn() { + Map<String, String> m = new HashMap<String, String>(); + m.put("Foo", "Bar"); + memberSet.add("fi"); + fpSet = new HashSet<String>(); + return m; + } - public Map<String, String> testFPWOCReturn() - { - Map<String, String> m = new HashMap<String, String>(); - m.put("Foo", "Bar"); - memberSet.add("fi"); - fpSet = new HashSet<String>(); - return m; - } + public void testFPWOCAsParm() { + Map<String, String> m = new HashMap<String, String>(); + m.put("Foo", "Bar"); + memberSet.add("fo"); + fpSet.add("boo"); + helper(0, m); + } - public void testFPWOCAsParm() - { - Map<String, String> m = new HashMap<String, String>(); - m.put("Foo", "Bar"); - memberSet.add("fo"); - fpSet.add("boo"); - helper(0, m); - } + public void testFPWOCCopy() { + Set<String> s = new LinkedHashSet<String>(); + s.add("foo"); + Set<String> c = s; + memberSet.add("fum"); + } - public void testFPWOCCopy() - { - Set<String> s = new LinkedHashSet<String>(); - s.add("foo"); - Set<String> c = s; - memberSet.add("fum"); - } + public void testFPWOCInArray() { + Vector<Integer> v = new Vector<Integer>(); + v.addElement(Integer.valueOf(0)); + Object[] o = new Object[] { v }; + } - public void testFPWOCInArray() - { - Vector<Integer> v = new Vector<Integer>(); - v.addElement(Integer.valueOf(0)); - Object[] o = new Object[] { v }; - } + public void testFPWOCUseReturnVal() { + LinkedList<String> l = new LinkedList<String>(); + l.add("Foo"); + l.add("Bar"); - public void testFPWOCUseReturnVal() - { - LinkedList<String> l = new LinkedList<String>(); - l.add("Foo"); - l.add("Bar"); + if (l.remove("Foo")) { + System.out.println("Dont' report"); + } + } - if (l.remove("Foo")) - { - System.out.println("Dont' report"); - } - } + public Set<String> testFPTrinary(boolean b) { + Set<String> s = new HashSet<String>(); + s.add("foo"); + s.add("bar"); - public Set<String> testFPTrinary(boolean b) - { - Set<String> s = new HashSet<String>(); - s.add("foo"); - s.add("bar"); + return b ? s : Collections.<String> emptySet(); + } - return b ? s : Collections.<String>emptySet(); - } + private void helper(int i, Map<String, String> x) { + } - private void helper(int i, Map<String, String> x) - { - } + public void testFPInnerClass(final Set<String> data) { + ActionListener al = new ActionListener() { + public void actionPerformed(ActionEvent ae) { + data.add("Woot"); + } + }; + } - public void testFPInnerClass(final Set<String> data) - { - ActionListener al = new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - data.add("Woot"); - } - }; - } + public List<String> fpOtherInstance(WOC_Sample ws) { + return ws.fpList; + } + + public String fpCheckReference(boolean b) { + List<String> s = null; + + if (b) { + s = new ArrayList<String>(); + s.add("foo"); + } + + String result; + if (s != null) { + result = "yes"; + } else { + result = "no"; + } + + return result; + } - public List<String> fpOtherInstance(WOC_Sample ws) - { - return ws.fpList; - } - - public static class FpContains { + public static class FpContains { private List<String> fpSet; public FpContains() { fpSet = new ArrayList<String>(); } + public void add() { fpSet.add("Foo"); } + protected void contains() { for (int i = 0; i < 10; i++) { if (fpSet.get(i) != null) { Modified: trunk/fb-contrib/samples/samples.fbp =================================================================== --- trunk/fb-contrib/samples/samples.fbp 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/samples/samples.fbp 2013-10-19 23:44:05 UTC (rev 1751) @@ -1,12 +1,13 @@ <Project projectName="sample"> - <Jar>./.</Jar> - <AuxClasspathEntry>././lib/jsp-api-2.2.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>././lib/junit-4.10.jar</AuxClasspathEntry> - <AuxClasspathEntry>././lib/log4j-1.2.16.jar</AuxClasspathEntry> - <AuxClasspathEntry>././lib/servlet-api-3.0.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>./lib/commons-lang3-3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>./lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> - <SrcDir>./.</SrcDir> + <Jar>././.</Jar> + <AuxClasspathEntry>./././lib/jsp-api-2.2.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./././lib/junit-4.10.jar</AuxClasspathEntry> + <AuxClasspathEntry>./././lib/log4j-1.2.16.jar</AuxClasspathEntry> + <AuxClasspathEntry>./././lib/servlet-api-3.0.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././lib/commons-lang3-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./lib/slf4j-api-1.7.5.jar</AuxClasspathEntry> + <SrcDir>././.</SrcDir> <SuppressionFilter> <LastVersion value="-1" relOp="NEQ"/> </SuppressionFilter> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -21,6 +21,12 @@ import java.util.HashMap; import java.util.Map; +/** + * holds statistics about classes collected in the first pass. + * To cut down on the size of the database, class, method, signature is not stored as a key + * only a hash of that data is stored. This will allow some false positives, but hopefully not + * enough to cause issues. + */ public class Statistics { private static Statistics statistics = new Statistics(); Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -0,0 +1,75 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2013 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.debug; + +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; + +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 OCSDebugger extends BytecodeScanningDetector { + + private static final String OCS_OUTPUT_FILE = "fb-contrib.ocs.output"; + private static final String OCS_METHOD_DESC = "fb-contrib.ocs.method"; + + private static final String OUTPUT_FILE_NAME = System.getProperty(OCS_OUTPUT_FILE); + private static final String METHOD_DESC = System.getProperty(OCS_METHOD_DESC); + + private OpcodeStack stack = new OpcodeStack(); + private PrintWriter pw = null; + + public OCSDebugger(BugReporter bugReporter) { + } + + public void visitClassContext(ClassContext classContext) { + if ((OUTPUT_FILE_NAME != null) && (METHOD_DESC != null)) + super.visitClassContext(classContext); + } + + public void visitCode(Code obj) { + Method m = getMethod(); + + String curMethodDesc = getClassContext().getJavaClass().getClassName() + "." + m.getName() + m.getSignature(); + if (curMethodDesc.equals(METHOD_DESC)) { + try { + pw = new PrintWriter(new FileWriter(OUTPUT_FILE_NAME)); + stack.resetForMethodEntry(this); + + super.visitCode(obj); + } catch (IOException e) { + } finally { + pw.close(); + pw = null; + } + } + } + + public void sawOpcode(int seen) { + stack.sawOpcode(this, seen); + pw.println(String.format("After executing: %-16s at PC: %-5d Stack Size: %-3d", Constants.OPCODE_NAMES[getOpcode()], getPC(), stack.getStackDepth())); + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java ___________________________________________________________________ Added: svn:eol ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:mimetype ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -18,8 +18,7 @@ */ package com.mebigfatguy.fbcontrib.detect; -import java.util.HashSet; -import java.util.Set; +import java.util.BitSet; import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; @@ -28,6 +27,8 @@ import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; +import com.mebigfatguy.fbcontrib.utils.RegisterUtils; + import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -38,7 +39,8 @@ private BugReporter bugReporter; private OpcodeStack stack; - private Set<Integer> initializedRegs; + private BitSet initializedRegs; + private BitSet iincRegs; /** * constructs an AIOB detector given the reporter to report bugs on @@ -52,7 +54,8 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); - initializedRegs = new HashSet<Integer>(); + initializedRegs = new BitSet(); + iincRegs = new BitSet(); super.visitClassContext(classContext); } finally { stack = null; @@ -64,20 +67,23 @@ Method m = getMethod(); stack.resetForMethodEntry(this); initializedRegs.clear(); + iincRegs.clear(); Type[] argTypes = m.getArgumentTypes(); int arg = ((m.getAccessFlags() & Constants.ACC_STATIC) != 0) ? 0 : 1; for (Type argType : argTypes) { String argSig = argType.getSignature(); - initializedRegs.add(Integer.valueOf(arg)); + initializedRegs.set(arg); arg += ("J".equals(argSig) || "D".equals(argSig)) ? 2 : 1; } super.visitCode(obj); initializedRegs.clear(); + iincRegs.clear(); } public void sawOpcode(int seen) { Integer size = null; + boolean sizeSet = false; try { switch (seen) { case ICONST_0: @@ -87,17 +93,39 @@ case ICONST_4: case ICONST_5: size = Integer.valueOf(seen - ICONST_0); + sizeSet = true; break; + case ILOAD: + case ILOAD_0: + case ILOAD_1: + case ILOAD_2: + case ILOAD_3: { + int reg = RegisterUtils.getLoadReg(this, seen); + if (iincRegs.get(reg)) { + size = null; + iincRegs.clear(reg); + sizeSet = true; + } + } + break; + + case BIPUSH: case SIPUSH: size = getIntConstant(); + sizeSet = true; break; + + case IINC: + iincRegs.set(getRegisterOperand()); + break; case LDC: Constant c = getConstantRefOperand(); if (c instanceof ConstantInteger) { size = Integer.valueOf(((ConstantInteger) c).getBytes()); + sizeSet = true; } break; @@ -106,6 +134,7 @@ if (stack.getStackDepth() >= 1) { OpcodeStack.Item item = stack.getStackItem(0); size = (Integer) item.getUserValue(); + sizeSet = true; } break; @@ -133,7 +162,7 @@ } int reg = arrayItem.getRegisterNumber(); - if ((reg >= 0) && !initializedRegs.contains(Integer.valueOf(reg))) { + if ((reg >= 0) && !initializedRegs.get(reg)) { bugReporter.reportBug(new BugInstance(this, "AIOB_ARRAY_STORE_TO_NULL_REFERENCE", HIGH_PRIORITY) .addClass(this) .addMethod(this) @@ -177,16 +206,16 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item value = stack.getStackItem(0); if (!value.isNull()) - initializedRegs.add(Integer.valueOf(getRegisterOperand())); + initializedRegs.set(getRegisterOperand()); } else { - initializedRegs.add(Integer.valueOf(getRegisterOperand())); + initializedRegs.set(getRegisterOperand()); } break; } } finally { stack.sawOpcode(this, seen); - if (size != null) { + if (sizeSet) { if (stack.getStackDepth() >= 1) { OpcodeStack.Item item = stack.getStackItem(0); item.setUserValue(size); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -75,7 +75,7 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); - wrappers = new HashMap<Integer, WrapperInfo>(); + wrappers = new HashMap<Integer, WrapperInfo>(10); super.visitClassContext(classContext); } finally { stack = null; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2013-07-14 19:44:11 UTC (rev 1750) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2013-10-19 23:44:05 UTC (rev 1751) @@ -19,6 +19,7 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.ArrayList; +import java.util.BitSet; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -47,24 +48,31 @@ * performance impact of that assignment. */ public class BloatedAssignmentScope extends BytecodeScanningDetector { - private static final Set<String> dangerousAssignmentClassSources = new HashSet<String>(); - private static final Set<String> dangerousAssignmentMethodSources = new HashSet<String>(); + private static final Set<String> dangerousAssignmentClassSources = new HashSet<String>(7); + private static final Set<String> dangerousAssignmentMethodSources = new HashSet<String>(4); static { - dangerousAssignmentClassSources.add("java/io/InputStream"); - dangerousAssignmentClassSources.add("java/io/ObjectInput"); + dangerousAssignmentClassSources.add("java/io/BufferedInputStream"); + dangerousAssignmentClassSources.add("java/io/DataInputStream"); + dangerousAssignmentClassSources.add("java/io/InputStream"); + dangerousAssignmentClassSources.add("java/io/ObjectInputStream"); + dangerousAssignmentClassSources.add("java/io/BufferedReader"); + dangerousAssignmentClassSources.add("java/io/FileReader"); + dangerousAssignmentClassSources.add("java/io/Reader"); dangerousAssignmentMethodSources.add("java/lang/System.currentTimeMillis()J"); dangerousAssignmentMetho... [truncated message content] |
From: <dbr...@us...> - 2013-07-14 19:44:15
|
Revision: 1750 http://sourceforge.net/p/fb-contrib/code/1750 Author: dbrosius Date: 2013-07-14 19:44:11 +0000 (Sun, 14 Jul 2013) Log Message: ----------- remove BAS from 4.8.4 Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-07-14 19:26:58 UTC (rev 1749) +++ trunk/fb-contrib/etc/findbugs.xml 2013-07-14 19:44:11 UTC (rev 1750) @@ -133,9 +133,9 @@ <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS" /> - +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-07-14 19:27:00
|
Revision: 1749 http://sourceforge.net/p/fb-contrib/code/1749 Author: dbrosius Date: 2013-07-14 19:26:58 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Version 4.8.4 Added Paths: ----------- tags/v4_8_4/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-07-14 19:23:11
|
Revision: 1748 http://sourceforge.net/p/fb-contrib/code/1748 Author: dbrosius Date: 2013-07-14 19:23:07 +0000 (Sun, 14 Jul 2013) Log Message: ----------- sync from github: prepare for version 4.8.4 Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/FCBL_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java Added Paths: ----------- trunk/fb-contrib/samples/AIOB_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/build.xml 2013-07-14 19:23:07 UTC (rev 1748) @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="4.9.0" /> + <property name="fb-contrib.version" value="4.8.4" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -182,6 +182,7 @@ <attribute name="Bundle-Vendor" value="FB-Contrib Project" /> <attribute name="Require-Bundle" value="edu.umd.cs.findbugs.plugin.eclipse" /> <attribute name="Bundle-ActivationPolicy" value="lazy" /> + <attribute name="Export-Package" value="com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect" /> </manifest> </jar> </target> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/etc/findbugs.xml 2013-07-14 19:23:07 UTC (rev 1748) @@ -30,9 +30,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents" speed="fast" reports="UCC_UNRELATED_COLLECTION_CONTENTS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" speed="fast" reports="DRE_DECLARED_RUNTIME_EXCEPTION" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PartiallyConstructedObjectAccess" speed="fast" reports="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" /> @@ -73,9 +73,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractOverriddenMethod" speed="fast" reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML" speed="fast" reports="CBX_CUSTOM_BUILT_XML" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.ConstantListIndex" speed="fast" reports="CLI_CONSTANT_LIST_INDEX" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SloppyClassReflection" speed="fast" reports="SCR_SLOPPY_CLASS_REFLECTION" /> @@ -176,9 +176,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryNewNullCheck" speed="fast" reports="UNNC_UNNECESSARY_NEW_NULL_CHECK" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeprecatedTypesafeEnumPattern" speed="fast" reports="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.TristateBooleanPattern" speed="fast" reports="TBP_TRISTATE_BOOLEAN_PATTERN" /> @@ -193,9 +193,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PoorlyDefinedParameter" speed="fast" reports="PDP_POORLY_DEFINED_PARAMETER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NonSymmetricEquals" speed="fast" reports="NSE_NON_SYMMETRIC_EQUALS" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField" speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" /> @@ -221,9 +221,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousGetterSetterUse" speed="fast" reports="SGSU_SUSPICIOUS_GETTER_SETTER_USE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects" speed="fast" reports="LGO_LINGERING_GRAPHICS_OBJECT" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsEqualsBuilderToEquals" speed="fast" reports="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsHashcodeBuilderToHashcode" speed="fast" reports="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE" /> @@ -235,7 +235,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BackportReusePublicIdentifiers" speed="fast" reports="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_MISMATCHED_RETURN,CU_CLONE_USABILITY_THROWS" /> - +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> @@ -244,6 +244,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> +--> <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -430,4 +432,6 @@ <BugPattern abbrev="PSC" type="PSC_PRESIZE_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="UMTP" type="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" category="CORRECTNESS" /> <BugPattern abbrev="NPMC" type="NPMC_NON_PRODUCTIVE_METHOD_CALL" category="CORRECTNESS" /> + <BugPattern abbrev="AIOB" type="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS" category="CORRECTNESS" /> + <BugPattern abbrev="AIOB" type="AIOB_ARRAY_STORE_TO_NULL_REFERENCE" category="CORRECTNESS" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/etc/messages.xml 2013-07-14 19:23:07 UTC (rev 1748) @@ -40,7 +40,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SyncCollectionIterators"> <Details> <![CDATA[ - <p> Looks for use of iterators on synchronized collections built from the Collections class</p> + <p> Looks for use of iterators on synchronized collections built from the java.util.Collections class</p> <p> As the collection in question was built thru Collections.synchronizedXXX, an assumption is made that this collection must be multithreaded safe. However, iterator access is used, which is explicitly unsafe. When iterators are to be used, synchronization should be done manually.</p> @@ -319,7 +319,8 @@ <Details> <![CDATA[ <p>Looks for methods that store the return result in a local variable and - then immediately returns that local variable.</p> + then immediately returns that local variable. It is simpler to just return + the method (or assignment) result directly.</p> <p>It is a fast detector</p> ]]> </Details> @@ -350,7 +351,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.OrphanedDOMNode"> <Details> <![CDATA[ - <p>Looks for methods that create DOM Nodes but do not add them to any DOM Document.</p> + <p>Looks for methods that create DOM nodes but do not add them to any DOM Document.</p> <p>It is a fast Detector</p> ]]> </Details> @@ -1332,7 +1333,24 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds"> + <Details> + <![CDATA[ + <p>Looks for questionable load/stores to array elements.<ul> + <li> + Looks for accesses to array elements using literal values that are known to be outside the bounds of the array. + This mistake will cause an ArrayIndexOutOfBoundsException to occur at runtime.</li> + <li> + Looks for stores to array elements where the array itself appears to have not been allocated. + </li> + </ul> + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -3484,7 +3502,7 @@ <p>This method serializes an instance of a non-static inner class. Since this class has a reference to the containing class, this outer class will be serialized as well. This is often not intentional, and will make the amount of data that is serialized much more than is needed. - If the outer classes is not desired to be serialized, either make the inner class, static, or + If the outer classes is not desired to be serialized, either make the inner class static, or pull it out into a separate "first class" class. ]]> </Details> @@ -3593,7 +3611,7 @@ <LongDescription>Method {1} backport concurrency utils</LongDescription> <Details> <![CDATA[ - <p> This class usees Backport Utils concurrent classes. Updated/Efficient version of these + <p> This class uses Backport Utils concurrent classes. Updated/Efficient version of these classes are available in versions of the JDK 5.0 and higher, and these classes should only be used if you are targeting JDK 1.4 and lower. </p> @@ -3633,7 +3651,7 @@ <![CDATA[ <p> This class implements the Cloneable interface but defines its clone method to still return a CloneNotSupportedException. Since you are implementing clone() it would make sense that the method - in question will _not_ throw that exception, so annotating your method with it just makes client use + in question will <em>not</em> throw that exception, so annotating your method with it just makes client use of your more painful as they have to handle an exception that will never happen. Just remove the throws clause from your method. </p> @@ -3691,6 +3709,27 @@ ]]> </Details> </BugPattern> + + <BugPattern type="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS"> + <ShortDescription>Method attempts to access an array element outside the array's size</ShortDescription> + <LongDescription>Method {1} attempts to access an array element outside the array's size</LongDescription> + <Details> + <![CDATA[ + <p>This method access an array element using a literal index that is know to be outside the size of the specified + array. This will cause an ArrayIndexOutOfBoundsException at runtime</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="AIOB_ARRAY_STORE_TO_NULL_REFERENCE"> + <ShortDescription>Method attempts to store an array element to an array that does not appear to be allocated</ShortDescription> + <LongDescription>Method {1} attempts to store an array element to an array that does not appear to be allocated</LongDescription> + <Details> + <![CDATA[ + <p>This method attempts to store an array element into an an array that appears to not have been allocated. + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -3804,4 +3843,5 @@ <BugCode abbrev="PSC">Presize Collection</BugCode> <BugCode abbrev="UMTP">Unbound Method Template Parameter</BugCode> <BugCode abbrev="NPMC">Non Productive Method Call</BugCode> + <BugCode abbrev="AIOB">Array Index Out of Bounds</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/htdocs/index.shtml 2013-07-14 19:23:07 UTC (rev 1748) @@ -107,6 +107,16 @@ is discarded. Since the method makes no changes to the object, calling this method is useless. The method call can be removed. </li> + <li><b>[AIOB] Array Index Out of Bounds</b><br/> + Looks for questionable load/stores to array elements.<ul> + <li> + Looks for accesses to array elements using literal values that are known to be outside the bounds of the array. + This mistake will cause an ArrayIndexOutOfBoundsException to occur at runtime.</li> + <li> + Looks for stores to array elements where the array itself appears to have not been allocated. + </li> + </ul> + </li> </ul> </div> <hr/> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/pom.xml 2013-07-14 19:23:07 UTC (rev 1748) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>4.9.0</version> + <version>4.8.4</version> <parent> <groupId>org.sonatype.oss</groupId> Added: trunk/fb-contrib/samples/AIOB_Sample.java =================================================================== --- trunk/fb-contrib/samples/AIOB_Sample.java (rev 0) +++ trunk/fb-contrib/samples/AIOB_Sample.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -0,0 +1,22 @@ + +public class AIOB_Sample +{ + int[] fa = new int[4]; + int[] fb; + + public void testOutOfBounds() + { + int[] a = new int[4]; + + a[4] = 2; + fa[4] = 2; + } + + public void testUnallocated() + { + int[] b = null; + + b[4] = 4; + fb[4] = 4; + } +} Property changes on: trunk/fb-contrib/samples/AIOB_Sample.java ___________________________________________________________________ Added: svn:eol ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/samples/FCBL_Sample.java =================================================================== --- trunk/fb-contrib/samples/FCBL_Sample.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/samples/FCBL_Sample.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -7,6 +7,7 @@ protected int boo; int hoo; private int fp; + private int multiMethodFP; private String test; private int x = 1; private int y = 2; @@ -57,4 +58,17 @@ test = "woowoo"; } + + public void mm1FP(int i) { + multiMethodFP = i; + mm2FP(3); + + if (multiMethodFP == i) { + System.out.println("FP"); + } + } + + public void mm2FP(int i) { + multiMethodFP = i; + } } Modified: trunk/fb-contrib/samples/samples.fbp =================================================================== --- trunk/fb-contrib/samples/samples.fbp 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/samples/samples.fbp 2013-07-14 19:23:07 UTC (rev 1748) @@ -1,10 +1,12 @@ <Project projectName="sample"> - <Jar>.</Jar> - <AuxClasspathEntry>./lib/jsp-api-2.2.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>./lib/junit-4.10.jar</AuxClasspathEntry> - <AuxClasspathEntry>./lib/log4j-1.2.16.jar</AuxClasspathEntry> - <AuxClasspathEntry>./lib/servlet-api-3.0.1.jar</AuxClasspathEntry> - <SrcDir>.</SrcDir> + <Jar>./.</Jar> + <AuxClasspathEntry>././lib/jsp-api-2.2.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././lib/junit-4.10.jar</AuxClasspathEntry> + <AuxClasspathEntry>././lib/log4j-1.2.16.jar</AuxClasspathEntry> + <AuxClasspathEntry>././lib/servlet-api-3.0.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./lib/commons-lang3-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> + <SrcDir>./.</SrcDir> <SuppressionFilter> <LastVersion value="-1" relOp="NEQ"/> </SuppressionFilter> Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -0,0 +1,197 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2013 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.HashSet; +import java.util.Set; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Constant; +import org.apache.bcel.classfile.ConstantInteger; +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 ArrayIndexOutOfBounds extends BytecodeScanningDetector { + + private BugReporter bugReporter; + private OpcodeStack stack; + private Set<Integer> initializedRegs; + + /** + * constructs an AIOB detector given the reporter to report bugs on + + * @param bugReporter the sync of bug reports + */ + public ArrayIndexOutOfBounds(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + initializedRegs = new HashSet<Integer>(); + super.visitClassContext(classContext); + } finally { + stack = null; + initializedRegs = null; + } + } + + public void visitCode(Code obj) { + Method m = getMethod(); + stack.resetForMethodEntry(this); + initializedRegs.clear(); + Type[] argTypes = m.getArgumentTypes(); + int arg = ((m.getAccessFlags() & Constants.ACC_STATIC) != 0) ? 0 : 1; + for (Type argType : argTypes) { + String argSig = argType.getSignature(); + initializedRegs.add(Integer.valueOf(arg)); + arg += ("J".equals(argSig) || "D".equals(argSig)) ? 2 : 1; + } + super.visitCode(obj); + + initializedRegs.clear(); + } + + public void sawOpcode(int seen) { + Integer size = null; + try { + switch (seen) { + case ICONST_0: + case ICONST_1: + case ICONST_2: + case ICONST_3: + case ICONST_4: + case ICONST_5: + size = Integer.valueOf(seen - ICONST_0); + break; + + case BIPUSH: + case SIPUSH: + size = getIntConstant(); + break; + + case LDC: + Constant c = getConstantRefOperand(); + if (c instanceof ConstantInteger) { + size = Integer.valueOf(((ConstantInteger) c).getBytes()); + } + break; + + case NEWARRAY: + case ANEWARRAY: + if (stack.getStackDepth() >= 1) { + OpcodeStack.Item item = stack.getStackItem(0); + size = (Integer) item.getUserValue(); + } + break; + + case IASTORE: + case LASTORE: + case FASTORE: + case DASTORE: + case AASTORE: + case BASTORE: + case CASTORE: + case SASTORE: + if (stack.getStackDepth() >= 3) { + OpcodeStack.Item indexItem = stack.getStackItem(1); + Integer index = (Integer) indexItem.getConstant(); + if (index != null) { + OpcodeStack.Item arrayItem = stack.getStackItem(2); + Integer sz = (Integer) arrayItem.getUserValue(); + if (sz != null) { + if (index.intValue() >= sz.intValue()) { + bugReporter.reportBug(new BugInstance(this, "AIOB_ARRAY_INDEX_OUT_OF_BOUNDS", HIGH_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + + int reg = arrayItem.getRegisterNumber(); + if ((reg >= 0) && !initializedRegs.contains(Integer.valueOf(reg))) { + bugReporter.reportBug(new BugInstance(this, "AIOB_ARRAY_STORE_TO_NULL_REFERENCE", HIGH_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + break; + + case IALOAD: + case LALOAD: + case FALOAD: + case DALOAD: + case AALOAD: + case BALOAD: + case CALOAD: + case SALOAD: + if (stack.getStackDepth() >= 2) { + OpcodeStack.Item indexItem = stack.getStackItem(0); + Integer index = (Integer) indexItem.getConstant(); + if (index != null) { + OpcodeStack.Item arrayItem = stack.getStackItem(1); + Integer sz = (Integer) arrayItem.getUserValue(); + if (sz != null) { + if (index.intValue() >= sz.intValue()) { + bugReporter.reportBug(new BugInstance(this, "AIOB_ARRAY_INDEX_OUT_OF_BOUNDS", HIGH_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + } + break; + + case ASTORE_0: + case ASTORE_1: + case ASTORE_2: + case ASTORE_3: + case ASTORE: + if (stack.getStackDepth() > 0) { + OpcodeStack.Item value = stack.getStackItem(0); + if (!value.isNull()) + initializedRegs.add(Integer.valueOf(getRegisterOperand())); + } else { + initializedRegs.add(Integer.valueOf(getRegisterOperand())); + } + break; + } + + } finally { + stack.sawOpcode(this, seen); + if (size != null) { + if (stack.getStackDepth() >= 1) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(size); + } + } + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java ___________________________________________________________________ Added: svn:eol ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -54,6 +54,7 @@ dangerousAssignmentClassSources.add("java/io/InputStream"); dangerousAssignmentClassSources.add("java/io/ObjectInput"); dangerousAssignmentMethodSources.add("java/lang/System.currentTimeMillis()J"); + dangerousAssignmentMethodSources.add("java/lang/System.nanoTime()J"); dangerousAssignmentMethodSources.add("java/util/Iterator.next()Ljava/lang/Object;"); dangerousAssignmentMethodSources.add("java/util/regex/Matcher.start()I"); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -117,9 +117,11 @@ si = stack.getStackItem(0); signature = si.getSignature(); if (isToStringBuilder(signature)) { - Pair p = stackTracker.pop(); - registerTracker.put(Integer.valueOf(p.register), - Boolean.valueOf(p.appendInvoked)); + if (!stackTracker.isEmpty()) { + Pair p = stackTracker.pop(); + registerTracker.put(Integer.valueOf(p.register), + Boolean.valueOf(p.appendInvoked)); + } } break; case INVOKESPECIAL: Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -82,13 +82,14 @@ } private static final Map<String, Integer> modifyingMethods = new HashMap<String, Integer>(); static { - modifyingMethods.put("add(Ljava/lang/Object;)Z", Integer.valueOf(1)); - modifyingMethods.put("addAll(Ljava/util/Collection;)Z", Integer.valueOf(1)); + Integer ONE = Integer.valueOf(1); + modifyingMethods.put("add(Ljava/lang/Object;)Z", ONE); + modifyingMethods.put("addAll(Ljava/util/Collection;)Z", ONE); modifyingMethods.put("addAll(ILjava/util/Collection;)Z", Integer.valueOf(2)); modifyingMethods.put("clear()V", Integer.valueOf(0)); - modifyingMethods.put("remove(I)Ljava/lang/Object;", Integer.valueOf(1)); - modifyingMethods.put("removeAll(Ljava/util/Collection;)Z", Integer.valueOf(1)); - modifyingMethods.put("retainAll(Ljava/util/Collection;)Z", Integer.valueOf(1)); + modifyingMethods.put("remove(I)Ljava/lang/Object;", ONE); + modifyingMethods.put("removeAll(Ljava/util/Collection;)Z", ONE); + modifyingMethods.put("retainAll(Ljava/util/Collection;)Z", ONE); } private BugReporter bugReporter; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -365,7 +365,7 @@ @Override public String toString() { - return basicBlock.toString() + "|" + uncheckedFields; + return basicBlock + "|" + uncheckedFields; } } } \ No newline at end of file Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -85,10 +85,10 @@ if (seen == INVOKESPECIAL) { String calledClass = getClassConstantOperand(); - String signature = getSigConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) || "java/lang/StringBuilder".equals(calledClass)) && "<init>".equals(getNameConstantOperand())) { + String signature = getSigConstantOperand(); if ("()V".equals(signature)) { OpcodeStack.Item itm = getStringBufferItemAt(2); if (itm != null) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -269,7 +269,7 @@ } else if ("(Ljava/lang/Object;)V".equals(sig)) { if (stack.getStackDepth() > 0) { final JavaClass clazz = stack.getStackItem(0).getJavaClass(); - if(clazz.instanceOf(THROWABLE_CLASS)) { + if((clazz != null) && clazz.instanceOf(THROWABLE_CLASS)) { bugReporter.reportBug(new BugInstance(this, "LO_LOGGER_LOST_EXCEPTION_STACK_TRACE", NORMAL_PRIORITY) .addClass(this) .addMethod(this) Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -77,6 +77,7 @@ riskyMethodNameContents.add("close"); riskyMethodNameContents.add("copy"); riskyMethodNameContents.add("currentTimeMillis"); + riskyMethodNameContents.add("nanoTime"); riskyMethodNameContents.add("newInstance"); riskyMethodNameContents.add("noneOf"); riskyMethodNameContents.add("allOf"); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -235,36 +235,40 @@ byte[] bytes = getCode().getCode(); if (lastPCs[1] != -1) { - int loadIns = CodeByteUtils.getbyte(bytes, lastPCs[2]); - if ((CodeByteUtils.getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) - && ((loadIns == LDC) || (loadIns == LDC_W)) - && (CodeByteUtils.getbyte(bytes, lastPCs[1]) == INVOKEVIRTUAL)) { - ConstantPool pool = getConstantPool(); - int toStringIndex = CodeByteUtils.getshort(bytes, lastPCs[1]+1); - ConstantMethodref toStringMR = (ConstantMethodref)pool.getConstant(toStringIndex); - String toStringCls = toStringMR.getClass(pool); - if (toStringCls.startsWith("java.lang.StringBu")) { - int consIndex = CodeByteUtils.getbyte(bytes, lastPCs[2]+1); - Constant c = pool.getConstant(consIndex); - if (c instanceof ConstantString) { - if ("".equals(((ConstantString) c).getBytes(pool))) { - int nandtIndex = toStringMR.getNameAndTypeIndex(); - ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); - if ("toString".equals(cnt.getName(pool))) { - int lengthIndex = CodeByteUtils.getshort(bytes, lastPCs[3]+1); - ConstantMethodref lengthMR = (ConstantMethodref)pool.getConstant(lengthIndex); - nandtIndex = lengthMR.getNameAndTypeIndex(); - cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); - if ("equals".equals(cnt.getName(pool))) { - bugReporter.reportBug(new BugInstance(this, "SPP_USE_STRINGBUILDER_LENGTH", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } - } - } + if (CodeByteUtils.getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) { + int loadIns = CodeByteUtils.getbyte(bytes, lastPCs[2]); + if (((loadIns == LDC) || (loadIns == LDC_W)) + && (CodeByteUtils.getbyte(bytes, lastPCs[1]) == INVOKEVIRTUAL)) { + ConstantPool pool = getConstantPool(); + int toStringIndex = CodeByteUtils.getshort(bytes, lastPCs[1]+1); + Constant cmr = pool.getConstant(toStringIndex); + if (cmr instanceof ConstantMethodref) { + ConstantMethodref toStringMR = (ConstantMethodref)cmr; + String toStringCls = toStringMR.getClass(pool); + if (toStringCls.startsWith("java.lang.&&StringBu")) { + int consIndex = CodeByteUtils.getbyte(bytes, lastPCs[2]+1); + Constant c = pool.getConstant(consIndex); + if (c instanceof ConstantString) { + if ("".equals(((ConstantString) c).getBytes(pool))) { + int nandtIndex = toStringMR.getNameAndTypeIndex(); + ConstantNameAndType cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); + if ("toString".equals(cnt.getName(pool))) { + int lengthIndex = CodeByteUtils.getshort(bytes, lastPCs[3]+1); + ConstantMethodref lengthMR = (ConstantMethodref)pool.getConstant(lengthIndex); + nandtIndex = lengthMR.getNameAndTypeIndex(); + cnt = (ConstantNameAndType)pool.getConstant(nandtIndex); + if ("equals".equals(cnt.getName(pool))) { + bugReporter.reportBug(new BugInstance(this, "SPP_USE_STRINGBUILDER_LENGTH", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + } + } + } + } } } } else if ((seen == IRETURN) && lastIfEqWasBoolean) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java 2013-06-01 19:30:46 UTC (rev 1747) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java 2013-07-14 19:23:07 UTC (rev 1748) @@ -214,6 +214,10 @@ } state = State.SEEN_NOTHING; break; + + case SEEN_ARRAYSTORE: + case SEEN_NEWARRAY: + break; } } finally { TernaryPatcher.pre(stack, seen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-06-01 19:30:50
|
Revision: 1747 http://sourceforge.net/p/fb-contrib/code/1747 Author: dbrosius Date: 2013-06-01 19:30:46 +0000 (Sat, 01 Jun 2013) Log Message: ----------- merge from git Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/bugrank.txt trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/ISB_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java Added Paths: ----------- trunk/fb-contrib/samples/NPMC_Sample.java trunk/fb-contrib/samples/UMTP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/build.xml 2013-06-01 19:30:46 UTC (rev 1747) @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="4.8.3" /> + <property name="fb-contrib.version" value="4.9.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -191,8 +191,8 @@ </target> <target name="srczip" description="builds the source distribution zip file"> - <zip destfile="${basedir}/fb-contrib-src-${fb-contrib.version}.zip" basedir="${basedir}"> - <fileset dir="${src.dir}"> + <zip destfile="${basedir}/fb-contrib-src-${fb-contrib.version}.zip"> + <fileset dir="${basedir}"> <include name="**/*.java" /> <include name="**/*.xml" /> <include name="**/*.xsd" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/etc/bugrank.txt 2013-06-01 19:30:46 UTC (rev 1747) @@ -79,7 +79,7 @@ 0 BugPattern SPP_EQUALS_ON_ENUM 0 BugPattern SPP_INVALID_BOOLEAN_NULL_CHECK 0 BugPattern SPP_USE_CHARAT -0 BugPattern SPP_USELESS_TRINARY +0 BugPattern SPP_USELESS_TERNARY 0 BugPattern SPP_SUSPECT_STRING_TEST 0 BugPattern SPP_USE_STRINGBUILDER_LENGTH 0 BugPattern SPP_INVALID_CALENDAR_COMPARE Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/etc/findbugs.xml 2013-06-01 19:30:46 UTC (rev 1747) @@ -17,7 +17,7 @@ <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering" speed="fast" reports="ISB_INEFFICIENT_STRING_BUFFERING,ISB_EMPTY_STRING_APPENDING" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering" speed="fast" reports="ISB_INEFFICIENT_STRING_BUFFERING,ISB_EMPTY_STRING_APPENDING,ISB_TOSTRING_APPENDING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SyncCollectionIterators" speed="slow" reports="SCI_SYNCHRONIZED_COLLECTION_ITERATORS" /> @@ -30,9 +30,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents" speed="fast" reports="UCC_UNRELATED_COLLECTION_CONTENTS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" speed="fast" reports="DRE_DECLARED_RUNTIME_EXCEPTION" /> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" /> - COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PartiallyConstructedObjectAccess" speed="fast" reports="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" /> @@ -73,9 +73,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractOverriddenMethod" speed="fast" reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML" speed="fast" reports="CBX_CUSTOM_BUILT_XML" /> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> - COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.ConstantListIndex" speed="fast" reports="CLI_CONSTANT_LIST_INDEX" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SloppyClassReflection" speed="fast" reports="SCR_SLOPPY_CLASS_REFLECTION" /> @@ -132,7 +132,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS" /> + 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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> @@ -176,9 +176,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryNewNullCheck" speed="fast" reports="UNNC_UNNECESSARY_NEW_NULL_CHECK" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeprecatedTypesafeEnumPattern" speed="fast" reports="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" /> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> - COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.TristateBooleanPattern" speed="fast" reports="TBP_TRISTATE_BOOLEAN_PATTERN" /> @@ -193,9 +193,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PoorlyDefinedParameter" speed="fast" reports="PDP_POORLY_DEFINED_PARAMETER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NonSymmetricEquals" speed="fast" reports="NSE_NON_SYMMETRIC_EQUALS" /> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> - COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField" speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" /> @@ -221,9 +221,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousGetterSetterUse" speed="fast" reports="SGSU_SUSPICIOUS_GETTER_SETTER_USE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects" speed="fast" reports="LGO_LINGERING_GRAPHICS_OBJECT" /> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> - COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsEqualsBuilderToEquals" speed="fast" reports="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsHashcodeBuilderToHashcode" speed="fast" reports="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE" /> @@ -235,7 +235,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BackportReusePublicIdentifiers" speed="fast" reports="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_MISMATCHED_RETURN,CU_CLONE_USABILITY_THROWS" /> -<!-- + <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> @@ -243,11 +243,12 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnboundMethodTemplateParameter" speed="fast" reports="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" /> ---> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> <BugPattern abbrev="ISB" type="ISB_EMPTY_STRING_APPENDING" category="PERFORMANCE" /> + <BugPattern abbrev="ISB" type="ISB_TOSTRING_APPENDING" category="CORRECTNESS" /> <BugPattern abbrev="SCI" type="SCI_SYNCHRONIZED_COLLECTION_ITERATORS" category="CORRECTNESS" /> <BugPattern abbrev="CC" type="CC_CYCLOMATIC_COMPLEXITY" category="STYLE" /> <BugPattern abbrev="OCP" type="OCP_OVERLY_CONCRETE_PARAMETER" category="STYLE" /> @@ -329,7 +330,7 @@ <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_ENUM" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_INVALID_BOOLEAN_NULL_CHECK" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_USE_CHARAT" category="PERFORMANCE" /> - <BugPattern abbrev="SPP" type="SPP_USELESS_TRINARY" category="PERFORMANCE" /> + <BugPattern abbrev="SPP" type="SPP_USELESS_TERNARY" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_SUSPECT_STRING_TEST" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_USE_STRINGBUILDER_LENGTH" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_INVALID_CALENDAR_COMPARE" category="CORRECTNESS" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/etc/messages.xml 2013-06-01 19:30:46 UTC (rev 1747) @@ -1359,6 +1359,18 @@ ]]> </Details> </BugPattern> + + <BugPattern type="ISB_TOSTRING_APPENDING"> + <ShortDescription>Method concatenates the result of a toString() call</ShortDescription> + <LongDescription>Method {1} concatenates the result of a toString() call</LongDescription> + <Details> + <![CDATA[ + <p> This method concatenates the output of a toString() call into a StringBuffer/Builder. + It is simpler just pass the object you want to append to the to append call, as that form + does not suffer the potential for NullPointerExceptions, and is easier to read.</p> + ]]> + </Details> + </BugPattern> <BugPattern type="SCI_SYNCHRONIZED_COLLECTION_ITERATORS"> <ShortDescription>Method creates iterators on synchronized collections</ShortDescription> @@ -2431,13 +2443,13 @@ </Details> </BugPattern> - <BugPattern type="SPP_USELESS_TRINARY"> - <ShortDescription>Method uses a trinary operator to cast a boolean to true or false</ShortDescription> - <LongDescription>Method {1} uses a trinary operator to cast a boolean to true or false</LongDescription> + <BugPattern type="SPP_USELESS_TERNARY"> + <ShortDescription>Method uses a ternary operator to cast a boolean to true or false</ShortDescription> + <LongDescription>Method {1} uses a ternary operator to cast a boolean to true or false</LongDescription> <Details> <![CDATA[ - <p>This method tests the value of a boolean and using a trinary operator to return either true or false. - The trinary operator is completely unecessary, just use the original boolean value.</p> + <p>This method tests the value of a boolean and using a ternary operator to return either true or false. + The ternary operator is completely unecessary, just use the original boolean value.</p> ]]> </Details> </BugPattern> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/htdocs/index.shtml 2013-06-01 19:30:46 UTC (rev 1747) @@ -73,9 +73,9 @@ </div> <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>[CVAA] ContraVariant Array Assignment</b><br/> Looks for contravariant array assignments. Since arrays are mutable data structures, their use @@ -86,6 +86,11 @@ same kind of exception, and throw the same exception always. These blocks can be coalesced into one. </li> + <li><b>[CAAL] Confusing Array As List</b><br/> + Looks for calls to Arrays.asList where the parameter is a primitive array. + This does not produce a list that holds the primitive boxed value, but a list of + one item, the array itself. + </li> <li><b>[PSC] Presize Collections</b><br/> Looks for methods that create and populate collections, and while knowing the end size of those collections, does not pre allocate the collection @@ -105,9 +110,9 @@ </ul> </div> <hr/> - <img id="v4_8_0_image" src="flip2.gif" onClick="toggleBlock('v4_8_0', 'v4_8_0_image');" align="top"/> + <img id="v4_8_0_image" src="flip1.gif" onClick="toggleBlock('v4_8_0', 'v4_8_0_image');" align="top"/> Detectors added in v4.8.0<br/> - <div id="v4_8_0" style="display:block;"> + <div id="v4_8_0" style="display:none;"> <ul> <li><b>[LGO] Lingering Graphics Object</b><br/> Looks for creation of java.awt.Graphics object that do not have the Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/pom.xml 2013-06-01 19:30:46 UTC (rev 1747) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>4.8.3</version> + <version>4.9.0</version> <parent> <groupId>org.sonatype.oss</groupId> Modified: trunk/fb-contrib/samples/ISB_Sample.java =================================================================== --- trunk/fb-contrib/samples/ISB_Sample.java 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/samples/ISB_Sample.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -68,6 +68,12 @@ return sb.toString(); } + public String testTOStringAppending() { + StringBuilder sb = new StringBuilder(); + sb.append(this.toString()); + return sb.toString(); + } + @Override public String toString() { Added: trunk/fb-contrib/samples/NPMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/NPMC_Sample.java (rev 0) +++ trunk/fb-contrib/samples/NPMC_Sample.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -0,0 +1,60 @@ +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + +public class NPMC_Sample implements Cloneable +{ + public void testToString() + { + StringBuilder sb = new StringBuilder(); + sb.append("hello").append("world").toString(); + } + + public void testXValue() + { + Integer i = Integer.valueOf(4); + i.intValue(); + Long l = Long.valueOf(4); + l.longValue(); + Double d = Double.valueOf(4); + d.doubleValue(); + Float f = Float.valueOf(4); + f.doubleValue(); + } + + public void testEquals(Object o) + { + equals(o); + } + + public void testHashCode() + { + hashCode(); + } + + public NPMC_Sample clone() + { + try + { + super.clone(); + + return null; + } + catch (CloneNotSupportedException cnse) + { + throw new Error(); + } + } + + public String[] testToArrayList() + { + List<String> l = new ArrayList<String>(); + l.toArray(); + Set<String> s = new HashSet<String>(); + s.toArray(); + + return null; + } +} Property changes on: trunk/fb-contrib/samples/NPMC_Sample.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/fb-contrib/samples/UMTP_Sample.java =================================================================== --- trunk/fb-contrib/samples/UMTP_Sample.java (rev 0) +++ trunk/fb-contrib/samples/UMTP_Sample.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -0,0 +1,38 @@ +import java.util.HashMap; +import java.util.Map; + + +public class UMTP_Sample { + + public <T, C> C getT(String s, int i, Class<C> cls) { + T t = (T) getFoo(); + System.out.println(t); + + return (C) new Object(); + } + + public <T> String fpUseClass(T t) { + return t.toString(); + } + + public <T> String fpUseClass(Class<T> c) { + return c.getName().toString(); + } + + public <T> String fpUseArray(T[] t) { + return t[0].toString(); + } + + private <K, V> Map<V, K> fpKVReverseMap(Map<K, V> map) { + Map<V, K> m = new HashMap<V, K>(); + for (Map.Entry<K, V> entry : map.entrySet()) { + m.put(entry.getValue(), entry.getKey()); + } + + return m; + } + + public Object getFoo() { + return null; + } +} Property changes on: trunk/fb-contrib/samples/UMTP_Sample.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -35,6 +35,8 @@ */ public class InefficientStringBuffering extends BytecodeScanningDetector { + private enum AppendType { NONE, CLEAR, NESTED, TOSTRING }; + private BugReporter bugReporter; private OpcodeStack stack; private boolean sawLDCEmpty; @@ -77,7 +79,7 @@ @Override public void sawOpcode(final int seen) { - Boolean nestedSB = null; + AppendType apType = AppendType.NONE; try { stack.mergeJumps(this); @@ -90,13 +92,13 @@ if ("()V".equals(signature)) { OpcodeStack.Item itm = getStringBufferItemAt(2); if (itm != null) { - nestedSB = Boolean.TRUE; + apType = AppendType.NESTED; } } else if ("(Ljava/lang/String;)V".equals(signature)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); - nestedSB = (Boolean)itm.getUserValue(); - if ((nestedSB != null) && nestedSB.booleanValue()) { + apType = (AppendType)itm.getUserValue(); + if (apType == AppendType.NESTED) { bugReporter.reportBug( new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", NORMAL_PRIORITY) .addClass(this) @@ -138,31 +140,38 @@ String methodName = getNameConstantOperand(); if ("append".equals(methodName)) { OpcodeStack.Item itm = getStringBufferItemAt(1); - nestedSB = (itm == null) ? null : (Boolean)itm.getUserValue(); + apType = (itm == null) ? AppendType.NONE : (AppendType )itm.getUserValue(); if (stack.getStackDepth() > 0) { itm = stack.getStackItem(0); - Boolean uValue = (Boolean)itm.getUserValue(); - if ((uValue != null) && uValue.booleanValue()) { + AppendType apValue = (AppendType)itm.getUserValue(); + if (apValue == AppendType.NESTED) { bugReporter.reportBug( new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); - + } else if (apValue == AppendType.TOSTRING){ + bugReporter.reportBug( + new BugInstance(this, "ISB_TOSTRING_APPENDING", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); } } } else if ("toString".equals(methodName)) { OpcodeStack.Item itm = getStringBufferItemAt(0); - nestedSB = (itm == null) ? null : (Boolean)itm.getUserValue(); + apType = (itm == null) ? AppendType.NONE : (AppendType)itm.getUserValue(); } + } else if ("toString".equals(getNameConstantOperand()) && "()Ljava/lang/String;".equals(getSigConstantOperand())) { + apType = AppendType.TOSTRING; } } else if ((seen == GOTO) || (seen == GOTO_W)) { int depth = stack.getStackDepth(); for (int i = 0; i < depth; i++) { OpcodeStack.Item itm = stack.getStackItem(i); - itm.setUserValue(Boolean.FALSE); + itm.setUserValue(AppendType.NONE); } } else if ((seen == LDC) || (seen == LDC_W)) { Constant c = getConstantRefOperand(); @@ -171,15 +180,17 @@ if (s.length() == 0) sawLDCEmpty = true; } + } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { + apType = AppendType.CLEAR; } } finally { TernaryPatcher.pre(stack, seen); stack.sawOpcode(this, seen); TernaryPatcher.post(stack, seen); - if (nestedSB != null) { + if (apType != AppendType.NONE) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); - itm.setUserValue(nestedSB); + itm.setUserValue(apType); } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -267,12 +267,14 @@ } } } else if ("(Ljava/lang/Object;)V".equals(sig)) { - final JavaClass clazz = stack.getStackItem(0).getJavaClass(); - if(clazz.instanceOf(THROWABLE_CLASS)) { - bugReporter.reportBug(new BugInstance(this, "LO_LOGGER_LOST_EXCEPTION_STACK_TRACE", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + if (stack.getStackDepth() > 0) { + final JavaClass clazz = stack.getStackItem(0).getJavaClass(); + if(clazz.instanceOf(THROWABLE_CLASS)) { + bugReporter.reportBug(new BugInstance(this, "LO_LOGGER_LOST_EXCEPTION_STACK_TRACE", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -142,7 +142,7 @@ } } else if ((seen == GOTO) || (seen == GOTO_W)) { if (stack.getStackDepth() > 0) { - methodSuspect = false; //Trinaries confuse us too much, if the code has a trinary well - oh well + methodSuspect = false; //Trinaries confuse us too much, if the code has a ternary well - oh well } } else if (seen == INVOKEVIRTUAL) { String clsName = getClassConstantOperand(); Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -0,0 +1,138 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2013 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.HashSet; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.bcel.classfile.Code; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for common methods that are believed to be non mutating, where the value + * is discarded. Since the method makes no changes to the object, calling this method + * is useless. The method call can be removed. + */ +public class NonProductiveMethodCall extends BytecodeScanningDetector { + + private static final Set<Pattern> IMMUTABLE_METHODS = new HashSet<Pattern>(); + + static { + IMMUTABLE_METHODS.add(Pattern.compile(".*@toString\\(\\)Ljava/lang/String;")); + IMMUTABLE_METHODS.add(Pattern.compile("java/lang/.+@.+Value\\(\\)[BCDFIJSZ]")); + IMMUTABLE_METHODS.add(Pattern.compile(".*@equals\\(Ljava/lang/Object;\\)Z")); + IMMUTABLE_METHODS.add(Pattern.compile(".*@hashCode\\(\\)I")); + IMMUTABLE_METHODS.add(Pattern.compile(".*@clone\\(\\).+")); + IMMUTABLE_METHODS.add(Pattern.compile("java/util/.+@toArray\\(\\)\\[.+")); + } + + private BugReporter bugReporter; + private OpcodeStack stack; + + /** + * constructs a NPMC detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public NonProductiveMethodCall(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to set and clear the stack + */ + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + stack = null; + } + } + + /** + * implements the visitor to reset the opcode stack + * + * @param obj the context object of the currently parsed code block + */ + public void visitCode(Code obj) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } + + /** + * implements the visitor to look for return values of common immutable method + * calls, that are thrown away. + * + * @param seen the opcode of the currently parsed instruction + */ + public void sawOpcode(int seen) { + String methodInfo = null; + try { + switch (seen) { + case INVOKEVIRTUAL: + case INVOKEINTERFACE: + case INVOKESTATIC: + String sig = getSigConstantOperand(); + if (!sig.endsWith("V")) { + methodInfo = getClassConstantOperand() + "@" + getNameConstantOperand() + getSigConstantOperand(); + } + break; + + case POP: + case POP2: + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + String mInfo = (String) item.getUserValue(); + if (mInfo != null) { + for (Pattern p : IMMUTABLE_METHODS) { + Matcher m = p.matcher(mInfo); + + if (m.matches()) { + bugReporter.reportBug(new BugInstance(this, "NPMC_NON_PRODUCTIVE_METHOD_CALL", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this) + .addString(mInfo)); + break; + } + } + } + } + break; + } + + + } finally { + stack.sawOpcode(this, seen); + if (methodInfo != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(methodInfo); + } + } + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -26,6 +26,8 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.CodeException; +import org.apache.bcel.classfile.LineNumber; +import org.apache.bcel.classfile.LineNumberTable; import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.collect.Statistics; @@ -272,21 +274,26 @@ if (!signature.endsWith("V") && methodName.equals(mc.getName()) && signature.equals(mc.getSignature()) && !isRiskyName(className, methodName)) { Object[] parms = mc.getParms(); if (Arrays.equals(parms, parmConstants)) { - Statistics statistics = Statistics.getStatistics(); - Statistics.MethodInfo mi = statistics.getMethodStatistics(getClassConstantOperand(), methodName, signature); - - bugReporter.reportBug(new BugInstance(this, "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS", - ((mi.numBytes >= highByteCountLimit) || (mi.numMethodCalls >= highMethodCallLimit)) ? - HIGH_PRIORITY : - ((mi.numBytes >= normalByteCountLimit) || (mi.numMethodCalls >= normalMethodCallLimit)) ? - NORMAL_PRIORITY : - ((mi.numBytes == 0) || (mi.numMethodCalls == 0)) ? - LOW_PRIORITY : - EXP_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this) - .addString(methodName + signature)); + int pc = getPC(); + int ln = getLineNumber(pc); + + if ((ln != mc.getLineNumber()) || (Math.abs(pc - mc.getPC()) < 10)) { + Statistics statistics = Statistics.getStatistics(); + Statistics.MethodInfo mi = statistics.getMethodStatistics(getClassConstantOperand(), methodName, signature); + + bugReporter.reportBug(new BugInstance(this, "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS", + ((mi.numBytes >= highByteCountLimit) || (mi.numMethodCalls >= highMethodCallLimit)) ? + HIGH_PRIORITY : + ((mi.numBytes >= normalByteCountLimit) || (mi.numMethodCalls >= normalMethodCallLimit)) ? + NORMAL_PRIORITY : + ((mi.numBytes == 0) || (mi.numMethodCalls == 0)) ? + LOW_PRIORITY : + EXP_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this) + .addString(methodName + signature)); + } } } @@ -309,17 +316,19 @@ } } } else { + int pc = getPC(); + int ln = getLineNumber(pc); if (seen == INVOKESTATIC) { - staticMethodCalls.put(className, new MethodCall(methodName, signature, parmConstants)); + staticMethodCalls.put(className, new MethodCall(methodName, signature, parmConstants, pc, ln)); } else { if (reg >= 0) { - localMethodCalls.put(Integer.valueOf(reg), new MethodCall(methodName, signature, parmConstants)); + localMethodCalls.put(Integer.valueOf(reg), new MethodCall(methodName, signature, parmConstants, pc, ln)); } else if (field != null) { OpcodeStack.Item obj = stack.getStackItem(parmCount); String fieldSource = (String) obj.getUserValue(); if (fieldSource == null) fieldSource = ""; - fieldMethodCalls.put(fieldSource + ":" + field.getName(), new MethodCall(methodName, signature, parmConstants)); + fieldMethodCalls.put(fieldSource + ":" + field.getName(), new MethodCall(methodName, signature, parmConstants, pc, ln)); } } } @@ -355,6 +364,42 @@ } return false; } + + /** + * returns the source line number for the pc, or just the pc if the line number table + * doesn't exist + * + * @param pc current pc + * @return the line number + */ + private int getLineNumber(int pc) { + LineNumberTable lnt = getMethod().getLineNumberTable(); + if (lnt == null) + return pc; + + LineNumber[] lns = lnt.getLineNumberTable(); + if (lns == null) + return pc; + + if (pc > lns[lns.length-1].getStartPC()) + return lns[lns.length-1].getLineNumber(); + + int lo = 0; + int hi = lns.length - 2; + int mid = 0; + while (lo <= hi) { + mid = (lo + hi) / 2; + if (pc < lns[mid].getStartPC()) { + hi = mid - 1; + } else if (pc >= lns[mid+1].getStartPC()) { + lo = mid + 1; + } else { + break; + } + } + + return lns[mid].getLineNumber(); + } /** * contains information about a method call @@ -364,11 +409,15 @@ private final String methodName; private final String methodSignature; private final Object[] methodParms; + private final int methodPC; + private final int methodLineNumber; - public MethodCall(String name, String signature, Object[] parms) { + public MethodCall(String name, String signature, Object[] parms, int pc, int lineNumber) { methodName = name; methodSignature = signature; methodParms = parms; + methodPC = pc; + methodLineNumber = lineNumber; } public String getName() { @@ -382,5 +431,13 @@ public Object[] getParms() { return methodParms; } + + public int getPC() { + return methodPC; + } + + public int getLineNumber() { + return methodLineNumber; + } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -288,7 +288,7 @@ } if (bug) { - bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_TRINARY", NORMAL_PRIORITY) + bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_TERNARY", NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this)); Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -0,0 +1,129 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2013 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; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.classfile.Signature; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.Detector; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.visitclass.PreorderVisitor; + +/** + * Looks for methods that declare method level template parameter(s) that are not bound to any of the + * method's parameters, and thus is not adding any validation/type safety to the method, and is + * just confusing. + */ +public class UnboundMethodTemplateParameter extends PreorderVisitor implements Detector { + + private static final Pattern TEMPLATED_SIGNATURE = Pattern.compile("(\\<[^\\>]+\\>)(.+)"); + private static final Pattern TEMPLATE = Pattern.compile("\\<?([^:]+):[^;]*;"); + private BugReporter bugReporter; + + + public UnboundMethodTemplateParameter(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to accept the class for visiting + * + * @param classContext the context object of the currently parsed class + */ + public void visitClassContext(ClassContext classContext) { + JavaClass cls = classContext.getJavaClass(); + cls.accept(this); + } + + /** + * implements the visitor to find methods that declare template parameters + * that are not bound to any parameter. + * + * @param obj the context object of the currently parsed method + */ + @Override + public void visitMethod(Method obj) { + Attribute[] attributes = obj.getAttributes(); + for (Attribute a : attributes) { + if (a.getName().equals("Signature")) { + TemplateSignature ts = parseSignatureAttribute((Signature) a); + if (ts != null) { + for (String templateParm : ts.templateParameters) { + if (!ts.signature.contains("T" + templateParm + ";") && !ts.signature.contains("[T" + templateParm + ";")) { + bugReporter.reportBug(new BugInstance(this, "UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addString("Template Parameter: " + templateParm)); + return; + } + } + } + return; + } + } + } + + public void report() { + } + + /** + * builds a template signature object based on the signature attribute of the method + * + * @param signatureAttribute the signature attribute + * @return a template signature if there are templates defined, otherwise null + */ + private TemplateSignature parseSignatureAttribute(Signature signatureAttribute) { + + Matcher m = TEMPLATED_SIGNATURE.matcher(signatureAttribute.getSignature()); + if (m.matches()) { + TemplateSignature ts = new TemplateSignature(); + ts.signature = m.group(2); + + String template = m.group(1); + + m = TEMPLATE.matcher(template); + List<String> templates = new ArrayList<String>(4); + while (m.find()) { + templates.add(m.group(1)); + } + ts.templateParameters = templates.toArray(new String[templates.size()]); + + return ts; + } + + return null; + } + + /** + * a simple data only class for holding the template parameters and method signature + */ + static class TemplateSignature { + String[] templateParameters; + String signature; + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -76,7 +76,7 @@ CodeException[] ce = obj.getExceptionTable(); if (ce != null) { for (CodeException element : ce) { - transitionPoints.add(Integer.valueOf(element.getHandlerPC())); + transitionPoints.add(Integer.valueOf(element.getEndPC())); } } super.visitCode(obj); @@ -103,6 +103,12 @@ case MULTIANEWARRAY: sawAlloc = true; break; + + case INVOKESPECIAL: + if ("<init>".equals(getNameConstantOperand())) { + sawAlloc = true; + } + break; case ASTORE: case ASTORE_0: @@ -126,9 +132,7 @@ case ALOAD_2: case ALOAD_3: int reg = RegisterUtils.getALoadReg(this, seen); - if (allocationRegs.contains(Integer.valueOf(reg))) { - sawAlloc = true; - } + sawAlloc = (allocationRegs.contains(Integer.valueOf(reg))); break; case IFNONNULL: @@ -184,11 +188,10 @@ TernaryPatcher.pre(stack, seen); stack.sawOpcode(this, seen); TernaryPatcher.post(stack, seen); - if (sawAlloc) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item item = stack.getStackItem(0); - item.setUserValue(Boolean.TRUE); - } + + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(sawAlloc ? Boolean.TRUE : null); } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2013-04-20 17:38:45 UTC (rev 1746) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2013-06-01 19:30:46 UTC (rev 1747) @@ -86,8 +86,17 @@ binaryOps.set(FREM); binaryOps.set(DREM); binaryOps.set(IOR); + binaryOps.set(LOR); binaryOps.set(IAND); + binaryOps.set(LAND); binaryOps.set(IXOR); + binaryOps.set(LXOR); + binaryOps.set(ISHL); + binaryOps.set(LSHL); + binaryOps.set(ISHR); + binaryOps.set(LSHR); + binaryOps.set(IUSHR); + binaryOps.set(LUSHR); } private final BugReporter bugReporter; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-04-20 17:38:47
|
Revision: 1746 http://sourceforge.net/p/fb-contrib/code/1746 Author: dbrosius Date: 2013-04-20 17:38:45 +0000 (Sat, 20 Apr 2013) Log Message: ----------- Version 4.8.3 Added Paths: ----------- tags/v4_8_3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-04-20 17:08:19
|
Revision: 1745 http://sourceforge.net/p/fb-contrib/code/1745 Author: dbrosius Date: 2013-04-20 17:08:15 +0000 (Sat, 20 Apr 2013) Log Message: ----------- prepare for 4.8.3 release Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/pom.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2013-04-19 12:02:04 UTC (rev 1744) +++ trunk/fb-contrib/build.xml 2013-04-20 17:08:15 UTC (rev 1745) @@ -17,7 +17,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="4.9.0" /> + <property name="fb-contrib.version" value="4.8.3" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-04-19 12:02:04 UTC (rev 1744) +++ trunk/fb-contrib/etc/findbugs.xml 2013-04-20 17:08:15 UTC (rev 1745) @@ -30,9 +30,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents" speed="fast" reports="UCC_UNRELATED_COLLECTION_CONTENTS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" speed="fast" reports="DRE_DECLARED_RUNTIME_EXCEPTION" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PartiallyConstructedObjectAccess" speed="fast" reports="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" /> @@ -73,9 +73,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.AbstractOverriddenMethod" speed="fast" reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML" speed="fast" reports="CBX_CUSTOM_BUILT_XML" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.ConstantListIndex" speed="fast" reports="CLI_CONSTANT_LIST_INDEX" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SloppyClassReflection" speed="fast" reports="SCR_SLOPPY_CLASS_REFLECTION" /> @@ -176,9 +176,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryNewNullCheck" speed="fast" reports="UNNC_UNNECESSARY_NEW_NULL_CHECK" /> <Detector class="com.mebigfatguy.fbcontrib.detect.DeprecatedTypesafeEnumPattern" speed="fast" reports="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.TristateBooleanPattern" speed="fast" reports="TBP_TRISTATE_BOOLEAN_PATTERN" /> @@ -193,9 +193,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PoorlyDefinedParameter" speed="fast" reports="PDP_POORLY_DEFINED_PARAMETER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NonSymmetricEquals" speed="fast" reports="NSE_NON_SYMMETRIC_EQUALS" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField" speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" /> @@ -221,9 +221,9 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousGetterSetterUse" speed="fast" reports="SGSU_SUSPICIOUS_GETTER_SETTER_USE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects" speed="fast" reports="LGO_LINGERING_GRAPHICS_OBJECT" /> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> -<!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsEqualsBuilderToEquals" speed="fast" reports="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsHashcodeBuilderToHashcode" speed="fast" reports="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE" /> @@ -235,7 +235,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BackportReusePublicIdentifiers" speed="fast" reports="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_MISMATCHED_RETURN,CU_CLONE_USABILITY_THROWS" /> - +<!-- <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> @@ -243,7 +243,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnboundMethodTemplateParameter" speed="fast" reports="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" /> - +--> <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2013-04-19 12:02:04 UTC (rev 1744) +++ trunk/fb-contrib/pom.xml 2013-04-20 17:08:15 UTC (rev 1745) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>4.9.0</version> + <version>4.8.3</version> <parent> <groupId>org.sonatype.oss</groupId> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java 2013-04-19 12:02:04 UTC (rev 1744) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java 2013-04-20 17:08:15 UTC (rev 1745) @@ -79,7 +79,7 @@ /** * implements the visitor to clear the opcode stack * - * @param seen the currently code block + * @param obj the currently code block */ public void visitCode(Code obj) { stack.resetForMethodEntry(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-04-19 12:02:08
|
Revision: 1744 http://sourceforge.net/p/fb-contrib/code/1744 Author: dbrosius Date: 2013-04-19 12:02:04 +0000 (Fri, 19 Apr 2013) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2013-04-18 18:16:49 UTC (rev 1743) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2013-04-19 12:02:04 UTC (rev 1744) @@ -44,7 +44,7 @@ internalPackages.add("org/apache/xerces/"); internalPackages.add("org/apache/xalan/"); externalPackages.add("com/sun/jersey"); - externalPackages.add("com/sun/xsom"); + externalPackages.add("com/sun/xml/xsom"); externalPackages.add("org/apache/xerces/xni/"); externalPackages.add("org/apache/xerces/xs/"); externalPackages.add("org/apache/xalan/extensions"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-04-18 18:17:00
|
Revision: 1743 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1743&view=rev Author: dbrosius Date: 2013-04-18 18:16:49 +0000 (Thu, 18 Apr 2013) Log Message: ----------- merge from github Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/samples/CU_Sample.java trunk/fb-contrib/samples/JAO_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/samples/PSC_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/etc/findbugs.xml 2013-04-18 18:16:49 UTC (rev 1743) @@ -132,7 +132,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE" /> + 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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> @@ -157,7 +157,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingFunctionSemantics" speed="fast" reports="CFS_CONFUSING_FUNCTION_SEMANTICS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.JUnitAssertionOddities" speed="fast" - reports="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT,JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE,JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT,JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" /> + reports="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT,JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE,JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT,JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED,JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousCloneAlgorithm" speed="fast" reports="SCA_SUSPICIOUS_CLONE_ALGORITHM" /> @@ -234,12 +234,16 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BackportReusePublicIdentifiers" speed="fast" reports="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_THROWS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_MISMATCHED_RETURN,CU_CLONE_USABILITY_THROWS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" /> <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnboundMethodTemplateParameter" speed="fast" reports="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -338,6 +342,8 @@ <BugPattern abbrev="SPP" type="SPP_EMPTY_CASING" category="STYLE" /> <BugPattern abbrev="SPP" type="SPP_TEMPORARY_TRIM" category="STYLE" /> <BugPattern abbrev="SPP" type="SPP_STRINGBUILDER_IS_MUTABLE" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_USE_GET0" category="PERFORMANCE" /> + <BugPattern abbrev="SPP" type="SPP_DOUBLE_APPENDED_LITERALS" category="PERFORMANCE" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> @@ -355,7 +361,9 @@ <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT" category="STYLE" /> <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE" category="STYLE" /> <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT" category="STYLE" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" category="CORRECTNESS" /> + <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" category="CORRECTNESS" /> + <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED" category="CORRECTNESS" /> + <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS" category="CORRECTNESS" /> <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" /> <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" /> <BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" /> @@ -415,7 +423,10 @@ <BugPattern abbrev="CCNE" type="CCNE_COMPARE_CLASS_EQUALS_NAME" category="CORRECTNESS" /> <BugPattern abbrev="BRPI" type="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" category ="PERFORMANCE" /> <BugPattern abbrev="CU" type="CU_CLONE_USABILITY_OBJECT_RETURN" category="STYLE" /> + <BugPattern abbrev="CU" type="CU_CLONE_USABILITY_MISMATCHED_RETURN" category="STYLE" /> <BugPattern abbrev="CU" type="CU_CLONE_USABILITY_THROWS" category="STYLE" /> <BugPattern abbrev="CAAL" type="CAAL_CONFUSING_ARRAY_AS_LIST" category="CORRECTNESS" /> <BugPattern abbrev="PSC" type="PSC_PRESIZE_COLLECTIONS" category="PERFORMANCE" /> + <BugPattern abbrev="UMTP" type="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" category="CORRECTNESS" /> + <BugPattern abbrev="NPMC" type="NPMC_NON_PRODUCTIVE_METHOD_CALL" category="CORRECTNESS" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/etc/messages.xml 2013-04-18 18:16:49 UTC (rev 1743) @@ -74,8 +74,8 @@ <Details> <![CDATA[ <p> Looks for for loops that iterate over a java.util.List using an integer index, and get, - rather than using an Iterator. An iterator may perform better depending List implementation, - but more importantly will allow the code to be converted to other collections type.</p> + rather than using an Iterator. An iterator may perform better depending on List implementation, + but more importantly will allow the code to be converted to other collection types.</p> <p>It is a moderately fast detector</p> ]]> </Details> @@ -85,7 +85,7 @@ <Details> <![CDATA[ <p> Looks for collections or arrays that hold objects that are unrelated thru class or - interface inheritance other than java.lang.Object. Doing so, makes for brittle code, + interface inheritance other than java.lang.Object. Doing so makes for brittle code, relying either on positional correspondence for type, or a reliance on instanceof to determine type. A better design usually can be had by creating a seperate class, which defines the different types required, and add an instance of that class to the @@ -101,7 +101,7 @@ <p> Looks for methods that declare Runtime exceptions in their throws clause. While doing so is not illegal, it may represent a misunderstanding as to the exception in question. If a RuntimeException is declared, it implies that this exception type is expected to happen, - which if true, should be handled in code, and not propogated. </p> + which if true should be handled in code, and not propagated. </p> <p>It is a fast detector</p> ]]> </Details> @@ -159,7 +159,8 @@ <![CDATA[ <p> Looks for classes that maintain two or more lists or arrays associated one-for-one through the same index to hold two or more pieces of related information. It would be better to create a new class that holds - all of these pieces of information, and place instances of this class in one list.</p> + all of these pieces of information, and place instances of this class in one list. Or if the two list are + related in key/value fashion, then a map.</p> <p>It is a fast detector</p> ]]> </Details> @@ -293,8 +294,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessAutoboxing"> <Details> <![CDATA[ - <p> Looks for methods that pass a primitive wrapper class object, to the - same classes Constructor. Patterns found are: + <p> Looks for methods that pass a primitive wrapper class object to the + same class' Constructor. Patterns found are: <ul> <li>new Boolean(Boolean)</li> <li>new Byte(Byte)</li> @@ -317,7 +318,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryStoreBeforeReturn"> <Details> <![CDATA[ - <p>Looks for methods that store the return result in a local variable, and + <p>Looks for methods that store the return result in a local variable and then immediately returns that local variable.</p> <p>It is a fast detector</p> ]]> @@ -622,7 +623,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.LostExceptionStackTrace"> <Details> <![CDATA[ - <p>Looks for methods that catch exceptions, and then throw a different exception, + <p>Looks for methods that catch exceptions, and then throw a different exception without embedding the original exception in the thrown one. Doing so, hides the real source of the exception, making debugging and fixing these problems difficult.</p> <p>It is a moderately fast detector</p> @@ -710,7 +711,7 @@ <Details> <![CDATA[ <p>Looks for classes that implement interfaces by relying on methods being - implemented in superclasses, even tho the superclass knows nothing about + implemented in superclasses, even though the superclass knows nothing about the interface being implemented by the child.</p> <p>It is a fast detector.</p> ]]> @@ -836,6 +837,7 @@ <li>Passing a constant as the second (actual) parameter</li> <li>not using the three parameter version of asserts for doubles</li> <li>Passing true or false as the first parameter instead of using assertTrue, or assertFalse</li> + <li>Using the assert keyword</li> </ul> </p> <p>It is a fast detector</p> @@ -1098,7 +1100,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionOnObjectMethods"> <Details> <![CDATA[ - <p>This detector looks for reflective calls on methods that are found java.lang.Object. + <p>This detector looks for reflective calls on methods that are found in the class java.lang.Object. As these methods are always available, there is no reason to use reflection to call them. </p> <p>It is a fast detector</p> @@ -1295,7 +1297,7 @@ </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections"> - <Details> + <Details> <![CDATA[ <p> Looks for methods that create collections using the default constructor, even though the number of elements that will be placed in the collection is known @@ -1307,6 +1309,30 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnboundMethodTemplateParameter"> + <Details> + <![CDATA[ + <p> Looks for methods that declare method level template parameter(s) that are not bound to any of the + method's parameters, and thus is not adding any validation/type safety to the method, and is + just confusing. + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall"> + <Details> + <![CDATA[ + <p> Looks for common methods that are non mutating where the return value is ignored. As these methods + do not change the object they are called on, calling this methods is pointless. They can be removed. + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -1314,7 +1340,7 @@ <LongDescription>Method {1} passes simple concatenating string in StringBuffer or StringBuilder append</LongDescription> <Details> <![CDATA[ - <p> This method uses StringBuffer or StringBuilder append to concatenate strings. However, it passes the result + <p> This method uses StringBuffer or StringBuilder's append method to concatenate strings. However, it passes the result of doing a simple String concatenation to one of these append calls, thus removing any performance gains of using the StringBuffer or StringBuilder class.</p> ]]> @@ -2568,6 +2594,28 @@ ]]> </Details> </BugPattern> + + <BugPattern type="SPP_USE_GET0"> + <ShortDescription>Method uses iterator().next() on a List to get the first item</ShortDescription> + <LongDescription>Method {1} uses iterator().next() on a List to get the first item</LongDescription> + <Details> + <![CDATA[ + This Method calls myList.iterator().next() on a List to get the first item. It is more performant + to just use myList.get(0). + ]]> + </Details> + </BugPattern> + + <BugPattern type="SPP_DOUBLE_APPENDED_LITERALS"> + <ShortDescription>Method appends two literal strings back to back to a StringBuilder</ShortDescription> + <LongDescription>Method {1} appends two literal strings back to back to a StringBuilder</LongDescription> + <Details> + <![CDATA[ + This method appends two literal strings to a StringBuilder back to back. This can be done with just + one append call, and may avoid intermediate reallocations of the StringBuilders backing store. + ]]> + </Details> + </BugPattern> <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> @@ -2804,6 +2852,30 @@ ]]> </Details> </BugPattern> + + <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED"> + <ShortDescription>Method uses java asserts rather than a junit assertion</ShortDescription> + <LongDescription>Method {1} uses java asserts rather than a junit assertion</LongDescription> + <Details> + <![CDATA[ + <p>This method uses a java assert to assure that a certain state is in effect. As this is + a junit test it makes more sense to either check this condition with a junit assert, or allow + a following exception to occur.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS"> + <ShortDescription>Method passes boolean expression to Assert.assertTrue</ShortDescription> + <LongDescription>Method {1} passes boolean expression to Assert.assertTrue</LongDescription> + <Details> + <![CDATA[ + <p>This method evaluates a boolean expression and passes that to Assert.assertTrue. It is better + to pass the two values that are being equated to the Assert.assertEquals method so that the + junit failure method is more meaningful of the intended test.</p> + ]]> + </Details> + </BugPattern> <BugPattern type="SCA_SUSPICIOUS_CLONE_ALGORITHM"> <ShortDescription>Clone method stores a new value to member field of source object</ShortDescription> @@ -3529,6 +3601,18 @@ ]]> </Details> </BugPattern> + + <BugPattern type="CU_CLONE_USABILITY_MISMATCHED_RETURN"> + <ShortDescription>Clone method declares it returns an type different then the owning class</ShortDescription> + <LongDescription>Clone method {1} declares it returns an type different then the owning class</LongDescription> + <Details> + <![CDATA[ + <p> This class implements the Cloneable interface but defines its clone method to return a type + that is different than the class itself, or any interfaces that the class implements. + </p> + ]]> + </Details> + </BugPattern> <BugPattern type="CU_CLONE_USABILITY_THROWS"> <ShortDescription>Clone method declares it throws CloneNotSupportedException</ShortDescription> @@ -3570,7 +3654,31 @@ </p> ]]> </Details> - </BugPattern>" + </BugPattern> + + <BugPattern type="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER"> + <ShortDescription>Method declares unbound method template parameter(s)</ShortDescription> + <LongDescription>Method {1} declares unbound method template parameter(s)</LongDescription> + <Details> + <![CDATA[ + <p>This method declares a method level template parameter that is not bound by any parameter of this + method. Therefore the template parameter adds no validation or type safety and can be removed, as it's + just confusing to the reader. + ]]> + </Details> + </BugPattern> + + <BugPattern type="NPMC_NON_PRODUCTIVE_METHOD_CALL"> + <ShortDescription>Method ignores return value of a non mutating method</ShortDescription> + <LongDescription>Method {1} ignores return value of a non mutating method</LongDescription> + <Details> + <![CDATA[ + <p>This method ignores the return value of a common method that is assumed to be none mutating. + If this method does in fact not modify the object it is called on, there is no reason to call + this method, and it can be removed. + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -3682,4 +3790,6 @@ <BugCode abbrev="CU">Clone Usability</BugCode> <BugCode abbrev="CAAL">Confusing Array asList</BugCode> <BugCode abbrev="PSC">Presize Collection</BugCode> + <BugCode abbrev="UMTP">Unbound Method Template Parameter</BugCode> + <BugCode abbrev="NPMC">Non Productive Method Call</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/htdocs/index.shtml 2013-04-18 18:16:49 UTC (rev 1743) @@ -86,6 +86,22 @@ same kind of exception, and throw the same exception always. These blocks can be coalesced into one. </li> + <li><b>[PSC] Presize Collections</b><br/> + Looks for methods that create and populate collections, and while knowing + the end size of those collections, does not pre allocate the collection + to be big enough. This just causes unneeded reallocations putting strain + on the garbage collector. + </li> + <li><b>[UMTP] Unbound Method Template Parameter</b><br/> + Looks for methods that declare method level template parameter(s) that are not bound to any of + the method's parameters, and thus is not adding any validation/type safety to the method, + and is just confusing. + </li> + <li><b>[NPMC] Non Productive Method Call</b><br/> + Looks for common methods that are believed to be non mutating, where the value + is discarded. Since the method makes no changes to the object, calling this method + is useless. The method call can be removed. + </li> </ul> </div> <hr/> Modified: trunk/fb-contrib/samples/CU_Sample.java =================================================================== --- trunk/fb-contrib/samples/CU_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/samples/CU_Sample.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -14,4 +14,27 @@ } } } + + class Unrelated implements Cloneable { + public String clone() { + try { + return (String) super.clone(); + } catch (CloneNotSupportedException cnse) { + throw new Error("Won't happen"); + } + } + } + + class FPCloneInterface implements Cloneable, Runnable { + public Runnable clone() { + try { + return (Runnable) super.clone(); + } catch (CloneNotSupportedException cnse) { + throw new Error("Won't happen"); + } + } + + public void run() { + } + } } Modified: trunk/fb-contrib/samples/JAO_Sample.java =================================================================== --- trunk/fb-contrib/samples/JAO_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/samples/JAO_Sample.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -3,35 +3,45 @@ -public class JAO_Sample extends TestCase +public class JAO_Sample extends TestCase { - + public void testExactDoubles(double d1, double d2) { Assert.assertEquals(d1, d2); } - + public void testTrue(boolean b) { Assert.assertEquals(true, b); } - + public void testFalse(boolean b) { Assert.assertEquals("Wow this is bad", false, b); } - + public void testWrongOrder(int i) { Assert.assertEquals(i, 10); } - + public void testAutoBoxNotNull(int i) { Assert.assertNotNull(i); Assert.assertNotNull(i == 3); } + + public void testAssertUsed(String s) + { + assert s != null; + } + public void testUseAssertEquals(String s, String s2) { + Assert.assertTrue(s.equals(s2)); + Assert.assertTrue(s.length() == s.length()); + } + public void test3ArgNP(float foo) { Assert.assertEquals(1.0f, foo, 0.1); Modified: trunk/fb-contrib/samples/PRMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/PRMC_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/samples/PRMC_Sample.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -92,4 +92,35 @@ } enum FPEnum { fee, fi, fo, fum }; + + + public boolean validChainedFields(Chain c1) { + return c1.chainedField.toString().equals(c1.chainedField.toString()); + } + + public boolean fpChainedFieldsOfDiffBases(Chain c1, Chain c2) + { + return c1.chainedField.toString().equals(c2.chainedField.toString()); + } + + class Chain + { + public Chain chainedField; + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("--"); + sb.append("XX"); + sb.append("--"); + sb.append("XX"); + sb.append("--"); + sb.append("XX"); + sb.append("--"); + sb.append("XX"); + sb.append("--"); + sb.append("XX"); + sb.append("--"); + return sb.toString(); + } + } } Modified: trunk/fb-contrib/samples/PSC_Sample.java =================================================================== --- trunk/fb-contrib/samples/PSC_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/samples/PSC_Sample.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -1,8 +1,13 @@ +import java.io.BufferedReader; +import java.io.IOException; import java.util.ArrayDeque; +import java.util.ArrayList; import java.util.Deque; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; @@ -36,10 +41,55 @@ commonWords.add("them"); } - public void testFPDontHaveCollectionForSizing(Iterator<Long> it) { + public void fpDontHaveCollectionForSizing(Iterator<Long> it) { Deque<Long> ad = new ArrayDeque<Long>(); while (it.hasNext()) { ad.add(it.next()); } } + + public void fpConditionalInLoop(Set<String> source) { + List<String> dest = new ArrayList<String>(); + for (String s : source) { + if (s.length() > 0) { + dest.add(s); + } + } + } + + public void fpSwitchInLoop(Set<Integer> source) { + List<Integer> dest = new ArrayList<Integer>(); + for (Integer s : source) { + switch (s.intValue()) { + case 0: + dest.add(s); + break; + case 1: + dest.remove(s); + break; + } + } + } + + public void fpAllocationInLoop(Map<String, String> source) { + Map<String, List<String>> dest = new HashMap<String, List<String>>(); + + for (Map.Entry<String, String> entry : source.entrySet()) { + + List<String> l = new ArrayList<String>(); + l.add(entry.getValue()); + dest.put(entry.getKey(), l); + } + } + + public List<String> fpUnknownSrcSize(BufferedReader br) throws IOException { + List<String> l = new ArrayList<String>(); + String line; + while ((line = br.readLine()) != null) { + l.add(line); + } + + return l; + + } } Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/samples/SPP_Sample.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -111,6 +111,13 @@ { return (b ? true : false); } + + public void testDoubleAppendLiteral(StringBuilder sb, String s) + { + sb.append("hello").append("there"); + sb.append("Hello").append(s).append("there"); + } + public boolean testFPUselessTrinary(boolean a, boolean b) { @@ -337,4 +344,8 @@ sb = sb.append("foo"); sb = sb.append("foo").append("boo").append("hoo"); } + + public String testListFirst(List<String> l) { + return l.iterator().next(); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -1,17 +1,17 @@ /* * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2013 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 @@ -24,11 +24,11 @@ { /** * shows the simple help - * + * * @param args standard command line args */ public static void main(final String[] args) { - JOptionPane.showMessageDialog( null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland", "fb-contrib: copyright 2005-2008", JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog( null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland", "fb-contrib: copyright 2005-2013", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -308,7 +308,7 @@ } else if ((seen == TABLESWITCH) || (seen == LOOKUPSWITCH)) { int pc = getPC(); int[] offsets = getSwitchOffsets(); - List<Integer> targets = new ArrayList<Integer>(); + List<Integer> targets = new ArrayList<Integer>(offsets.length); for (int offset : offsets) { targets.add(Integer.valueOf(offset + pc)); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -47,6 +47,7 @@ } private BugReporter bugReporter; + private JavaClass cls; private String clsName; /** @@ -64,13 +65,15 @@ */ public void visitClassContext(ClassContext classContext) { try { - JavaClass cls = classContext.getJavaClass(); + cls = classContext.getJavaClass(); if (cls.implementationOf(CLONE_CLASS)) { clsName = cls.getClassName(); cls.accept(this); } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); + } finally { + cls = null; } } @@ -81,24 +84,37 @@ */ @Override public void visitMethod(Method obj) { - if (obj.isPublic() && !obj.isSynthetic() && obj.getName().equals("clone") && (obj.getArgumentTypes().length == 0)) { + try { + if (obj.isPublic() && !obj.isSynthetic() && obj.getName().equals("clone") && (obj.getArgumentTypes().length == 0)) { - String returnClsName = obj.getReturnType().getSignature(); - returnClsName = returnClsName.substring(1, returnClsName.length() - 1).replaceAll("/", "."); - if (!clsName.equals(returnClsName)) - { - bugReporter.reportBug(new BugInstance(this, "CU_CLONE_USABILITY_OBJECT_RETURN", NORMAL_PRIORITY) + String returnClsName = obj.getReturnType().getSignature(); + returnClsName = returnClsName.substring(1, returnClsName.length() - 1).replaceAll("/", "."); + if (!clsName.equals(returnClsName)) + { + if ("java.lang.Object".equals(returnClsName)) { + bugReporter.reportBug(new BugInstance(this, "CU_CLONE_USABILITY_OBJECT_RETURN", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this)); + } else { + JavaClass cloneClass = Repository.lookupClass(returnClsName); + if (!cls.instanceOf(cloneClass)) { + bugReporter.reportBug(new BugInstance(this, "CU_CLONE_USABILITY_MISMATCHED_RETURN", HIGH_PRIORITY) .addClass(this) .addMethod(this)); - } + } + } + } - ExceptionTable et = obj.getExceptionTable(); + ExceptionTable et = obj.getExceptionTable(); - if ((et != null) && (et.getLength() > 0)) { - bugReporter.reportBug(new BugInstance(this, "CU_CLONE_USABILITY_THROWS", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this)); + if ((et != null) && (et.getLength() > 0)) { + bugReporter.reportBug(new BugInstance(this, "CU_CLONE_USABILITY_THROWS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this)); + } } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -1,17 +1,17 @@ /* * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2013 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 @@ -60,8 +60,8 @@ private boolean srcInited; private SourceLineAnnotation srcLineAnnotation; private String[] sourceLines; - - + + /** * constructs a FP detector given the reporter to report bugs on * @param bugReporter the sync of bug reports @@ -69,10 +69,10 @@ public FinalParameters(final BugReporter bugReporter) { this.bugReporter = bugReporter; } - + /** * overrides the visitor to initialize the 'has source' flag - * + * * @param classContext the context object for the currently parsed class */ @Override @@ -80,14 +80,14 @@ srcInited = false; super.visitClassContext(classContext); } - + /** * overrides the visitor capture source lines for the method - * + * * @param obj the method object for the currently parsed method */ @Override - public void visitMethod(final Method obj) { + public void visitMethod(final Method obj) { methodName = obj.getName(); if ("<clinit>".equals(methodName) || "<init>".equals(methodName)) return; @@ -97,35 +97,35 @@ isStatic = (obj.getAccessFlags() & Constants.ACC_STATIC) != 0; isAbstract = (obj.getAccessFlags() & Constants.ACC_ABSTRACT) != 0; parmCount = Type.getArgumentTypes(obj.getSignature()).length; - + super.visitMethod(obj); srcLineAnnotation = null; sourceLines = null; } - + /** * reads the sourcefile based on the source line annotation for the method - * + * * @param obj the method object for the currently parsed method - * + * * @return an array of source lines for the method */ private String[] getSourceLines(Method obj) { - + BufferedReader sourceReader = null; - + if (srcInited) return sourceLines; - + try { srcLineAnnotation = SourceLineAnnotation.forEntireMethod(getClassContext().getJavaClass(), obj); if (srcLineAnnotation != null) - { + { SourceFinder sourceFinder = AnalysisContext.currentAnalysisContext().getSourceFinder(); SourceFile sourceFile = sourceFinder.findSourceFile(srcLineAnnotation.getPackageName(), srcLineAnnotation.getSourceFile()); sourceReader = new BufferedReader(new InputStreamReader(sourceFile.getInputStream())); - - List<String> lines = new ArrayList<String>(); + + List<String> lines = new ArrayList<String>(100); String line; while ((line = sourceReader.readLine()) != null) lines.add(line); @@ -145,20 +145,20 @@ srcInited = true; return sourceLines; } - + /** * overrides the visitor to find the source lines for the method header, to find non final parameters - * + * * @param obj the code object for the currently parsed method */ @Override public void visitCode(final Code obj) { if (sourceLines == null) return; - + if (isAbstract) return; - + if ("<clinit>".equals(methodName) || "<init>".equals(methodName)) return; @@ -174,7 +174,7 @@ if (methodLine < 0) return; - + for (int i = methodLine; i <= methodStart; i++) { if ((i < 0) || (i >= sourceLines.length)) return; @@ -182,21 +182,21 @@ if (line.indexOf("final") >= 0) return; } - + changedParms = new HashSet<Integer>(); super.visitCode(obj); - + BugInstance bi = null; for (int i = 0; i < parmCount; i++) { if (changedParms.remove(Integer.valueOf(i))) continue; - + int reg; if (!isStatic) reg = i + 1; else reg = i; - + String parmName = getRegisterName(obj, reg); if (bi == null) { bi = new BugInstance(this, "FP_FINAL_PARAMETERS", LOW_PRIORITY) @@ -209,10 +209,10 @@ } changedParms = null; } - + /** * overrides the visitor to find local variable reference stores to store them as changed - * + * * @param seen the currently parsed opcode */ @Override @@ -223,13 +223,13 @@ changedParms.add(Integer.valueOf(parm)); } } - + /** * returns the variable name of the specified register slot - * + * * @param obj the currently parsed code object * @param reg the variable register of interest - * + * * @return the variable name of the specified register */ private String getRegisterName(final Code obj, final int reg) { @@ -241,25 +241,25 @@ } return String.valueOf(reg); } - + /** * return the register number that is be stored - * + * * @param seen the opcode of the currently parsed statement - * + * * @return the register number being stored */ private int getAStoreParameter(final int seen) { int reg = RegisterUtils.getAStoreReg(this, seen); - + if (!isStatic) reg--; - + if (reg >= parmCount) reg = -1; - + return reg; - + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -44,6 +44,7 @@ internalPackages.add("org/apache/xerces/"); internalPackages.add("org/apache/xalan/"); externalPackages.add("com/sun/jersey"); + externalPackages.add("com/sun/xsom"); externalPackages.add("org/apache/xerces/xni/"); externalPackages.add("org/apache/xerces/xs/"); externalPackages.add("org/apache/xalan/extensions"); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -1,17 +1,17 @@ /* * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2013 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 @@ -38,8 +38,10 @@ import edu.umd.cs.findbugs.ba.ClassContext; /** looks for odd uses of the Assert class of the JUnit framework */ -public class JUnitAssertionOddities extends BytecodeScanningDetector +public class JUnitAssertionOddities extends BytecodeScanningDetector { + private enum State {SAW_NOTHING, SAW_IF_ICMPNE, SAW_ICONST_1, SAW_GOTO, SAW_ICONST_0, SAW_EQUALS}; + private static final String RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations"; private static final String TEST_ANNOTATION_SIGNATURE = "Lorg/junit/Test;"; private static final String OLD_ASSERT_CLASS = "junit/framework/Assert"; @@ -62,7 +64,8 @@ private OpcodeStack stack; private boolean isTestCaseDerived; private boolean isAnnotationCapable; - + private State state; + /** * constructs a JOA detector given the reporter to report bugs on * @param bugReporter the sync of bug reports @@ -70,10 +73,10 @@ public JUnitAssertionOddities(BugReporter bugReporter) { this.bugReporter = bugReporter; } - + /** * override the visitor to see if this class could be a test class - * + * * @param classContext the context object of the currently parsed class */ @Override @@ -92,12 +95,12 @@ stack = null; } } - + @Override public void visitCode(Code obj) { Method m = getMethod(); boolean isTestMethod = isTestCaseDerived && m.getName().startsWith("test"); - + if (!isTestMethod && isAnnotationCapable) { Attribute[] atts = m.getAttributes(); for (Attribute att : atts) { @@ -123,20 +126,21 @@ } } } - + if (isTestMethod) { stack.resetForMethodEntry(this); + state = State.SAW_NOTHING; super.visitCode(obj); } } - + @Override public void sawOpcode(int seen) { String userValue = null; - + try { stack.mergeJumps(this); - + if (seen == INVOKESTATIC) { String clsName = getClassConstantOperand(); if (OLD_ASSERT_CLASS.equals(clsName) || NEW_ASSERT_CLASS.equals(clsName)) { @@ -147,7 +151,7 @@ if (argTypes.length == 2) { if (argTypes[0].equals(Type.STRING) && argTypes[1].equals(Type.STRING)) return; - + if (stack.getStackDepth() >= 2) { OpcodeStack.Item item1 = stack.getStackItem(1); Object cons1 = item1.getConstant(); @@ -157,7 +161,7 @@ .addMethod(this) .addSourceLine(this)); return; - } + } OpcodeStack.Item item0 = stack.getStackItem(0); if (item0.getConstant() != null) { bugReporter.reportBug(new BugInstance(this, "JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT", NORMAL_PRIORITY) @@ -186,6 +190,13 @@ .addSourceLine(this)); } } + } else if ("assertTrue".equals(methodName)) { + if ((state == State.SAW_ICONST_0) || (state == State.SAW_EQUALS)) { + bugReporter.reportBug(new BugInstance(this, "JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } } else { String methodName = getNameConstantOperand(); @@ -196,7 +207,63 @@ userValue = "valueOf"; } } + } else if (seen == ATHROW) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + String throwClass = item.getSignature(); + if ("Ljava/lang/AssertionError;".equals(throwClass)) { + bugReporter.reportBug(new BugInstance(this, "JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } + + switch (state) { + case SAW_NOTHING: + case SAW_EQUALS: + if (seen == IF_ICMPNE) + state = State.SAW_IF_ICMPNE; + else + state = State.SAW_NOTHING; + break; + + case SAW_IF_ICMPNE: + if (seen == ICONST_1) + state = State.SAW_ICONST_1; + else + state = State.SAW_NOTHING; + break; + + case SAW_ICONST_1: + if (seen == GOTO) + state = State.SAW_GOTO; + else + state = State.SAW_NOTHING; + break; + + case SAW_GOTO: + if (seen == ICONST_0) + state = State.SAW_ICONST_0; + else + state = State.SAW_NOTHING; + break; + + default: + state = State.SAW_NOTHING; + break; + } + + if (seen == INVOKEVIRTUAL) { + String methodName = getNameConstantOperand(); + String sig = getSigConstantOperand(); + if ("equals".equals(methodName) && "(Ljava/lang/Object;)Z".equals(sig)) { + state = State.SAW_EQUALS; + } + } + + } finally { TernaryPatcher.pre(stack, seen); stack.sawOpcode(this, seen); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -55,7 +55,8 @@ /** * constructs a NOS detector given the reporter to report bugs on * @param bugReporter the sync of bug reports - */ public NonOwnedSynchronization(BugReporter bugReporter) { + */ + public NonOwnedSynchronization(BugReporter bugReporter) { this.bugReporter = bugReporter; } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -182,6 +182,8 @@ */ @Override public void sawOpcode(int seen) { + String userValue = null; + try { stack.mergeJumps(this); if (branchTargets.remove(Integer.valueOf(getPC()))) { @@ -200,7 +202,31 @@ } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { localMethodCalls.remove(Integer.valueOf(RegisterUtils.getAStoreReg(this, seen))); } else if (seen == PUTFIELD) { - fieldMethodCalls.remove(getNameConstantOperand()); + String fieldSource = ""; + + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + fieldSource = (String) item.getUserValue(); + if (fieldSource == null) + fieldSource = ""; + } + fieldMethodCalls.remove(fieldSource + ":" + getNameConstantOperand()); + } else if (seen == GETFIELD) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + userValue = (String) item.getUserValue(); + if (userValue == null) { + int reg = item.getRegisterNumber(); + if (reg >= 0) { + userValue = String.valueOf(reg); + } else { + XField xf = item.getXField(); + if (xf != null) { + userValue = xf.getName(); + } + } + } + } } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE) || (seen == INVOKESTATIC)) { String signature = getSigConstantOperand(); int parmCount = Type.getArgumentTypes(signature).length; @@ -232,7 +258,10 @@ if (reg >= 0) { mc = localMethodCalls.get(Integer.valueOf(reg)); } else if (field != null) { - mc = fieldMethodCalls.get(field.getName()); + String fieldSource = (String) obj.getUserValue(); + if (fieldSource == null) + fieldSource = ""; + mc = fieldMethodCalls.get(fieldSource + ":" + field.getName()); } else { return; } @@ -267,7 +296,16 @@ if (reg >= 0) { localMethodCalls.remove(Integer.valueOf(reg)); } else if (field != null) { - fieldMethodCalls.remove(field.getName()); + String fieldSource = ""; + + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + fieldSource = (String) item.getUserValue(); + if (fieldSource == null) + fieldSource = ""; + } + + fieldMethodCalls.remove(fieldSource + ":" + field.getName()); } } } else { @@ -277,7 +315,11 @@ if (reg >= 0) { localMethodCalls.put(Integer.valueOf(reg), new MethodCall(methodName, signature, parmConstants)); } else if (field != null) { - fieldMethodCalls.put(field.getName(), new MethodCall(methodName, signature, parmConstants)); + OpcodeStack.Item obj = stack.getStackItem(parmCount); + String fieldSource = (String) obj.getUserValue(); + if (fieldSource == null) + fieldSource = ""; + fieldMethodCalls.put(fieldSource + ":" + field.getName(), new MethodCall(methodName, signature, parmConstants)); } } } @@ -285,6 +327,12 @@ } } finally { stack.sawOpcode(this, seen); + if (userValue != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(userValue); + } + } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -52,14 +52,15 @@ PRESIZEABLE_COLLECTIONS.add("java/util/LinkedHashSet"); PRESIZEABLE_COLLECTIONS.add("java/util/PriorityBlockingQueue"); PRESIZEABLE_COLLECTIONS.add("java/util/PriorityQueue"); - PRESIZEABLE_COLLECTIONS.add("java/util/TreeSet"); PRESIZEABLE_COLLECTIONS.add("java/util/Vector"); } private BugReporter bugReporter; private OpcodeStack stack; private int allocNumber; + private Map<Integer, Integer> allocLocation; private Map<Integer, List<Integer>> allocToAddPCs; + private List<DownBranch> downBranches; public PresizeCollections(BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -73,11 +74,15 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); + allocLocation = new HashMap<Integer, Integer>(); allocToAddPCs = new HashMap<Integer, List<Integer>>(); + downBranches = new ArrayList<DownBranch>(); super.visitClassContext(classContext); } finally { stack = null; + allocLocation = null; allocToAddPCs = null; + downBranches = null; } } @@ -89,7 +94,9 @@ public void visitCode(Code obj) { stack.resetForMethodEntry(this); allocNumber = 0; + allocLocation.clear(); allocToAddPCs.clear(); + downBranches.clear(); super.visitCode(obj); for (List<Integer> pcs : allocToAddPCs.values()) { @@ -146,24 +153,60 @@ } break; + case LOOKUPSWITCH: + case TABLESWITCH: + int[] offsets = getSwitchOffsets(); + if (offsets.length > 1) { + int secondCase = offsets[1] + getPC(); + DownBranch db = new DownBranch(getPC(), secondCase); + downBranches.add(db); + } + break; + + case IFEQ: + case IFNE: + case IFLT: + case IFGE: + case IFGT: + case IFLE: + case IF_ICMPEQ: + case IF_ICMPNE: + case IF_ICMPLT: + case IF_ICMPGE: + case IF_ICMPGT: + case IF_ICMPLE: + case IF_ACMPEQ: + case IF_ACMPNE: + case IFNULL: + case IFNONNULL: case GOTO: case GOTO_W: if (getBranchOffset() < 0) { int target = getBranchTarget(); - Iterator<List<Integer>> it = allocToAddPCs.values().iterator(); + Iterator<Map.Entry<Integer, List<Integer>>> it = allocToAddPCs.entrySet().iterator(); while (it.hasNext()) { - List<Integer> pcs = it.next(); - for (Integer pc : pcs) { - if (pc > target) { - bugReporter.reportBug(new BugInstance(this, "PSC_PRESIZE_COLLECTIONS", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this, pc)); - it.remove(); - break; + Map.Entry<Integer, List<Integer>> entry = it.next(); + Integer allocLoc = allocLocation.get(entry.getKey()); + if ((allocLoc != null) && (allocLoc.intValue() < target)) { + List<Integer> pcs = entry.getValue(); + for (Integer pc : pcs) { + if (pc > target) { + int numDownBranches = countDownBranches(target, pc); + if (numDownBranches <= 1) { + bugReporter.reportBug(new BugInstance(this, "PSC_PRESIZE_COLLECTIONS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this, pc)); + it.remove(); + } + break; + } } } } + } else { + DownBranch db = new DownBranch(getPC(), getBranchTarget()); + downBranches.add(db); } } } finally { @@ -171,9 +214,37 @@ if (sawAlloc) { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); - item.setUserValue(Integer.valueOf(++allocNumber)); + ++allocNumber; + item.setUserValue(Integer.valueOf(allocNumber)); + allocLocation.put(Integer.valueOf(allocNumber), Integer.valueOf(getPC())); } } } } + + private int countDownBranches(int loopTop, int addPC) { + int numDownBranches = 0; + for (DownBranch db : downBranches) { + if ((db.fromPC > loopTop) && (db.fromPC < addPC) && (db.toPC > addPC)) { + numDownBranches++; + } + } + + return numDownBranches; + } + + static class DownBranch { + public int fromPC; + public int toPC; + + public DownBranch(int from, int to) { + fromPC = from; + toPC = to; + } + + @Override + public String toString() { + return "DownBranch[From: " + fromPC + " To: " + toPC + "]"; + } + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-03-04 04:47:55 UTC (rev 1742) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-04-18 18:16:49 UTC (rev 1743) @@ -23,6 +23,8 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.bcel.Repository; import org.apache.bcel.classfile.Code; @@ -62,6 +64,8 @@ collectionInterfaces.add("java/util/Map"); collectionInterfaces.add("java/util/SortedMap"); } + + private static final Pattern APPEND_PATTERN = Pattern.compile("append:([0-9]+):(.*)"); private static JavaClass calendarClass; static { @@ -347,16 +351,21 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); String mName = (String) item.getUserValue(); - if ("trim".equals(mName)) { - item.setUserValue(null); - } else if ((mName != null) && (mName.startsWith("append:"))) { - int appendReg = Integer.parseInt(mName.substring("append:".length())); - if (reg == appendReg) { - ... [truncated message content] |
From: <dbr...@us...> - 2013-03-04 04:48:05
|
Revision: 1742 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1742&view=rev Author: dbrosius Date: 2013-03-04 04:47:55 +0000 (Mon, 04 Mar 2013) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/WOC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java Added Paths: ----------- trunk/fb-contrib/samples/CAAL_Sample.java trunk/fb-contrib/samples/CU_Sample.java trunk/fb-contrib/samples/PSC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/etc/findbugs.xml 2013-03-04 04:47:55 UTC (rev 1742) @@ -132,7 +132,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> <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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM" /> + 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,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> @@ -165,7 +165,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousClusteredSessionSupport" speed="fast" reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse" speed="fast" reports="IICU_INCORRECT_INTERNAL_CLASS_USE" /> @@ -237,6 +237,8 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_THROWS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> <!-- BugPattern --> @@ -334,7 +336,8 @@ <BugPattern abbrev="SPP" type="SPP_SERIALVER_SHOULD_BE_PRIVATE" category="STYLE" /> <BugPattern abbrev="SPP" type="SPP_NON_ARRAY_PARM" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_EMPTY_CASING" category="STYLE" /> - <BugPattern abbrev="SPP" type="SPP_TEMPORARY_TRIM" category="STYLE" /> + <BugPattern abbrev="SPP" type="SPP_TEMPORARY_TRIM" category="STYLE" /> + <BugPattern abbrev="SPP" type="SPP_STRINGBUILDER_IS_MUTABLE" category="CORRECTNESS" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> @@ -356,6 +359,7 @@ <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" /> <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" /> <BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" /> + <BugPattern abbrev="LO" type="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_CLASS" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_PARAMETER" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_STUTTERED_MESSAGE" category="STYLE" /> @@ -413,4 +417,5 @@ <BugPattern abbrev="CU" type="CU_CLONE_USABILITY_OBJECT_RETURN" category="STYLE" /> <BugPattern abbrev="CU" type="CU_CLONE_USABILITY_THROWS" category="STYLE" /> <BugPattern abbrev="CAAL" type="CAAL_CONFUSING_ARRAY_AS_LIST" category="CORRECTNESS" /> + <BugPattern abbrev="PSC" type="PSC_PRESIZE_COLLECTIONS" category="PERFORMANCE" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/etc/messages.xml 2013-03-04 04:47:55 UTC (rev 1742) @@ -145,9 +145,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DubiousListCollection"> <Details> <![CDATA[ - <p> Looks for constructors of non final classes that make method calls to non final methods. - As these methods could be overridden, the overridden method will be accessing an object that - is only partially constructed, perhaps causing problems.</p> + <p> looks for fields that are implementations of java.util.List, but that are used in a set-like fashion. + Since lookup type operations are performed using a linear search for Lists, the performance for large + Lists will be poor. Consideration should be made as to whether these fields should be sets. In the + case that order is important, consider using LinkedHashSet.</p> <p>It is a fast detector</p> ]]> </Details> @@ -284,8 +285,7 @@ thread itself, introducing client calls will confuse the thread state of the object in question, and will cause spurious thread state changes, either waking threads up when not intended, or removing the the thread from the runnable state.</p> - </p> - <p>It is a fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -319,8 +319,7 @@ <![CDATA[ <p>Looks for methods that store the return result in a local variable, and then immediately returns that local variable.</p> - </p> - <p>It is a fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -329,8 +328,7 @@ <Details> <![CDATA[ <p>Looks for methods that are direct copies of the implementation in the super class</p> - </p> - <p>It is a fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -343,8 +341,7 @@ do not, and cannot define an equals method, reference equality is used for these collections, which is probably not desired. If it is, consider using the IdentityHashMap class when using Maps in this case, to better document your intentions.</p> - </p> - <p>It is a fast detector</p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -1256,6 +1253,7 @@ Comparing class name ignores the class loader. </p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -1267,6 +1265,7 @@ classes are available in versions of the JDK 5.0 and higher, and these classes should only be used if you are targeting JDK 1.4 and lower. </p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -1278,6 +1277,7 @@ not swallow CloneNotSupportedException. Not doing so makes the clone method not as simple to use, and should be harmless to do so. </p> + <p>It is a fast detector</p> ]]> </Details> </Detector> @@ -1289,10 +1289,24 @@ This does not produce a list that holds the primitive boxed values, but a list of one item, the array itself. </p> + <p>It is a fast detector</p> ]]> </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections"> + <Details> + <![CDATA[ + <p> Looks for methods that create collections using the default constructor, + even though the number of elements that will be placed in the collection is known + apriori, and thus could be pre-allocated. Not doing so just causes more intermediate + reallocations which is unnecessary. + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> <BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING"> @@ -1499,7 +1513,7 @@ <Details> <![CDATA[ <p>This method uses floating point variables to index a loop. Since floating point - math is inprecise, rounding errors will accumulate over time each time the loop is + math is imprecise, rounding errors will accumulate over time each time the loop is executed. It is usually better to use integer indexing, and calculate the new value of the floating point number at the top of the loop body.</p> ]]> @@ -2542,6 +2556,19 @@ </Details> </BugPattern> + <BugPattern type="SPP_STRINGBUILDER_IS_MUTABLE"> + <ShortDescription>Method needlessly assigns a StringBuilder to itself, as it's mutable</ShortDescription> + <LongDescription>Method {1} needlessly assigns a StringBuilder to itself, as it's mutable</LongDescription> + <Details> + <![CDATA[ + This method calls StringBuilder.append and assigns the results to the same StringBuilder as + <pre>sb = sb.append("foo")</pre> + As StringBuilder is mutable this is not necessary. + This is also true of StringBuffer. + ]]> + </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> @@ -2815,6 +2842,19 @@ </Details> </BugPattern> + <BugPattern type="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE"> + <ShortDescription>Method incorrectly passes exception as first argument to logger method</ShortDescription> + <LongDescription>Method {1} incorrectly passes exception as first argument to logger method</LongDescription> + <Details> + <![CDATA[ + <p>This method passes an exception as the first argument to a logger method. The stack + trace is potentially lost due to the logger emitting the exception using toString(). It + is better to construct a log message with sufficient context and pass the exception as + the second argument to capture the stack trace.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="LO_SUSPECT_LOG_CLASS"> <ShortDescription>Method specifies an unrelated class when allocating a Logger</ShortDescription> <LongDescription>Method {1} specifies an unrelated class when allocating a Logger</LongDescription> @@ -3096,7 +3136,7 @@ <Details> <![CDATA[ <p>This method tests a field to make sure it's not null before executing a conditional block of - code. However in the conditional block is reassigns the field. It is likely that the guard + code. However in the conditional block it reassigns the field. It is likely that the guard should have been a check to see if the field is null, not that the field was not null.</p> ]]> </Details> @@ -3108,7 +3148,7 @@ <Details> <![CDATA[ <p>This method tests a local variable to make sure it's not null before executing a conditional block of - code. However in the conditional block is reassigns the local variable. It is likely that the guard + code. However in the conditional block it reassigns the local variable. It is likely that the guard should have been a check to see if the local variable is null, not that the local variable was not null.</p> ]]> </Details> @@ -3518,6 +3558,19 @@ ]]> </Details> </BugPattern> + + <BugPattern type="PSC_PRESIZE_COLLECTIONS"> + <ShortDescription>Method does not presize the allocation of a collection</ShortDescription> + <LongDescription>Method {1} does not presize the allocation of a collection</LongDescription> + <Details> + <![CDATA[ + <p> This method allocates a collection using the default constructor even though it is known + apriori how many items are going to be placed in the collection (or at least a reasonable guess) + and thus needlessly causes intermediate reallocations of the collection. + </p> + ]]> + </Details> + </BugPattern>" <!-- BugCode --> @@ -3628,4 +3681,5 @@ <BugCode abbrev="BRPI">Backport concurrent reuse of public identifiers</BugCode> <BugCode abbrev="CU">Clone Usability</BugCode> <BugCode abbrev="CAAL">Confusing Array asList</BugCode> + <BugCode abbrev="PSC">Presize Collection</BugCode> </MessageCollection> Added: trunk/fb-contrib/samples/CAAL_Sample.java =================================================================== --- trunk/fb-contrib/samples/CAAL_Sample.java (rev 0) +++ trunk/fb-contrib/samples/CAAL_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -0,0 +1,38 @@ +import java.util.Arrays; +import java.util.List; + + +public class CAAL_Sample { + + public void testCAAL(int[] v) { + List l = Arrays.asList(v); + } + + public void testCAAL(char[] v) { + List l = Arrays.asList(v); + } + + public void testCAAL(byte[] v) { + List l = Arrays.asList(v); + } + + public void testCAAL(short[] v) { + List l = Arrays.asList(v); + } + + public void testCAAL(long[] v) { + List l = Arrays.asList(v); + } + + public void testCAAL(float[] v) { + List l = Arrays.asList(v); + } + + public void testCAAL(double[] v) { + List l = Arrays.asList(v); + } + + public void testCAAL(boolean[] v) { + List l = Arrays.asList(v); + } +} Property changes on: trunk/fb-contrib/samples/CAAL_Sample.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/fb-contrib/samples/CU_Sample.java =================================================================== --- trunk/fb-contrib/samples/CU_Sample.java (rev 0) +++ trunk/fb-contrib/samples/CU_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -0,0 +1,17 @@ + +public class CU_Sample implements Cloneable { + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + class CU_FP implements Cloneable { + public CU_FP clone() { + try { + return (CU_FP) super.clone(); + } catch (CloneNotSupportedException cnse) { + throw new Error("Won't happen"); + } + } + } +} Property changes on: trunk/fb-contrib/samples/CU_Sample.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/fb-contrib/samples/PSC_Sample.java =================================================================== --- trunk/fb-contrib/samples/PSC_Sample.java (rev 0) +++ trunk/fb-contrib/samples/PSC_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -0,0 +1,45 @@ +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + + +public class PSC_Sample { + + public void testPSC(List<PSC_Sample> samples) { + Set<String> names = new HashSet<String>(); + for (PSC_Sample s : samples) { + names.add(s.toString()); + } + } + + public void testPSCEnumerated() { + Set<String> commonWords = new HashSet<String>(); + commonWords.add("a"); + commonWords.add("an"); + commonWords.add("the"); + commonWords.add("by"); + commonWords.add("of"); + commonWords.add("and"); + commonWords.add("or"); + commonWords.add("in"); + commonWords.add("with"); + commonWords.add("my"); + commonWords.add("I"); + commonWords.add("on"); + commonWords.add("over"); + commonWords.add("under"); + commonWords.add("it"); + commonWords.add("they"); + commonWords.add("them"); + } + + public void testFPDontHaveCollectionForSizing(Iterator<Long> it) { + Deque<Long> ad = new ArrayDeque<Long>(); + while (it.hasNext()) { + ad.add(it.next()); + } + } +} Property changes on: trunk/fb-contrib/samples/PSC_Sample.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/samples/SPP_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -18,40 +18,40 @@ public class SPP_Sample implements Serializable { public static final long serialVersionUID = -2766574418713802220L; - + private static final double pi = 3.14; private static final double e = 2.72; public static final String FALSE_POSITIVE = "INTERN_OK_HERE".intern(); - + static enum Flap { Smack, Jack }; - + public void testSPPBitSet(BitSet b) { b.set(-1); } - + public String testSPPIntern() { return "FOO".intern(); //and yes i've seen this! } - + public String testSBWithChars() { StringBuffer sb = new StringBuffer('v'); sb.append("ictory"); return sb.toString(); } - + public double area(double radius) { return pi * radius * radius; } - + public void testStutter(String s) { String a = a = s; } - + public void testNAN(double d) { if (d == Double.NaN) @@ -59,7 +59,7 @@ System.out.println("It's a nan"); } } - + public void testNAN(float f) { if (f == Float.NaN) @@ -67,17 +67,17 @@ System.out.println("It's a nan"); } } - + public void testBigDecimal() { BigDecimal d = new BigDecimal(2.1); } - + public void testEmptySB() { StringBuffer sb = new StringBuffer(""); } - + public void equalsOnEnum(Flap f) { if (f.equals(Flap.Jack)) @@ -85,7 +85,7 @@ System.out.println("Flap Jacks"); } } - + public void testCPPBoolean(Boolean a, Boolean b, Boolean c, Boolean d, Boolean e) { if (b && b.booleanValue()) @@ -97,7 +97,7 @@ System.out.println("Booya"); } } - + public char usechatAt(String s) { if (s.length() > 0) @@ -106,32 +106,32 @@ } return ' '; } - + public boolean testUselessTrinary(boolean b) { return (b ? true : false); } - + public boolean testFPUselessTrinary(boolean a, boolean b) { if (a && b) { return a || b; } - + return a && b; } - + public boolean testFPTrinaryOnInt(String s) { return (s.length() != 0); } - + public void testSuspiciousStringTests(String s) { int a = 0, b = 0, c = 0, d = 0; String e = "Foo"; - + if ((s == null) || (s.length() > 0)) { System.out.println("Booya"); @@ -144,7 +144,7 @@ { System.out.println("Booya"); } - + if ((e == null) || (e.length() > 0)) { System.out.println("Booya"); @@ -158,42 +158,42 @@ System.out.println("Booya"); } } - + public void testFPSST(String s) { int a = 0, b = 0, c = 0, d = 0; String e = "Foo"; - + if ((s == null) || (s.length() == 0)) { System.out.println("Booya"); } - + if ((s != null) && (s.length() >= 0)) { System.out.println("Booya"); } - + if ((s != null) && (s.length() != 0)) { System.out.println("Booya"); } - + if ((e == null) || (e.length() == 0)) { System.out.println("Booya"); } - + if ((e != null) && (e.length() >= 0)) { System.out.println("Booya"); } - + if ((e != null) && (e.length() != 0)) { System.out.println("Booya"); } - + Set<String> m = new HashSet<String>(); Iterator<String> it = m.iterator(); while (it.hasNext()) @@ -203,11 +203,11 @@ { continue; } - + System.out.println("Booya"); } } - + public void sbToString(StringBuffer sb) { if (sb.toString().length() == 0) @@ -219,7 +219,7 @@ System.out.println("Booya"); } } - + public String cpNullOrZero(StringTokenizer tokenizer) { while (tokenizer.hasMoreTokens()) @@ -233,15 +233,15 @@ return sField; } - + return null; } - + public boolean testCalBeforeAfter(Calendar c, Date d) { return c.after(d) || c.before(d); } - + public void testUseContainsKey(Map m) { if (m.keySet().contains("Foo")) @@ -249,87 +249,92 @@ System.out.println("Yup"); } } - + public void testCollectionSizeEqualsZero(Set<String> s) { if (s.size() == 0) { System.out.println("empty"); } - + if (s.size() <= 0) { System.out.println("empty"); } } - + public boolean testDerivedGregorianCalendar() { Calendar c = new GregorianCalendar() {}; Calendar s = new GregorianCalendar(); - + return s.after(c); } - + public void testGetProperties() { String lf = System.getProperties().getProperty("line.separator"); } - + public boolean testCasing(String a, String b) { if (a.toUpperCase().equalsIgnoreCase(b)) { return true; } - + if (a.toLowerCase().compareToIgnoreCase(b) == 0) { return true; } - + return false; } - + public void castRandomToInt() { int i = (int)Math.random(); - + Random r = new Random(); i = (int) r.nextDouble(); - + i = (int) r.nextFloat(); } - + public void testSAC(List<String> input) { String[] copy = new String[input.size()]; System.arraycopy(input, 0, copy, 0, copy.length); - + System.arraycopy(copy, 0, input, 0, copy.length); } - + public void testArray() { List<String> notAnArray = new ArrayList<String>(); - + Array.getLength(notAnArray); - + Array.getBoolean(notAnArray, 0); - + Array.setInt(notAnArray, 0, 1); } - + public boolean testEmptyIgnoreCase(String s) { return (s.equalsIgnoreCase("")); } - + public void testTrim(String s) { if (s.trim().length() > 0) System.out.println(s); - + if (s.trim().equals("Booyah")) { System.out.println("Booyah->" + s); } } + + public void testSBAssigning(StringBuilder sb) { + sb = sb.append("foo"); + sb = sb.append("foo").append("boo").append("hoo"); + } } Modified: trunk/fb-contrib/samples/WOC_Sample.java =================================================================== --- trunk/fb-contrib/samples/WOC_Sample.java 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/samples/WOC_Sample.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -101,4 +101,22 @@ { return ws.fpList; } + + public static class FpContains { + private List<String> fpSet; + + public FpContains() { + fpSet = new ArrayList<String>(); + } + public void add() { + fpSet.add("Foo"); + } + protected void contains() { + for (int i = 0; i < 10; i++) { + if (fpSet.get(i) != null) { + System.out.println("Contains"); + } + } + } + } } Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -0,0 +1,110 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2013 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 org.apache.bcel.Repository; +import org.apache.bcel.classfile.ExceptionTable; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.Detector; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.visitclass.PreorderVisitor; + +/** + * finds classes that implement clone() that do not specialize the return value, and do + * not swallow CloneNotFoundException. Not doing so makes the clone method not as simple + * to use, and should be harmless to do. + */ +public class CloneUsability extends PreorderVisitor implements Detector { + + private static JavaClass CLONE_CLASS; + + static { + try { + CLONE_CLASS = Repository.lookupClass("java.lang.Cloneable"); + } catch (ClassNotFoundException cnfe) { + CLONE_CLASS = null; + } + } + + private BugReporter bugReporter; + private String clsName; + + /** + * constructs a CU detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public CloneUsability(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * overrides the visitor to check for classes that implement Cloneable. + * + * @param classContext the context object that holds the JavaClass being parsed + */ + public void visitClassContext(ClassContext classContext) { + try { + JavaClass cls = classContext.getJavaClass(); + if (cls.implementationOf(CLONE_CLASS)) { + clsName = cls.getClassName(); + cls.accept(this); + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } + } + + /** + * overrides the visitor to grab the method name and reset the state. + * + * @param obj the method being parsed + */ + @Override + public void visitMethod(Method obj) { + if (obj.isPublic() && !obj.isSynthetic() && obj.getName().equals("clone") && (obj.getArgumentTypes().length == 0)) { + + String returnClsName = obj.getReturnType().getSignature(); + returnClsName = returnClsName.substring(1, returnClsName.length() - 1).replaceAll("/", "."); + if (!clsName.equals(returnClsName)) + { + bugReporter.reportBug(new BugInstance(this, "CU_CLONE_USABILITY_OBJECT_RETURN", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this)); + } + + ExceptionTable et = obj.getExceptionTable(); + + if ((et != null) && (et.getLength() > 0)) { + bugReporter.reportBug(new BugInstance(this, "CU_CLONE_USABILITY_THROWS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this)); + } + } + } + + /** + * implements the Detector with a nop + */ + public void report() { + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mimetype + text/plain Added: svn:eol-style + native Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -81,7 +81,7 @@ String calledClass = stack.getStackItem(1).getSignature(); if ("Lorg/apache/commons/lang3/builder/EqualsBuilder;" .equals(calledClass) - || "org/apache/commons/lang/builder/EqualsBuilder" + || "Lorg/apache/commons/lang/builder/EqualsBuilder;" .equals(calledClass)) { bugReporter.reportBug(new BugInstance(this, "CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS", Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -81,7 +81,7 @@ String calledClass = stack.getStackItem(0).getSignature(); if ("Lorg/apache/commons/lang3/builder/HashCodeBuilder;" .equals(calledClass) - || "org/apache/commons/lang/builder/HashCodeBuilder" + || "Lorg/apache/commons/lang/builder/HashCodeBuilder;" .equals(calledClass)) { bugReporter.reportBug(new BugInstance(this, "CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE", Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -0,0 +1,119 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2013 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.HashSet; +import java.util.Set; + +import org.apache.bcel.classfile.Code; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * + * looks for calls to Arrays.asList where the parameter is a primitive array. + * This does not produce a list that holds the primitive boxed value, but a list of + * one item, the array itself. + * + */ +public class ConfusingArrayAsList extends BytecodeScanningDetector { + + private static Set<String> PRIMITIVE_ARRAYS = new HashSet<String>(); + static { + PRIMITIVE_ARRAYS.add("[[B"); + PRIMITIVE_ARRAYS.add("[[C"); + PRIMITIVE_ARRAYS.add("[[S"); + PRIMITIVE_ARRAYS.add("[[I"); + PRIMITIVE_ARRAYS.add("[[J"); + PRIMITIVE_ARRAYS.add("[[F"); + PRIMITIVE_ARRAYS.add("[[D"); + PRIMITIVE_ARRAYS.add("[[Z"); + + } + private BugReporter bugReporter; + private OpcodeStack stack; + + /** + * constructs a CAAL detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public ConfusingArrayAsList(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to create and teardown the opcode stack + * + * @param classContext the context object of the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + stack = null; + } + } + + /** + * implements the visitor to clear the opcode stack + * + * @param seen the currently code block + */ + public void visitCode(Code obj) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } + + /** + * implements the visitor to find calls to Arrays.asList with a primitive array + * + * @param seen the currently visitor opcode + */ + @Override + public void sawOpcode(int seen) { + try { + if (seen == INVOKESTATIC) { + String clsName = getClassConstantOperand(); + if ("java/util/Arrays".equals(clsName)) { + String methodName = getNameConstantOperand(); + if ("asList".equals(methodName)) { + if (stack.getStackDepth() == 1) { + OpcodeStack.Item item = stack.getStackItem(0); + String sig = item.getSignature(); + if (PRIMITIVE_ARRAYS.contains(sig)) { + bugReporter.reportBug(new BugInstance(this, "CAAL_CONFUSING_ARRAY_AS_LIST", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + } + } + } finally { + stack.sawOpcode(this, seen); + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mimetype + text/plain Added: svn:eol-style + native Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -266,7 +266,15 @@ } } } - } + } else if ("(Ljava/lang/Object;)V".equals(sig)) { + final JavaClass clazz = stack.getStackItem(0).getJavaClass(); + if(clazz.instanceOf(THROWABLE_CLASS)) { + bugReporter.reportBug(new BugInstance(this, "LO_LOGGER_LOST_EXCEPTION_STACK_TRACE", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -74,7 +74,10 @@ riskyMethodNameContents.add("clone"); riskyMethodNameContents.add("close"); riskyMethodNameContents.add("copy"); - riskyMethodNameContents.add("currentTimeMillis"); + riskyMethodNameContents.add("currentTimeMillis"); + riskyMethodNameContents.add("newInstance"); + riskyMethodNameContents.add("noneOf"); + riskyMethodNameContents.add("allOf"); String userNameProp = System.getProperty(PRMC_RISKY_FIELD_USER_KEY); if (userNameProp != null) { Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -0,0 +1,179 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2013 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; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.classfile.Code; +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; + +/** + * finds methods that create and populate collections, and while knowing + * the end size of those collections, does not pre allocate the collection + * to be big enough. This just causes unneeded reallocations putting strain + * on the garbage collector. */ +public class PresizeCollections extends BytecodeScanningDetector { + + private static final Set<String> PRESIZEABLE_COLLECTIONS = new HashSet<String>(); + static { + PRESIZEABLE_COLLECTIONS.add("java/util/ArrayBlockingQueue"); + PRESIZEABLE_COLLECTIONS.add("java/util/ArrayDeque"); + PRESIZEABLE_COLLECTIONS.add("java/util/ArrayList"); + PRESIZEABLE_COLLECTIONS.add("java/util/HashSet"); + PRESIZEABLE_COLLECTIONS.add("java/util/LinkedBlockingQueue"); + PRESIZEABLE_COLLECTIONS.add("java/util/LinkedHashSet"); + PRESIZEABLE_COLLECTIONS.add("java/util/PriorityBlockingQueue"); + PRESIZEABLE_COLLECTIONS.add("java/util/PriorityQueue"); + PRESIZEABLE_COLLECTIONS.add("java/util/TreeSet"); + PRESIZEABLE_COLLECTIONS.add("java/util/Vector"); + } + + private BugReporter bugReporter; + private OpcodeStack stack; + private int allocNumber; + private Map<Integer, List<Integer>> allocToAddPCs; + + public PresizeCollections(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * overrides the visitor to initialize the opcode stack + * + * @param classContext the context object that holds the JavaClass being parsed + */ + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + allocToAddPCs = new HashMap<Integer, List<Integer>>(); + super.visitClassContext(classContext); + } finally { + stack = null; + allocToAddPCs = null; + } + } + + /** + * implements the visitor to reset the opcode stack + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + stack.resetForMethodEntry(this); + allocNumber = 0; + allocToAddPCs.clear(); + super.visitCode(obj); + + for (List<Integer> pcs : allocToAddPCs.values()) { + if (pcs.size() > 16) { + bugReporter.reportBug(new BugInstance(this, "PSC_PRESIZE_COLLECTIONS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this, pcs.get(0))); + } + } + } + + /** + * implements the visitor to look for creation of collections + * that are then populated with a known number of elements usually + * based on another collection, but the new collection is not presized. + * @param seen the opcode of the currently parsed instruction + */ + @Override + public void sawOpcode(int seen) { + boolean sawAlloc = false; + try { + switch (seen) { + case INVOKESPECIAL: + String clsName = getClassConstantOperand(); + if (PRESIZEABLE_COLLECTIONS.contains(clsName)) { + String methodName = getNameConstantOperand(); + if ("<init>".equals(methodName)) { + String signature = getSigConstantOperand(); + if ("()V".equals(signature)) { + sawAlloc = true; + } + } + } + break; + + case INVOKEINTERFACE: + String methodName = getNameConstantOperand(); + if ("add".equals(methodName) || "addAll".equals(methodName)) { + String signature = getSigConstantOperand(); + Type[] argTypes = Type.getArgumentTypes(signature); + if ((argTypes.length == 1) && (stack.getStackDepth() > 1)) { + OpcodeStack.Item item = stack.getStackItem(1); + Integer allocNum = (Integer) item.getUserValue(); + if (allocNum != null) { + List<Integer> lines = allocToAddPCs.get(allocNum); + if (lines == null) { + lines = new ArrayList<Integer>(); + allocToAddPCs.put(allocNum, lines); + } + lines.add(getPC()); + } + } + } + break; + + case GOTO: + case GOTO_W: + if (getBranchOffset() < 0) { + int target = getBranchTarget(); + Iterator<List<Integer>> it = allocToAddPCs.values().iterator(); + while (it.hasNext()) { + List<Integer> pcs = it.next(); + for (Integer pc : pcs) { + if (pc > target) { + bugReporter.reportBug(new BugInstance(this, "PSC_PRESIZE_COLLECTIONS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this, pc)); + it.remove(); + break; + } + } + } + } + } + } finally { + stack.sawOpcode(this, seen); + if (sawAlloc) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(Integer.valueOf(++allocNumber)); + } + } + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mimetype + text/plain Added: svn:eol-style + native Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -1,17 +1,17 @@ /* * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2013 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 @@ -51,7 +51,7 @@ /** * looks for silly bugs that are simple but do not fit into one large pattern. */ -public class SillynessPotPourri extends BytecodeScanningDetector +public class SillynessPotPourri extends BytecodeScanningDetector { private static final Set<String> collectionInterfaces = new HashSet<String>(); static { @@ -62,7 +62,7 @@ collectionInterfaces.add("java/util/Map"); collectionInterfaces.add("java/util/SortedMap"); } - + private static JavaClass calendarClass; static { try { @@ -71,7 +71,7 @@ calendarClass = null; } } - + private final BugReporter bugReporter; private OpcodeStack stack; private int lastPCs[]; @@ -81,7 +81,7 @@ private boolean lastLoadWasString; /** branch targets, to a set of branch instructions */ private Map<Integer, Set<Integer>> branchTargets; - + /** * constructs a SPP detector given the reporter to report bugs on * @param bugReporter the sync of bug reports @@ -89,7 +89,7 @@ public SillynessPotPourri(BugReporter bugReporter) { this.bugReporter = bugReporter; } - + @Override public void visitField(Field field) { if ("serialVersionUID".equals(field.getName()) @@ -100,7 +100,7 @@ .addField(this)); } } - + @Override public void visitClassContext(ClassContext classContext) { try { @@ -114,10 +114,10 @@ branchTargets = null; } } - + /** * implements the visitor to reset the opcode stack - * + * * @param obj the context object for the currently parsed Code */ @Override @@ -131,17 +131,17 @@ branchTargets.clear(); super.visitCode(obj); } - + /** * implements the visitor to look for various silly bugs - * + * * @param seen the opcode of the currently parsed instruction */ @Override public void sawOpcode(int seen) { int reg = -1; String userValue = null; - try { + try { if (((seen >= IFEQ) && (seen <= GOTO)) || (seen == IFNULL) || (seen == IFNONNULL) || (seen == GOTO_W)) { Integer branchTarget = Integer.valueOf(getBranchTarget()); Set<Integer> branchInsSet = branchTargets.get(branchTarget); @@ -152,13 +152,13 @@ } branchInsSet.add(Integer.valueOf(getPC())); } - + if ((seen == IFEQ) || (seen == IFLE) || (seen == IFNE)) { if (lastLoadWasString && (lastPCs[0] != -1)) { byte[] bytes = getCode().getCode(); int loadIns = CodeByteUtils.getbyte(bytes, lastPCs[2]); int brOffset = (loadIns == ALOAD) ? 11 : 10; - + if ((((loadIns >= ALOAD_0) && (loadIns <= ALOAD_3)) || (loadIns == ALOAD)) && (CodeByteUtils.getbyte(bytes, lastPCs[3]) == INVOKEVIRTUAL) && (CodeByteUtils.getbyte(bytes, lastPCs[2]) == loadIns) @@ -183,7 +183,7 @@ } } } - + if ((seen == IFEQ) || (seen == IFNE) || (seen == IFGT)) { if (stack.getStackDepth() == 1) { OpcodeStack.Item item = stack.getStackItem(0); @@ -195,7 +195,7 @@ } } } - + if (seen == IFNE) { byte[] bytes = getCode().getCode(); if (lastPCs[2] != -1) { @@ -228,7 +228,7 @@ OpcodeStack.Item itm = stack.getStackItem(0); lastIfEqWasBoolean = "Z".equals(itm.getSignature()); } - + byte[] bytes = getCode().getCode(); if (lastPCs[1] != -1) { int loadIns = CodeByteUtils.getbyte(bytes, lastPCs[2]); @@ -266,7 +266,7 @@ } else if ((seen == IRETURN) && lastIfEqWasBoolean) { byte[] bytes = getCode().getCode(); if ((lastPCs[0] != -1) - && ((0x00FF & bytes[lastPCs[3]]) == ICONST_0) + && ((0x00FF & bytes[lastPCs[3]]) == ICONST_0) && ((0x00FF & bytes[lastPCs[2]]) == GOTO) && ((0x00FF & bytes[lastPCs[1]]) == ICONST_1) && ((0x00FF & bytes[lastPCs[0]]) == IFEQ)) { @@ -282,7 +282,7 @@ { bug = false; } - + if (bug) { bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_TRINARY", NORMAL_PRIORITY) .addClass(this) @@ -297,7 +297,7 @@ double d = ((ConstantDouble) con).getBytes(); double piDelta = Math.abs(d - Math.PI); double eDelta = Math.abs(d - Math.E); - + if (((piDelta > 0.0) && (piDelta < 0.002)) || ((eDelta > 0.0) && (eDelta < 0.002))) { bugReporter.reportBug(new BugInstance(this, "SPP_USE_MATH_CONSTANT", NORMAL_PRIORITY) @@ -312,7 +312,7 @@ 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) @@ -326,7 +326,7 @@ Float f1 = (Float)item.getConstant(); item = stack.getStackItem(1); Float f2 = (Float)item.getConstant(); - + if (((f1 != null) && f1.isNaN()) || ((f2 != null) && f2.isNaN())) { bugReporter.reportBug(new BugInstance(this, "SPP_USE_ISNAN", NORMAL_PRIORITY) .addClass(this) @@ -346,8 +346,17 @@ } if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); - if ("trim".equals(item.getUserValue())) { + String mName = (String) item.getUserValue(); + if ("trim".equals(mName)) { item.setUserValue(null); + } else if ((mName != null) && (mName.startsWith("append:"))) { + int appendReg = Integer.parseInt(mName.substring("append:".length())); + if (reg == appendReg) { + bugReporter.reportBug(new BugInstance(this, "SPP_STRINGBUILDER_IS_MUTABLE", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } } } else if (((seen >= ALOAD_0) && (seen <= ASTORE_3)) || (seen == ALOAD)) { @@ -425,7 +434,7 @@ } } } - + } } else if (seen == INVOKEVIRTUAL) { String className = getClassConstantOperand(); @@ -448,6 +457,16 @@ } } } + } else if ("java/lang/StringBuilder".equals(className) || "java/lang/StringBuffer".equals(className)) { + if ("append".equals(methodName)) { + if (stack.getStackDepth() > 1) { + OpcodeStack.Item item = stack.getStackItem(1); + if (item.getRegisterNumber() > -1) + userValue = "append:" + item.getRegisterNumber(); + else + userValue = (String) item.getUserValue(); + } + } } else if ("java/lang/String".equals(className)) { if ("intern".equals(methodName)) { String owningMethod = getMethod().getName(); @@ -468,7 +487,7 @@ } else if ("toLowerCase".equals(methodName) || "toUpperCase".equals(methodName)) { userValue = "IgnoreCase"; - } else if ("equalsIgnoreCase".equals(methodName) + } else if ("equalsIgnoreCase".equals(methodName) || "compareToIgnoreCase".equals(methodName)) { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(1); @@ -506,7 +525,7 @@ bugReporter.reportBug(new BugInstance(this, "SPP_TEMPORARY_TRIM", NORMAL_PRIORITY) .addClass(this) .addMethod(this) - .addSourceLine(this)); + .addSourceLine(this)); } } } @@ -539,7 +558,7 @@ break; } } - + if (found) { bugReporter.reportBug(new BugInstance(this, "SPP_INVALID_BOOLEAN_NULL_CHECK", NORMAL_PRIORITY) .addClass(this) @@ -563,11 +582,11 @@ .addClass(this) .addMethod(this) .addSourceLine(this)); - } + } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } - + } } } else if ("java/util/Properties".equals(className)) { @@ -597,10 +616,10 @@ Object o = item.getConstant(); if (o instanceof Integer) { int parm = ((Integer) o).intValue(); - if ((parm > 32) - && (parm < 127) + if ((parm > 32) + && (parm < 127) && (parm != 64) - && ((parm % 10) != 0) + && ((parm % 10) != 0) && ((parm % 5) != 0)) { bugReporter.reportBug(new BugInstance(this, "SPP_NO_CHAR_SB_CTOR", LOW_PRIORITY) .addClass(this) @@ -619,8 +638,8 @@ .addClass(this) .addMethod(this) .addSourceLine(this)); - } - } + } + } } } } else if ("java/math/BigDecimal".equals(className)) { @@ -657,7 +676,7 @@ } } } - + if (collectionInterfaces.contains(className)) { String method = getNameConstantOperand(); if ("size".equals(method)) { @@ -665,7 +684,7 @@ } } } - + } finally { TernaryPatcher.pre(stack, seen); stack.sawOpcode(this, seen); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2013-02-10 02:29:13 UTC (rev 1741) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2013-03-04 04:47:55 UTC (rev 1742) @@ -28,6 +28,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Queue; import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; @@ -70,6 +71,7 @@ collectionClasses.add(Vector.class.getName()); collectionClasses.add(ArrayList.class.getName()); collectionClasses.add(LinkedList.class.getName()); + collectionClasses.add(Queue.class.getName()); } private static Set<String> writeMethods = new HashSet<String>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2013-02-10 02:29:21
|
Revision: 1741 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1741&view=rev Author: dbrosius Date: 2013-02-10 02:29:13 +0000 (Sun, 10 Feb 2013) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/samples/MRC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java Modified: trunk/fb-contrib/samples/MRC_Sample.java =================================================================== --- trunk/fb-contrib/samples/MRC_Sample.java 2013-02-06 05:02:24 UTC (rev 1740) +++ trunk/fb-contrib/samples/MRC_Sample.java 2013-02-10 02:29:13 UTC (rev 1741) @@ -1,3 +1,4 @@ +import java.awt.Component; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -6,6 +7,8 @@ @SuppressWarnings("all") public class MRC_Sample { + private Component[] components; + private int getValue() { return 1; } @@ -87,4 +90,25 @@ } return totLength; } + + private int getFPLoopVar(List<String> c) { + for (int i = 0; i < c.size(); i++) { + if (c.get(i) == null) { + return i; + } + } + + throw new RuntimeException(); + } + + private int fpFindComponent(Component component) { + int index = 0; + while (this.components[index] != component) { + index++; + if (index >= this.components.length) { + return 0; + } + } + return index; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2013-02-06 05:02:24 UTC (rev 1740) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2013-02-10 02:29:13 UTC (rev 1741) @@ -18,6 +18,9 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.HashMap; +import java.util.Map; + import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Method; @@ -38,6 +41,8 @@ { private final BugReporter bugReporter; private OpcodeStack stack; + private int returnRegister; + private Map<Integer, Object> registerConstants; private Object returnConstant; private boolean methodSuspect; private int returnPC; @@ -54,9 +59,11 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); + registerConstants = new HashMap<Integer, Object>(); super.visitClassContext(classContext); } finally { stack = null; + registerConstants = null; } } @@ -73,7 +80,9 @@ && ((aFlags & Constants.ACC_SYNTHETIC) == 0) && (!m.getSignature().endsWith(")Z"))) { stack.resetForMethodEntry(this); + returnRegister = -1; returnConstant = null; + registerConstants.clear(); methodSuspect = true; returnPC = -1; super.visitCode(obj); @@ -108,12 +117,18 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); + int register = item.getRegisterNumber(); + if (registerConstants.containsKey(register) && (registerConstants.get(register) == null)) { + methodSuspect = false; + return; + } + Object constant = item.getConstant(); if (constant == null) { methodSuspect = false; return; } - if ((item.getUserValue() != null) && ("".equals(constant))) { + if (Boolean.TRUE.equals(item.getUserValue()) && ("".equals(constant))) { methodSuspect = false; return; } @@ -122,6 +137,7 @@ return; } + returnRegister = item.getRegisterNumber(); returnConstant = constant; } } else if ((seen == GOTO) || (seen == GOTO_W)) { @@ -133,7 +149,35 @@ if (clsName.startsWith("java/lang/StringB")) { sawSBToString = "toString".equals(getNameConstantOperand()); } + } else if ((seen >= ISTORE) && (seen <= ASTORE_3) || (seen == IINC)) { + int register = getRegisterOperand(); + if ((returnRegister != -1) && (register == returnRegister)) { + methodSuspect = false; + } + + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + Object constant = item.getConstant(); + if (registerConstants.containsKey(register)) { + if ((constant == null) || !constant.equals(registerConstants.get(register))) { + registerConstants.put(register, null); + } + } else { + registerConstants.put(register, constant); + } + } else { + registerConstants.put(register, null); + } + + if (returnRegister == register) { + Object constant = registerConstants.get(returnRegister); + if (constant != null) { + methodSuspect = false; + } + } } + + } finally { TernaryPatcher.pre(stack, seen); stack.sawOpcode(this, seen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |