[Fb-contrib-commit] SF.net SVN: fb-contrib:[1834] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2018-05-11 03:30:50
|
Revision: 1834 http://sourceforge.net/p/fb-contrib/code/1834 Author: dbrosius Date: 2018-05-11 03:29:38 +0000 (Fri, 11 May 2018) Log Message: ----------- sync from github 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.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousMapCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ListUsageIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MapUsageIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PoorMansEnum.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousShadedClassUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/WiringIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/ToString.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/src/samples/java/ex/AI_Sample.java trunk/fb-contrib/src/samples/java/ex/LO_Sample.java trunk/fb-contrib/src/samples/java/ex/MRC_Sample.java trunk/fb-contrib/src/samples/java/ex/OCP_Sample.java trunk/fb-contrib/src/samples/java/ex/PMB_Sample.java trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java trunk/fb-contrib/src/samples/java/ex/PSC_Sample.java trunk/fb-contrib/src/samples/java/ex/SEO_Sample.java trunk/fb-contrib/src/samples/java/ex/SPP_Sample.java Added Paths: ----------- trunk/fb-contrib/etc/pmd-rules.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SetUsageIssues.java trunk/fb-contrib/src/samples/java/ex/FII_Sample.java trunk/fb-contrib/src/samples/java/ex/SUI_Sample.java trunk/fb-contrib/src/samples/java/ex/ce/ trunk/fb-contrib/src/samples/java/ex/ce/CE_Sample.java trunk/fb-contrib/src/samples/java/ex/ce/Envy.java Removed Paths: ------------- trunk/fb-contrib/src/samples/java/ex/CE_Sample.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2018-03-04 05:49:10 UTC (rev 1833) +++ trunk/fb-contrib/build.xml 2018-05-11 03:29:38 UTC (rev 1834) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.2.1" /> + <property name="fb-contrib.version" value="7.2.2-SNAPSHOT" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2018-03-04 05:49:10 UTC (rev 1833) +++ trunk/fb-contrib/etc/bugrank.txt 2018-05-11 03:29:38 UTC (rev 1834) @@ -53,6 +53,13 @@ +0 BugPattern EXS_EXCEPTION_SOFTENING_RETURN_FALSE +0 BugPattern FCBL_FIELD_COULD_BE_LOCAL +2 BugPattern FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY ++0 BugPattern FII_AVOID_CONTAINS_ON_COLLECTED_STREAM ++0 BugPattern FII_AVOID_SIZE_ON_COLLECTED_STREAM ++0 BugPattern FII_COMBINE_FILTERS ++1 BugPattern FII_USE_ANY_MATCH ++0 BugPattern FII_USE_FIND_FIRST ++0 BugPattern FII_USE_FUNCTION_IDENTITY ++0 BugPattern FII_USE_METHOD_REFERENCE +0 BugPattern FPL_FLOATING_POINT_LOOPS +6 BugPattern FP_FINAL_PARAMETERS +0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD @@ -218,7 +225,6 @@ +0 BugPattern SPP_NON_USEFUL_TOSTRING +0 BugPattern SPP_NO_CHAR_SB_CTOR +0 BugPattern SPP_NULL_BEFORE_INSTANCEOF -+0 BugPattern SPP_NULL_CHECK_ON_OPTIONAL +0 BugPattern SPP_SERIALVER_SHOULD_BE_PRIVATE +0 BugPattern SPP_STATIC_FORMAT_STRING +0 BugPattern SPP_STRINGBUFFER_WITH_EMPTY_STRING @@ -237,6 +243,7 @@ +0 BugPattern SPP_USE_ISNAN +0 BugPattern SPP_USE_MATH_CONSTANT +0 BugPattern SPP_USE_STRINGBUILDER_LENGTH ++0 BugPattern SPP_USE_ZERO_WITH_COMPARATOR +0 BugPattern SPP_WRONG_COMMONS_TO_STRING_OBJECT +0 BugPattern SSCU_SUSPICIOUS_SHADED_CLASS_USE +0 BugPattern STB_STACKED_TRY_BLOCKS @@ -245,6 +252,8 @@ +0 BugPattern STT_TOSTRING_MAP_KEYING +0 BugPattern STT_TOSTRING_STORED_IN_FIELD +0 BugPattern SUA_SUSPICIOUS_UNINITIALIZED_ARRAY ++0 BugPattern SUI_CONTAINS_BEFORE_ADD ++0 BugPattern SUI_CONTAINS_BEFORE_REMOVE +0 BugPattern SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT +0 BugPattern TBP_TRISTATE_BOOLEAN_PATTERN +0 BugPattern TR_TAIL_RECURSION Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2018-03-04 05:49:10 UTC (rev 1833) +++ trunk/fb-contrib/etc/findbugs.xml 2018-05-11 03:29:38 UTC (rev 1834) @@ -23,17 +23,15 @@ <!-- Detectors --> - <!-- COMMENT OUT FOR RELEASE + <!-- 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.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" /> @@ -148,7 +146,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SCRV_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_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_SERIALVER_SHOULD_BE_PRIVATE,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,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL,SPP_STATIC_FORMAT_STRING,SPP_NULL_CHECK_ON_OPTIONAL,SPP_WRONG_COMMONS_TO_STRING_OBJECT" /> + 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_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_SERIALVER_SHOULD_BE_PRIVATE,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,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL,SPP_STATIC_FORMAT_STRING,SPP_WRONG_COMMONS_TO_STRING_OBJECT,SPP_USE_ZERO_WITH_COMPARATOR" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -327,12 +325,18 @@ <Detector class="com.mebigfatguy.fbcontrib.collect.CollectNullableMethodStatus" speed="fast" reports="" hidden="true" /> - <!-- COMMENT OUT FOR POINT RELEASE + <!-- COMMENT OUT FOR POINT RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.ListUsageIssues" speed="fast" reports="LUI_USE_SINGLETON_LIST,LUI_USE_COLLECTION_ADD,LUI_USE_GET0"/> - COMMENT OUT FOR POINT RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.FunctionalInterfaceIssues" speed="fast" reports="FII_USE_METHOD_REFERENCE,FII_AVOID_CONTAINS_ON_COLLECTED_STREAM,FII_USE_ANY_MATCH,FII_USE_FIND_FIRST,FII_COMBINE_FILTERS,FII_USE_FUNCTION_IDENTITY,FII_AVOID_SIZE_ON_COLLECTED_STREAM" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.SetUsageIssues" speed="fast" reports="SUI_CONTAINS_BEFORE_ADD,SUI_CONTAINS_BEFORE_REMOVE"/> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="slow" reports="CE_CLASS_ENVY" /> + + <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -441,8 +445,8 @@ <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_STRING_BUILDER" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_CONVERSION_OF_STRING_LITERAL" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_STATIC_FORMAT_STRING" category="CORRECTNESS" /> - <BugPattern abbrev="SPP" type="SPP_NULL_CHECK_ON_OPTIONAL" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_WRONG_COMMONS_TO_STRING_OBJECT" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_USE_ZERO_WITH_COMPARATOR" 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" /> @@ -618,14 +622,23 @@ <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_USES_ORELSEGET_WITH_NULL" category="CORRECTNESS" /> <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT" category="CORRECTNESS"/> <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH" category="CORRECTNESS"/> - <BugPattern abbrev="RFI" type="RFI_SET_ACCESSIBLE" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="AI" type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="MUI" type="MUI_CONTAINSKEY_BEFORE_GET" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="RFI" type="RFI_SET_ACCESSIBLE" category="CORRECTNESS"/> + <BugPattern abbrev="AI" type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" category="CORRECTNESS"/> + <BugPattern abbrev="MUI" type="MUI_CONTAINSKEY_BEFORE_GET" category="CORRECTNESS"/> <BugPattern abbrev="MUI" type="MUI_GET_BEFORE_REMOVE" category="CORRECTNESS"/> <BugPattern abbrev="MUI" type="MUI_CALLING_SIZE_ON_SUBCONTAINER" category="CORRECTNESS" /> <BugPattern abbrev="MUI" type="MUI_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR" category="CORRECTNESS" /> <BugPattern abbrev="MUI" type="MUI_USE_CONTAINSKEY" category="CORRECTNESS" /> - <BugPattern abbrev="LUI" type="LUI_USE_SINGLETON_LIST" category="CORRECTNESS" /> - <BugPattern abbrev="LUI" type="LUI_USE_COLLECTION_ADD" category="CORRECTNESS" /> - <BugPattern abbrev="LUI" type="LUI_USE_GET0" category="CORRECTNESS" /> + <BugPattern abbrev="LUI" type="LUI_USE_SINGLETON_LIST" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="LUI" type="LUI_USE_COLLECTION_ADD" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="LUI" type="LUI_USE_GET0" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_USE_METHOD_REFERENCE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_AVOID_CONTAINS_ON_COLLECTED_STREAM" category="CORRECTNESS" experimental="true "/> + <BugPattern abbrev="FII" type="FII_USE_ANY_MATCH" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_USE_FIND_FIRST" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_COMBINE_FILTERS" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_USE_FUNCTION_IDENTITY" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_AVOID_SIZE_ON_COLLECTED_STREAM" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SUI" type="SUI_CONTAINS_BEFORE_ADD" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SUI" type="SUI_CONTAINS_BEFORE_REMOVE" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2018-03-04 05:49:10 UTC (rev 1833) +++ trunk/fb-contrib/etc/messages.xml 2018-05-11 03:29:38 UTC (rev 1834) @@ -22,7 +22,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectMethodsReturningImmutableCollections"> <Details> <![CDATA[ @@ -30,7 +30,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectNullableMethodStatus"> <Details> <![CDATA[ @@ -62,7 +62,7 @@ <![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, + is made that this collection must be multithreading 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> ]]> @@ -82,7 +82,7 @@ <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 uses methods defined by an implemented interface or superclass 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> @@ -108,7 +108,7 @@ 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, - which defines the different types required, and add an instance of that class to the + which defines the different types required, and adding an instance of that class to the collection, or array.</p> <p>It is a fast detector.</p> ]]> @@ -129,7 +129,7 @@ } </code> But what does that tell you? Is this method very very likely to throw NullPointerExceptions? - If it is, why isn't this method handling them so that exceptions aren't thrown. So don't do this. + If it is, why isn't this method handling them so that exceptions aren't thrown? So don't do this. If an NPE is very likely, then check for it, and handle the situation. </p> ]]> @@ -139,12 +139,11 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy"> <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 their class' 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> - <p>It is a fast detector.</p> + <p>It is a slow detector.</p> ]]> </Details> </Detector> @@ -189,7 +188,7 @@ <![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. Or if the two list are + all of these pieces of information, and place instances of this class in one list. Or if the two lists are related in key/value fashion, then use a map instead.</p> <p>It is a fast detector.</p> ]]> @@ -199,7 +198,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.FinalParameters"> <Details> <![CDATA[ - <p>Looks for methods that correctly do not write to a parameter. To help document this you should consider + <p>Looks for methods that correctly do not write to a parameter. To help document this, you should consider defining these parameters as final.</p> <p>It is a slow detector.</p> ]]> @@ -210,7 +209,7 @@ <Details> <![CDATA[ <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 + exception. Since this is an abstract class, it may be cleaner to simply define this method as abstract, so that correct subclass behavior is enforced.</p> <p>It is a fast detector.</p> ]]> @@ -232,7 +231,7 @@ <![CDATA[ <p>Looks for methods that use floating point indexes for loops. Since floating point math is imprecise, rounding errors will occur each time through the loop causing - hard to find problems. It is usually better to use integer indexing, and calculating + hard-to-find problems. It is usually better to use integer indexing, and calculate the correct floating point value from the index.</p> <p>It is a fast detector.</p> ]]> @@ -276,7 +275,7 @@ <pre><code> public void test(Character c) </code></pre> - but instead maps to one that takes an int, long, float or double, such as + but it instead maps to one that takes an int, long, float or double, such as <pre><code> public void test(int i) </code></pre> @@ -384,7 +383,7 @@ <Details> <![CDATA[ <p>Looks for methods that create DOM nodes but do not add them to any DOM Document. - Either the node was needed to be added to the tree, or the node likely was created in error.</p> + Either the node needed to be added to the tree, or the node likely was created in error.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -404,7 +403,7 @@ <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 concatenating 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 transformed at runtime, using parameters set through Transformer.setParameter.</p> @@ -430,7 +429,7 @@ <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 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, on even a map with informative key names + would be a better choice for a container, or even a map with informative key names would be better.</p> <p>It is a fast detector.</p> ]]> @@ -540,7 +539,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.FieldCouldBeLocal"> <Details> <![CDATA[ - <p>Looks for classes that define fields that are used in a locals only fashion, + <p>Looks for classes that define fields that are used in a local-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> @@ -574,7 +573,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance"> <Details> <![CDATA[ - <p>Looks for violation of Section 508, Accessibility for People with disabilities Act.</p> + <p>Looks for violation of Section 508, Accessibility for People with Disabilities Act.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -679,7 +678,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.TailRecursion"> <Details> <![CDATA[ - <p>Looks for methods that make a recursive call to itself as the last statement in the + <p>Looks for methods that make recursive calls to themselves as the last statement in the method. This tail recursion could be converted into a simple loop which would improve the performance and stack requirements.</p> <p>It is a fast detector.</p> @@ -704,7 +703,7 @@ <![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> + class.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -714,7 +713,7 @@ <Details> <![CDATA[ <p>Looks for classes 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 choices (a negative number, 0, and a positive number).</p> <p>It is a fast detector.</p> ]]> @@ -734,7 +733,7 @@ <Details> <![CDATA[ <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 + <p>Looks for assignments to variables in a scope larger than their 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> ]]> @@ -868,7 +867,7 @@ <Details> <![CDATA[ <p>Looks for JUnit or TestNG test case methods that use assertions with odd parameters. - Including in this is: + Included in this is: <ul> <li>Passing a constant as the second (actual) parameter in a JUnit test</li> <li>Not using the three parameter version of asserts for doubles</li> @@ -1105,7 +1104,7 @@ <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 + 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> @@ -1195,7 +1194,7 @@ <![CDATA[ <p>This detector looks for object creation where the object isn't assigned to any variable or field. This implies that the class operates through side effects in the constructor, which makes - for difficult to maintain code.</p> + for difficult-to-maintain code.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -1205,7 +1204,7 @@ <Details> <![CDATA[ <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> + with the value retrieved from the same bean's corollary getter, like this:</p> <pre><code> person.setAge(person.getAge()); </code></pre> @@ -1218,7 +1217,7 @@ <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 + <p>This detector looks for creation of java.awt.Graphics objects that do not have the <code>.dispose()</code> method called on them when finished. These objects will be cleaned up by the Garbage collector, bug given the likelihood 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> @@ -1230,7 +1229,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks"> <Details> <![CDATA[ - <p>This detector looks for two or more try catch blocks that are consecutive + <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> @@ -1263,7 +1262,7 @@ <Details> <![CDATA[ <p>This detector looks for uses for commons-lang <code>ToStringBuilder</code> where the - result of <code>toString()</code> is returned without an intermediate invocation of toString().</p> + result of <code>toString()</code> is returned without an intermediate invocation of append().</p> <p>It is a fast detector.</p> ]]> </Details> @@ -1378,7 +1377,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.CollectionNamingConfusion"> <Details> <![CDATA[ @@ -1390,11 +1389,11 @@ ]]> </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 + <p>Looks for fields defined with simple types, (int, String, etc) that are used like enums. 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> @@ -1401,26 +1400,26 @@ ]]> </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, assuming the method isn't used through reflection.</p> - <p>It is fast detector.</p> + <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.FindClassCircularDependencies"> <Details> <![CDATA[ - <p>This detector looks circular dependencies among classes. </p> + <p>This detector looks for circular dependencies among classes. </p> <p>It is a moderately fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection"> <Details> <![CDATA[ @@ -1440,7 +1439,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.HttpClientProblems"> <Details> <![CDATA[ @@ -1450,7 +1449,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.Unjitable"> <Details> <![CDATA[ @@ -1461,76 +1460,76 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ConflictingTimeUnits"> <Details> <![CDATA[ <p>Looks for methods that perform arithmetic operations on values representing time - where the time unit is incompatible, i.e. adding a millisecond value to a nanosecond value. + where the time unit is incompatible, e.g. adding a millisecond value to a nanosecond value. </p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.CharsetIssues"> - <Details> - <![CDATA[ + + <Detector class="com.mebigfatguy.fbcontrib.detect.CharsetIssues"> + <Details> + <![CDATA[ <p>Looks for manual specification of String encoding using String constants where either - a StandardCharset could be used (JDK7) or where the encoding is not recognized with the - current JDK.</p> - <p>It is a fast detector.</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.ContainsBasedConditional"> - <Details> - <![CDATA[ - <p>Looks for complex if expressions made up of multiple conditions joined by OR, where the same - local variable is compared to a static value. When the number of conditions grow it is much cleaner - to build a static set of the possible values, and use the contains method on that set. This will - shorten the code, and make it more self documenting.</p> + a StandardCharset could be used (JDK7) or where the encoding is not recognized with the + current JDK.</p> <p>It is a fast detector.</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod"> - <Details> - <![CDATA[ + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ContainsBasedConditional"> + <Details> + <![CDATA[ + <p>Looks for complex <code>if</code> expressions made up of multiple conditions joined by OR, where the same + local variable is compared to a static value. When the number of conditions grows it is much cleaner + to build a static set of the possible values, and use the <code>contains</code> method on that set. This will + shorten the code, and make it more self documenting.</p> + <p>It is a fast detector.</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod"> + <Details> + <![CDATA[ <p>Looks for methods that are declared more permissively than the code is using. For instance, declaring - a method public, when it could just be declared private. Having methods have more permissive access than they - need to have limits your ability to make observations about these methods, like parameter usage, - refactorability, and derivability. This detector will not report on methods that are never called in - the case this method is an API like method intended to be called by client code. If this method is - also called through reflection, this detector may erroneous report it.</p> + a method public, when it could just be declared private. Giving methods more permissive access than they + need to have limits your ability to make observations about these methods, like parameter usage, + refactorability, and derivability. This detector will not report on methods that are never called, in + case this method is an API-like method intended to be called by client code. If this method is + also called through reflection, this detector may erroneously report it.</p> <p>It is a moderately fast detector.</p> - ]]> - </Details> - </Detector> - + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.StringifiedTypes"> <Details> <![CDATA[ <p>Looks for classes that store fields that are Strings that impersonate instances of classes, or collections that are - fields that hold Strings that impersonate a class. Examples of String impersonating are storing: + fields that hold Strings that impersonate a class. Examples of String impersonation are storing: <ul> <li>The result of a toString call</li> - <li>Strings build from parsing or building strings from other objects, such as "1,2,3,4" or "Project:3"</li> + <li>Strings built from parsing or building strings from other objects, such as "1,2,3,4" or "Project:3"</li> </ul> By using Strings you are throwing away type-safety, and making it difficult to reason about what the values of variables - in use are. If a String has multiple parts to it, it probably belongs as a first class Class. + in use are. If a String has multiple parts to it, it probably belongs as a first-class Class. </p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousLoopSearch"> <Details> <![CDATA[ - <p>Looks for methods that assign a value to a variable in an if equals conditional in a loop, but does not break after doing so. + <p>Looks for methods that assign a value to a variable in an "if equals" conditional in a loop, but do not break after doing so. Since equality would seem to be a one time event, continuing with the loop seems pointless, and a break statement in the if statement seems like it should be added.</p> <p>It is a fast detector.</p> @@ -1537,7 +1536,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles"> <Details> <![CDATA[ @@ -1548,12 +1547,12 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass"> <Details> <![CDATA[ - <p>Looks for classes that are not fully complete from a usability point of view. Making them more difficult to use - than it should be. Things such as + <p>Looks for classes that are not fully complete from a usability point of view, making them more difficult to use + than they should be. Things such as <ul> <li>Using the default package</li> <li>Missing hashCode/equals</li> @@ -1565,7 +1564,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues"> <Details> <![CDATA[ @@ -1574,22 +1573,22 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.JPAIssues"> <Details> <![CDATA[ - <p>Looks for problems with the use of the JPA specification, including spring's + <p>Looks for problems with the use of the JPA specification, including Spring's support of JPA</p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.SuboptimalExpressionOrder"> <Details> <![CDATA[ <p>Looks for conditional expressions that are a combination of simple local variable (in)equalities - and tests on the results of method calls where the method calls are done first. By placing the simple + and tests on the results of method calls, where the method calls are done first. By placing the simple conditions first you may eliminate costly calls in certain cases. This assumes that the method calls do not have side effects that should happen always.</p> <p>It is a fast detector.</p> @@ -1596,7 +1595,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.IOIssues"> <Details> <![CDATA[ @@ -1605,30 +1604,30 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.DubiousMapCollection"> <Details> <![CDATA[ - <p>Looks for use of maps that are private fields in a List only way, that is, maps that are created in constructors + <p>Looks for use of maps that are private fields in a List-only way, that is, maps that are created in constructors or static initializers, and are only iterated over. Often this is done because the Map allows for two values, as opposed - to a List. The Fix is to just create a List of some object that holds all the values.</p> + to a List. The fix is to just create a List of some object that holds all the values.</p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.BuryingLogic"> <Details> <![CDATA[ <p>Looks for methods that needlessly push a large chunk of code to the right through indenting with braces. - The code is basically an if/else-then-return structure. The if true test does the bulk of the logic, and the else - just returns. It is more readable if the bulk of the logic is move as far to the left in the method as is possible. + The code is basically an if/else-then-return structure. The "if true" test does the bulk of the logic, and the else + just returns. It is more readable if the bulk of the logic is moved as far to the left in the method as is possible. </p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.WiringIssues"> <Details> <![CDATA[ @@ -1637,36 +1636,36 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ConcurrentCollectionIssues"> <Details> <![CDATA[ - <p>Looks for problems with using concurrent collections + <p>Looks for problems with using concurrent collections. <ul> - <li>Adding a collection as a value of Concurrent map, without the use of putIfAbsent</li> + <li>Adding a collection as a value of a Concurrent map, without the use of putIfAbsent</li> </ul> </p> <p>It is a fast detector.</p> - ]]> + ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.UseTryWithResources"> <Details> <![CDATA[ <p>Looks for use of auto-closeable resources in JDK 7 or later that are not using - the try-with-resources paradigm. To avoid problems, and ease the reader, use of try-with-resources + the try-with-resources paradigm. To avoid problems, and ease the reader, use of try-with-resources is recommended</p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousShadedClassUse"> <Details> <![CDATA[ - <p>Looks for use of shaded methods from 3rdparty jars, created by tools such as the maven shade plugin. - These methods are from classes that have been included in a jar, for internal use, and are copies of real 3rdparty jars. + <p>Looks for use of shaded methods from 3rd-party jars, created by tools such as the Maven shade plugin. + These methods are from classes that have been included in a jar, for internal use, and are copies of real 3rd-party jars. It is likely you meant to use the real class from the real jar, but your IDE picked the wrong import to use. </p> <p>It is a fast detector.</p> @@ -1677,13 +1676,13 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnsynchronizedSingletonFieldWrites"> <Details> <![CDATA[ - <p>Looks for writes to fields of classes that are believed to be classes used only as Singletons. These + <p>Looks for writes to fields of classes that are believed to be classes used only as Singletons. These classes include Enums, as well as spring beans that are Singleton scoped.</p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.OptionalIssues"> <Details> <![CDATA[ @@ -1692,11 +1691,11 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryApiConversion"> <Details> <![CDATA[ - <p>Looks for code that appears to be using two forms of similar apis, an older one, and a new one. + <p>Looks for code that appears to be using two forms of similar apis: an older one, and a new one. It finds code that creates newer api objects by first instantiating older api objects, and converting them into the new form. It is simpler just to create the new object directly.</p> <p>It is a fast detector</p> @@ -1703,7 +1702,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionIssues"> <Details> <![CDATA[ @@ -1712,16 +1711,16 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.AnnotationIssues"> <Details> <![CDATA[ - <p>Looks for issues around use of standard anntations</p> + <p>Looks for issues around use of standard annotations</p> <p>It is a fast detector</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.MapUsageIssues"> <Details> <![CDATA[ @@ -1730,7 +1729,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ListUsageIssues"> <Details> <![CDATA[ @@ -1740,7 +1739,24 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.FunctionalInterfaceIssues"> + <Details> + <![CDATA[ + <p>Looks for various issues around the use of @FunctionalInterfaces.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.SetUsageIssues"> + <Details> + <![CDATA[ + <p>Looks for various issues around the use of the Set interface</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> </Detector> @@ -1755,7 +1771,7 @@ <p>This method uses <code>StringBuffer</code> or <code>StringBuilder</code>'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 <code>StringBuffer</code> or <code>StringBuilder</code> class.</p> - + <p> Java will implicitly use StringBuilders, which can make this hard to detect or fix. For example, <br/> <pre><code> @@ -1764,7 +1780,7 @@ sb.append(e.getKey() + e.getValue()); //bug detected here } </code></pre><br/> - + gets automatically turned into something like: <br/> <pre><code> StringBuilder sb = new StringBuilder(); @@ -1775,9 +1791,9 @@ <b>sb.append(tempBuilder.toString());</b> //this isn't too efficient } </code></pre><br/> - + which involves a temporary <code>StringBuilder</code>, which is completely unnecessary. To prevent this from happening, simply do:<br/> - + <pre><code> StringBuilder sb = new StringBuilder(); for (Map.Entry<Integer, String> e : map.entrySet()) { @@ -1811,12 +1827,12 @@ <p>This method concatenates the output of a <code>toString()</code> call into a <code>StringBuffer</code> or <code>StringBuilder</code>. 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 <code>NullPointerException</code>s, and is easier to read.</p> - + <p> - Keep in mind that Java compiles simple <code>String</code> concatenation to use <code>StringBuilder</code>s, + Keep in mind that Java compiles simple <code>String</code> concatenation to use <code>StringBuilder</code>s, so you may see this bug even when you don't use <code>StringBuilder</code>s explicitly. </p> - + <p> Instead of: <br/> <pre><code> @@ -1846,7 +1862,7 @@ <Details> <![CDATA[ <p>This method uses a synchronized collection, built from Collections.synchronizedXXXX, but accesses it - through an iterator. Since an iterator is, by definition, multithreaded unsafe, this is a conflict in + through an iterator. Since an iterator is, by definition, multithreading-unsafe, this is a conflict in concept. When using iterators, you should do the synchronization manually.</p> ]]> </Details> @@ -1857,7 +1873,7 @@ <LongDescription>Method {1} is excessively complex, with a cyclomatic complexity of {3}</LongDescription> <Details> <![CDATA[ - <p>This method has a high cyclomatic complexity figure, which calculates the number of branch + <p>This method has a high cyclomatic complexity figure, which represents the number of branch points. It is likely difficult to test, and is brittle to change. Consider refactoring this method into several to reduce the risk.</p> ]]> @@ -1882,7 +1898,7 @@ } </code></pre> - The parameter list is currently defined as an <code>ArrayList</code>, which is a concrete implementation of the <code>List</code> interface. + The parameter list is currently defined as an <code>ArrayList</code>, which is a concrete implementation of the <code>List</code> interface. Specifying <code>ArrayList</code> is unnecessary here, because we aren't using any <code>ArrayList</code>-specific methods (like <code>ensureCapacity()</code> or <code>trimToSize()</code>). Instead of using the concrete definition, it is better to do something like:<br/> <pre><code> @@ -1903,7 +1919,7 @@ <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 iterate over a java.util.List, by calling + <p>This method uses an integer-based <code>for</code> 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> @@ -1917,7 +1933,7 @@ <Details> <![CDATA[ <p>This method adds unrelated objects to a collection or array, requiring careful and brittle - data access to that collection. Create a separate class with properties needed, and add + data access to that collection. Create a separate class with the properties needed, and add an instance of this class to the collection or array, if possible.</p> ]]> </Details> @@ -1941,7 +1957,6 @@ <LongDescription>Method {1} excessively uses methods of another class</LongDescription> <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 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 @@ -1966,8 +1981,8 @@ "someOtherString".equals(str); //or "someOtherString".compareTo(str);</code></pre><br/> - that is, call <code>equals()</code> or <code>compareTo()</code> on the string literal, passing the - variable as an argument, this exception could never happen as both <code>equals()</code> and + that is, call <code>equals()</code> or <code>compareTo()</code> on the string literal, passing the + variable as an argument, then this exception could never happen as both <code>equals()</code> and <code>compareTo()</code> check for <code>null</code>.</p> ]]> </Details> @@ -1978,7 +1993,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 overridden, a subclasses + <p>This constructor makes a call to a non-final method. Since this method can be overridden, a subclass' 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> ]]> @@ -1992,7 +2007,7 @@ <![CDATA[ <p>This class defines a field based on java.util.List, but uses it to some extent like a Set. Since lookup type operations are performed using a linear search for Lists, the performance for large - Lists will be poor. If the list is known to only contain a small number of items, (3, 4, etc) then it + Lists will be poor. If the list is known to only contain a small number of items (3, 4, etc), then it doesn't matter. Otherwise, consider changing this field's implementation to a set-based one. If order of iteration is important to maintain insert order, perhaps consider a LinkedHashSet.</p> ]]> @@ -2022,7 +2037,7 @@ //or, for just two elements Map<String,Integer> wordCounts = new HashMap<String,Integer>(); </code></pre> - + </p> ]]> </Details> @@ -2036,10 +2051,10 @@ <p>This method 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 as final.</p> - - <p>Performance gains are debatable as "the final keyword does not appear in the class file for - local variables and parameters, thus it cannot impact the runtime performance. Its only use - is to clarify the coders intent that the variable not be changed (which many consider dubious + + <p>Performance gains are debatable as "the final keyword does not appear in the class file for + local variables and parameters, thus it cannot impact the runtime performance. Its only use + is to clarify the coder's intent that the variable not be changed (which many consider dubious reason for its usage), and dealing with anonymous inner classes." - http://stackoverflow.com/a/266981/1447621 </p> ]]> </Details> @@ -2130,7 +2145,7 @@ <Details> <![CDATA[ <p>This method makes a static method call on an instance reference. For - reading comprehension of the code is better to call the method on the class, + reading comprehension of the code it is better to call the method on the class, rather than an instance. Perhaps this method's static nature has changed since this code was written, and should be revisited.</p> ]]> @@ -2142,9 +2157,9 @@ <LongDescription>Method {1} calls wait, notify or notifyAll on a Thread instance</LongDescription> <Details> <![CDATA[ - <p>This method invokes the methods wait, notify or notifyAll on a Thread instance. - Doing so will confuse the internal thread state behavior causing spurious thread - wakeups/sleeps because the internal mechanism also uses the thread instance for its + <p>This method invokes the methods <code>wait</code>, <code>notify</code> or <code>notifyAll</code> on a Thread instance. + Doing so will confuse the internal thread state behavior, causing spurious thread + wakeups/sleeps, because the internal mechanism also uses the thread instance for its notifications.</p> ]]> </Details> @@ -2168,7 +2183,7 @@ <Details> <![CDATA[ <p>This method passes a primitive value retrieved from a <code>BoxedPrimitive.parseBoxedPrimitive("1")</code> call to - the same class's constructor. It is simpler to just pass the string to the BoxedPrimitives constructor or, better yet, use the static valueOf.</p> + the same class's constructor. It is simpler to just pass the string to the BoxedPrimitive constructor or, better yet, use the static valueOf.</p> <p>Instead of something like:<br/> <pre><code> Boolean bo = new Boolean(Boolean.parseBoolean("true")); @@ -2194,7 +2209,7 @@ <LongDescription>Method {1} passes primitive wrapper to Wrapper class valueOf method</LongDescription> <Details> <![CDATA[ - <p>This method passes a wrapped primitive object to the same class's .valueOf method. + <p>This method passes a wrapped primitive object to the same class' <code>valueOf</code> method. Since wrapper classes are immutable, you can just use the original object, rather than calling valueOf to create a new one. This code works because of an abuse of autoboxing.</p> ]]> @@ -2210,7 +2225,7 @@ the boxedValue() method to convert to a primitive. When it is desired to convert from a String to a primitive value, it is simpler to use the BoxedPrimitive.parseBoxedPrimitive(String) method. </p> - + <p>Instead of something like:<br/> <pre><code> public int someMethod(String data) { @@ -2228,7 +2243,7 @@ } </code></pre> </p> - + ]]> </Details> </BugPattern> @@ -2239,9 +2254,9 @@ <Details> <![CDATA[ <p>This method passes a String to a wrapped primitive object's parse method, which in turn calls - the valueOf() method to convert to a boxed primitive. When it is desired to convert from a String + the <code>valueOf</code> method to convert to a boxed primitive. When it is desired to convert from a String to a boxed primitive object, it is simpler to use the BoxedPrimitive.valueOf(String) method.</p> - + <p>Instead of something like:<br/> <pre><code> Boolean bo = Boolean.valueOf(Boolean.parseBoolean("true")); @@ -2275,7 +2290,7 @@ float f = 1.234f; </code></pre> </p> - + ]]> </Details> </BugPattern> @@ -2325,7 +2340,7 @@ Boolean b = Boolean.FALSE; </code></pre> </p> - + <p>Be aware that this boxing happens automatically when you might not expect it. For example, <br/> <pre><code> Map<String, Boolean> statusMap = ... @@ -2335,9 +2350,9 @@ return false; //the "false" here is boxed } </code></pre> - has two cases of this needless autoboxing. This can be made more efficient by simply substituting + has two cases of this needless autoboxing. This can be made more efficient by simply substituting in the constant values: <br/> - + <pre><code> Map<String, Boolean> statusMap = ... @@ -2390,8 +2405,8 @@ </BugPattern> <BugPattern type="COM_COPIED_OVERRIDDEN_METHOD"> - <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> + <ShortDescription>Method is implemented with an exact copy of its superclass' method</ShortDescription> + <LongDescription>Method {1} is implemented with an exact copy of its superclass' method</LongDescription> <Details> <![CDATA[ <p>This method is implemented using an exact copy of its superclass method's @@ -2399,7 +2414,7 @@ ]]> </Details> </BugPattern> - + <BugPattern type="COM_PARENT_DELEGATED_CALL"> <ShortDescription>Method merely delegates to its superclass's version</ShortDescription> <LongDescription>Method {1} merely delegates to its superclass's version</LongDescription> @@ -2417,7 +2432,7 @@ <Details> <![CDATA[ <p>This method passes an array as the key to a Map, element in a Set, or item in a List when - the contains method is used on the List. Since arrays do not and cannot override the equals + the contains method is used on the List. Since arrays do not and cannot override the <code>equals</code> method, collection inclusion is based on the reference's address, which is probably not desired. In the case that this is a TreeMap or TreeSet, consider passing a Comparator to the map's constructor.</p> @@ -2453,7 +2468,7 @@ <![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 build XML structures in external files that are + and validate. It is much cleaner to build XML structures in external files that are read in and transformed into the final product, through modification by Transformer.setParameter.</p> ]]> </Details> @@ -2465,10 +2480,10 @@ <Details> <![CDATA[ <p>This method implements a synchronized block, but the code found at the beginning - of this block only accesses local variables, and not member variables, or this. - For better performance, move the code that accesses local variables only, above the + of this block only accesses local variables, and not member variables or <code>this</code>. + For better performance, move the code that accesses local variables only above the synchronized block, and leave the synchronized block only for field accesses, or access - to this object.</p> + to <code>this</code>.</p> ]]> </Details> </BugPattern> @@ -2587,8 +2602,8 @@ <LongDescription>Method {1} calls wait when await was probably intended</LongDescription> <Details> <![CDATA[ - <p>This method calls wait() on a on mutex defined in the java.util.concurrent package. - These classes, define await, instead of wait, and it is most likely that await + <p>This method calls wait() on a mutex defined in the java.util.concurrent package. + These classes define <code>await</code>, instead of <code>wait</code>, and it is most likely that <code>await</code> was intended.</p> ]]> </Details> @@ -2599,7 +2614,7 @@ <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 methods to perform database work. This makes the code specific to this vendor, and unable to run on other databases.</p> ]]> </Details> @@ -2616,9 +2631,9 @@ {<code>add()</code>, <code>append()</code>, <code>offer()</code>, <code>put()</code>, ...} <br/> with no method calls to removal meth... [truncated message content] |