[Fb-contrib-commit] SF.net SVN: fb-contrib:[1761] trunk/fb-contrib
Brought to you by:
dbrosius
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] |