fb-contrib-commit Mailing List for fb-contrib (Page 3)
Brought to you by:
dbrosius
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(56) |
Oct
(60) |
Nov
(58) |
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(66) |
Feb
(55) |
Mar
(85) |
Apr
(115) |
May
(35) |
Jun
(28) |
Jul
(3) |
Aug
(48) |
Sep
(37) |
Oct
(22) |
Nov
(14) |
Dec
(66) |
2007 |
Jan
(45) |
Feb
(63) |
Mar
(10) |
Apr
(1) |
May
(1) |
Jun
(12) |
Jul
|
Aug
|
Sep
(25) |
Oct
(21) |
Nov
(39) |
Dec
|
2008 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(5) |
May
(2) |
Jun
(32) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2009 |
Jan
(10) |
Feb
(31) |
Mar
(32) |
Apr
(35) |
May
(25) |
Jun
|
Jul
(31) |
Aug
(10) |
Sep
(95) |
Oct
(35) |
Nov
(10) |
Dec
(34) |
2010 |
Jan
(90) |
Feb
(4) |
Mar
(7) |
Apr
(20) |
May
(20) |
Jun
(13) |
Jul
(7) |
Aug
(18) |
Sep
(25) |
Oct
(4) |
Nov
(16) |
Dec
(2) |
2011 |
Jan
(1) |
Feb
|
Mar
(11) |
Apr
(3) |
May
(2) |
Jun
(26) |
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(14) |
Nov
(3) |
Dec
(4) |
2013 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(4) |
May
|
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(3) |
2014 |
Jan
(4) |
Feb
(2) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(2) |
Nov
(7) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(3) |
2018 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(5) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dbr...@us...> - 2016-01-25 22:44:20
|
Revision: 1790 http://sourceforge.net/p/fb-contrib/code/1790 Author: dbrosius Date: 2016-01-25 22:44:19 +0000 (Mon, 25 Jan 2016) Log Message: ----------- Version 6.6.0 Added Paths: ----------- tags/v6_6_0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2016-01-25 22:40:05
|
Revision: 1789 http://sourceforge.net/p/fb-contrib/code/1789 Author: dbrosius Date: 2016-01-25 22:39:59 +0000 (Mon, 25 Jan 2016) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/.classpath 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/htdocs/repository.html trunk/fb-contrib/license.txt trunk/fb-contrib/plugin.xml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/BED_Sample.java trunk/fb-contrib/samples/IMC_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/UCPM_Sample.java trunk/fb-contrib/samples/UTAO_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/StatisticsKey.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.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/CharsetIssues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.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/CollectionNamingConfusion.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/ConflatingResourcesAndFiles.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.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/ContainsBasedConditional.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.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/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/HangingExecutors.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.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/JAXRSIssues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JPAIssues.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/LocalTypeDetector.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/MissingMethodsDetector.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.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/OverlyPermissiveMethod.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/PoorMansEnum.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/RuntimeExceptionDeclared.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/StackedTryBlocks.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/StringifiedTypes.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuboptimalExpressionOrder.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/SuspiciousLoopSearch.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/UnitTestAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Unjitable.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/UnusedParameter.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/AttributesUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CollectionUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/FQMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/OpcodeUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/PublicAPI.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/QMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/TernaryPatcher.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/ToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/UnmodifiableSet.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/samples/IOI_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IOIssues.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/.classpath 2016-01-25 22:39:59 UTC (rev 1789) @@ -16,7 +16,7 @@ <classpathentry kind="lib" path="lib/httpcore-4.3.2.jar"/> <classpathentry kind="lib" path="lib/httpclient-4.3.4.jar"/> <classpathentry kind="lib" path="lib/annotations-3.0.0.jar"/> - <classpathentry kind="lib" path="lib/asm-debug-all-5.0.2.jar"/> + <classpathentry kind="lib" path="lib/asm-debug-all-5.0.2.jar" sourcepath="/home/dave/.m2/repository/org/ow2/asm/asm-debug-all/5.0.2/asm-debug-all-5.0.2-sources.jar"/> <classpathentry kind="lib" path="lib/bcel-findbugs-6.0.jar" sourcepath="lib/sources/bcel-findbugs-6.0-sources.jar"> <attributes> <attribute name="javadoc_location" value="http://commons.apache.org/proper/commons-bcel/apidocs/"/> @@ -29,5 +29,7 @@ <classpathentry kind="lib" path="lib/jsr311-api-1.1.1.jar" sourcepath="lib/sources/jsr311-api-1.1.1-sources.jar"/> <classpathentry kind="lib" path="lib/spring-tx-4.2.3.RELEASE.jar"/> <classpathentry kind="lib" path="lib/javax.persistence-2.1.1.jar"/> + <classpathentry kind="lib" path="lib/commons-io-1.3.2.jar" sourcepath="lib/sources/commons-io-1.3.2-sources.jar"/> + <classpathentry kind="lib" path="lib/mockito-all-2.0.2-beta.jar"/> <classpathentry kind="output" path="target/classes/main"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/build.xml 2016-01-25 22:39:59 UTC (rev 1789) @@ -28,7 +28,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="6.4.2" /> + <property name="fb-contrib.version" value="6.6.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -42,6 +42,7 @@ <get src="http://repo1.maven.org/maven2/com/mebigfatguy/yank/yank/1.4.0/yank-1.4.0.jar" dest="${user.home}/.ant/lib"/> <get src="https://bitbucket.org/kjlubick/bugrankcheckstyle/downloads/bug-rank-check-style-1.0.0.jar" dest="${user.home}/.ant/lib"/> <get src="http://repo1.maven.org/maven2/com/mebigfatguy/vcsversion/vcsversion/0.4.0/vcsversion-0.4.0.jar" dest="${user.home}/.ant/lib"/> + <get src="http://repo1.maven.org/maven2/com/mebigfatguy/fb-delta/fb-delta/0.2.0/fb-delta-0.2.0.jar" dest="${user.home}/.ant/lib" ignoreerrors="true"/> </target> <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank" unless="no.yank"> @@ -55,7 +56,8 @@ <target name="info"> <echo message="fb-contrib - a findbugs plugin"/> <echo message=""/> - <echo message=" This project requires three jars to build fb-contrib: yank, bug-rank-check-style and vcsversion" /> + <echo message=" This project requires three jars to build fb-contrib: yank, bug-rank-check-style, vcsversion and" /> + <echo message=" and optionally fb-delta, to generate delta's of bug reports"/> <echo message=""/> <echo message=" This project uses yank (https://github.com/mebigfatguy/yank) for dependency management"/> <echo message=" download yank.jar and place in ~/.ant/lib directory"/> @@ -70,6 +72,12 @@ <echo message=" and can be downloaded and placed in ~/.ant/lib as well"/> <echo message=" http://search.maven.org/#search%7Cga%7C1%7Cvcsversion"/> <echo message="===="/> + <echo message=" If you want to generate delta reports between two sample.xml runs, this project also uses fb-delta to do"/> + <echo message=" delta-ing between two samples.xml files, to report what has been 'fixed' and what is 'new'"/> + <echo message=" and can be downloaded and placed in ~/.ant/lib as well"/> + <echo message=" http://search.maven.org/#search%7Cga%7C1%7Cfb-delta"/> + <echo message="===="/> + <echo message=" This task can be automated by running ant infra_jars"/> </target> @@ -93,9 +101,10 @@ <pathelement location="${lib.dir}/javax.servlet-api-${javax.servlet-api.version}.jar" /> <pathelement location="${lib.dir}/log4j-${log4j.version}.jar" /> <pathelement location="${lib.dir}/commons-lang3-${commons-lang3.version}.jar" /> - <pathelement location="${lib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> - <pathelement location="${lib.dir}/slf4j-api-${slf4j-api.version}.jar" /> - <pathelement location="${lib.dir}/guava-${guava.version}.jar" /> + <pathelement location="${lib.dir}/commons-io-${commons-io.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" /> <pathelement location="${lib.dir}/httpclient-cache-${httpclient-cache.version}.jar" /> <pathelement location="${lib.dir}/httpcore-${httpcore.version}.jar" /> <pathelement location="${lib.dir}/httpclient-${httpclient.version}.jar" /> @@ -103,6 +112,7 @@ <pathelement location="${lib.dir}/jsr311-api-${jsr311-api.version}.jar" /> <pathelement location="${lib.dir}/spring-tx-${spring-tx.version}.jar" /> <pathelement location="${lib.dir}/javax.persistence-${javax.persistence.version}.jar" /> + <pathelement location="${lib.dir}/mockito-all-${mockito-all.version}.jar" /> </path> </target> @@ -111,7 +121,7 @@ <xmlvalidate lenient="false" failonerror="yes"> <attribute name="http://apache.org/xml/features/validation/schema" value="true" /> <attribute name="http://xml.org/sax/features/namespaces" value="true" /> - <fileset dir="${etc.dir}" includes="*.xml" /> + <fileset dir="${etc.dir}" includes="*.xml" excludes="findbugs-exclude.xml"/> </xmlvalidate> <bug-rank-check-style findbugsxml="etc/findbugs.xml" failOnMissingDetector="false" /> </target> @@ -195,7 +205,7 @@ <target name="javadoc" depends="-init" description="build the javadoc for the project"> <javadoc packagenames="com.mebigfatguy.*" sourcepath="${src.dir}" classpathref="fb-contrib.classpath" destdir="${javadoc.dir}" windowtitle="fb-contrib api"> <doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle> - <bottom><![CDATA[<i>Copyright © 2005-2015 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> + <bottom><![CDATA[<i>Copyright © 2005-2016 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> </javadoc> </target> @@ -210,6 +220,21 @@ </fileset> </copy> </target> + + <target name="sample_delta" depends="build" xmlns:fbdelta="antlib:com.mebigfatguy.fbdelta" description="compares this runs reported bugs on the sample classes set, against the stored report"> + <taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties" classpath="${lib.dir}/findbugs-ant-${findbugs-ant.version}.jar"/> + <findbugs reportlevel="low" home="${findbugs.dir}" auxClassPathRef="fb-contrib.samples.classpath" output="xml:withMessages" jvmargs="-ea -Xmx800m" projectName="Samples" outputFile="${target.dir}/samples.xml"> + <class location="${samples.classes.dir}" /> + </findbugs> + + <fbdelta:fbdelta baseReport="${basedir}/samples.xml" updateReport="${target.dir}/samples.xml" outputReport="${target.dir}/samples_delta.xml" changed="delta"/> + <antcall target="report"/> + </target> + + <target name="report" if="${delta}"> + <loadfile property="diff" srcFile="${target.dir}/samples_delta.xml"/> + <echo>${diff}</echo> + </target> <target name="release" depends="build, srczip, html, javadoc" description="prepares everything for a release" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/etc/bugrank.txt 2016-01-25 22:39:59 UTC (rev 1789) @@ -60,10 +60,13 @@ +0 BugPattern IICU_INCORRECT_INTERNAL_CLASS_USE +0 BugPattern IKNC_INCONSISTENT_HTTP_ATTRIBUTE_CASING +0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING ++1 BugPattern IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES +2 BugPattern IMC_IMMATURE_CLASS_NO_EQUALS +2 BugPattern IMC_IMMATURE_CLASS_NO_HASHCODE +0 BugPattern IMC_IMMATURE_CLASS_NO_PACKAGE +2 BugPattern IMC_IMMATURE_CLASS_NO_TOSTRING ++0 BugPattern IOI_COPY_WITH_READER ++0 BugPattern IOI_DOUBLE_BUFFER_COPY +0 BugPattern IPU_IMPROPER_PROPERTIES_USE +0 BugPattern IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY +0 BugPattern ISB_EMPTY_STRING_APPENDING Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/etc/findbugs.xml 2016-01-25 22:39:59 UTC (rev 1789) @@ -28,8 +28,6 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> COMMENT OUT FOR RELEASE --> @@ -209,7 +207,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousNullGuard" speed="fast" reports="SNG_SUSPICIOUS_NULL_FIELD_GUARD,SNG_SUSPICIOUS_NULL_LOCAL_GUARD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.MoreDumbMethods" speed="fast" - reports="MDM_RUNTIME_EXIT_OR_HALT,MDM_RUNFINALIZATION,MDM_BIGDECIMAL_EQUALS,MDM_INETADDRESS_GETLOCALHOST,MDM_PROMISCUOUS_SERVERSOCKET,MDM_RANDOM_SEED,MDM_SECURERANDOM_CTOR,MDM_SECURERANDOM_GETSEED,MDM_THREAD_PRIORITIES,MDM_THREAD_YIELD,MDM_WAIT_WITHOUT_TIMEOUT,MDM_THREAD_FAIRNESS,MDM_REENTRANTLOCK_HELDBY,MDM_STRING_BYTES_ENCODING,MDM_SETDEFAULTLOCALE" /> + reports="MDM_RUNTIME_EXIT_OR_HALT,MDM_RUNFINALIZATION,MDM_BIGDECIMAL_EQUALS,MDM_INETADDRESS_GETLOCALHOST,MDM_PROMISCUOUS_SERVERSOCKET,MDM_RANDOM_SEED,MDM_SECURERANDOM_CTOR,MDM_SECURERANDOM_GETSEED,MDM_THREAD_PRIORITIES,MDM_THREAD_YIELD,MDM_WAIT_WITHOUT_TIMEOUT,MDM_THREAD_FAIRNESS,MDM_REENTRANTLOCK_HELDBY,MDM_STRING_BYTES_ENCODING,MDM_SETDEFAULTLOCALE,MDM_LOCK_ISLOCKED,MDM_SIGNAL_NOT_SIGNALALL" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionOnObjectMethods" speed="fast" reports="ROOM_REFLECTION_ON_OBJECT_METHODS" /> @@ -247,7 +245,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument" speed="fast" reports="ICA_INVALID_CONSTANT_ARRAY" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument" speed="fast" reports="ICA_INVALID_CONSTANT_ARGUMENT" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> @@ -287,18 +285,21 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.StringifiedTypes" speed="fast" reports="STT_STRING_PARSING_A_FIELD,STT_TOSTRING_STORED_IN_FIELD" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass" speed="moderate" reports="IMC_IMMATURE_CLASS_NO_EQUALS,IMC_IMMATURE_CLASS_NO_HASHCODE,IMC_IMMATURE_CLASS_NO_PACKAGE,IMC_IMMATURE_CLASS_NO_TOSTRING" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass" speed="moderate" reports="IMC_IMMATURE_CLASS_NO_EQUALS,IMC_IMMATURE_CLASS_NO_HASHCODE,IMC_IMMATURE_CLASS_NO_PACKAGE,IMC_IMMATURE_CLASS_NO_TOSTRING,IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES" /> <Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues" speed="fast" reports="JXI_GET_ENDPOINT_CONSUMES_CONTENT,JXI_INVALID_CONTEXT_PARAMETER_TYPE,JXI_PARM_PARAM_NOT_FOUND_IN_PATH,JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT" /> - - <!-- COMMENT OUT FOR POINT RELEASE + <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.JPAIssues" speed="fast" reports="JPAI_TRANSACTION_ON_NON_PUBLIC_METHOD,JPAI_HC_EQUALS_ON_MANAGED_ENTITY,JPAI_NON_PROXIED_TRANSACTION_CALL,JPAI_INEFFICIENT_EAGER_FETCH,JPAI_IGNORED_MERGE_RESULT,JPAI_NON_SPECIFIED_TRANSACTION_EXCEPTION_HANDLING,JPAI_UNNECESSARY_TRANSACTION_EXCEPTION_HANDLING"/> <Detector class="com.mebigfatguy.fbcontrib.detect.SuboptimalExpressionOrder" speed="fast" reports="SEO_SUBOPTIMAL_EXPRESSION_ORDER"/> - COMMENT OUT FOR POINT RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.IOIssues" speed="fast" reports="IOI_DOUBLE_BUFFER_COPY,IOI_COPY_WITH_READER"/> + <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -539,6 +540,7 @@ <BugPattern abbrev="STT" type="STT_TOSTRING_STORED_IN_FIELD" category="STYLE" /> <BugPattern abbrev="SLS" type="SLS_SUSPICIOUS_LOOP_SEARCH" category="CORRECTNESS" /> <BugPattern abbrev="CRF" type="CRF_CONFLATING_RESOURCES_AND_FILES" category="CORRECTNESS" /> + <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES" category="STYLE" /> <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_NO_EQUALS" category="STYLE" /> <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_NO_HASHCODE" category="STYLE" /> <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_NO_PACKAGE" category="STYLE" /> @@ -555,5 +557,7 @@ <BugPattern abbrev="JPAI" type="JPAI_NON_SPECIFIED_TRANSACTION_EXCEPTION_HANDLING" category="CORRECTNESS" experimental="true"/> <BugPattern abbrev="JPAI" type="JPAI_UNNECESSARY_TRANSACTION_EXCEPTION_HANDLING" category="CORRECTNESS" experimental="true"/> <BugPattern abbrev="SEO" type="SEO_SUBOPTIMAL_EXPRESSION_ORDER" category="PERFORMANCE" experimental="true"/> + <BugPattern abbrev="IOI" type="IOI_DOUBLE_BUFFER_COPY" category="PERFORMANCE" experimental="true"/> + <BugPattern abbrev="IOI" type="IOI_COPY_WITH_READER" category="PERFORMANCE" experimental="true"/> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/etc/messages.xml 2016-01-25 22:39:59 UTC (rev 1789) @@ -1573,6 +1573,15 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.IOIssues"> + <Details> + <![CDATA[ + <p>Looks for various issues around doing I/O with streams and reader/writers.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> @@ -5082,6 +5091,19 @@ </Details> </BugPattern> + <BugPattern type="IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES"> + <ShortDescription>Method uses IDE generated parameter names</ShortDescription> + <LongDescription>Method {1} uses IDE generated parameter names</LongDescription> + <Details> + <![CDATA[ + <p>This method appears to have been generated from an interface or super class using an IDE. + As such the IDE generated generic names (arg0, arg1, arg2) for parameters for this method, + and the author of this method did not change them to be meaningful. For better understandability + it is recommended that you name these parameters with regard to their function. + ]]> + </Details> + </BugPattern> + <BugPattern type="JXI_GET_ENDPOINT_CONSUMES_CONTENT"> <ShortDescription>JAX-RS Method implements a GET request but consumes input</ShortDescription> <LongDescription>JAX-RS Method {1} implements a GET request but consumes input</LongDescription> @@ -5236,7 +5258,7 @@ <LongDescription>Method {1} orders expressions in a conditional in a sub optimal way</LongDescription> <Details> <![CDATA[ - <p>This method builds a conditional for an if or while statement where the expressions contain both simple + <p>This method builds a conditional expression, for example, in an if or while statement where the expressions contain both simple local variable comparisons, as well as comparisons on method calls. The expression orders these so that the method calls come before the simple local variable call comparisons. This causes method calls to be executed in conditions when they do not need to be, and thus potentially causes a lot of code to be executed for nothing. By ordering the expressions so that @@ -5247,6 +5269,33 @@ ]]> </Details> </BugPattern> + + <BugPattern type="IOI_DOUBLE_BUFFER_COPY"> + <ShortDescription>Method passes a Buffered Stream/Reader/Writer to a already buffering copy method</ShortDescription> + <LongDescription>Method {1} passes a Buffered Stream/Reader/Writer to a already buffering copy method</LongDescription> + <Details> + <![CDATA[ + <p>This method copies data from input to output using streams or reader/writers using a well known copy method, from java.nio, commons-io, + springframework, guava or poi. These methods are efficient in that they copy these files using buffers. However this method is also + buffering the streams, causing a double buffering to occur. So data first goes to one buffer, then is copied too another buffer, before + making it to the destination (or vice-versa). This just causes the copy operation to be inefficent both from a time perspective, as well + as a memory allocation one. When using these copy methods, do not pass buffered streams/readers/writers. + ]]> + </Details> + </BugPattern> + + <BugPattern type="IOI_COPY_WITH_READER"> + <ShortDescription>Method performs bulk stream copy with a java.io.Reader derived input</ShortDescription> + <LongDescription>Method {1} performs bulk stream copy with a java.io.Reader derived input</LongDescription> + <Details> + <![CDATA[ + <p>This method copies data from a java.io.Reader derived class to an output class, using a bulk copy method + supplied by java.nio, commons-io, springframework, guava or poi. Since you are copying the entire stream, you + don't care about it's contents, and thus using a Reader is wasteful as a reader has to do the hard work of + converting byte data to characters, when there is no need to do this. Use stream based inputs for better performance.</p> + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -5380,4 +5429,5 @@ <BugCode abbrev="JXI">JAX-RS Issues</BugCode> <BugCode abbrev="JPAI">JPA Issues</BugCode> <BugCode abbrev="SEO">Suboptimal Expression Order</BugCode> + <BugCode abbrev="IOI">IO Issues</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/htdocs/index.shtml 2016-01-25 22:39:59 UTC (rev 1789) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 6.4.2 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 6.6.0 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on @@ -81,6 +81,13 @@ Detectors added in git<br/> <div id="git" style="display:none;"> <ul> + </ul> + </div> + <hr/> + <img id="git_image" src="flip2.gif" onClick="toggleBlock('v6_6_0', 'v6_6_0_image');" align="top"/> + Detectors added in v6.6.0<br/> + <div id="v6_6_0" style="display:block;"> + <ul> <li><b>[STB] Stacked Try Blocks</b><br/> Looks for two or more try catch blocks that are consecutive and catch the same kind of exception, and throw the same exception always. These blocks can @@ -97,12 +104,15 @@ called won't have side-effects that are desired. At present it only looks for simple sequences of 'and' based conditions. </li> + <li><b>[IOI] IO Issues</b><br/> + looks for various issues around input/output/streaming Library use. + </li> </ul> </div> <hr/> - <img id="v6_4_0_image" src="flip2.gif" onClick="toggleBlock('v6_4_0', 'v6_4_0_image');" align="top"/> + <img id="v6_4_0_image" src="flip1.gif" onClick="toggleBlock('v6_4_0', 'v6_4_0_image');" align="top"/> Detectors added in v6.4.0<br/> - <div id="v6_4_0" style="display:block;"> + <div id="v6_4_0" style="display:none;"> <ul> <li><b>[OPM] Overly Permissive Method</b><br/> Looks for methods that are declared more permissively than the code is using. For instance, declaring Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/htdocs/repository.html 2016-01-25 22:39:59 UTC (rev 1789) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>6.4.2</td></tr> + <tr><td><b>Version:</b></td><td>6.6.0</td></tr> </table> </div> Modified: trunk/fb-contrib/license.txt =================================================================== --- trunk/fb-contrib/license.txt 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/license.txt 2016-01-25 22:39:59 UTC (rev 1789) @@ -1,8 +1,8 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -10,7 +10,7 @@ as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -112,7 +112,7 @@ former contains code derived from the library, whereas the latter must be combined with the library in order to run. - GNU LESSER GENERAL PUBLIC LICENSE + GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other @@ -146,7 +146,7 @@ on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - + 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an @@ -432,7 +432,7 @@ of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. @@ -455,7 +455,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries @@ -485,7 +485,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. @@ -500,5 +500,3 @@ Ty Coon, President of Vice That's all there is to it! - - Modified: trunk/fb-contrib/plugin.xml =================================================================== --- trunk/fb-contrib/plugin.xml 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/plugin.xml 2016-01-25 22:39:59 UTC (rev 1789) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> -<plugin> +<plugin id="eclipse_fb_plugin" name="eclipse_fb_plugin" version="1.0"> <extension point="edu.umd.cs.findbugs.plugin.eclipse.findbugsPlugins"> <findbugsPlugin fbPluginId="com.mebigfatguy.fbcontrib" libraryPath="."></findbugsPlugin> </extension> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/pom.xml 2016-01-25 22:39:59 UTC (rev 1789) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>6.4.2</version> + <version>6.6.0</version> <prerequisites> <maven>2.2.1</maven> @@ -219,6 +219,7 @@ <dependency><groupId>com.google.code.findbugs</groupId><artifactId>findbugs</artifactId><version>3.0.1</version></dependency> </dependencies> <configuration> + <excludeFilterFile>etc/findbugs-exclude.xml</excludeFilterFile> <effort>Max</effort> </configuration> <executions> Modified: trunk/fb-contrib/samples/BED_Sample.java =================================================================== --- trunk/fb-contrib/samples/BED_Sample.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/samples/BED_Sample.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -66,6 +66,13 @@ } } + static void fpJustThrowIt(boolean permissible, String message) throws IOException { + IOException e = new FileNotFoundException(message); + if (!permissible) { + throw e; + } + } + public Object iAmCreatingAnObject() { return new Object() { private byte[] iHaveToThrowAnException() throws IOException { @@ -78,4 +85,24 @@ File.createTempFile("foo", "bar"); return "Test".getBytes("UTF-8"); } + + private void issue92a() throws InterruptedException { + System.out.println("test"); + } + + public static void issue92b() throws InterruptedException { + System.out.println("test"); + } + + public static Process fpInterrupted(String command) throws IOException, InterruptedException { + + Object sync = new Object(); + Process p = Runtime.getRuntime().exec(command); + synchronized (sync) { + sync.wait(); + } + + return p; + } + } Modified: trunk/fb-contrib/samples/IMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/IMC_Sample.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/samples/IMC_Sample.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -3,15 +3,20 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.junit.Assert; +import org.junit.Test; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Opcodes; + public class IMC_Sample { private String reportMe; - + @SuperSecret class FPClassIMC { private String dontReportMe; } - + class FPFieldIMC { @SuperSecret private String dontReportMe; @@ -21,15 +26,40 @@ class IMCFPHasAToString { @SuperSecret private String fooo; - + @Override public String toString() { return fooo; } } - @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.FIELD}) +@Target({ ElementType.TYPE, ElementType.FIELD }) @interface SuperSecret { } + +class FPIMCTestClass { + + private int data1, data2; + + @Test + public void doTest() { + Assert.assertEquals(data1, data2); + } +} + +class MyVisitor extends AnnotationVisitor { + + String name; + + public MyVisitor() { + super(Opcodes.ASM4); + } + + @Override + public AnnotationVisitor visitAnnotation(String arg0, String arg1) { + name = arg0; + + return super.visitAnnotation(arg0, arg1); + } +} Added: trunk/fb-contrib/samples/IOI_Sample.java =================================================================== --- trunk/fb-contrib/samples/IOI_Sample.java (rev 0) +++ trunk/fb-contrib/samples/IOI_Sample.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -0,0 +1,30 @@ +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; + +public class IOI_Sample { + + public byte[] getIOIData(File f) throws IOException { + try (InputStream is = new BufferedInputStream(new FileInputStream(f)); ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + + IOUtils.copy(is, baos); + + return baos.toByteArray(); + } + } + + public byte[] getIOIReaderData(File f) throws IOException { + try (FileReader r = new FileReader(f); ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + + IOUtils.copy(r, baos); + + return baos.toByteArray(); + } + } +} Property changes on: trunk/fb-contrib/samples/IOI_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/PRMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/PRMC_Sample.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/samples/PRMC_Sample.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -127,6 +127,20 @@ System.out.println(Arrays.asList("foo")); System.out.println(Arrays.asList("bar")); } + + public void fpWithFinally() { + Object foo = new Object(); + try { + willThrow(); + System.err.println(foo.toString()); + } finally { + System.out.println(foo.toString()); + } + } + + void willThrow() { + throw new RuntimeException("kaboom!"); + } public void setValue(int i) { } Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/samples/SPP_Sample.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -387,6 +387,14 @@ } return Math.random() > 0.5; } + + public boolean fpNullAndInstanceOfUnrelated(Throwable t, Object tag) { + if ((tag != null) && (t instanceof RuntimeException)) { + return true; + } + + return false; + } public void testToString() { SPP_Sample s = new SPP_Sample(); Modified: trunk/fb-contrib/samples/UCPM_Sample.java =================================================================== --- trunk/fb-contrib/samples/UCPM_Sample.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/samples/UCPM_Sample.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -57,4 +57,13 @@ // no tag, starts with doesn't have a char equivalent return s.startsWith("*") ? s.substring(1) : s; } + + public String fpGitHubIssue95(int value) { + return "(" + value + ")"; + } + + public String okIssue95(int value) { + StringBuilder sb = new StringBuilder(); + return sb.append("(").append(value).append(")").toString(); + } } Modified: trunk/fb-contrib/samples/UTAO_Sample.java =================================================================== --- trunk/fb-contrib/samples/UTAO_Sample.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/samples/UTAO_Sample.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -1,5 +1,7 @@ import org.junit.Assert; import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import junit.framework.TestCase; @@ -9,8 +11,8 @@ public void testExactDoubles(double d1, double d2) { Assert.assertEquals(d1, d2); Assert.assertEquals("Still bad", d1, d2); - Assert.assertEquals(0.1, d1, d2); // Actually good - Assert.assertEquals("This one is ok", 0.1, d1, d2); // Still good + Assert.assertEquals(0.1, d1, d2); // Actually good + Assert.assertEquals("This one is ok", 0.1, d1, d2); // Still good } public void testTrue(boolean b) { @@ -20,11 +22,11 @@ public void testFalse(boolean b) { Assert.assertEquals("Wow this is bad", false, b); } - + public void testNull(String s) { Assert.assertEquals(null, s); } - + public void testNotNull(String s) { Assert.assertNotEquals(null, s); } @@ -46,23 +48,23 @@ Assert.assertTrue(s.equals(s2)); Assert.assertTrue(s.length() == s.length()); } - + public void testUseAssertNotEquals(String s, String s2) { Assert.assertFalse(s.equals(s2)); Assert.assertFalse(s.length() == s.length()); Assert.assertFalse("this is bad", s.equals(s2)); Assert.assertFalse("this is reallly bad", s.length() == s.length()); } - + public void testUseAssertNotEqualsCrossed(String s, String s2) { - Assert.assertTrue(!s.equals(s2)); + Assert.assertTrue(!s.equals(s2)); Assert.assertTrue(s.length() != s.length()); Assert.assertTrue("this is bad", !s.equals(s2)); Assert.assertTrue("this is reallly bad", s.length() != s.length()); } - + public void testUseAssertEqualsCrossed(String s, String s2) { - Assert.assertFalse(!s.equals(s2)); + Assert.assertFalse(!s.equals(s2)); Assert.assertFalse(s.length() != s.length()); Assert.assertFalse("this is bad", !s.equals(s2)); Assert.assertFalse("this is reallly bad", s.length() != s.length()); @@ -87,16 +89,16 @@ private void check(String a, String b) { Assert.assertEquals(a, b); } - - @Test(expected=RuntimeException.class) + + @Test(expected = RuntimeException.class) public void fpNoAssertsWithJUnitExpects() { throw new RuntimeException(); } - + @Test @SuppressWarnings("deprecation") public void usingOldClasses(int x) { - junit.framework.Assert.assertEquals(0, x); + junit.framework.Assert.assertEquals(0, x); } } @@ -114,20 +116,20 @@ public void testFalse(boolean b) { org.testng.Assert.assertEquals(b, false, "Wow this is bad"); } - + @org.testng.annotations.Test public void testExactDoubles(double d1, double d2) { - org.testng.Assert.assertEquals(d1, d2, "Don't ever do this!"); + org.testng.Assert.assertEquals(d1, d2, "Don't ever do this!"); } - + @org.testng.annotations.Test public void testNull(String s) { - org.testng.Assert.assertEquals(s, null); + org.testng.Assert.assertEquals(s, null); } - + @org.testng.annotations.Test public void testNotNull(String s) { - org.testng.Assert.assertNotEquals(s, null); + org.testng.Assert.assertNotEquals(s, null); } @org.testng.annotations.Test @@ -151,33 +153,53 @@ org.testng.Assert.assertTrue(s.equals(s2)); org.testng.Assert.assertTrue(s.length() == s.length()); } - + @org.testng.annotations.Test public void testUseAssertNotEquals(String s, String s2) { - org.testng.Assert.assertFalse(s.equals(s2)); - org.testng.Assert.assertFalse(s.length() == s.length()); + org.testng.Assert.assertFalse(s.equals(s2)); + org.testng.Assert.assertFalse(s.length() == s.length()); } - + @org.testng.annotations.Test public void testUseAssertNotEqualsCrossed(String s, String s2) { - org.testng.Assert.assertTrue(!s.equals(s2)); - org.testng.Assert.assertTrue(s.length() != s.length()); + org.testng.Assert.assertTrue(!s.equals(s2)); + org.testng.Assert.assertTrue(s.length() != s.length()); } - + @org.testng.annotations.Test public void testUseAssertEqualsCrossed(String s, String s2) { - org.testng.Assert.assertFalse(!s.equals(s2)); - org.testng.Assert.assertFalse(s.length() != s.length()); + org.testng.Assert.assertFalse(!s.equals(s2)); + org.testng.Assert.assertFalse(s.length() != s.length()); } @org.testng.annotations.Test public void test3ArgNP(float foo, int boo) { - org.testng.Assert.assertEquals(foo, 1.0f, 0.1); - org.testng.Assert.assertEquals(boo, 20, 0); + org.testng.Assert.assertEquals(foo, 1.0f, 0.1); + org.testng.Assert.assertEquals(boo, 20, 0); } - - @org.testng.annotations.Test(expectedExceptions=RuntimeException.class) + + @org.testng.annotations.Test(expectedExceptions = RuntimeException.class) public void fpNoAssertsWithNGExpects() { throw new RuntimeException(); } } + +class GitHubIssue94 { + private Object realObject; + + @Mock + private Object mockObject; + + @org.testng.annotations.BeforeMethod + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + realObject = new Object(); + } + + @org.testng.annotations.Test + public void fpShouldNotEqualMockObject() { + org.testng.Assert.assertNotEquals(realObject, mockObject); + } + +} Modified: trunk/fb-contrib/samples/samples.fbp =================================================================== --- trunk/fb-contrib/samples/samples.fbp 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/samples/samples.fbp 2016-01-25 22:39:59 UTC (rev 1789) @@ -1,20 +1,23 @@ <Project projectName="sample"> - <Jar>../target/classes/samples</Jar> - <AuxClasspathEntry>../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/commons-collections-3.2.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/log4j-1.2.17.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/commons-lang3-3.3.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/slf4j-api-1.7.7.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/guava-17.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/httpclient-4.3.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/httpclient-cache-4.3.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/httpcore-4.3.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/commons-codec-1.6.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/junit-4.12.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/testng-6.9.6.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/jsr311-api-1.1.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> - <SrcDir>./.</SrcDir> + <Jar>././../target/classes/samples</Jar> + <AuxClasspathEntry>././../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/commons-collections-3.2.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/log4j-1.2.17.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/commons-lang3-3.3.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/slf4j-api-1.7.7.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/guava-17.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/httpclient-4.3.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/httpclient-cache-4.3.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/httpcore-4.3.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/commons-codec-1.6.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/commons-io-1.3.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/junit-4.12.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/testng-6.9.6.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/jsr311-api-1.1.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/mockito-all-2.0.2-beta.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/asm-debug-all-5.0.2.jar</AuxClasspathEntry> + <SrcDir>./././.</SrcDir> </Project> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2015 Dave Brosius + * Copyright (C) 2005-2016 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -34,7 +34,7 @@ public static void main(final String[] args) { JOptionPane.showMessageDialog(null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland", - "fb-contrib: copyright 2005-2015", JOptionPane.INFORMATION_MESSAGE); + "fb-contrib: copyright 2005-2016", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2015 Dave Brosius + * Copyright (C) 2005-2016 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/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2015 Dave Brosius + * Copyright (C) 2005-2016 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/collect/ImmutabilityType.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2015 Dave Brosius + * Copyright (C) 2005-2016 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/collect/MethodInfo.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java 2016-01-25 22:39:59 UTC (rev 1789) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2015 Dave Brosius + * Copyright (C) 2005-2016 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/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2015-12-30 20:32:17 UTC (rev 1788) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2016-01-25 22:39:59 UTC (r... [truncated message content] |
From: <dbr...@us...> - 2015-12-30 20:32:19
|
Revision: 1788 http://sourceforge.net/p/fb-contrib/code/1788 Author: dbrosius Date: 2015-12-30 20:32:17 +0000 (Wed, 30 Dec 2015) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-12-29 21:37:08 UTC (rev 1787) +++ trunk/fb-contrib/build.xml 2015-12-30 20:32:17 UTC (rev 1788) @@ -28,7 +28,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="6.5.0-SNAPSHOT" /> + <property name="fb-contrib.version" value="6.4.2" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-12-29 21:37:08 UTC (rev 1787) +++ trunk/fb-contrib/etc/findbugs.xml 2015-12-30 20:32:17 UTC (rev 1788) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -32,7 +32,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" /> @@ -291,13 +291,13 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues" speed="fast" reports="JXI_GET_ENDPOINT_CONSUMES_CONTENT,JXI_INVALID_CONTEXT_PARAMETER_TYPE,JXI_PARM_PARAM_NOT_FOUND_IN_PATH,JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT" /> - <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.JPAIssues" speed="fast" reports="JPAI_TRANSACTION_ON_NON_PUBLIC_METHOD,JPAI_HC_EQUALS_ON_MANAGED_ENTITY,JPAI_NON_PROXIED_TRANSACTION_CALL,JPAI_INEFFICIENT_EAGER_FETCH,JPAI_IGNORED_MERGE_RESULT,JPAI_NON_SPECIFIED_TRANSACTION_EXCEPTION_HANDLING,JPAI_UNNECESSARY_TRANSACTION_EXCEPTION_HANDLING"/> <Detector class="com.mebigfatguy.fbcontrib.detect.SuboptimalExpressionOrder" speed="fast" reports="SEO_SUBOPTIMAL_EXPRESSION_ORDER"/> - <!-- COMMENT OUT FOR POINT RELEASE --> + COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2015-12-29 21:37:08 UTC (rev 1787) +++ trunk/fb-contrib/etc/messages.xml 2015-12-30 20:32:17 UTC (rev 1788) @@ -3859,8 +3859,9 @@ <LongDescription>Method {1} creates exception with logger parameter markers in message</LongDescription> <Details> <![CDATA[ - <p>This method creates a standard exception passing a message string which contains an SLF4J style - parameter marker '{}'. This marker will not be translated as it is not processed by the Exception class. + <p>This method passes a standard exception as a logger parameter, and expects this exception to be substituted in + an SLF4J style parameter marker '{}'. This marker will not be translated as SLF4J doesn't process the Exception class + for markers. </p> ]]> </Details> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2015-12-29 21:37:08 UTC (rev 1787) +++ trunk/fb-contrib/htdocs/index.shtml 2015-12-30 20:32:17 UTC (rev 1788) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 6.4.1 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 6.4.2 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2015-12-29 21:37:08 UTC (rev 1787) +++ trunk/fb-contrib/htdocs/repository.html 2015-12-30 20:32:17 UTC (rev 1788) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>6.4.1</td></tr> + <tr><td><b>Version:</b></td><td>6.4.2</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2015-12-29 21:37:08 UTC (rev 1787) +++ trunk/fb-contrib/pom.xml 2015-12-30 20:32:17 UTC (rev 1788) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>6.5.0-SNAPSHOT</version> + <version>6.4.2</version> <prerequisites> <maven>2.2.1</maven> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2015-12-29 21:37:08 UTC (rev 1787) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2015-12-30 20:32:17 UTC (rev 1788) @@ -253,6 +253,11 @@ } } + /** + * looks for a variety of logging issues with log statements + * + * @throws ClassNotFoundException if the exception class, or a parent class can't be found + */ private void checkForProblemsWithLoggerMethods() throws ClassNotFoundException { String callingClsName = getClassConstantOperand(); if (callingClsName.endsWith("Log") || (callingClsName.endsWith("Logger"))) { @@ -316,6 +321,10 @@ } } + /** + * looks for slf4j calls where an exception is passed as a logger parameter, expecting to be substituted for a {} + * marker. As slf4j just passes the exception down to the message generation itself, the {} marker will go unpopulated. + */ private void checkForLoggerParam() { if (Values.CONSTRUCTOR.equals(getNameConstantOperand())) { String cls = getClassConstantOperand(); @@ -339,6 +348,11 @@ } } + /** + * looks for instantiation of a logger with what looks like a class name that isn't the same + * as the class in which it exists. There are some cases where a 'classname-like' string is + * presented purposely different than this class, and an attempt is made to ignore those. + */ private void lookForSuspectClasses() { String callingClsName = getClassConstantOperand(); String mthName = getNameConstantOperand(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2015-12-29 21:37:12
|
Revision: 1787 http://sourceforge.net/p/fb-contrib/code/1787 Author: dbrosius Date: 2015-12-29 21:37:08 +0000 (Tue, 29 Dec 2015) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/.classpath 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/htdocs/repository.html trunk/fb-contrib/samples/ACEM_Sample.java trunk/fb-contrib/samples/MDM_Sample.java trunk/fb-contrib/samples/OCP_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/UMTP_Sample.java trunk/fb-contrib/samples/UTAO_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JAXRSIssues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SQLInLoop.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseVarArgs.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/samples/JPAI_Sample.java trunk/fb-contrib/samples/SEO_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JPAIssues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuboptimalExpressionOrder.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/QMethod.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/.classpath 2015-12-29 21:37:08 UTC (rev 1787) @@ -27,5 +27,7 @@ <classpathentry kind="lib" path="lib/junit-4.12.jar"/> <classpathentry kind="lib" path="lib/testng-6.9.6.jar"/> <classpathentry kind="lib" path="lib/jsr311-api-1.1.1.jar" sourcepath="lib/sources/jsr311-api-1.1.1-sources.jar"/> + <classpathentry kind="lib" path="lib/spring-tx-4.2.3.RELEASE.jar"/> + <classpathentry kind="lib" path="lib/javax.persistence-2.1.1.jar"/> <classpathentry kind="output" path="target/classes/main"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/build.xml 2015-12-29 21:37:08 UTC (rev 1787) @@ -101,6 +101,8 @@ <pathelement location="${lib.dir}/httpclient-${httpclient.version}.jar" /> <pathelement location="${lib.dir}/commons-codec-${commons-codec.version}.jar" /> <pathelement location="${lib.dir}/jsr311-api-${jsr311-api.version}.jar" /> + <pathelement location="${lib.dir}/spring-tx-${spring-tx.version}.jar" /> + <pathelement location="${lib.dir}/javax.persistence-${javax.persistence.version}.jar" /> </path> </target> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/etc/bugrank.txt 2015-12-29 21:37:08 UTC (rev 1787) @@ -71,6 +71,13 @@ +0 BugPattern ISB_TOSTRING_APPENDING +0 BugPattern ITC_INHERITANCE_TYPE_CHECKING +2 BugPattern ITU_INAPPROPRIATE_TOSTRING_USE ++1 BugPattern JPAI_HC_EQUALS_ON_MANAGED_ENTITY ++1 BugPattern JPAI_IGNORED_MERGE_RESULT ++1 BugPattern JPAI_INEFFICIENT_EAGER_FETCH ++0 BugPattern JPAI_NON_PROXIED_TRANSACTION_CALL ++0 BugPattern JPAI_NON_SPECIFIED_TRANSACTION_EXCEPTION_HANDLING ++0 BugPattern JPAI_TRANSACTION_ON_NON_PUBLIC_METHOD ++0 BugPattern JPAI_UNNECESSARY_TRANSACTION_EXCEPTION_HANDLING +0 BugPattern JVR_JDBC_VENDOR_RELIANCE +0 BugPattern JXI_GET_ENDPOINT_CONSUMES_CONTENT +0 BugPattern JXI_INVALID_CONTEXT_PARAMETER_TYPE @@ -157,6 +164,7 @@ +0 BugPattern SCR_SLOPPY_CLASS_REFLECTION +0 BugPattern SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT +0 BugPattern SEC_SIDE_EFFECT_CONSTRUCTOR ++0 BugPattern SEO_SUBOPTIMAL_EXPRESSION_ORDER +0 BugPattern SGSU_SUSPICIOUS_GETTER_SETTER_USE +0 BugPattern SG_SLUGGISH_GUI +0 BugPattern SIL_SQL_IN_LOOP @@ -179,6 +187,7 @@ +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 Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/etc/findbugs.xml 2015-12-29 21:37:08 UTC (rev 1787) @@ -147,7 +147,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_CONTAINSKEY,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" /> + 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_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" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -292,6 +292,11 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues" speed="fast" reports="JXI_GET_ENDPOINT_CONSUMES_CONTENT,JXI_INVALID_CONTEXT_PARAMETER_TYPE,JXI_PARM_PARAM_NOT_FOUND_IN_PATH,JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT" /> <!-- COMMENT OUT FOR POINT RELEASE --> + + <Detector class="com.mebigfatguy.fbcontrib.detect.JPAIssues" speed="fast" reports="JPAI_TRANSACTION_ON_NON_PUBLIC_METHOD,JPAI_HC_EQUALS_ON_MANAGED_ENTITY,JPAI_NON_PROXIED_TRANSACTION_CALL,JPAI_INEFFICIENT_EAGER_FETCH,JPAI_IGNORED_MERGE_RESULT,JPAI_NON_SPECIFIED_TRANSACTION_EXCEPTION_HANDLING,JPAI_UNNECESSARY_TRANSACTION_EXCEPTION_HANDLING"/> + + <Detector class="com.mebigfatguy.fbcontrib.detect.SuboptimalExpressionOrder" speed="fast" reports="SEO_SUBOPTIMAL_EXPRESSION_ORDER"/> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -403,6 +408,7 @@ <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="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" /> @@ -541,5 +547,13 @@ <BugPattern abbrev="JXI" type="JXI_INVALID_CONTEXT_PARAMETER_TYPE" category="CORRECTNESS" /> <BugPattern abbrev="JXI" type="JXI_PARM_PARAM_NOT_FOUND_IN_PATH" category="CORRECTNESS" /> <BugPattern abbrev="JXI" type="JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT" category="CORRECTNESS" /> + <BugPattern abbrev="JPAI" type="JPAI_TRANSACTION_ON_NON_PUBLIC_METHOD" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="JPAI" type="JPAI_HC_EQUALS_ON_MANAGED_ENTITY" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="JPAI" type="JPAI_NON_PROXIED_TRANSACTION_CALL" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="JPAI" type="JPAI_INEFFICIENT_EAGER_FETCH" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="JPAI" type="JPAI_IGNORED_MERGE_RESULT" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="JPAI" type="JPAI_NON_SPECIFIED_TRANSACTION_EXCEPTION_HANDLING" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="JPAI" type="JPAI_UNNECESSARY_TRANSACTION_EXCEPTION_HANDLING" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="SEO" type="SEO_SUBOPTIMAL_EXPRESSION_ORDER" category="PERFORMANCE" experimental="true"/> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/etc/messages.xml 2015-12-29 21:37:08 UTC (rev 1787) @@ -1547,9 +1547,32 @@ <Details> <![CDATA[ <p>Looks for problems with the use of the JAX-RS specification.</p> + <p>It is a fast detector</p> ]]> </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 + 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 + conditions first you may elminate 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> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> @@ -3245,6 +3268,20 @@ ]]> </Details> </BugPattern> + + <BugPattern type="SPP_NULL_CHECK_ON_OPTIONAL"> + <ShortDescription>Method checks an Optional reference for null or non nullness</ShortDescription> + <LongDescription>Method {1} checks an Optional reference for null or non nullness</LongDescription> + <Details> + <![CDATA[ + This method uses an Optional variable, and checks the reference value for whether it is null or not null. + Since the point of the Optional class is to avoid 'the null reference problem', having code that needs to + check the reference itself is self defeating, and therefore makes the use of the Optional variable useless. + You should never use a variable of type Optional that has a value of null, and so there should be no need to + check for it. + ]]> + </Details> + </BugPattern> <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> <ShortDescription>Method assigns a variable in a larger scope than is needed</ShortDescription> @@ -5103,6 +5140,112 @@ ]]> </Details> </BugPattern> + + <BugPattern type="JPAI_TRANSACTION_ON_NON_PUBLIC_METHOD"> + <ShortDescription>Method has a Spring @Transactional annotation on it, but is non-public</ShortDescription> + <LongDescription>Method {1} has a Spring @Transactional annotation on it, but is non-public</LongDescription> + <Details> + <![CDATA[ + <p>This method specifies a Spring @Transactional annotation but the method is defined as being non public. + Spring only creates transactional boundaries on methods that are public, and so this annotation not doing + anything for this method. Make the method public, or place the annotation on a more appropriate method. + ]]> + </Details> + </BugPattern> + + <BugPattern type="JPAI_HC_EQUALS_ON_MANAGED_ENTITY"> + <ShortDescription>JPA Entity with Generated @Id defined with hashCode/equals</ShortDescription> + <LongDescription>JPA Entity {0} with Generated @Id defined with hashCode/equals</LongDescription> + <Details> + <![CDATA[ + <p>This class is defined to be a JPA Entity, and has an @Id field that is generated by the JPA provider. + Since you do not control when that Id is created directly, it is risky to implement hashCode/equals for this + class, and especially for use with Collections, as the data behind the algorithms will not be immutable, and + thus cause problems when those fields change, and the object is in the collection. It is usually safer + to not define hashCode and equals for entity objects, but treat them as objects for IdentityHashSet/Maps instead. + ]]> + </Details> + </BugPattern> + + <BugPattern type="JPAI_NON_PROXIED_TRANSACTION_CALL"> + <ShortDescription>Method annotated with @Transactional is called from a non Spring proxy</ShortDescription> + <LongDescription>Method {1} annotated with @Transactional is called from a non Spring proxy</LongDescription> + <Details> + <![CDATA[ + <p>This method call is to a method that has a @Transactional annotation on it. However since this call is from the + same class, it is not going through any Spring proxy, and thus the transactional quality of this method is completely + lost. @Transactional method must always be called through a Spring bean that is autowired.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="JPAI_INEFFICIENT_EAGER_FETCH"> + <ShortDescription>OneToMany join specifies 1+n EAGER join</ShortDescription> + <LongDescription>OneToMany join specifies 1+n EAGER join</LongDescription> + <Details> + <![CDATA[ + <p>This JPA entity specifies a @OneToMany join with a fetch type of EAGER. By Default EAGER joins perform + select operations on each element returned from the original query in sequence, thus producing 1 + n queries. + If you are going to use EAGER joins, it is wise to specify a Join type by using @Fetch annotations in + Hibernate or @JoinFetch/@BatchFetch annotations (or hints) in EclipseLink, for example. Even so, These + annotations may only apply in limited cases, such as in the use of find.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="JPAI_IGNORED_MERGE_RESULT"> + <ShortDescription>Method ignores the return value of EntityManager.merge</ShortDescription> + <LongDescription>Method {1} ignores the return value of EntityManager.merge</LongDescription> + <Details> + <![CDATA[ + <p>This method calls EntityManager.merge, and throws away the resultant value. This result is the + managed entity version of the potentially unmanaged object that was passed to merge. You should use + the returned managed entity for any further use.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="JPAI_NON_SPECIFIED_TRANSACTION_EXCEPTION_HANDLING"> + <ShortDescription>Method does not specify how to handle transaction when exception is thrown</ShortDescription> + <LongDescription>Method {1} does not specify how to handle transaction when exception is thrown</LongDescription> + <Details> + <![CDATA[ + <p>This method declares that it throws one or more non-runtime exceptions. It also is annotated with a + @Transactional annotation but fails to describe whether to rollback the transaction or not based on this + thrown exception. use 'rollbackFor' or 'noRollbackFor' attributes of the Transactional annotation to + document this.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="JPAI_UNNECESSARY_TRANSACTION_EXCEPTION_HANDLING"> + <ShortDescription>Method declares handling a transactional exception that won't be thrown</ShortDescription> + <LongDescription>Method {1} declares handling a transactional exception that won't be thrown</LongDescription> + <Details> + <![CDATA[ + <p>This method declares that it either rolls back or does not rollback a transaction based on an + expected transaction being thrown. However this exception can not be thrown from this method, and so the + annotation is useless.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="SEO_SUBOPTIMAL_EXPRESSION_ORDER"> + <ShortDescription>Method orders expressions in a conditional in a sub optimal way</ShortDescription> + <LongDescription>Method {1} orders expressions in a conditional in a sub optimal way</LongDescription> + <Details> + <![CDATA[ + <p>This method builds a conditional for an if or while statement where the expressions contain both simple + local variable comparisons, as well as comparisons on method calls. The expression orders these so that the method calls + come before the simple local variable call comparisons. This causes method calls to be executed in conditions when they + do not need to be, and thus potentially causes a lot of code to be executed for nothing. By ordering the expressions so that + the simple conditions contains local variable conditions are first, you eliminate this waste. This assumes that the method + calls do not have side effects. If the method do have side effects, it is probably a better idea to pull these calls out of + the condition and execute them first, assigning a value to a local variable. In this way you give a hint that the call may have + side effects.</p> + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -5234,4 +5377,6 @@ <BugCode abbrev="CRF">Conflating Resources And Files</BugCode> <BugCode abbrev="IMC">Immature Class</BugCode> <BugCode abbrev="JXI">JAX-RS Issues</BugCode> + <BugCode abbrev="JPAI">JPA Issues</BugCode> + <BugCode abbrev="SEO">Suboptimal Expression Order</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/htdocs/index.shtml 2015-12-29 21:37:08 UTC (rev 1787) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 6.4.0 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 6.4.1 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on @@ -86,6 +86,17 @@ same kind of exception, and throw the same exception always. These blocks can be coalesced into one. </li> + <li><b>[JPAI] JPA Issues</b><br/> + Looks for various issues around the use of the Java Persistence API (JPA), including + with use with spring-tx. + </li> + <li><b>[SEO] Suboptimal Expression Order</b><br/> + Looks for conditional expressions where both simple local variable (in)equalities are used + along with method calls, where the method calls are done first. By placing the simple local + checks first, you eliminate potentially costly calls in some cases. This assumes that the methods + called won't have side-effects that are desired. At present it only looks for simple sequences + of 'and' based conditions. + </li> </ul> </div> <hr/> Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/htdocs/repository.html 2015-12-29 21:37:08 UTC (rev 1787) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>6.4.0</td></tr> + <tr><td><b>Version:</b></td><td>6.4.1</td></tr> </table> </div> Modified: trunk/fb-contrib/samples/ACEM_Sample.java =================================================================== --- trunk/fb-contrib/samples/ACEM_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/samples/ACEM_Sample.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -1,9 +1,19 @@ -public abstract class ACEM_Sample { +public abstract class ACEM_Sample implements Foo { public void test() { } public int test1() { throw new UnsupportedOperationException("Not implemented"); } + + @Override + public void doFPFoo() { + } + + +} + +interface Foo { + void doFPFoo(); } \ No newline at end of file Added: trunk/fb-contrib/samples/JPAI_Sample.java =================================================================== --- trunk/fb-contrib/samples/JPAI_Sample.java (rev 0) +++ trunk/fb-contrib/samples/JPAI_Sample.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -0,0 +1,145 @@ +import java.io.FileNotFoundException; +import java.io.IOException; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EntityManager; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; + +import org.springframework.transaction.annotation.Transactional; + +public class JPAI_Sample { + + EntityManager em; + + @Transactional + private void writeData() { + } + + @Transactional + public void writeGoodData() { + } + + private void badWrite() { + writeGoodData(); + } + + public void ignoreMergeResult(MyEntity e, SubEntity s) { + + em.merge(e); + em.merge(s); + + List<SubEntity> ss = new ArrayList<SubEntity>(); + ss.add(s); + e.setSubEntities(ss); + + em.flush(); + } + + @Transactional + public void noRollbacks(MyEntity e) throws IOException { + + } + + @Transactional(rollbackFor = { SQLException.class, CloneNotSupportedException.class }, noRollbackFor = IOException.class) + public void noDeclaredRollbackExceptions() { + } + + @Transactional(rollbackFor = SQLException.class, noRollbackFor = IOException.class) + public void fpDefinedRollBack(MyEntity e) throws SQLException, FileNotFoundException { + } + + @Transactional(readOnly = true) + public void fpReadOnlyExceptions(MyEntity e) throws IOException { + } + + @Entity + @Table(name = "MY_ENTITY") + public static class MyEntity { + + private Integer id; + private List<SubEntity> subEntities; + + @Id + @SequenceGenerator(name = "MY_ENTITY_SEQ", sequenceName = "MY_ENTITY_SEQ", allocationSize = 100) + @GeneratedValue(generator = "MY_ENTITY_SEQ") + @Column(name = "ID", nullable = false, unique = true) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "myEntity", targetEntity = MyEntity.class) + public List<SubEntity> getSubEntities() { + return subEntities; + } + + public void setSubEntities(List<SubEntity> subEntities) { + this.subEntities = subEntities; + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof MyEntity)) { + return false; + } + + MyEntity that = (MyEntity) o; + if (id == null) { + return that.id == null; + } + + return id.equals(that.id); + } + } + + @Entity + @Table(name = "SUB_ENTITY") + public static class SubEntity { + + public Integer subId; + public MyEntity myEntity; + + @Id + @SequenceGenerator(name = "SUB_ENTITY_SEQ", sequenceName = "SUB_ENTITY_SEQ", allocationSize = 100) + @GeneratedValue(generator = "SUB_ENTITY_SEQ") + @Column(name = "SUB_ID", nullable = false, unique = true) + public Integer getSubId() { + return subId; + } + + public void setSubId(Integer subId) { + this.subId = subId; + } + + @JoinColumn(name = "ID", referencedColumnName = "ID", nullable = false) + @ManyToOne(fetch = FetchType.EAGER, targetEntity = MyEntity.class) + public MyEntity getMyEntity() { + return myEntity; + } + + public void setMyEntity(MyEntity myEntity) { + this.myEntity = myEntity; + } + + } +} Property changes on: trunk/fb-contrib/samples/JPAI_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/MDM_Sample.java =================================================================== --- trunk/fb-contrib/samples/MDM_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/samples/MDM_Sample.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -12,6 +12,9 @@ import javax.net.ssl.SSLServerSocketFactory; public class MDM_Sample implements Runnable { + private ReentrantLock myLock; + + public MDM_Sample() throws Exception { boolean b; @@ -103,4 +106,8 @@ private static void touch(Object o) { } + + private void fpAssertReentrantLock() { + assert myLock.isHeldByCurrentThread(); + } } Modified: trunk/fb-contrib/samples/OCP_Sample.java =================================================================== --- trunk/fb-contrib/samples/OCP_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/samples/OCP_Sample.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -165,6 +165,7 @@ } class fpOverride { + @SuppressWarnings("deprecation") public static final Comparator<Date> COMPARATOR = new Comparator<Date>() { @Override // no tag, override Modified: trunk/fb-contrib/samples/PRMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/PRMC_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/samples/PRMC_Sample.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -15,6 +15,8 @@ private static PRMC_Sample SAMPLE1; private static PRMC_Sample SAMPLE2; String data; + String[] array1; + String[] array2; public boolean test1(Calendar c) { Date d = c.getTime(); @@ -149,4 +151,13 @@ return sb.toString(); } } -} + + class SFIssue71 { + protected String[] inc = new String[0]; + protected String[] dec = new String[0]; + + public void fplog() { + System.out.println(Arrays.toString(inc)); + System.out.println(Arrays.toString(dec)); + } + }} Added: trunk/fb-contrib/samples/SEO_Sample.java =================================================================== --- trunk/fb-contrib/samples/SEO_Sample.java (rev 0) +++ trunk/fb-contrib/samples/SEO_Sample.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -0,0 +1,31 @@ +import java.util.Random; + +public class SEO_Sample { + + public void seo() { + int a = calcA(); + int b = calcB(); + + System.out.println(a + b); + + if (hasC() && (a == 0) && (b > 3)) { + System.out.println(a - b); + } + } + + + private int calcA() { + Random r = new Random(); + return r.nextInt(10); + } + + private int calcB() { + Random r = new Random(); + return r.nextInt(10); + } + + private boolean hasC() { + Random r = new Random(); + return r.nextBoolean(); + } +} Property changes on: trunk/fb-contrib/samples/SEO_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/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/samples/SPP_Sample.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -17,6 +17,8 @@ import java.util.Set; import java.util.StringTokenizer; +import com.google.common.base.Optional; + @SuppressWarnings("all") public class SPP_Sample implements Serializable { public static final long serialVersionUID = -2766574418713802220L; @@ -367,6 +369,14 @@ System.out.println(x.trim()); return x; } + + public String testOptional(Optional<String> o) { + if (o == null) { + return ""; + } + + return o.get(); + } public boolean fpNullAndInstanceOf(Object o) { if (o != null) { Modified: trunk/fb-contrib/samples/UMTP_Sample.java =================================================================== --- trunk/fb-contrib/samples/UMTP_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/samples/UMTP_Sample.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -33,6 +33,9 @@ public <X, Y> void fpEmbedded(Map<X, Map<String, Y>> x) { } + + public <C, K extends C, V extends C> void fpParentRestriction(Iterable<K> source, Map<K, V> target) { + } public Object getFoo() { return null; Modified: trunk/fb-contrib/samples/UTAO_Sample.java =================================================================== --- trunk/fb-contrib/samples/UTAO_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/samples/UTAO_Sample.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -3,6 +3,7 @@ import junit.framework.TestCase; +@SuppressWarnings("deprecation") public class UTAO_Sample extends TestCase { public void testExactDoubles(double d1, double d2) { @@ -93,6 +94,7 @@ } @Test + @SuppressWarnings("deprecation") public void usingOldClasses(int x) { junit.framework.Assert.assertEquals(0, x); } Modified: trunk/fb-contrib/samples/samples.fbp =================================================================== --- trunk/fb-contrib/samples/samples.fbp 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/samples/samples.fbp 2015-12-29 21:37:08 UTC (rev 1787) @@ -1,19 +1,20 @@ <Project projectName="sample"> - <Jar>./../target/classes/samples</Jar> - <AuxClasspathEntry>./../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/commons-collections-3.2.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/log4j-1.2.17.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/commons-lang3-3.3.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/slf4j-api-1.7.7.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/guava-17.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/httpclient-4.3.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/httpclient-cache-4.3.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/httpcore-4.3.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/commons-codec-1.6.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/junit-4.12.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/testng-6.9.6.jar</AuxClasspathEntry> + <Jar>../target/classes/samples</Jar> + <AuxClasspathEntry>../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/commons-collections-3.2.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/log4j-1.2.17.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/commons-lang3-3.3.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/slf4j-api-1.7.7.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/guava-17.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/httpclient-4.3.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/httpclient-cache-4.3.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/httpcore-4.3.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/commons-codec-1.6.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/junit-4.12.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/testng-6.9.6.jar</AuxClasspathEntry> <AuxClasspathEntry>../lib/jsr311-api-1.1.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> <SrcDir>./.</SrcDir> </Project> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -18,6 +18,9 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.HashSet; +import java.util.Set; + import org.apache.bcel.Repository; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.ConstantString; @@ -25,6 +28,7 @@ import org.apache.bcel.classfile.Method; import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.QMethod; import com.mebigfatguy.fbcontrib.utils.Values; import edu.umd.cs.findbugs.BugInstance; @@ -53,6 +57,7 @@ } private final BugReporter bugReporter; + private Set<QMethod> interfaceMethods; private String methodName; private State state; @@ -74,9 +79,17 @@ */ @Override public void visitClassContext(ClassContext classContext) { - JavaClass cls = classContext.getJavaClass(); - if (cls.isAbstract()) - super.visitClassContext(classContext); + try { + JavaClass cls = classContext.getJavaClass(); + if (cls.isAbstract()) { + interfaceMethods = collectInterfaceMethods(cls); + super.visitClassContext(classContext); + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } finally { + interfaceMethods = null; + } } /** @@ -101,8 +114,10 @@ public void visitCode(Code obj) { if (Values.CONSTRUCTOR.equals(methodName) || Values.STATIC_INITIALIZER.equals(methodName)) return; - - super.visitCode(obj); + + if (!interfaceMethods.contains(new QMethod(methodName, getMethod().getSignature()))) { + super.visitCode(obj); + } } /** @@ -169,4 +184,15 @@ state = State.SAW_DONE; } } + + private Set<QMethod> collectInterfaceMethods(JavaClass cls) throws ClassNotFoundException { + Set<QMethod> methods = new HashSet<QMethod>(); + for (JavaClass inf : cls.getAllInterfaces()) { + for (Method m : inf.getMethods()) { + methods.add(new QMethod(m.getName(), m.getSignature())); + } + } + + return methods; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -871,7 +871,7 @@ stores.remove(Integer.valueOf(r)); } - if ((stores.size() > 0) && (children != null)) { + if ((children != null) && (stores.size() > 0)) { for (Map.Entry<Integer, Integer> entry : stores.entrySet()) { int childUseCount = 0; boolean inIgnoreSB = false; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -39,9 +39,11 @@ import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.CodeByteUtils; import com.mebigfatguy.fbcontrib.utils.OpcodeUtils; +import com.mebigfatguy.fbcontrib.utils.QMethod; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import com.mebigfatguy.fbcontrib.utils.TernaryPatcher; import com.mebigfatguy.fbcontrib.utils.ToString; +import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import com.mebigfatguy.fbcontrib.utils.Values; import edu.umd.cs.findbugs.BugInstance; @@ -66,8 +68,7 @@ private static JavaClass collectionClass; private static JavaClass iteratorClass; private static Set<JavaClass> exceptionClasses; - private static final Set<String> collectionMethods; - + static { try { collectionClass = Repository.lookupClass("java/util/Collection"); @@ -84,26 +85,31 @@ } catch (ClassNotFoundException cnfe) { // don't have a bugReporter yet, so do nothing } - - collectionMethods = new HashSet<String>(3); - collectionMethods.add("entrySet()Ljava/lang/Set;"); - collectionMethods.add("keySet()Ljava/lang/Set;"); - collectionMethods.add("values()Ljava/lang/Collection;"); } - private static final Map<String, Integer> modifyingMethods; + private static final Set<QMethod> collectionMethods = UnmodifiableSet.create( + new QMethod("entrySet", "()Ljava/lang/Set;"), + new QMethod("keySet", "()Ljava/lang/Set;"), + new QMethod("values", "()Ljava/lang/Collection;") + ); + + private static final Map<QMethod, Integer> modifyingMethods; static { - Map<String, Integer> mm = new HashMap<String, Integer>(); - mm.put("add(Ljava/lang/Object;)Z", Values.ONE); - mm.put("addAll(Ljava/util/Collection;)Z", Values.ONE); - mm.put("addAll(ILjava/util/Collection;)Z", Values.TWO); - mm.put("clear()V", Values.ZERO); - mm.put("remove(I)Ljava/lang/Object;", Values.ONE); - mm.put("removeAll(Ljava/util/Collection;)Z", Values.ONE); - mm.put("retainAll(Ljava/util/Collection;)Z", Values.ONE); - modifyingMethods = Collections.<String, Integer>unmodifiableMap(mm); + Map<QMethod, Integer> mm = new HashMap<QMethod, Integer>(); + mm.put(new QMethod("add", "(Ljava/lang/Object;)Z"), Values.ONE); + mm.put(new QMethod("addAll", "(Ljava/util/Collection;)Z"), Values.ONE); + mm.put(new QMethod("addAll", "(ILjava/util/Collection;)Z"), Values.TWO); + mm.put(new QMethod("clear", "()V"), Values.ZERO); + mm.put(new QMethod("remove", "(I)Ljava/lang/Object;"), Values.ONE); + mm.put(new QMethod("removeAll", "(Ljava/util/Collection;)Z"), Values.ONE); + mm.put(new QMethod("retainAll", "(Ljava/util/Collection;)Z"), Values.ONE); + modifyingMethods = Collections.<QMethod, Integer>unmodifiableMap(mm); } + + private static final QMethod ITERATOR = new QMethod("iterator", "()Ljava/util/Iterator;"); + private static final QMethod REMOVE = new QMethod("remove", "(Ljava/lang/Object;)Z"); + private static final QMethod HASNEXT = new QMethod("hasNext", "()Z"); private final BugReporter bugReporter; private OpcodeStack stack; @@ -186,7 +192,7 @@ String className = getClassConstantOperand(); String methodName = getNameConstantOperand(); String signature = getSigConstantOperand(); - String methodInfo = methodName + signature; + QMethod methodInfo = new QMethod(methodName, signature); if (isCollection(className)) { if (collectionMethods.contains(methodInfo)) { @@ -195,12 +201,12 @@ groupId = findCollectionGroup(itm, true); } - } else if ("iterator()Ljava/util/Iterator;".equals(methodInfo)) { + } else if (ITERATOR.equals(methodInfo)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); groupId = findCollectionGroup(itm, true); } - } else if ("remove(Ljava/lang/Object;)Z".equals(methodInfo)) { + } else if (REMOVE.equals(methodInfo)) { if (stack.getStackDepth() > 1) { OpcodeStack.Item itm = stack.getStackItem(1); int id = findCollectionGroup(itm, true); @@ -252,7 +258,7 @@ } } } - } else if ("java/util/Iterator".equals(className) && "hasNext()Z".equals(methodInfo)) { + } else if ("java/util/Iterator".equals(className) && HASNEXT.equals(methodInfo)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); Integer id = (Integer) itm.getUserValue(); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -1,26 +1,24 @@ /* * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2015 Dave Brosius - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package com.mebigfatguy.fbcontrib.detect; -import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -31,7 +29,9 @@ import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.QMethod; import com.mebigfatguy.fbcontrib.utils.ToString; +import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -43,47 +43,44 @@ import edu.umd.cs.findbugs.ba.XField; /** - * looks for fields that are implementations of java.util.List, but that are - * used in a set-like fashion. Since lookup type operations are performed using - * a linear search for Lists, the performance for large Lists will be poor. - * Consideration should be made as to whether these fields should be sets. In - * the case that order is important, consider using LinkedHashSet. + * looks for fields that are implementations of java.util.List, but that are used in a set-like fashion. Since lookup type operations are performed using a + * linear search for Lists, the performance for large Lists will be poor. Consideration should be made as to whether these fields should be sets. In the case + * that order is important, consider using LinkedHashSet. */ public class DubiousListCollection extends BytecodeScanningDetector { - private static final Set<String> setMethods; - private static final Set<String> listMethods; - static { - Set<String> sm = new HashSet<String>(); - sm.add("contains(Ljava/lang/Object;)Z"); - sm.add("containsAll(Ljava/util/Collection;)Z"); - sm.add("remove(Ljava/lang/Object;)Ljava/lang/Object;"); - sm.add("removeAll(Ljava/util/Collection;)Z"); - sm.add("retainAll(Ljava/util/Collection;)Z"); - setMethods = Collections.<String>unmodifiableSet(sm); + private static final Set<QMethod> setMethods = UnmodifiableSet.create( + //@formatter:off + new QMethod("contains", "(Ljava/lang/Object;)Z"), + new QMethod("containsAll", "(Ljava/util/Collection;)Z"), + new QMethod("remove", "(Ljava/lang/Object;)Ljava/lang/Object;"), + new QMethod("removeAll", "(Ljava/util/Collection;)Z"), + new QMethod("retainAll", "(Ljava/util/Collection;)Z") + //@formatter:on + ); - Set<String> lm = new HashSet<String>(); - lm.add("add(ILjava/lang/Object;)V"); - lm.add("addAll(ILjava/util/Collection;)Z"); - lm.add("lastIndexOf(Ljava/lang/Object;)I"); - lm.add("remove(I)Ljava/lang/Object;"); - lm.add("set(ILjava/lang/Object;)Ljava/lang/Object;"); - lm.add("subList(II)Ljava/util/List;"); - lm.add("listIterator()Ljava/util/ListIterator;"); - lm.add("listIterator(I)Ljava/util/ListIterator;"); - listMethods = Collections.<String>unmodifiableSet(lm); + private static final Set<QMethod> listMethods = UnmodifiableSet.create( + //@formatter:off + new QMethod("add", "(ILjava/lang/Object;)V"), + new QMethod("addAll", "(ILjava/util/Collection;)Z"), + new QMethod("lastIndexOf", "(Ljava/lang/Object;)I"), + new QMethod("remove", "(I)Ljava/lang/Object;"), + new QMethod("set", "(ILjava/lang/Object;)Ljava/lang/Object;"), + new QMethod("subList", "(II)Ljava/util/List;"), + new QMethod("listIterator", "()Ljava/util/ListIterator;"), + new QMethod("listIterator", "(I)Ljava/util/ListIterator;") + // Theoretically get(i) and indexOf(Object) are list Methods but are so + // abused, as to be meaningless + //@formatter:on + ); - // Theoretically get(i) and indexOf(Object) are list Methods but are so - // abused, as to be meaningless - } - private final BugReporter bugReporter; private final OpcodeStack stack = new OpcodeStack(); private final Map<String, FieldInfo> fieldsReported = new HashMap<String, FieldInfo>(10); /** * constructs a DLC detector given the reporter to report bugs on - * + * * @param bugReporter * the sync of bug reports */ @@ -93,7 +90,7 @@ /** * overrides the visitor to accept classes that define List based fields - * + * * @param classContext * the context object for the currently parsed class */ @@ -119,7 +116,7 @@ /** * overrides the visitor to reset the opcode stack object - * + * * @param obj * the code object for the currently parse method */ @@ -130,9 +127,8 @@ } /** - * overrides the visitor to record all method calls on List fields. If a - * method is not a set based method, remove it from further consideration - * + * overrides the visitor to record all method calls on List fields. If a method is not a set based method, remove it from further consideration + * * @param seen * the current opcode parsed. */ @@ -152,11 +148,12 @@ FieldInfo fi = fieldsReported.get(fieldName); if (fi != null) { String methodName = getNameConstantOperand(); - String methodInfo = methodName + signature; - if (listMethods.contains(methodInfo)) + QMethod methodInfo = new QMethod(methodName, signature); + if (listMethods.contains(methodInfo)) { fieldsReported.remove(fieldName); - else if (setMethods.contains(methodInfo)) + } else if (setMethods.contains(methodInfo)) { fi.addUse(getPC()); + } } } } @@ -185,14 +182,13 @@ } /** - * return the field object that the current method was called on, by finding - * the reference down in the stack based on the number of parameters - * + * return the field object that the current method was called on, by finding the reference down in the stack based on the number of parameters + * * @param stk * the opcode stack where fields are stored * @param signature * the signature of the called method - * + * * @return the field annotation for the field whose method was executed */ private static XField getFieldFromStack(final OpcodeStack stk, final String signature) { @@ -205,8 +201,7 @@ } /** - * implements the detector, by reporting all remaining fields that only have - * set based access + * implements the detector, by reporting all remaining fields that only have set based access */ private void reportBugs() { int major = getClassContext().getJavaClass().getMajor(); @@ -228,18 +223,19 @@ /** * builds a field annotation by finding the field in the classes' field list - * + * * @param fieldName * the field for which to built the field annotation - * + * * @return the field annotation of the specified field */ private FieldAnnotation getFieldAnnotation(final String fieldName) { JavaClass cls = getClassContext().getJavaClass(); Field[] fields = cls.getFields(); for (Field f : fields) { - if (f.getName().equals(fieldName)) + if (f.getName().equals(fieldName)) { return new FieldAnnotation(cls.getClassName(), fieldName, f.getSignature(), (f.getAccessFlags() & Constants.ACC_STATIC) != 0); + } } return null; // shouldn't happen } @@ -254,12 +250,14 @@ /** * increments the number of times this field has a set method called on it * - * @param pc the current instruction offset + * @param pc + * the current instruction offset */ public void addUse(final int pc) { setCnt++; - if (slAnnotation == null) + if (slAnnotation == null) { slAnnotation = SourceLineAnnotation.fromVisitedInstruction(DubiousListCollection.this.getClassContext(), DubiousListCollection.this, pc); + } } public SourceLineAnnotation getSourceLineAnnotation() { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -42,6 +42,8 @@ import org.apache.bcel.generic.INVOKEVIRTUAL; import org.apache.bcel.generic.Instruction; import org.apache.bcel.generic.InstructionHandle; +import org.apache.bcel.generic.ObjectType; +import org.apache.bcel.generic.ReferenceType; import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.ToString; @@ -275,13 +277,15 @@ } else if (ins instanceof INVOKESPECIAL) { INVOKESPECIAL is = (INVOKESPECIAL) ins; - if (Values.CONSTRUCTOR.equals(is.getMethodName(cpg)) && (is.getClassName(cpg).startsWith(clsContext.getJavaClass().getClassName() + "$"))) { + ReferenceType rt = is.getReferenceType(cpg); + if (Values.CONSTRUCTOR.equals(is.getMethodName(cpg)) && ((rt instanceof ObjectType) && ((ObjectType) rt).getClassName().startsWith(clsContext.getJavaClass().getClassName() + "$"))) { localizableFields.clear(); } } else if (ins instanceof INVOKEVIRTUAL) { INVOKEVIRTUAL is = (INVOKEVIRTUAL) ins; - if (is.getClassName(cpg).equals(clsName)) { + ReferenceType rt = is.getReferenceType(cpg); + if ((rt instanceof ObjectType) && ((ObjectType) rt).getClassName().equals(clsName)) { String methodDesc = is.getName(cpg) + is.getSignature(cpg); Set<String> fields = methodFieldModifiers.get(methodDesc); if (fields != null) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -19,10 +19,10 @@ */ package com.mebigfatguy.fbcontrib.detect; -import java.util.HashSet; import java.util.Set; import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -34,40 +34,33 @@ */ public class HttpClientProblems extends MissingMethodsDetector { - private static Set<String> httpRequestClasses = new HashSet<String>(); + private static Set<String> httpRequestClasses = UnmodifiableSet.create( + "org.apache.http.client.methods.HttpGet", + "org.apache.http.client.methods.HttpPut", + "org.apache.http.client.methods.HttpDelete", + "org.apache.http.client.methods.HttpPost", + "org.apache.http.client.methods.HttpPatch" + ); - static { - httpRequestClasses.add("org.apache.http.client.methods.HttpGet"); - httpRequestClasses.add("org.apache.http.client.methods.HttpPut"); - httpRequestClasses.add("org.apache.http.client.methods.HttpDelete"); - httpRequestClasses.add("org.apache.http.client.methods.HttpPost"); - httpRequestClasses.add("org.apache.http.client.methods.HttpPatch"); - } - - private static Set<String> resetMethods = new HashSet<String>(); - - static { - resetMethods.add("reset"); - resetMethods.add("releaseConnection"); - } - + private static Set<String> resetMethods = UnmodifiableSet.create( + "reset", + "releaseConnection" + ); + // Any methods that should not be treated as a "will call a reset method" - private static Set<String> whiteListMethods = new HashSet<String>(); + private static Set<String> whiteListMethods = UnmodifiableSet.create( + "execute", + "fatal", + "error", + "info", + "debug", + "trace", + "println", + "print", + "format", + "append" // for when Java uses StringBuilders to append Strings + ); - static { - whiteListMethods.add("execute"); - whiteListMethods.add("fatal"); - whiteListMethods.add("error"); - whiteListMethods.add("info"); - whiteListMethods.add("debug"); - whiteListMethods.add("trace"); - whiteListMethods.add("println"); - whiteListMethods.add("print"); - whiteListMethods.add("format"); - whiteListMethods.add("append"); // for when Java uses StringBuilders to - // append Strings - } - public HttpClientProblems(BugReporter bugReporter) { super(bugReporter); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java 2015-12-12 17:33:56 UTC (rev 1786) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java 2015-12-29 21:37:08 UTC (rev 1787) @@ -153,7 +153,7 @@ /** * looks to see the field has a runtime visible ... [truncated message content] |
From: <dbr...@us...> - 2015-12-12 17:34:00
|
Revision: 1786 http://sourceforge.net/p/fb-contrib/code/1786 Author: dbrosius Date: 2015-12-12 17:33:56 +0000 (Sat, 12 Dec 2015) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/ISB_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/WOC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.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/InvalidConstantArgument.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/MissingMethodsDetector.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.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/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SluggishGui.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/UnitTestAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/build.xml 2015-12-12 17:33:56 UTC (rev 1786) @@ -2,6 +2,14 @@ <project name="fb-contrib" default="default"> + <presetdef name="javac"> + <javac encoding="UTF-8" /> + </presetdef> + + <presetdef name="javadoc"> + <javadoc encoding="UTF-8" /> + </presetdef> + <property file="user.properties" /> <property file="build.properties" /> <property file="version.properties" /> @@ -20,7 +28,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="6.4.0" /> + <property name="fb-contrib.version" value="6.5.0-SNAPSHOT" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/etc/findbugs.xml 2015-12-12 17:33:56 UTC (rev 1786) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -32,7 +32,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" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/etc/messages.xml 2015-12-12 17:33:56 UTC (rev 1786) @@ -52,7 +52,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SyncCollectionIterators"> <Details> <![CDATA[ - <p>Looks for use of iterators on synchronized collections built from the java.util.Collections class</p> + <p>Looks for use of iterators on synchronized collections built from the java.util.Collections class.</p> <p>As the collection in question was built through Collections.synchronizedXXX, an assumption is made that this collection must be multithreaded safe. However, iterator access is used, which is explicitly unsafe. When iterators are to be used, synchronization should be done manually.</p> @@ -322,7 +322,7 @@ Since primitive wrapper classes are immutable this is needless garbage being created. Just use the original reference. </p> - <p>It also looks for calls to BoxedClass.valueOf(x) where X is already a Boxed class</p> + <p>It also looks for calls to BoxedClass.valueOf(x) where X is already a BoxedClass</p> <p>It also looks for calls to BoxedClass.valueOf(myString).boxedValue(), when instead it is simpler to use BoxedClass.parseBoxed(myString)</p> <p>It is a fast detector.</p> @@ -696,7 +696,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues"> <Details> <![CDATA[ - <p>Looks for class that implement Comparator or Comparable, and whose compare or compareTo + <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 (a negative number, 0, and a positive number).</p> <p>It is a fast detector.</p> @@ -847,11 +847,11 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnitTestAssertionOddities"> <Details> <![CDATA[ - <p>Looks for junit or testng test case methods that use assertions with odd parameters. + <p>Looks for JUnit or TestNG test case methods that use assertions with odd parameters. Including 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> + <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> <li>Passing true or false as the first parameter instead of using assertTrue, or assertFalse</li> <li>Using the assert keyword</li> </ul> @@ -911,7 +911,7 @@ should not be counted on.</p> Packages that shouldn't be used are: <ul> - <li>com.sun.xxx</li> + <li>sun.xxx</li> <li>org.apache.xerces.xxx</li> <li>org.apache.xalan.xxx</li> </ul> @@ -1496,7 +1496,7 @@ <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: <ul> - <li>the result of a toString call</li> + <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> </ul> By using Strings you are throwing away type-safety, and making it difficult to reason about what the values of variables @@ -1513,7 +1513,7 @@ <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. 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> + <p>It is a fast detector.</p> ]]> </Details> </Detector> @@ -1521,10 +1521,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles"> <Details> <![CDATA[ - <p>Looks for methods that use the File api on resources retrieved from URLs where the URL in question isn't from a file protocol. - In the case of classpath resources, this will work if the code is executed from directories, but fail using jars. - If using resources, then use URL.openStream() method instead of File apis.</p> - <p>It is a fast detector</p> + <p>Looks for methods that use the File API on resources retrieved from URLs where the URL in question isn't from a file protocol. + In the case of classpath resources, this will work if the code is executed from directories, but fail using JARs. + If using resources, then use URL.openStream() method instead of File APIs.</p> + <p>It is a fast detector.</p> ]]> </Details> </Detector> @@ -1533,12 +1533,12 @@ <Details> <![CDATA[ <p>Looks for classes that are not fully complete from a usability point of view. Making them more difficult to use - than should be. Things such as - <UL> - <LI>Missing toString() method</LI> - </UL> + than it should be. Things such as + <ul> + <li>Missing toString() method</li> + </ul> </p> - <p>It is a moderately fast detector</p> + <p>It is a moderately fast detector.</p> ]]> </Details> </Detector> @@ -1737,7 +1737,7 @@ <![CDATA[ <p>This method declares a RuntimeException derived class in its throws clause. This may indicate a misunderstanding as to how unchecked exceptions are handled. - If is felt that a RuntimeException is so prevalent that it should be declared, it + If it is felt that a RuntimeException is so prevalent that it should be declared, it is probably a better idea to prevent the occurrence in code.</p> ]]> </Details> @@ -2195,11 +2195,11 @@ </BugPattern> <BugPattern type="COM_PARENT_DELEGATED_CALL"> - <ShortDescription>Method merely delegates to it's superclass's version</ShortDescription> - <LongDescription>Method {1} merely delegates to it's superclass's version</LongDescription> + <ShortDescription>Method merely delegates to its superclass's version</ShortDescription> + <LongDescription>Method {1} merely delegates to its superclass's version</LongDescription> <Details> <![CDATA[ - <p>This method is implemented to just delegate it's implementation by calling + <p>This method is implemented to just delegate its implementation by calling the superclass method with the same signature. This method can just be removed.</p> ]]> </Details> @@ -3123,7 +3123,7 @@ <LongDescription>Method {1} uses iterator().next() on a List to get the first item</LongDescription> <Details> <![CDATA[ - <p>This Method calls myList.iterator().next() on a List to get the first item. It is more performant + <p>This method calls myList.iterator().next() on a List to get the first item. It is more performant to just use myList.get(0).</p> ]]> </Details> @@ -3247,8 +3247,8 @@ </BugPattern> <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> - <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> - <LongDescription>Method {1} assigns a variable in a larger scope then is needed</LongDescription> + <ShortDescription>Method assigns a variable in a larger scope than is needed</ShortDescription> + <LongDescription>Method {1} assigns a variable in a larger scope than is needed</LongDescription> <Details> <![CDATA[ <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> @@ -3447,8 +3447,8 @@ </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT"> - <ShortDescription>Junit test method passes constant to second (actual) assertion parameter</ShortDescription> - <LongDescription>Junit test method {1} passes constant to second (actual) assertion parameter</LongDescription> + <ShortDescription>JUnit test method passes constant to second (actual) assertion parameter</ShortDescription> + <LongDescription>JUnit test method {1} passes constant to second (actual) assertion parameter</LongDescription> <Details> <![CDATA[ <p>This method calls assert passing a constant value as the second of the two values. The assert @@ -3459,8 +3459,8 @@ </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE"> - <ShortDescription>Junit test method asserts that two doubles are exactly equal</ShortDescription> - <LongDescription>Junit test method {1} asserts that two doubles are exactly equal</LongDescription> + <ShortDescription>JUnit test method asserts that two doubles are exactly equal</ShortDescription> + <LongDescription>JUnit test method {1} asserts that two doubles are exactly equal</LongDescription> <Details> <![CDATA[ <p>This method calls assert with two doubles or Doubles. Due to the imprecision of doubles, you @@ -3470,8 +3470,8 @@ </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT"> - <ShortDescription>Junit test method asserts that a value is true or false</ShortDescription> - <LongDescription>Junit test method {1} asserts that a value is true or false</LongDescription> + <ShortDescription>JUnit test method asserts that a value is true or false</ShortDescription> + <LongDescription>JUnit test method {1} asserts that a value is true or false</LongDescription> <Details> <![CDATA[ <p>This method asserts that a value is equal to true or false. It is simpler to just @@ -3481,8 +3481,8 @@ </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL"> - <ShortDescription>Junit test method asserts that an auto-boxed value is not null</ShortDescription> - <LongDescription>Junit test method {1} asserts that an auto-boxed value is not null</LongDescription> + <ShortDescription>JUnit test method asserts that an autoboxed value is not null</ShortDescription> + <LongDescription>JUnit test method {1} asserts that an autoboxed value is not null</LongDescription> <Details> <![CDATA[ <p>This method asserts that a primitive value that was autoboxed into a boxed primitive was not @@ -3493,66 +3493,66 @@ </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED"> - <ShortDescription>Junit test method uses Java asserts rather than a junit assertion</ShortDescription> - <LongDescription>Junit test method {1} uses Java asserts rather than a junit assertion</LongDescription> + <ShortDescription>JUnit test method uses Java asserts rather than a JUnit assertion</ShortDescription> + <LongDescription>JUnit test method {1} uses Java asserts rather than a JUnit assertion</LongDescription> <Details> <![CDATA[ <p>This method uses a Java assert to assure that a certain state is in effect. As this is - a junit test it makes more sense to either check this condition with a junit assert, or allow + a JUnit test it makes more sense to either check this condition with a JUnit assert, or allow a following exception to occur.</p> ]]> </Details> </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NULL"> - <ShortDescription>Junit test method passes null Assert.assertEquals</ShortDescription> - <LongDescription>Junit test method {1} passes null to Assert.assertEquals</LongDescription> + <ShortDescription>JUnit test method passes null Assert.assertEquals</ShortDescription> + <LongDescription>JUnit test method {1} passes null to Assert.assertEquals</LongDescription> <Details> <![CDATA[ <p>This method compares an object's equality to null. It is better to use the Assert.assertNull - method so that the junit failure method is more meaningful of the intended test.</p> + method so that the JUnit failure method is more meaningful of the intended test.</p> ]]> </Details> </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL"> - <ShortDescription>Junit test method passes null Assert.assertNotEquals</ShortDescription> - <LongDescription>Junit test method {1} passes null to Assert.assertNotEquals</LongDescription> + <ShortDescription>JUnit test method passes null Assert.assertNotEquals</ShortDescription> + <LongDescription>JUnit test method {1} passes null to Assert.assertNotEquals</LongDescription> <Details> <![CDATA[ <p>This method compares an object's inequality to null. It is better to use the Assert.assertNotNull - method so that the junit failure method is more meaningful of the intended test.</p> + method so that the JUnit failure method is more meaningful of the intended test.</p> ]]> </Details> </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS"> - <ShortDescription>Junit test method passes boolean expression to Assert.assertFalse / Assert.assertTrue</ShortDescription> - <LongDescription>Junit test method {1} passes boolean expression to Assert.assertFalse / Assert.assertTrue</LongDescription> + <ShortDescription>JUnit test method passes boolean expression to Assert.assertFalse / Assert.assertTrue</ShortDescription> + <LongDescription>JUnit test method {1} passes boolean expression to Assert.assertFalse / Assert.assertTrue</LongDescription> <Details> <![CDATA[ <p>This method evaluates a boolean expression and passes that to Assert.assertFalse / Assert.assertTrue. It is better to pass the two values that are being equated to the Assert.assertEquals method so that the - junit failure method is more meaningful of the intended test.</p> + JUnit failure method is more meaningful of the intended test.</p> ]]> </Details> </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS"> - <ShortDescription>Junit test method passes boolean expression to Assert.assertFalse / Assert.assertTrue</ShortDescription> - <LongDescription>Junit test method {1} passes boolean expression to Assert.assertFalse / Assert.assertTrue</LongDescription> + <ShortDescription>JUnit test method passes boolean expression to Assert.assertFalse / Assert.assertTrue</ShortDescription> + <LongDescription>JUnit test method {1} passes boolean expression to Assert.assertFalse / Assert.assertTrue</LongDescription> <Details> <![CDATA[ <p>This method evaluates a boolean expression and passes that to Assert.assertFalse / Assert.assertTrue. It is better to pass the two values that are being equated to the Assert.assertNotEquals method so that the - junit failure method is more meaningful of the intended test.</p> + JUnit failure method is more meaningful of the intended test.</p> ]]> </Details> </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT"> - <ShortDescription>Junit test method appears to have no assertions</ShortDescription> - <LongDescription>Junit test method {1} appears to have no assertions</LongDescription> + <ShortDescription>JUnit test method appears to have no assertions</ShortDescription> + <LongDescription>JUnit test method {1} appears to have no assertions</LongDescription> <Details> <![CDATA[ <p>This JUnit test method has no assertions. While a unit test could still be valid if it relies on whether @@ -3569,7 +3569,7 @@ <Details> <![CDATA[ <p>This JUnit 4 test is still using classes from the junit.framework.* package. You should switch them - over to the corresponding org.junit.* set of classes, instead</p> + over to the corresponding org.junit.* set of classes, instead.</p> ]]> </Details> </BugPattern> @@ -3609,8 +3609,8 @@ </BugPattern> <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL"> - <ShortDescription>TestNG test method asserts that an auto-boxed value is not null</ShortDescription> - <LongDescription>TestNG test method {1} asserts that an auto-boxed value is not null</LongDescription> + <ShortDescription>TestNG test method asserts that an autoboxed value is not null</ShortDescription> + <LongDescription>TestNG test method {1} asserts that an autoboxed value is not null</LongDescription> <Details> <![CDATA[ <p>This method asserts that a primitive value that was autoboxed into a boxed primitive was not @@ -3621,12 +3621,12 @@ </BugPattern> <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED"> - <ShortDescription>TestNG test method uses Java asserts rather than a testng assertion</ShortDescription> - <LongDescription>TestNG test method {1} uses Java asserts rather than a testng assertion</LongDescription> + <ShortDescription>TestNG test method uses Java asserts rather than a TestNG assertion</ShortDescription> + <LongDescription>TestNG test method {1} uses Java asserts rather than a TestNG assertion</LongDescription> <Details> <![CDATA[ <p>This method uses a Java assert to assure that a certain state is in effect. As this is - a testng test it makes more sense to either check this condition with a testng assert, or allow + a TestNG test it makes more sense to either check this condition with a TestNG assert, or allow a following exception to occur.</p> ]]> </Details> @@ -3724,7 +3724,7 @@ <p>This method catches an exception and generates a new exception of type java.lang.Exception, passing the original exception as the new Exception's cause. If the original Exception was actually an java.lang.Error, this is dubious as you should not be handling errors. If the original exception is a more specific exception, there is no - reason to wrap it in an exception of the java.lang.Exception class, and just obfuscates the type of error that is occuring. + reason to wrap it in an exception of the java.lang.Exception class, and just obfuscates the type of error that is occurring. </p> ]]> </Details> @@ -3852,7 +3852,7 @@ to change or removal. You should not be using these classes.</p> Packages that shouldn't be used are: <ul> - <li>com.sun.xxx</li> + <li>sun.xxx</li> <li>org.apache.xerces.xxx</li> <li>org.apache.xalan.xxx</li> </ul> @@ -3872,9 +3872,9 @@ type functionality, which seems dubious when done on a collection</p> <p>Finally, as a collection is often modified, problems will occur if the collection is contained in a set, because the hashCode, equals or compareTo values will change while the - collection is in the set</p> + collection is in the set.</p> <p>If you wish to maintain a collection of collections, it is probably better to use a List - as the outer collection</p> + as the outer collection.</p> ]]> </Details> </BugPattern> @@ -4172,7 +4172,7 @@ <LongDescription>Method {1} calls deprecated SecureRandom method {2}</LongDescription> <Details> <![CDATA[ - <p>The <code>In JDK 1.5 or less, SecureRandom()</code> constructors and <code>SecureRandom.getSeed()</code> method are recommended against using. Call <code>SecureRandom.getInstance()</code> and <code>SecureRandom.getInstance().generateSeed()</code> instead.</p> + <p>In JDK 1.5 or less, the <code>SecureRandom()</code> constructors and <code>SecureRandom.getSeed()</code> method are recommended against using. Call <code>SecureRandom.getInstance()</code> and <code>SecureRandom.getInstance().generateSeed()</code> instead.</p> ]]> </Details> </BugPattern> @@ -4246,7 +4246,7 @@ <p>As per the Java specifications, "UTF-8", "US-ASCII", "UTF-16" and "ISO-8859-1" will all be valid <a href = "http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html#standard">encoding charsets</a>. If you aren't sure, try "UTF-8".</p> - <p><b>New in Java 1.7</b>, You can specify an encoding from <code>StandardCharsets</code>, like <code>StandardCharsets.UTF_8</code>. These are generally preferrable because you don't have to deal with <code>UnsupportedEncodingException</code>.</p> + <p><b>New in Java 1.7</b>, you can specify an encoding from <code>StandardCharsets</code>, like <code>StandardCharsets.UTF_8</code>. These are generally preferrable because you don't have to deal with <code>UnsupportedEncodingException</code>.</p> ]]> </Details> </BugPattern> @@ -4450,7 +4450,7 @@ <LongDescription>Method {1} compares class name instead of comparing the class</LongDescription> <Details> <![CDATA[ - <p>In a JVM, Two classes are the same class (and consequently the same type) if + <p>In a JVM, two classes are the same class (and consequently the same type) if they are loaded by the same class loader, and they have the same fully qualified name [JVMSpec 1999]. @@ -4484,8 +4484,8 @@ </BugPattern> <BugPattern type="CU_CLONE_USABILITY_MISMATCHED_RETURN"> - <ShortDescription>Clone method declares it returns a type different then the owning class</ShortDescription> - <LongDescription>Clone method {1} declares it returns a type different then the owning class</LongDescription> + <ShortDescription>Clone method declares it returns a type different than the owning class</ShortDescription> + <LongDescription>Clone method {1} declares it returns a type different than the owning class</LongDescription> <Details> <![CDATA[ <p>This class implements the Cloneable interface but defines its clone method to return a type @@ -4531,7 +4531,7 @@ and thus needlessly causes intermediate reallocations of the collection.</p> <p>You can use the constructor that takes an initial size and that will be much better, but due to the loadFactor of Maps and Sets, even this will not be a correct estimate.</p> - <p>If you are using guava, use its methods that allocate maps and sets with a predetermined size, + <p>If you are using Guava, use its methods that allocate maps and sets with a predetermined size, to get the best chance for no reallocations, such as: <ul> <li>Sets.newHashSetWithExpectedSize(int)</li> @@ -4655,7 +4655,7 @@ <Details> <![CDATA[ <p>This method attempts to modify a collection that it got from a source that could potentially have created an - immutable collection, thru Arrays.asList, Collections.unmodifiableXXX, or one of guava's methods. Doing so will cause + immutable collection, through Arrays.asList, Collections.unmodifiableXXX, or one of Guava's methods. Doing so will cause an exception, as these collections are not mutable.</p> ]]> </Details> @@ -4979,13 +4979,13 @@ </BugPattern> <BugPattern type="CRF_CONFLATING_RESOURCES_AND_FILES"> - <ShortDescription>This method accesses URL resources using the File api</ShortDescription> - <LongDescription>This method {1} accesses URL resources using the File api]</LongDescription> + <ShortDescription>This method accesses URL resources using the File API</ShortDescription> + <LongDescription>This method {1} accesses URL resources using the File API</LongDescription> <Details> <![CDATA[ - <p>This method fetches a resource from a URL, and uses the File api to manipulate it. If this resource is a - classpath resource, it will work if the resource is a file in a directory. If however the file is inside a jar file - this will fail. Use the URL.openStream api instead to access the data of the classpath resource. + <p>This method fetches a resource from a URL, and uses the File API to manipulate it. If this resource is a + classpath resource, it will work if the resource is a file in a directory. If however the file is inside a JAR file + this will fail. Use the URL.openStream API instead to access the data of the classpath resource. </p> ]]> </Details> @@ -4996,7 +4996,7 @@ <LongDescription>Class {0} does not implement an equals method</LongDescription> <Details> <![CDATA[ - <p>This class which has instance fields has no equals(Object o) method, It is possible that this + <p>This class which has instance fields has no equals(Object o) method. It is possible that this class is never used in a context where this is required, it is often assumed, however, from clients of this class that it is, so it is good to add such methods when you create them. </p> @@ -5009,7 +5009,7 @@ <LongDescription>Class {0} does not implement a hashCode method</LongDescription> <Details> <![CDATA[ - <p>This class which has instance fields has no hashCode() method, It is possible that this + <p>This class which has instance fields has no hashCode() method. It is possible that this class is never used in a context where this is required, it is often assumed, however, from clients of this class that it is, so it is good to add such methods when you create them. </p> @@ -5050,7 +5050,7 @@ <Details> <![CDATA[ <p>This JAX-RS endpoint is annotated to be used as @GET requests, but also documents that it - consumes JSON or XML data. Since a get request pulls parameters from the url, and not + consumes JSON or XML data. Since a GET request pulls parameters from the URL, and not the body of request, this pattern is problematic. If you wish to consume JSON or XML data, this request should be annotated with @POST. ]]> @@ -5075,7 +5075,7 @@ <li>javax.servlet.HttpServletRequest</li> <li>javax.servlet.HttpServletResponse</li> </ul> - It is possible that your container can supply additional types, but these types are not standard are may + It is possible that your container can supply additional types, but these types are not standard and may not be supported on other application servers.</p> ]]> </Details> @@ -5099,7 +5099,7 @@ <![CDATA[ <p>This JAX-RS endpoint declares parameters without specifying where the value of this parameter comes from. You can specify this by using one of several 'Param' annotations (@PathParam, @CookieParam, @FormParam @HeaderParam @MatrixParam @QueryParam), - by adding a @Context parameter annotation, or you can declare that the method @Consumes an xml or json stream. + by adding a @Context parameter annotation, or you can declare that the method @Consumes an XML or JSON stream. ]]> </Details> </BugPattern> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/pom.xml 2015-12-12 17:33:56 UTC (rev 1786) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>6.4.0</version> + <version>6.5.0-SNAPSHOT</version> <prerequisites> <maven>2.2.1</maven> @@ -74,6 +74,9 @@ <name>Juan Martín Sotuyo Dodero</name> <email>jua...@gm...</email> </contributor> + <contributor> + <name>Richard Fearn</name> + </contributor> </contributors> <licenses> Modified: trunk/fb-contrib/samples/ISB_Sample.java =================================================================== --- trunk/fb-contrib/samples/ISB_Sample.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/samples/ISB_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -116,5 +116,15 @@ public String xform(String a) { return a; } + + enum MonsterSpeak {UNGA, BUNGA} + + public String speak(MonsterSpeak s) { + return "hello" + 1 + s.toString(); + } + + public String fpSpeak(MonsterSpeak s) { + return 1 + s.toString(); + } } Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/samples/SPP_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -1,6 +1,8 @@ import java.io.Serializable; import java.lang.reflect.Array; import java.math.BigDecimal; +import java.sql.PreparedStatement; +import java.sql.SQLException; import java.util.ArrayList; import java.util.BitSet; import java.util.Calendar; @@ -396,7 +398,12 @@ return t.equals("foo"); } - + + public void fpGitHubIssue81(PreparedStatement sqlQuery, String name) throws SQLException { + if (name != null && !(name = name.trim()).equals("")) { + sqlQuery.setString(1, name + "%"); + } + } } class StringProducer { Modified: trunk/fb-contrib/samples/WOC_Sample.java =================================================================== --- trunk/fb-contrib/samples/WOC_Sample.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/samples/WOC_Sample.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -45,6 +45,13 @@ System.out.println("woops"); } } + + public void testIterateEmpty() { + Set<String> ss = new HashSet<String>(); + + for (String s : ss) { + } + } public Map<String, String> testFPWOCReturn() { // no tag, value is returned Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -21,8 +21,8 @@ import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; -import java.io.FileOutputStream; import java.io.PrintStream; import java.nio.charset.StandardCharsets; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; @@ -57,7 +58,7 @@ String curMethodDesc = getClassContext().getJavaClass().getClassName() + "." + m.getName() + m.getSignature(); if (curMethodDesc.equals(METHOD_DESC)) { try { - pw = new PrintWriter(OUTPUT_FILE_NAME, "UTF-8"); + pw = new PrintWriter(OUTPUT_FILE_NAME, StandardCharsets.UTF_8.name()); stack.resetForMethodEntry(this); super.visitCode(obj); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -216,6 +216,12 @@ if (catchHandlers.get(pc)) { ignoreRegs.set(reg); + ScopeBlock catchSB = findScopeBlock(rootScopeBlock, pc+1); + if ((catchSB != null) && (catchSB.getStart() < pc)) { + ScopeBlock sb = new ScopeBlock(pc, catchSB.getFinish()); + catchSB.setFinish(getPC() - 1); + rootScopeBlock.addChild(sb); + } } else if (monitorSyncPCs.size() > 0) { ignoreRegs.set(reg); } else if (sawNull) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -171,10 +171,11 @@ case INVOKEVIRTUAL: case INVOKEINTERFACE: case INVOKESTATIC: - FQMethod methodCall = new FQMethod(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand()); + String signature = getSigConstantOperand(); + FQMethod methodCall = new FQMethod(getClassConstantOperand(), getNameConstantOperand(), signature); unit = TIME_UNIT_GENERATING_METHODS.get(methodCall); if (unit == Units.CALLER) { - int offset = Type.getArgumentTypes(getSigConstantOperand()).length; + int offset = Type.getArgumentTypes(signature).length; if (stack.getStackDepth() > offset) { OpcodeStack.Item item = stack.getStackItem(offset); unit = (Units) item.getUserValue(); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -35,6 +35,7 @@ import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.ToString; +import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import com.mebigfatguy.fbcontrib.utils.Values; import edu.umd.cs.findbugs.BugInstance; @@ -55,27 +56,16 @@ */ public class HangingExecutors extends BytecodeScanningDetector { - private static final Set<String> hangableSig; + private static final Set<String> hangableSig = UnmodifiableSet.create( + "Ljava/util/concurrent/ExecutorService;", + "Ljava/util/concurrent/AbstractExecutorService;", + "Ljava/util/concurrent/ForkJoinPool;", + "Ljava/util/concurrent/ScheduledThreadPoolExecutor;", + "Ljava/util/concurrent/ThreadPoolExecutor;" + ); - static { - Set<String> hs = new HashSet<String>(); - hs.add("Ljava/util/concurrent/ExecutorService;"); - hs.add("Ljava/util/concurrent/AbstractExecutorService;"); - hs.add("Ljava/util/concurrent/ForkJoinPool;"); - hs.add("Ljava/util/concurrent/ScheduledThreadPoolExecutor;"); - hs.add("Ljava/util/concurrent/ThreadPoolExecutor;"); - hangableSig = Collections.unmodifiableSet(hs); - } + private static final Set<String> shutdownMethods = UnmodifiableSet.create("shutdown","shutdownNow"); - private static final Set<String> shutdownMethods; - - static { - Set<String> sm = new HashSet<String>(); - sm.add("shutdown"); - sm.add("shutdownNow"); - shutdownMethods = Collections.unmodifiableSet(sm); - } - private final BugReporter bugReporter; private Map<XField, AnnotationPriority> hangingFieldCandidates; private Map<XField, Integer> exemptExecutors; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -1,9 +1,9 @@ package com.mebigfatguy.fbcontrib.detect; +import org.apache.bcel.Repository; import org.apache.bcel.classfile.AnnotationEntry; import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.Repository; import com.mebigfatguy.fbcontrib.collect.MethodInfo; import com.mebigfatguy.fbcontrib.collect.Statistics; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -19,7 +19,6 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -32,6 +31,7 @@ import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import com.mebigfatguy.fbcontrib.utils.SignatureUtils; import com.mebigfatguy.fbcontrib.utils.TernaryPatcher; +import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -51,35 +51,31 @@ @CustomUserValue public class InappropriateToStringUse extends BytecodeScanningDetector { - private static final Set<String> validToStringClasses = new HashSet<String>(); + private static final Set<String> validToStringClasses = UnmodifiableSet.create( + "java/lang/Object", // too many fps + "java/lang/Byte", + "java/lang/Character", + "java/lang/Short", + "java/lang/Integer", + "java/lang/Boolean", + "java/lang/Float", + "java/lang/Double", + "java/lang/Long", + "java/lang/String", + "java/lang/Number", + "java/lang/StringBuffer", + "java/lang/StringBuilder", + "java/io/StringWriter" + ); - static { - validToStringClasses.add("java/lang/Object"); // too many fps - validToStringClasses.add("java/lang/Byte"); - validToStringClasses.add("java/lang/Character"); - validToStringClasses.add("java/lang/Short"); - validToStringClasses.add("java/lang/Integer"); - validToStringClasses.add("java/lang/Boolean"); - validToStringClasses.add("java/lang/Float"); - validToStringClasses.add("java/lang/Double"); - validToStringClasses.add("java/lang/Long"); - validToStringClasses.add("java/lang/String"); - validToStringClasses.add("java/lang/Number"); - validToStringClasses.add("java/lang/StringBuffer"); - validToStringClasses.add("java/lang/StringBuilder"); - validToStringClasses.add("java/io/StringWriter"); - } + private static final Set<String> stringAlgoMethods = UnmodifiableSet.create( + "indexOf", + "contains", + "startsWith", + "endsWith", + "substring" + ); - private static final Set<String> stringAlgoMethods = new HashSet<String>(); - - static { - stringAlgoMethods.add("indexOf"); - stringAlgoMethods.add("contains"); - stringAlgoMethods.add("startsWith"); - stringAlgoMethods.add("endsWith"); - stringAlgoMethods.add("substring"); - } - private final BugReporter bugReporter; private OpcodeStack stack; private Map<Integer, String> toStringRegisters; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -18,7 +18,6 @@ */ package com.mebigfatguy.fbcontrib.detect; -import java.util.HashSet; import java.util.Set; import org.apache.bcel.classfile.Constant; @@ -28,6 +27,7 @@ import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.ToString; +import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -40,23 +40,24 @@ */ public class IncorrectInternalClassUse implements Detector { private final BugReporter bugReporter; - private static final Set<String> internalPackages = new HashSet<String>(); - private static final Set<String> externalPackages = new HashSet<String>(); - static { - internalPackages.add("sun/"); - internalPackages.add("org/apache/commons/digester/annotations/internal"); - internalPackages.add("org/apache/xerces/"); - internalPackages.add("org/apache/xalan/"); - internalPackages.add("org/mockito/internal/"); - internalPackages.add("org/springframework/asm/"); - internalPackages.add("org/springframework/cglib/"); - internalPackages.add("org/springframework/objenesis/"); - externalPackages.add("org/apache/xerces/xni/"); - externalPackages.add("org/apache/xerces/xs/"); - externalPackages.add("org/apache/xalan/extensions"); - } - + private static final Set<String> internalPackages = UnmodifiableSet.create( + "sun/", + "org/apache/commons/digester/annotations/internal", + "org/apache/xerces/", + "org/apache/xalan/", + "org/mockito/internal/", + "org/springframework/asm/", + "org/springframework/cglib/", + "org/springframework/objenesis/" + ); + + private static final Set<String> externalPackages = UnmodifiableSet.create( + "org/apache/xerces/xni/", + "org/apache/xerces/xs/", + "org/apache/xalan/extensions" + ); + /** * constructs a IICU detector given the reporter to report bugs on * @@ -99,6 +100,7 @@ */ @Override public void report() { + // not used, required by the interface } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -25,6 +25,7 @@ import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.OpcodeUtils; import com.mebigfatguy.fbcontrib.utils.TernaryPatcher; +import com.mebigfatguy.fbcontrib.utils.ToString; import com.mebigfatguy.fbcontrib.utils.Values; import edu.umd.cs.findbugs.BugInstance; @@ -40,7 +41,7 @@ @CustomUserValue public class InefficientStringBuffering extends BytecodeScanningDetector { private enum AppendType { - NONE, CLEAR, NESTED, TOSTRING + CLEAR, NESTED, TOSTRING }; private BugReporter bugReporter; @@ -90,23 +91,24 @@ @Override public void sawOpcode(final int seen) { - AppendType apType = AppendType.NONE; + ISBUserValue userValue = null; + try { stack.precomputation(this); if (seen == INVOKESPECIAL) { - apType = sawInvokeSpecial(apType); + userValue = sawInvokeSpecial(userValue); } else if (seen == INVOKEVIRTUAL) { if (sawLDCEmpty) { dealWithEmptyString(); } - apType = sawInvokeVirtual(apType); + userValue = sawInvokeVirtual(userValue); } else if ((seen == GOTO) || (seen == GOTO_W)) { int depth = stack.getStackDepth(); for (int i = 0; i < depth; i++) { OpcodeStack.Item itm = stack.getStackItem(i); - itm.setUserValue(AppendType.NONE); + itm.setUserValue(null); } } else if ((seen == LDC) || (seen == LDC_W)) { Constant c = getConstantRefOperand(); @@ -117,14 +119,14 @@ } } } else if (OpcodeUtils.isALoad(seen)) { - apType = AppendType.CLEAR; + userValue = new ISBUserValue(AppendType.CLEAR, true); } } finally { handleOpcode(seen); - if (apType != AppendType.NONE) { + if (userValue != null) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); - itm.setUserValue(apType); + itm.setUserValue(userValue); } } } @@ -136,43 +138,60 @@ TernaryPatcher.post(stack, seen); } - private AppendType sawInvokeVirtual(AppendType apType) { + private ISBUserValue sawInvokeVirtual(ISBUserValue userValue) { String calledClass = getClassConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) || "java/lang/StringBuilder".equals(calledClass))) { String methodName = getNameConstantOperand(); if ("append".equals(methodName)) { OpcodeStack.Item itm = getStringBufferItemAt(1); - apType = (itm == null) ? AppendType.NONE : (AppendType) itm.getUserValue(); + userValue = (ISBUserValue) itm.getUserValue(); if (stack.getStackDepth() > 0) { itm = stack.getStackItem(0); - Object userVal = itm.getUserValue(); - AppendType apValue = (userVal instanceof AppendType ? (AppendType) userVal : AppendType.NONE); - switch (apValue) { - case NESTED: - bugReporter.reportBug(new BugInstance(this, BugType.ISB_INEFFICIENT_STRING_BUFFERING.name(), - "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this)); - break; - case TOSTRING: - bugReporter.reportBug(new BugInstance(this, BugType.ISB_TOSTRING_APPENDING.name(), NORMAL_PRIORITY).addClass(this).addMethod(this) - .addSourceLine(this)); - break; - default: - break; + ISBUserValue uv = (ISBUserValue) itm.getUserValue(); + if (uv != null) { + switch (uv.getAppendType()) { + case NESTED: + bugReporter.reportBug(new BugInstance(this, BugType.ISB_INEFFICIENT_STRING_BUFFERING.name(), + "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this)); + break; + case TOSTRING: + if (stack.getStackDepth() > 1) { + itm = stack.getStackItem(1); + if (itm != null) { + uv = (ISBUserValue) itm.getUserValue(); + + if ((uv != null) && uv.hasResolvedString()) { + bugReporter.reportBug(new BugInstance(this, BugType.ISB_TOSTRING_APPENDING.name(), NORMAL_PRIORITY).addClass(this).addMethod(this) + .addSourceLine(this)); + } + } + } + break; + default: + break; + } } } + + if (getSigConstantOperand().startsWith("(Ljava/lang/String;)")) { + if (userValue == null) { + userValue = new ISBUserValue(AppendType.CLEAR, true); + } else { + userValue = new ISBUserValue(userValue.getAppendType(), true); + } + } } else if ("toString".equals(methodName)) { OpcodeStack.Item itm = getStringBufferItemAt(0); - apType = (itm == null) ? AppendType.NONE : (AppendType) itm.getUserValue(); + userValue = (ISBUserValue) itm.getUserValue(); } } else if ("toString".equals(getNameConstantOperand()) && "()Ljava/lang/String;".equals(getSigConstantOperand())) { - // calls to this.toString() are okay, some people like to be - // explicit + // calls to this.toString() are okay, some people like to be explicit if ((stack.getStackDepth() > 0) && (stack.getStackItem(0).getRegisterNumber() != 0)) { - apType = AppendType.TOSTRING; + userValue = new ISBUserValue(AppendType.TOSTRING); } } - return apType; + return userValue; } private void dealWithEmptyString() { @@ -195,7 +214,7 @@ } } - private AppendType sawInvokeSpecial(AppendType apType) { + private ISBUserValue sawInvokeSpecial(ISBUserValue userValue) { String calledClass = getClassConstantOperand(); if (("java/lang/StringBuffer".equals(calledClass) || "java/lang/StringBuilder".equals(calledClass)) && Values.CONSTRUCTOR.equals(getNameConstantOperand())) { @@ -203,20 +222,24 @@ if ("()V".equals(signature)) { OpcodeStack.Item itm = getStringBufferItemAt(2); if (itm != null) { - apType = AppendType.NESTED; + userValue = new ISBUserValue(AppendType.NESTED); } } else if ("(Ljava/lang/String;)V".equals(signature)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); - apType = (AppendType) itm.getUserValue(); - if (apType == AppendType.NESTED) { + userValue = (ISBUserValue) itm.getUserValue(); + if ((userValue != null) && userValue.getAppendType() == AppendType.NESTED) { bugReporter.reportBug(new BugInstance(this, BugType.ISB_INEFFICIENT_STRING_BUFFERING.name(), NORMAL_PRIORITY).addClass(this) .addMethod(this).addSourceLine(this)); } + + if (userValue == null) { + userValue = new ISBUserValue(AppendType.CLEAR, true); + } } } } - return apType; + return userValue; } private OpcodeStack.Item getStringBufferItemAt(int depth) { @@ -230,4 +253,53 @@ return null; } + + class ISBUserValue { + + private AppendType appendType; + private boolean hasResolvedString; + + public ISBUserValue(AppendType appType) { + this(appType, false); + } + + public ISBUserValue(AppendType appType, boolean resolved) { + appendType = appType; + hasResolvedString = resolved; + } + + public AppendType getAppendType() { + return appendType; + } + + public boolean hasResolvedString() { + return hasResolvedString; + } + + @Override + public int hashCode() { + return appendType.hashCode() ^ (hasResolvedString ? 1 : 0); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ISBUserValue)) { + return false; + } + + ISBUserValue that = (ISBUserValue) obj; + return (appendType == that.appendType) && (hasResolvedString == that.hasResolvedString); + } + + private InefficientStringBuffering getOuterType() { + return InefficientStringBuffering.this; + } + + @Override + public String toString() { + return ToString.build(this); + } + + + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -144,7 +144,7 @@ if (stack.getStackDepth() > parmOffset) { OpcodeStack.Item item = stack.getStackItem(parmOffset); - Comparable<?> cons = (Comparable<?>) item.getConstant(); + Comparable cons = (Comparable) item.getConstant(); if (!info.isValid(cons)) { int badParm = 1 + (info.fromStart ? info.parameterOffset : Type.getArgumentTypes(sig).length - info.parameterOffset - 1); bugReporter.reportBug(new BugInstance(this, BugType.ICA_INVALID_CONSTANT_ARGUMENT.name(), NORMAL_PRIORITY).addClass(this) @@ -169,7 +169,7 @@ * legal values, and what offset from the start or end of the method the parm * is */ - static class ParameterInfo<T extends Comparable<?>> { + static class ParameterInfo<T extends Comparable<T>> { private int parameterOffset; private boolean fromStart; private Set<T> validValues; @@ -198,7 +198,7 @@ return info; } - public boolean isValid(Comparable o) { + public boolean isValid(Comparable<T> o) { if (o == null) { return true; } @@ -211,7 +211,7 @@ } } - static class Range<T extends Comparable<?>> { + static class Range<T extends Comparable<T>> { T from; T to; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -26,6 +26,7 @@ import org.apache.bcel.Constants; import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -61,12 +62,8 @@ synchClassMethods.put("java/util/Collections", syncMethods); } - private static final Set<String> selfReturningMethods = new HashSet<String>(); + private static final Set<String> selfReturningMethods = UnmodifiableSet.create("java/lang/StringBuffer.append"); - static { - selfReturningMethods.add("java/lang/StringBuffer.append"); - } - private BugReporter bugReporter; /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2015-11-25 22:58:52 UTC (rev 1785) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2015-12-12 17:33:56 UTC (rev 1786) @@ -34,7 +34,6 @@ import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.OpcodeUtils; -import com.mebigfat... [truncated message content] |
From: <dbr...@us...> - 2015-11-25 22:58:54
|
Revision: 1785 http://sourceforge.net/p/fb-contrib/code/1785 Author: dbrosius Date: 2015-11-25 22:58:52 +0000 (Wed, 25 Nov 2015) Log Message: ----------- Version 6.4.0 Added Paths: ----------- tags/v6_4_0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2015-11-25 22:44:58
|
Revision: 1784 http://sourceforge.net/p/fb-contrib/code/1784 Author: dbrosius Date: 2015-11-25 22:44:53 +0000 (Wed, 25 Nov 2015) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-11-25 21:51:59 UTC (rev 1783) +++ trunk/fb-contrib/build.xml 2015-11-25 22:44:53 UTC (rev 1784) @@ -20,7 +20,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="6.3.0" /> + <property name="fb-contrib.version" value="6.4.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-11-25 21:51:59 UTC (rev 1783) +++ trunk/fb-contrib/etc/findbugs.xml 2015-11-25 22:44:53 UTC (rev 1784) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -32,7 +32,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" /> @@ -282,8 +282,6 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousLoopSearch" speed="fast" reports="SLS_SUSPICIOUS_LOOP_SEARCH" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles" speed="fast" reports="CRF_CONFLATING_RESOURCES_AND_FILES" /> - - <!-- COMMENT OUT FOR POINT RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod" speed="fast" reports="OPM_OVERLY_PERMISSIVE_METHOD" /> @@ -294,6 +292,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues" speed="fast" reports="JXI_GET_ENDPOINT_CONSUMES_CONTENT,JXI_INVALID_CONTEXT_PARAMETER_TYPE,JXI_PARM_PARAM_NOT_FOUND_IN_PATH,JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT" /> <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -529,9 +528,9 @@ <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME" category="CORRECTNESS"/> <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING" category="CORRECTNESS"/> <BugPattern abbrev="CBC" type="CBC_CONTAINS_BASED_CONDITIONAL" category="STYLE"/> - <BugPattern abbrev="OPM" type="OPM_OVERLY_PERMISSIVE_METHOD" category="STYLE" experimental="true" /> - <BugPattern abbrev="STT" type="STT_STRING_PARSING_A_FIELD" category="STYLE" experimental="true" /> - <BugPattern abbrev="STT" type="STT_TOSTRING_STORED_IN_FIELD" category="STYLE" experimental="true" /> + <BugPattern abbrev="OPM" type="OPM_OVERLY_PERMISSIVE_METHOD" category="STYLE" /> + <BugPattern abbrev="STT" type="STT_STRING_PARSING_A_FIELD" category="STYLE" /> + <BugPattern abbrev="STT" type="STT_TOSTRING_STORED_IN_FIELD" category="STYLE" /> <BugPattern abbrev="SLS" type="SLS_SUSPICIOUS_LOOP_SEARCH" category="CORRECTNESS" /> <BugPattern abbrev="CRF" type="CRF_CONFLATING_RESOURCES_AND_FILES" category="CORRECTNESS" /> <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_NO_EQUALS" category="STYLE" /> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2015-11-25 21:51:59 UTC (rev 1783) +++ trunk/fb-contrib/htdocs/index.shtml 2015-11-25 22:44:53 UTC (rev 1784) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 6.2.3 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 6.4.0 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on @@ -86,7 +86,14 @@ same kind of exception, and throw the same exception always. These blocks can be coalesced into one. </li> - <li><b>[OPM] Overly Permissive Method</b><br/> + </ul> + </div> + <hr/> + <img id="v6_4_0_image" src="flip2.gif" onClick="toggleBlock('v6_4_0', 'v6_4_0_image');" align="top"/> + Detectors added in v6.4.0<br/> + <div id="v6_4_0" style="display:block;"> + <ul> + <li><b>[OPM] Overly Permissive Method</b><br/> 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. </li> @@ -98,12 +105,15 @@ Looks for classes that are not fully implemented to be a well rounded class. While the class will likely work fine, it is more difficult to use or understand than necessary. </li> - </ul> - </div> + <li><b>[JXI] JAX-RS Issues</b><br/> + Looks for problems with the use of the JAX-RS specification. + </li> + </ul> + </div> <hr/> <img id="v6_2_0_image" src="flip2.gif" onClick="toggleBlock('v6_2_0', 'v6_2_0_image');" align="top"/> Detectors added in v6.2.0<br/> - <div id="v6_2_0" style="display:block;"> + <div id="v6_2_0" style="display:none;"> <ul> <li><b>[CSI] Charset Issues</b><br/> Looks for issues related to manually specified charsets by using string literals. Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2015-11-25 21:51:59 UTC (rev 1783) +++ trunk/fb-contrib/htdocs/repository.html 2015-11-25 22:44:53 UTC (rev 1784) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>6.2.3</td></tr> + <tr><td><b>Version:</b></td><td>6.4.0</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2015-11-25 21:51:59 UTC (rev 1783) +++ trunk/fb-contrib/pom.xml 2015-11-25 22:44:53 UTC (rev 1784) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>6.3.0-SNAPSHOT</version> + <version>6.4.0</version> <prerequisites> <maven>2.2.1</maven> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2015-11-25 21:52:04
|
Revision: 1783 http://sourceforge.net/p/fb-contrib/code/1783 Author: dbrosius Date: 2015-11-25 21:51:59 +0000 (Wed, 25 Nov 2015) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/.classpath 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/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/AWCBR_Sample.java trunk/fb-contrib/samples/LSC_Sample.java trunk/fb-contrib/samples/LSYC_Sample.java trunk/fb-contrib/samples/OCP_Sample.java trunk/fb-contrib/samples/OPM_Sample.java trunk/fb-contrib/samples/SCRV_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/UTAO_Sample.java trunk/fb-contrib/samples/WOC_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CharsetIssues.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/CollectionNamingConfusion.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflatingResourcesAndFiles.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.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/ContainsBasedConditional.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/DateComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.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/InvalidConstantArgument.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalTypeDetector.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.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/NonProductiveMethodCall.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/OverlyPermissiveMethod.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/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Unjitable.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/UseVarArgs.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/PublicAPI.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/ToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/samples/IMC_Sample.java trunk/fb-contrib/samples/JXI_Sample.java trunk/fb-contrib/samples/STT_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JAXRSIssues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/RuntimeExceptionDeclared.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StringifiedTypes.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/FQMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/UnmodifiableSet.java Removed Paths: ------------- trunk/fb-contrib/samples/CIS_Sample.java trunk/fb-contrib/samples/SC_Sample.java trunk/fb-contrib/samples/SMA_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassImpersonatingString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/.classpath 2015-11-25 21:51:59 UTC (rev 1783) @@ -24,8 +24,8 @@ </classpathentry> <classpathentry kind="lib" path="lib/commons-codec-1.6.jar"/> <classpathentry kind="lib" path="lib/findbugs-3.0.1.jar" sourcepath="lib/sources/findbugs-3.0.1-sources.jar"/> - <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> <classpathentry kind="lib" path="lib/junit-4.12.jar"/> <classpathentry kind="lib" path="lib/testng-6.9.6.jar"/> + <classpathentry kind="lib" path="lib/jsr311-api-1.1.1.jar" sourcepath="lib/sources/jsr311-api-1.1.1-sources.jar"/> <classpathentry kind="output" path="target/classes/main"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/build.xml 2015-11-25 21:51:59 UTC (rev 1783) @@ -15,8 +15,8 @@ <property name="samples.classes.dir" value="${target.dir}/classes/samples" /> <property name="javadoc.dir" value="${target.dir}/javadoc" /> <property name="htdocs.dir" value="${basedir}/htdocs" /> - <property name="javac.source" value="1.6" /> - <property name="javac.target" value="1.6" /> + <property name="javac.source" value="1.7" /> + <property name="javac.target" value="1.7" /> <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> @@ -32,7 +32,7 @@ <target name="infra_jars" description="pull jars needed to build fb-contrib to ${user.dir}/.ant/lib"> <mkdir dir="${user.home}/.ant/lib" /> <get src="http://repo1.maven.org/maven2/com/mebigfatguy/yank/yank/1.4.0/yank-1.4.0.jar" dest="${user.home}/.ant/lib"/> - <get src="https://bitbucket.org/klubick/bugrankcheckstyle/downloads/bug-rank-check-style-1.0.0.jar" dest="${user.home}/.ant/lib"/> + <get src="https://bitbucket.org/kjlubick/bugrankcheckstyle/downloads/bug-rank-check-style-1.0.0.jar" dest="${user.home}/.ant/lib"/> <get src="http://repo1.maven.org/maven2/com/mebigfatguy/vcsversion/vcsversion/0.4.0/vcsversion-0.4.0.jar" dest="${user.home}/.ant/lib"/> </target> @@ -92,6 +92,7 @@ <pathelement location="${lib.dir}/httpcore-${httpcore.version}.jar" /> <pathelement location="${lib.dir}/httpclient-${httpclient.version}.jar" /> <pathelement location="${lib.dir}/commons-codec-${commons-codec.version}.jar" /> + <pathelement location="${lib.dir}/jsr311-api-${jsr311-api.version}.jar" /> </path> </target> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/etc/bugrank.txt 2015-11-25 21:51:59 UTC (rev 1783) @@ -22,8 +22,6 @@ +2 BugPattern CE_CLASS_ENVY +0 BugPattern CFS_CONFUSING_FUNCTION_SEMANTICS +0 BugPattern CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE -+0 BugPattern CIS_STRING_PARSING_A_FIELD -+0 BugPattern CIS_TOSTRING_STORED_IN_FIELD +0 BugPattern CLI_CONSTANT_LIST_INDEX +0 BugPattern CNC_COLLECTION_NAMING_CONFUSION +0 BugPattern COM_COPIED_OVERRIDDEN_METHOD @@ -62,6 +60,10 @@ +0 BugPattern IICU_INCORRECT_INTERNAL_CLASS_USE +0 BugPattern IKNC_INCONSISTENT_HTTP_ATTRIBUTE_CASING +0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING ++2 BugPattern IMC_IMMATURE_CLASS_NO_EQUALS ++2 BugPattern IMC_IMMATURE_CLASS_NO_HASHCODE ++0 BugPattern IMC_IMMATURE_CLASS_NO_PACKAGE ++2 BugPattern IMC_IMMATURE_CLASS_NO_TOSTRING +0 BugPattern IPU_IMPROPER_PROPERTIES_USE +0 BugPattern IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY +0 BugPattern ISB_EMPTY_STRING_APPENDING @@ -70,6 +72,10 @@ +0 BugPattern ITC_INHERITANCE_TYPE_CHECKING +2 BugPattern ITU_INAPPROPRIATE_TOSTRING_USE +0 BugPattern JVR_JDBC_VENDOR_RELIANCE ++0 BugPattern JXI_GET_ENDPOINT_CONSUMES_CONTENT ++0 BugPattern JXI_INVALID_CONTEXT_PARAMETER_TYPE ++0 BugPattern JXI_PARM_PARAM_NOT_FOUND_IN_PATH ++0 BugPattern JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT +0 BugPattern LEST_LOST_EXCEPTION_STACK_TRACE +0 BugPattern LGO_LINGERING_GRAPHICS_OBJECT +2 BugPattern LII_LIST_INDEXED_ITERATING @@ -147,9 +153,9 @@ +0 BugPattern SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR +0 BugPattern SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR +0 BugPattern SCI_SYNCHRONIZED_COLLECTION_ITERATORS ++0 BugPattern SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES +0 BugPattern SCR_SLOPPY_CLASS_REFLECTION +0 BugPattern SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT -+0 BugPattern SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES +0 BugPattern SEC_SIDE_EFFECT_CONSTRUCTOR +0 BugPattern SGSU_SUSPICIOUS_GETTER_SETTER_USE +0 BugPattern SG_SLUGGISH_GUI @@ -194,6 +200,8 @@ +0 BugPattern SPP_USE_STRINGBUILDER_LENGTH +0 BugPattern STB_STACKED_TRY_BLOCKS +2 BugPattern STS_SPURIOUS_THREAD_STATES ++0 BugPattern STT_STRING_PARSING_A_FIELD ++0 BugPattern STT_TOSTRING_STORED_IN_FIELD +0 BugPattern SUA_SUSPICIOUS_UNINITIALIZED_ARRAY +0 BugPattern SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT +0 BugPattern TBP_TRISTATE_BOOLEAN_PATTERN @@ -218,6 +226,10 @@ +0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE +2 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT +0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS ++0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS ++0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL ++0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NULL ++1 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USING_DEPRECATED +0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT +0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED +0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT @@ -225,6 +237,9 @@ +0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE +2 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT +0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS ++0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS ++0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL ++0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NULL +0 BugPattern UTA_USE_TO_ARRAY +0 BugPattern UVA_USE_VAR_ARGS +0 BugPattern WEM_OBSCURING_EXCEPTION Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/etc/findbugs.xml 2015-11-25 21:51:59 UTC (rev 1783) @@ -28,8 +28,6 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> @@ -50,7 +48,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents" speed="fast" reports="UCC_UNRELATED_COLLECTION_CONTENTS" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" speed="fast" reports="DRE_DECLARED_RUNTIME_EXCEPTION" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.RuntimeExceptionDeclared" speed="fast" reports="DRE_DECLARED_RUNTIME_EXCEPTION" /> <Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" /> @@ -146,10 +144,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PossibleIncompleteSerialization" speed="fast" reports="PIS_POSSIBLE_INCOMPLETE_SERIALIZATION" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> + <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_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL,SPP_STATIC_FORMAT_STRING" /> + 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_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" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -172,7 +170,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingFunctionSemantics" speed="fast" reports="CFS_CONFUSING_FUNCTION_SEMANTICS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UnitTestAssertionOddities" speed="fast" - reports="UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT,UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE,UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT,UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED,UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS,UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT,UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT,UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE,UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT,UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED,UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS,UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT," /> + reports="UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT,UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE,UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT,UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED,UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NULL,UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL,UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS,UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS,UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT,UTAO_JUNIT_ASSERTION_ODDITIES_USING_DEPRECATED,UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT,UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE,UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT,UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED,UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NULL,UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL,UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS,UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS,UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT," /> <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousCloneAlgorithm" speed="fast" reports="SCA_SUSPICIOUS_CLONE_ALGORITHM" /> @@ -289,8 +287,12 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod" speed="fast" reports="OPM_OVERLY_PERMISSIVE_METHOD" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.ClassImpersonatingString" speed="fast" reports="CIS_STRING_PARSING_A_FIELD,CIS_TOSTRING_STORED_IN_FIELD" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.StringifiedTypes" speed="fast" reports="STT_STRING_PARSING_A_FIELD,STT_TOSTRING_STORED_IN_FIELD" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass" speed="moderate" reports="IMC_IMMATURE_CLASS_NO_EQUALS,IMC_IMMATURE_CLASS_NO_HASHCODE,IMC_IMMATURE_CLASS_NO_PACKAGE,IMC_IMMATURE_CLASS_NO_TOSTRING" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues" speed="fast" reports="JXI_GET_ENDPOINT_CONSUMES_CONTENT,JXI_INVALID_CONTEXT_PARAMETER_TYPE,JXI_PARM_PARAM_NOT_FOUND_IN_PATH,JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT" /> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -369,7 +371,7 @@ <BugPattern abbrev="URV" type="URV_CHANGE_RETURN_TYPE" category="STYLE" /> <BugPattern abbrev="URV" type="URV_INHERITED_METHOD_WITH_RELATED_TYPES" category="STYLE" /> <BugPattern abbrev="PIS" type="PIS_POSSIBLE_INCOMPLETE_SERIALIZATION" category="CORRECTNESS" /> - <BugPattern abbrev="SCRV" type="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" category="CORRECTNESS" /> + <BugPattern abbrev="SCRV" type="SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_NEGATIVE_BITSET_ITEM" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_INTERN_ON_CONSTANT" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_NO_CHAR_SB_CTOR" category="CORRECTNESS" /> @@ -422,14 +424,21 @@ <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT" category="STYLE" /> <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" category="CORRECTNESS" /> <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NULL" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL" category="CORRECTNESS" /> <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS" category="CORRECTNESS" /> <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_USING_DEPRECATED" category="CORRECTNESS" /> <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT" category="STYLE" /> <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE" category="STYLE" /> <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT" category="STYLE" /> <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" category="CORRECTNESS" /> <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NULL" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL" category="CORRECTNESS" /> <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS" category="CORRECTNESS" /> <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT" category="CORRECTNESS" /> <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" /> <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" /> @@ -449,7 +458,6 @@ <BugPattern abbrev="BED" type="BED_HIERARCHICAL_EXCEPTION_DECLARATION" category="CORRECTNESS" /> <BugPattern abbrev="UNNC" type="UNNC_UNNECESSARY_NEW_NULL_CHECK" category="CORRECTNESS" /> <BugPattern abbrev="DTEP" type="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" category="STYLE" /> - <BugPattern abbrev="SMA" type="SMA_STUTTERED_METHOD_ARGUMENTS" category="STYLE" /> <BugPattern abbrev="TBP" type="TBP_TRISTATE_BOOLEAN_PATTERN" category="STYLE" /> <BugPattern abbrev="SUA" type="SUA_SUSPICIOUS_UNINITIALIZED_ARRAY" category="CORRECTNESS" /> <BugPattern abbrev="ITU" type="ITU_INAPPROPRIATE_TOSTRING_USE" category="CORRECTNESS" /> @@ -522,9 +530,17 @@ <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING" category="CORRECTNESS"/> <BugPattern abbrev="CBC" type="CBC_CONTAINS_BASED_CONDITIONAL" category="STYLE"/> <BugPattern abbrev="OPM" type="OPM_OVERLY_PERMISSIVE_METHOD" category="STYLE" experimental="true" /> - <BugPattern abbrev="CIS" type="CIS_STRING_PARSING_A_FIELD" category="STYLE" experimental="true" /> - <BugPattern abbrev="CIS" type="CIS_TOSTRING_STORED_IN_FIELD" category="STYLE" experimental="true" /> + <BugPattern abbrev="STT" type="STT_STRING_PARSING_A_FIELD" category="STYLE" experimental="true" /> + <BugPattern abbrev="STT" type="STT_TOSTRING_STORED_IN_FIELD" category="STYLE" experimental="true" /> <BugPattern abbrev="SLS" type="SLS_SUSPICIOUS_LOOP_SEARCH" category="CORRECTNESS" /> <BugPattern abbrev="CRF" type="CRF_CONFLATING_RESOURCES_AND_FILES" category="CORRECTNESS" /> + <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_NO_EQUALS" category="STYLE" /> + <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_NO_HASHCODE" category="STYLE" /> + <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_NO_PACKAGE" category="STYLE" /> + <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_NO_TOSTRING" category="STYLE" /> + <BugPattern abbrev="JXI" type="JXI_GET_ENDPOINT_CONSUMES_CONTENT" category="CORRECTNESS" /> + <BugPattern abbrev="JXI" type="JXI_INVALID_CONTEXT_PARAMETER_TYPE" category="CORRECTNESS" /> + <BugPattern abbrev="JXI" type="JXI_PARM_PARAM_NOT_FOUND_IN_PATH" category="CORRECTNESS" /> + <BugPattern abbrev="JXI" type="JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT" category="CORRECTNESS" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/etc/messages.xml 2015-11-25 21:51:59 UTC (rev 1783) @@ -107,7 +107,7 @@ </Details> </Detector> - <Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException"> + <Detector class="com.mebigfatguy.fbcontrib.detect.RuntimeExceptionDeclared"> <Details> <![CDATA[ <p>Looks for methods that declare RuntimeExceptions in their throws clause. While doing @@ -182,15 +182,8 @@ <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, 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. It's only use - is to clarify the coders 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> - + <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> ]]> </Details> @@ -978,17 +971,6 @@ </Details> </Detector> - <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments"> - <Details> experimental="true" - <![CDATA[ - <p>Looks for method calls that pass the same value for two separate parameters, where - those arguments are not constants. Often this is a cut/paste mistake, but if not, it is - confusing why you would pass the same value for two arguments.</p> - <p>It is a fast detector.</p> - ]]> - </Details> - </Detector> - <Detector class="com.mebigfatguy.fbcontrib.detect.TristateBooleanPattern"> <Details> <![CDATA[ @@ -1508,7 +1490,7 @@ </Details> </Detector> - <Detector class="com.mebigfatguy.fbcontrib.detect.ClassImpersonatingString"> + <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 @@ -1546,6 +1528,28 @@ ]]> </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 should be. Things such as + <UL> + <LI>Missing toString() method</LI> + </UL> + </p> + <p>It is a moderately fast detector</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues"> + <Details> + <![CDATA[ + <p>Looks for problems with the use of the JAX-RS specification.</p> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> @@ -2783,14 +2787,14 @@ </Details> </BugPattern> - <BugPattern type="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES"> + <BugPattern type="SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES"> <ShortDescription>Comparator method doesn't seem to return all ordering values</ShortDescription> <LongDescription>Comparator method {1} doesn't seem to return all ordering values</LongDescription> <Details> <![CDATA[ <p>This compareTo or compare method returns constant values for to represent less than, - equals and greater than. However it does not return each type. Given that comparators - are transitive, this seems incorrect.</p> + equals and greater than. However it does not return each type, or it unconditionally returns a non zero value. + Given that comparators are transitive, this seems incorrect.</p> ]]> </Details> </BugPattern> @@ -3500,18 +3504,52 @@ </Details> </BugPattern> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NULL"> + <ShortDescription>Junit test method passes null Assert.assertEquals</ShortDescription> + <LongDescription>Junit test method {1} passes null to Assert.assertEquals</LongDescription> + <Details> + <![CDATA[ + <p>This method compares an object's equality to null. It is better to use the Assert.assertNull + method so that the junit failure method is more meaningful of the intended test.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL"> + <ShortDescription>Junit test method passes null Assert.assertNotEquals</ShortDescription> + <LongDescription>Junit test method {1} passes null to Assert.assertNotEquals</LongDescription> + <Details> + <![CDATA[ + <p>This method compares an object's inequality to null. It is better to use the Assert.assertNotNull + method so that the junit failure method is more meaningful of the intended test.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS"> - <ShortDescription>Junit test method passes boolean expression to Assert.assertTrue</ShortDescription> - <LongDescription>Junit test method {1} passes boolean expression to Assert.assertTrue</LongDescription> + <ShortDescription>Junit test method passes boolean expression to Assert.assertFalse / Assert.assertTrue</ShortDescription> + <LongDescription>Junit test method {1} passes boolean expression to Assert.assertFalse / Assert.assertTrue</LongDescription> <Details> <![CDATA[ - <p>This method evaluates a boolean expression and passes that to Assert.assertTrue. It is better - to pass the two values that are being equated to the Assert.assertEquals method so that the + <p>This method evaluates a boolean expression and passes that to Assert.assertFalse / Assert.assertTrue. + It is better to pass the two values that are being equated to the Assert.assertEquals method so that the junit failure method is more meaningful of the intended test.</p> ]]> </Details> </BugPattern> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS"> + <ShortDescription>Junit test method passes boolean expression to Assert.assertFalse / Assert.assertTrue</ShortDescription> + <LongDescription>Junit test method {1} passes boolean expression to Assert.assertFalse / Assert.assertTrue</LongDescription> + <Details> + <![CDATA[ + <p>This method evaluates a boolean expression and passes that to Assert.assertFalse / Assert.assertTrue. + It is better to pass the two values that are being equated to the Assert.assertNotEquals method so that the + junit failure method is more meaningful of the intended test.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT"> <ShortDescription>Junit test method appears to have no assertions</ShortDescription> <LongDescription>Junit test method {1} appears to have no assertions</LongDescription> @@ -3525,9 +3563,20 @@ </Details> </BugPattern> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USING_DEPRECATED"> + <ShortDescription>JUnit 4 test using deprecated junit.framework.* classes</ShortDescription> + <LongDescription>JUnit 4 test {1} using deprecated junit.framework.* classes</LongDescription> + <Details> + <![CDATA[ + <p>This JUnit 4 test is still using classes from the junit.framework.* package. You should switch them + over to the corresponding org.junit.* set of classes, instead</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT"> <ShortDescription>TestNG test method passes constant to first (actual) assertion parameter</ShortDescription> - <LongDescription>TestNG test method {1} passes constant to forst (actual) assertion parameter</LongDescription> + <LongDescription>TestNG test method {1} passes constant to first (actual) assertion parameter</LongDescription> <Details> <![CDATA[ <p>This method calls assert passing a constant value as the first of the two values. The assert @@ -3583,18 +3632,52 @@ </Details> </BugPattern> + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NULL"> + <ShortDescription>TestNG test method passes null Assert.assertEquals</ShortDescription> + <LongDescription>TestNG test method {1} passes null to Assert.assertEquals</LongDescription> + <Details> + <![CDATA[ + <p>This method compares an object's equality to null. It is better to use the Assert.assertNull + method so that the TestNG failure method is more meaningful of the intended test.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL"> + <ShortDescription>TestNG test method passes null Assert.assertNotEquals</ShortDescription> + <LongDescription>TestNG test method {1} passes null to Assert.assertNotEquals</LongDescription> + <Details> + <![CDATA[ + <p>This method compares an object's inequality to null. It is better to use the Assert.assertNotNull + method so that the TestNG failure method is more meaningful of the intended test.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS"> - <ShortDescription>TestNG test method passes boolean expression to Assert.assertTrue</ShortDescription> - <LongDescription>TestNG test method {1} passes boolean expression to Assert.assertTrue</LongDescription> + <ShortDescription>TestNG test method passes boolean expression to Assert.assertFalse / Assert.assertTrue</ShortDescription> + <LongDescription>TestNG test method {1} passes boolean expression to Assert.assertFalse / Assert.assertTrue</LongDescription> <Details> <![CDATA[ - <p>This method evaluates a boolean expression and passes that to Assert.assertTrue. It is better - to pass the two values that are being equated to the Assert.assertEquals method so that the + <p>This method evaluates a boolean expression and passes that to Assert.assertFalse / Assert.assertTrue. + It is better to pass the two values that are being equated to the Assert.assertEquals method so that the TestNG failure method is more meaningful of the intended test.</p> ]]> </Details> </BugPattern> + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS"> + <ShortDescription>TestNG test method passes boolean expression to Assert.assertFalse / Assert.assertTrue</ShortDescription> + <LongDescription>TestNG test method {1} passes boolean expression to Assert.assertFalse / Assert.assertTrue</LongDescription> + <Details> + <![CDATA[ + <p>This method evaluates a boolean expression and passes that to Assert.assertFalse / Assert.assertTrue. + It is better to pass the two values that are being equated to the Assert.assertNotEquals method so that the + TestNG failure method is more meaningful of the intended test.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT"> <ShortDescription>TestNG test method appears to have no assertions</ShortDescription> <LongDescription>TestNG test method {1} appears to have no assertions</LongDescription> @@ -3844,19 +3927,6 @@ </Details> </BugPattern> - <BugPattern type="SMA_STUTTERED_METHOD_ARGUMENTS"> - <ShortDescription>Code calls a method passing the same value to two different arguments</ShortDescription> - <LongDescription>Code {1} calls a method passing the same value to two different arguments</LongDescription> - <Details> - <![CDATA[ - <p>This method calls a method passing the same value for two or more of the parameters. - Often this is a cut/paste bug, but if not, it is confusing why you would pass the same value for two - different parameters. Perhaps an alternative method that just takes one parameter should be overridden - in this case.</p> - ]]> - </Details> - </BugPattern> - <BugPattern type="TBP_TRISTATE_BOOLEAN_PATTERN"> <ShortDescription>Method returns null for Boolean type</ShortDescription> <LongDescription>Method {1} returns null for Boolean type</LongDescription> @@ -4868,7 +4938,7 @@ </Details> </BugPattern> - <BugPattern type="CIS_TOSTRING_STORED_IN_FIELD"> + <BugPattern type="STT_TOSTRING_STORED_IN_FIELD"> <ShortDescription>This method stores the value of a toString() call into a field</ShortDescription> <LongDescription>This method {0} stores the value of a toString() call into a field</LongDescription> <Details> @@ -4882,7 +4952,7 @@ </Details> </BugPattern> - <BugPattern type="CIS_STRING_PARSING_A_FIELD"> + <BugPattern type="STT_STRING_PARSING_A_FIELD"> <ShortDescription>This method parses a String that is a field</ShortDescription> <LongDescription>This method {1} parses a String that is a field</LongDescription> <Details> @@ -4921,6 +4991,119 @@ </Details> </BugPattern> + <BugPattern type="IMC_IMMATURE_CLASS_NO_EQUALS"> + <ShortDescription>Class does not implement an equals method</ShortDescription> + <LongDescription>Class {0} does not implement an equals method</LongDescription> + <Details> + <![CDATA[ + <p>This class which has instance fields has no equals(Object o) method, It is possible that this + class is never used in a context where this is required, it is often assumed, however, from clients + of this class that it is, so it is good to add such methods when you create them. + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="IMC_IMMATURE_CLASS_NO_HASHCODE"> + <ShortDescription>Class does not implement a hashCode method</ShortDescription> + <LongDescription>Class {0} does not implement a hashCode method</LongDescription> + <Details> + <![CDATA[ + <p>This class which has instance fields has no hashCode() method, It is possible that this + class is never used in a context where this is required, it is often assumed, however, from clients + of this class that it is, so it is good to add such methods when you create them. + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="IMC_IMMATURE_CLASS_NO_PACKAGE"> + <ShortDescription>Class is defined in the default package</ShortDescription> + <LongDescription>Class {0} id defined in the default package</LongDescription> + <Details> + <![CDATA[ + <p>This class has been created in the default package. Classes should be defined in a + proper package structure, typically defined by the reverse of the domain name of the + owner of the code base. Putting code in the default (no) package limits it usefulness, and + leaves it open to name collisions. + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="IMC_IMMATURE_CLASS_NO_TOSTRING"> + <ShortDescription>Class does not implement a toString method</ShortDescription> + <LongDescription>Class {0} does not implement a toString method</LongDescription> + <Details> + <![CDATA[ + <p>This class which has instance fields has no toString() method, which will make debugging with this + class more difficult than it could be. Consider adding a method. Using libraries like commons-lang3 + ToStringBuilder makes this process easy. + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="JXI_GET_ENDPOINT_CONSUMES_CONTENT"> + <ShortDescription>JAX-RS Method implements a GET request but consumes input</ShortDescription> + <LongDescription>JAX-RS Method {1} implements a GET request but consumes input</LongDescription> + <Details> + <![CDATA[ + <p>This JAX-RS endpoint is annotated to be used as @GET requests, but also documents that it + consumes JSON or XML data. Since a get request pulls parameters from the url, and not + the body of request, this pattern is problematic. If you wish to consume JSON or XML data, + this request should be annotated with @POST. + ]]> + </Details> + </BugPattern> + + <BugPattern type="JXI_INVALID_CONTEXT_PARAMETER_TYPE"> + <ShortDescription>JAX-RS Method specifies an invalid @Context parameter type</ShortDescription> + <LongDescription>JAX-RS {1} Method specifies an invalid @Context parameter type</LongDescription> + <Details> + <![CDATA[ + <p>This JAX-RS endpoint annotates a parameter with a @Context annotation. This annotation can supply values + for the following types: + <ul> + <li>javax.ws.rs.core.UriInfo</li> + <li>javax.ws.rs.core.HttpHeaders</li> + <li>javax.ws.rs.core.Request</li> + <li>javax.ws.rs.core.SecurityContext</li> + <li>javax.ws.rs.ext.Providers</li> + <li>javax.servlet.ServletConfig</li> + <li>javax.servlet.ServletContext</li> + <li>javax.servlet.HttpServletRequest</li> + <li>javax.servlet.HttpServletResponse</li> + </ul> + It is possible that your container can supply additional types, but these types are not standard are may + not be supported on other application servers.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="JXI_PARM_PARAM_NOT_FOUND_IN_PATH"> + <ShortDescription>JAX-RS Method specifies non-resolveable @PathParam</ShortDescription> + <LongDescription>JAX-RS Method {1} specifies non-resolveable @PathParam</LongDescription> + <Details> + <![CDATA[ + <p>This JAX-RS endpoint has a @PathParam specified that is not found in the @Path annotation + and thus can not determine from where to populate that parameter.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT"> + <ShortDescription>JAX-RS Method defines a parameter that has no @*Param or @Context annotation, or @Consumes method annotation</ShortDescription> + <LongDescription>JAX-RS Method {1} defines a parameter that has no @*Param or @Context annotation, or @Consumes method annotation</LongDescription> + <Details> + <![CDATA[ + <p>This JAX-RS endpoint declares parameters without specifying where the value of this parameter comes from. + You can specify this by using one of several 'Param' annotations (@PathParam, @CookieParam, @FormParam @HeaderParam @MatrixParam @QueryParam), + by adding a @Context parameter annotation, or you can declare that the method @Consumes an xml or json stream. + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -5001,7 +5184,6 @@ <BugCode abbrev="BED">Bogus Exception Declaration</BugCode> <BugCode abbrev="UNNC">Unnecessary New Null Check</BugCode> <BugCode abbrev="DTEP">Deprecated Typesafe Enum Pattern</BugCode> - <BugCode abbrev="SMA">Stuttered Method Arguments</BugCode> <BugCode abbrev="TBP">Tristate Boolean Pattern</BugCode> <BugCode abbrev="SUA">Suspicious Uninitialized Array</BugCode> <BugCode abbrev="ITU">Inappropriate toString Use</BugCode> @@ -5047,7 +5229,9 @@ <BugCode abbrev="CSI">Charset Issues</BugCode> <BugCode abbrev="CBC">Contains Based Conditional</BugCode> <BugCode abbrev="OPM">Overly Permissive Method</BugCode> - <BugCode abbrev="CIS">Class Impersonating String</BugCode> + <BugCode abbrev="STT">Stringified Types</BugCode> <BugCode abbrev="SLS">Suspicious Loop Search</BugCode> <BugCode abbrev="CRF">Conflating Resources And Files</BugCode> + <BugCode abbrev="IMC">Immature Class</BugCode> + <BugCode abbrev="JXI">JAX-RS Issues</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/htdocs/index.shtml 2015-11-25 21:51:59 UTC (rev 1783) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 6.2.2 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 6.2.3 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on @@ -90,10 +90,14 @@ 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. </li> - <li><b>[CIS] Class Impersonating String</b><br/> + <li><b>[STT] Stringified Types</b><br/> Looks for string fields that appear to be built with parsing or calling toString() on another object, or from objects that are fields. </li> + <li><b>[IMC] Immature Class</b><br/> + Looks for classes that are not fully implemented to be a well rounded class. While + the class will likely work fine, it is more difficult to use or understand than necessary. + </li> </ul> </div> <hr/> Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/htdocs/repository.html 2015-11-25 21:51:59 UTC (rev 1783) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>6.2.2</td></tr> + <tr><td><b>Version:</b></td><td>6.2.3</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/pom.xml 2015-11-25 21:51:59 UTC (rev 1783) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>6.3.0</version> + <version>6.3.0-SNAPSHOT</version> <prerequisites> <maven>2.2.1</maven> @@ -72,6 +72,7 @@ </contributor> <contributor> <name>Juan Martín Sotuyo Dodero</name> + <email>jua...@gm...</email> </contributor> </contributors> @@ -160,44 +161,14 @@ <pluginManagement> <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>buildnumber-maven-plugin</artifactId> - <version>1.3</version> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> + <plugin><artifactId>maven-clean-plugin</artifactId><version>2.6.1</version></plugin> + <plugin><groupId>org.codehaus.mojo</groupId><artifactId>buildnumber-maven-plugin</artifactId><version>1.3</version></plugin> + <plugin><groupId>org.codehaus.mojo</groupId><artifactId>findbugs-maven-plugin</artifactId><version>2.5.5</version></plugin> + <plugin><artifactId>maven-compiler-plugin</artifactId><version>3.1</version></plugin> + <plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.2</version></plugin> + <plugin><artifactId>maven-install-plugin</artifactId><version>2.5.2</version></plugin> + <plugin><artifactId>maven-jar-plugin</artifactId><version>2.6</version> <configuration> - <compilerArgument>-Xlint</compilerArgument> - </configuration> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-deploy-plugin</artifactId> - <version>2.8.1</version> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-install-plugin</artifactId> - <version>2.5.1</version> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.5</version> - <configuration> <archive> <manifestEntries> <fb-contrib-version>${project.version}</fb-contrib-version> @@ -218,43 +189,17 @@ </archive> </configuration> </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-project-info-reports-plugin</artifactId> - <version>2.7</version> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-resources-plugin</artifactId> - <version>2.6</version> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <version>3.3</version> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>2.2.1</version> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.17</version> - </plugin> + <plugin><artifactId>maven-project-info-reports-plugin</artifactId><version>2.7</version></plugin> + <plugin><artifactId>maven-resources-plugin</artifactId><version>2.7</version></plugin> + <plugin><artifactId>maven-site-plugin</artifactId><version>3.4</version></plugin> + <plugin><artifactId>maven-source-plugin</artifactId><version>2.2.1</version></plugin> + <plugin><artifactId>maven-surefire-plugin</artifactId><version>2.18.1</version></plugin> </plugins> </pluginManagement> <plugins> <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>buildnumber-maven-plugin</artifactId> + <groupId>org.codehaus.mojo</groupId><artifactId>buildnumber-maven-plugin</artifactId> <executions> <execution> <phase>validate</phase> @@ -266,11 +211,26 @@ </plugin> <plugin> - <groupId>org.apache.maven.plugins</groupId> + <groupId>org.codehaus.mojo</groupId><artifactId>findbugs-maven-plugin</artifactId> + <dependencies> + <dependency><groupId>com.google.code.findbugs</groupId><artifactId>findbugs</artifactId><version>3.0.1</version></dependency> + </dependencies> + <configuration> + <effort>Max</effort> + </configuration> + <executions> + <execution> + <goals><goal>check</goal></goals> + </execution> + </executions> + </plugin> + + <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.6</source> - <target>1.6</target> + <compilerArgument>-Xlint</compilerArgument> + <source>1.7</source> + <target>1.7</target> </configuration> </plugin> </plugins> Modified: trunk/fb-contrib/samples/AWCBR_Sample.java =================================================================== --- trunk/fb-contrib/samples/AWCBR_Sample.java 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/samples/AWCBR_Sample.java 2015-11-25 21:51:59 UTC (rev 1783) @@ -1,3 +1,7 @@ +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; + public class AWCBR_Sample { public void m(int[] v) { v[0]++; @@ -24,4 +28,15 @@ i = data[0]; return i; } + + public boolean testFPInvoke(Method m) throws Exception { + + Set<String> s = new HashSet<String>(); + Object[] args = new Object[] { s }; + m.invoke(this, args); + + s = (Set<String>) args[0]; + + return s.isEmpty(); + } } Deleted: trunk/fb-contrib/samples/CIS_Sample.java =================================================================== --- trunk/fb-contrib/samples/CIS_Sample.java 2015-08-22 22:14:18 UTC (rev 1782) +++ trunk/fb-contrib/samples/CIS_Sample.java 2015-11-25 21:51:59 UTC (rev 1783) @@ -1,40 +0,0 @@ -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -public class CIS_Sample { - - enum Sample { - Hi, Lo - }; - - Map<String, Object> map = new HashMap<String, Object>(); - - String val; - - public void testToStringToField() { - val = Sample.Hi.toString(); - } - - public void testSBWithToStringToField(Date d, Integer i) { - StringBuilder s = new StringBuilder(); - s.append(d); - s.append(i); - val = s.toString(); - } - - public Object testSBToMapField(Date d1, Date d2) { - map.put("a-v", d1 + ":" + d2); - return map.get(d1 + "-" + d2); - } - - public String testParseOfMapResult() { - String s = (String) map.get("foo"); - int colonPos = s.indexOf(":"); - return s.substring(0, colonPos); - } - - public void fpTestToStringToFieldSB(String s) { - val = s + "wow"; - } -} Added: trunk/fb-contrib/samples/IMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/IMC_Sample.java (rev 0) +++ trunk/fb-contrib/samples/IMC_Sample.java 2015-11-25 21:51:59 UTC (rev 1783) @@ -0,0 +1,35 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +public class IMC_Sample { + + private String reportMe; + + @SuperSecret + class FPClassIMC { + private String dontReportMe; + } + + class FPFieldIMC { + @SuperSecret + private String dontReportMe; + } +} + +class IMCFPHasAToString { + @SuperSecret + private String fooo; + + @Override + public String toString() { + return fooo; + } +} + + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD}) +@interface SuperSecret { +} Property changes on: trunk/fb-contrib/samples/IMC_Sample.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/fb-contrib/samples/JXI_Sample.java =================================================================== --- trunk/fb-contrib/samples/JXI_Sample.java (rev 0) +++ trunk/fb-contrib/samples/JXI_Sample.java 2015-11-25 21:51:59 UTC (rev 1783) @@ -0,0 +1,79 @@ +import java.io.InputStream; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +@Path("/booya/{weasel}") +public class JXI_Sample { + + @GET + @Path("/stuff") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response loadStuff(Stuff s) { + return Response.ok().build(); + } + + @POST + @Path("/stuffit/{blub}") + public Response stufStuff(@PathParam("blub") String blub, Stuff s) { + return Response.ok().build(); + } + + @GET + @Path("/stuffNotRight/{good}") + public Response mismatchParm(@PathParam("bad") String bad) { + return Response.ok().build(); + } + + @PUT + @Path("/stuffMe") + public Response stuffWithBadContext(@Context InputStream is) { + return Response.ok().build(); + } + + @GET + @Path("/stuffy") + @Produces(MediaType.APPLICATION_JSON) + public Response fpFine(Stuff s) { + return Response.ok().build(); + } + + + @GET + @Path("/stuffToClassAnnot/{good}") + public Response fpUseClassAnnot(@PathParam("weasel") String bad) { + return Response.ok().build(); + } + + @POST + @Path("/stuffok/{blub}") + public Response fpStuff(@PathParam("blub") String blub, String body) { + return Response.ok().build(); + } + + @POST + @Path("/stuffyup/{blub}") + @Consumes(MediaType.APPLICATION_JSON) + public Response fpStuff2(@PathParam("blub") String blub, Stuff body) { + return Response.ok().build(); + } + + @PUT + @Path("/stuffGoodContext") + public Response fpStuffGoodContext(@Context UriInfo info) { + return Response.ok().build(); + } + + static class Stuff { + } +} Property changes on: trunk/fb-contrib/samples/JXI_Sample.java ____________________________________________________... [truncated message content] |
From: <dbr...@us...> - 2015-08-22 22:14:21
|
Revision: 1782 http://sourceforge.net/p/fb-contrib/code/1782 Author: dbrosius Date: 2015-08-22 22:14:18 +0000 (Sat, 22 Aug 2015) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/samples/DWI_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.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/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseVarArgs.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/.classpath 2015-08-22 22:14:18 UTC (rev 1782) @@ -11,7 +11,7 @@ <classpathentry kind="lib" path="lib/javax.servlet.jsp-api-2.3.1.jar"/> <classpathentry kind="lib" path="lib/commons-lang3-3.3.jar"/> <classpathentry kind="lib" path="lib/slf4j-api-1.7.7.jar"/> - <classpathentry kind="lib" path="lib/guava-17.0.jar"/> + <classpathentry kind="lib" path="lib/guava-17.0.jar" sourcepath="lib/sources/guava-17.0-sources.jar"/> <classpathentry kind="lib" path="lib/httpclient-cache-4.3.4.jar"/> <classpathentry kind="lib" path="lib/httpcore-4.3.2.jar"/> <classpathentry kind="lib" path="lib/httpclient-4.3.4.jar"/> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/build.xml 2015-08-22 22:14:18 UTC (rev 1782) @@ -126,7 +126,7 @@ </target> <target name="jar" depends="compile" xmlns:vcs="antlib:com.mebigfatguy.vcsversion" description="produces the fb-contrib jar file"> - <vcs:vcsversion vcs="git" revisionProperty="_rev_" dateProperty="_date_" branchProperty="_branch_"/> + <vcs:vcsversion vcs="git" revisionProperty="_rev_" dateProperty="_date_" branchProperty="_branch_" urlProperty="_url_"/> <jar destfile="${target.dir}/fb-contrib-${fb-contrib.version}.jar"> <fileset dir="etc"> <include name="findbugs.xml" /> @@ -144,7 +144,10 @@ <manifest> <attribute name="fb-contrib-version" value="${fb-contrib.version}" /> <attribute name="Main-Class" value="com.mebigfatguy.fbcontrib.FBContrib" /> - <attribute name="git-revision" value="${_branch_} ${_rev_} ${_date_}" /> + <attribute name="git-url" value="${_url_}" /> + <attribute name="git-branch" value="${_branch_}" /> + <attribute name="git-revision" value="${_rev_}" /> + <attribute name="git-date" value="${_date_}" /> <attribute name="Eclipse-RegisterBuddy" value="edu.umd.cs.findbugs.plugin.eclipse" /> <attribute name="Bundle-ManifestVersion" value="2" /> <attribute name="Bundle-Name" value="fb-contrib plugin" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/etc/findbugs.xml 2015-08-22 22:14:18 UTC (rev 1782) @@ -286,7 +286,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles" speed="fast" reports="CRF_CONFLATING_RESOURCES_AND_FILES" /> <!-- COMMENT OUT FOR POINT RELEASE --> - + <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod" speed="fast" reports="OPM_OVERLY_PERMISSIVE_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ClassImpersonatingString" speed="fast" reports="CIS_STRING_PARSING_A_FIELD,CIS_TOSTRING_STORED_IN_FIELD" /> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/htdocs/index.shtml 2015-08-22 22:14:18 UTC (rev 1782) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 6.2.1 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 6.2.2 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/htdocs/repository.html 2015-08-22 22:14:18 UTC (rev 1782) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>6.2.1</td></tr> + <tr><td><b>Version:</b></td><td>6.2.2</td></tr> </table> </div> Modified: trunk/fb-contrib/samples/DWI_Sample.java =================================================================== --- trunk/fb-contrib/samples/DWI_Sample.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/samples/DWI_Sample.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -13,15 +13,17 @@ Iterator<Integer> it = bagOInts.iterator(); while (it.hasNext()) { Integer i = it.next(); - if ((i.intValue() & 0x01) == 1) + if ((i.intValue() & 0x01) == 1) { bagOInts.remove(i); + } } } public void addIf(Set<String> s, Collection<String> c) { for (String ss : s) { - if (ss.equals("addem")) + if (ss.equals("addem")) { s.addAll(c); + } } } @@ -52,6 +54,26 @@ } } + public void fpRemoveWithReturn(Set<String> ss) { + for (String s : ss) { + if (s.equals("foo")) { + ss.remove("foo"); + return; + } + } + } + + public boolean fpRemoveWithReturn2(Set<String> ss) { + for (String s : ss) { + if (s.equals("foo")) { + ss.remove("foo"); + return true; + } + } + + return false; + } + public void fpNonCMECollection() { for (String s : cow) { if (s.isEmpty()) { Modified: trunk/fb-contrib/samples/PRMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/PRMC_Sample.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/samples/PRMC_Sample.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -6,6 +6,8 @@ import java.util.List; import java.util.Set; +import com.google.common.collect.Lists; + import edu.emory.mathcs.backport.java.util.Collections; @SuppressWarnings("all") @@ -30,8 +32,9 @@ @Override public boolean equals(Object o) { PRMC_Sample rmc = (PRMC_Sample) o; - if (data.equals("INF") || rmc.data.equals("INF")) + if (data.equals("INF") || rmc.data.equals("INF")) { return false; + } return data.equals(rmc.data); } @@ -113,6 +116,11 @@ SAMPLE2.setValue(5); } + public void fpWithGuava() { + List<String> l = Lists.newArrayList(); + List<String> ll = Lists.newArrayList(); + } + public void fpAsListLiterals() { System.out.println(Arrays.asList("foo")); System.out.println(Arrays.asList("bar")); @@ -124,6 +132,7 @@ class Chain { public Chain chainedField; + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("--"); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -100,7 +100,7 @@ /** * constructs a BAS detector given the reporter to report bugs on - * + * * @param bugReporter * the sync of bug reports */ @@ -111,7 +111,7 @@ /** * implements the visitor to create and the clear the register to location * map - * + * * @param classContext * the context object of the currently parsed class */ @@ -137,7 +137,7 @@ /** * implements the visitor to reset the register to location map - * + * * @param obj * the context object of the currently parsed code block */ @@ -186,7 +186,7 @@ /** * 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 */ @@ -378,8 +378,9 @@ } else if (seen == MONITOREXIT) { if (monitorSyncPCs.size() > 0) { ScopeBlock sb = findSynchronizedScopeBlock(rootScopeBlock, monitorSyncPCs.get(0).intValue()); - if (sb != null) + if (sb != null) { sb.setFinish(pc); + } monitorSyncPCs.remove(monitorSyncPCs.size() - 1); } } @@ -402,7 +403,7 @@ /** * returns either a register number of a field reference of the object that * a method is being called on, or null, if it can't be determined. - * + * * @return either an Integer for a register, or a String for the field name, * or null */ @@ -437,7 +438,7 @@ /** * returns the scope block in which this register was assigned, by * traversing the scope block tree - * + * * @param sb * the scope block to start searching in * @param pc @@ -463,12 +464,12 @@ /** * returns an existing scope block that has the same target as the one * looked for - * + * * @param sb * the scope block to start with * @param target * the target to look for - * + * * @return the scope block found or null */ private ScopeBlock findScopeBlockWithTarget(ScopeBlock sb, int start, int target) { @@ -493,7 +494,7 @@ /** * finds the scope block that is the active synchronized block - * + * * @return the scope block */ private ScopeBlock findSynchronizedScopeBlock(ScopeBlock sb, int monitorEnterPC) { @@ -516,19 +517,20 @@ /** * returns the catch handler for a given try block - * + * * @param pc * the current instruction * @return the pc of the handler for this pc if it's the start of a try * block, or -1 - * + * */ private int findCatchHandlerFor(int pc) { CodeException[] exceptions = getMethod().getCode().getExceptionTable(); if (exceptions != null) { for (CodeException ex : exceptions) { - if (ex.getStartPC() == pc) + if (ex.getStartPC() == pc) { return ex.getHandlerPC(); + } } } @@ -554,7 +556,7 @@ /** * construts a new scope block - * + * * @param start * the beginning of the block * @param finish @@ -577,7 +579,7 @@ /** * returns a string representation of the scope block - * + * * @returns a string representation */ @Override @@ -587,7 +589,7 @@ /** * returns the scope blocks parent - * + * * @return the parent of this scope block */ public ScopeBlock getParent() { @@ -596,7 +598,7 @@ /** * returns the children of this scope block - * + * * @return the scope blocks children */ public List<ScopeBlock> getChildren() { @@ -605,7 +607,7 @@ /** * returns the start of the block - * + * * @return the start of the block */ public int getStart() { @@ -614,7 +616,7 @@ /** * returns the end of the block - * + * * @return the end of the block */ public int getFinish() { @@ -623,7 +625,7 @@ /** * sets the start pc of the block - * + * * @param start * the start pc */ @@ -633,7 +635,7 @@ /** * sets the finish pc of the block - * + * * @param finish * the finish pc */ @@ -654,7 +656,7 @@ /** * returns whether this scope block is a loop - * + * * @returns whether this block is a loop */ public boolean isLoop() { @@ -670,7 +672,7 @@ /** * returns whether this block was caused from a goto - * + * * @returns whether this block was caused by a goto */ public boolean isGoto() { @@ -686,7 +688,7 @@ /** * returns whether this block was caused from a synchronized block - * + * * @returns whether this block was caused by a synchronized block */ public boolean isSync() { @@ -702,7 +704,7 @@ /** * returns whether this block was caused from a try block - * + * * @returns whether this block was caused by a try block */ public boolean isTry() { @@ -718,7 +720,7 @@ /** * returns whether this block was caused from a case block - * + * * @returns whether this block was caused by a case block */ public boolean isCase() { @@ -727,7 +729,7 @@ /** * adds the register as a store in this scope block - * + * * @param reg * the register that was stored * @param pc @@ -748,7 +750,7 @@ /** * removes stores to registers that where retrieved from method calls on * assocObject - * + * * @param assocObject * the object that a method call was just performed on */ @@ -768,7 +770,7 @@ /** * adds the register as a load in this scope block - * + * * @param reg * the register that was loaded * @param pc @@ -785,7 +787,7 @@ /** * adds a scope block to this subtree by finding the correct place in * the hierarchy to store it - * + * * @param newChild * the scope block to add to the tree */ @@ -795,8 +797,9 @@ if (children != null) { for (ScopeBlock child : children) { if ((newChild.startLocation > child.startLocation) && (newChild.startLocation < child.finishLocation)) { - if (newChild.finishLocation > child.finishLocation) + if (newChild.finishLocation > child.finishLocation) { newChild.finishLocation = child.finishLocation; + } child.addChild(newChild); return; } @@ -818,7 +821,7 @@ /** * removes a child from this node - * + * * @param child * the child to remove */ @@ -887,10 +890,10 @@ /** * returns whether this block either loads or stores into the register * in question - * + * * @param reg * the register to look for loads or stores - * + * * @return whether the block uses the register */ public boolean usesReg(Integer reg) { @@ -945,7 +948,7 @@ return true; } - String key = clsName + "." + getNameConstantOperand() + getSigConstantOperand(); + String key = clsName + '.' + getNameConstantOperand() + getSigConstantOperand(); if (dangerousAssignmentMethodSources.contains(key)) { return true; } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -1,17 +1,17 @@ /* * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2015 Dave Brosius - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -91,7 +91,7 @@ /** * constructs a CTU detector given the reporter to report bugs on - * + * * @param bugReporter * the sync of bug reports */ @@ -101,7 +101,7 @@ /** * overrides the visitor to reset the stack - * + * * @param classContext * the context object of the currently parsed class */ @@ -117,7 +117,7 @@ /** * overrides the visitor to resets the stack for this method. - * + * * @param obj * the context object for the currently parsed code block */ @@ -141,7 +141,7 @@ case INVOKEVIRTUAL: case INVOKEINTERFACE: case INVOKESTATIC: - String methodCall = getClassConstantOperand() + "." + getNameConstantOperand() + getSigConstantOperand(); + String methodCall = getClassConstantOperand() + '.' + getNameConstantOperand() + getSigConstantOperand(); unit = TIME_UNIT_GENERATING_METHODS.get(methodCall); if (unit == Units.CALLER) { int offset = Type.getArgumentTypes(getSigConstantOperand()).length; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -98,7 +98,7 @@ String methodName = m.getName(); if ((m.isPublic() || m.isProtected()) && (!m.isAbstract() && !m.isSynthetic() && (!Values.CONSTRUCTOR.equals(methodName) && !Values.STATIC_INITIALIZER.equals(methodName)))) { - String methodInfo = methodName + ":" + m.getSignature(); + String methodInfo = methodName + ':' + m.getSignature(); superclassCode.put(methodInfo, new CodeInfo(m.getCode(), m.getAccessFlags())); } } @@ -122,7 +122,7 @@ */ @Override public void visitMethod(Method obj) { - curMethodInfo = obj.getName() + ":" + obj.getSignature(); + curMethodInfo = obj.getName() + ':' + obj.getSignature(); } /** @@ -196,9 +196,11 @@ } } else { int expectedInstruction = getExpectedReturnInstruction(getMethod().getReturnType()); - if (seen == expectedInstruction) { + if ((seen == expectedInstruction) && (getNextPC() == getCode().getCode().length)) { bugReporter.reportBug( new BugInstance(this, BugType.COM_PARENT_DELEGATED_CALL.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this)); + } else { + ignore = true; } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -68,7 +68,7 @@ /** * constructs a CBX detector given the reporter to report bugs on - * + * * @param bugReporter * the sync of bug reports */ @@ -138,7 +138,7 @@ if ("java/lang/StringBuffer".equals(clsName) || "java/lang/StringBuilder".equals(clsName)) { String methodName = getNameConstantOperand(); String methodSig = getSigConstantOperand(); - if (Values.CONSTRUCTOR.equals(methodName) && ("(Ljava/lang/String;)L" + clsName + ";").equals(methodSig)) { + if (Values.CONSTRUCTOR.equals(methodName) && ("(Ljava/lang/String;)L" + clsName + ';').equals(methodSig)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); strCon = (String) itm.getConstant(); @@ -150,7 +150,7 @@ if ("java/lang/StringBuffer".equals(clsName) || "java/lang/StringBuilder".equals(clsName)) { String methodName = getNameConstantOperand(); String methodSig = getSigConstantOperand(); - if ("append".equals(methodName) && ("(Ljava/lang/String;)L" + clsName + ";").equals(methodSig)) { + if ("append".equals(methodName) && ("(Ljava/lang/String;)L" + clsName + ';').equals(methodSig)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); strCon = (String) itm.getConstant(); @@ -161,17 +161,20 @@ if (strCon != null) { strCon = strCon.trim(); - if (strCon.length() == 0) + if (strCon.length() == 0) { return; + } for (Map.Entry<Pattern, Boolean> entry : xmlPatterns.entrySet()) { Matcher m = entry.getKey().matcher(strCon); if (m.matches()) { xmlItemCount++; - if (entry.getValue().booleanValue()) + if (entry.getValue().booleanValue()) { xmlConfidentCount++; - if ((firstPC < 0) && (xmlConfidentCount > 0)) + } + if ((firstPC < 0) && (xmlConfidentCount > 0)) { firstPC = getPC(); + } break; } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -1,17 +1,17 @@ /* * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2015 Dave Brosius - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -51,20 +51,21 @@ /** * constructs a CC detector given the reporter to report bugs on - * + * * @param bugReporter * the sync of bug reports */ public CyclomaticComplexity(final BugReporter bugReporter) { this.bugReporter = bugReporter; Integer limit = Integer.getInteger(LIMIT_PROPERTY); - if (limit != null) + if (limit != null) { reportLimit = limit.intValue(); + } } /** * overrides the visitor to store the class context - * + * * @param context * the context object for the currently parsed class */ @@ -88,7 +89,7 @@ /** * overrides the visitor to navigate the basic block list to count branches - * + * * @param obj * the method of the currently parsed method */ @@ -96,19 +97,22 @@ public void visitMethod(final Method obj) { try { - if ((obj.getAccessFlags() & Constants.ACC_SYNTHETIC) != 0) + if ((obj.getAccessFlags() & Constants.ACC_SYNTHETIC) != 0) { return; + } Code code = obj.getCode(); - if (code == null) + if (code == null) { return; + } // There really is no valid relationship between reportLimit and // code // length, but it is good enough. If the method is small, don't // bother - if (code.getCode().length < (2 * reportLimit)) + if (code.getCode().length < (2 * reportLimit)) { return; + } BitSet exceptionNodeTargets = new BitSet(); @@ -144,7 +148,7 @@ bugReporter.reportBug(bug); } } catch (CFGBuilderException cbe) { - bugReporter.logError("Failure examining basic blocks for method " + classContext.getJavaClass().getClassName() + "." + obj.getName() + bugReporter.logError("Failure examining basic blocks for method " + classContext.getJavaClass().getClassName() + '.' + obj.getName() + " in Cyclomatic Complexity detector", cbe); } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -111,7 +111,7 @@ /** * constructs a DWI detector given the reporter to report bugs on - * + * * @param bugReporter * the sync of bug reports */ @@ -128,8 +128,9 @@ */ @Override public void visitClassContext(ClassContext classContext) { - if ((collectionClass == null) || (iteratorClass == null)) + if ((collectionClass == null) || (iteratorClass == null)) { return; + } try { stack = new OpcodeStack(); @@ -207,9 +208,11 @@ if (loop != null) { int pc = getPC(); if (loop.hasPC(pc)) { - boolean breakFollows = breakFollows(loop, !"V".equals(Type.getReturnType(signature).getSignature())); + boolean needPop = !"V".equals(Type.getReturnType(signature).getSignature()); + boolean breakFollows = breakFollows(loop, needPop); + boolean returnFollows = breakFollows ? false : returnFollows(loop, needPop); - if (!breakFollows) { + if (!breakFollows && !returnFollows) { bugReporter.reportBug(new BugInstance(this, BugType.DWI_DELETING_WHILE_ITERATING.name(), NORMAL_PRIORITY) .addClass(this).addMethod(this).addSourceLine(this)); } @@ -247,8 +250,9 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); Integer id = (Integer) itm.getUserValue(); - if (id != null) + if (id != null) { groupId = id.intValue(); + } } } } else if ((seen == PUTFIELD) || (seen == PUTSTATIC)) { @@ -277,8 +281,9 @@ Integer regIt = Integer.valueOf(reg); Iterator<Integer> curIt = groupToIterator.values().iterator(); while (curIt.hasNext()) { - if (curIt.next().equals(regIt)) + if (curIt.next().equals(regIt)) { curIt.remove(); + } } groupToIterator.put(id, regIt); } @@ -320,12 +325,14 @@ int target = getBranchTarget(); int gotoAddr = target - 3; int ins = getCode().getCode()[gotoAddr]; - if (ins < 0) + if (ins < 0) { ins = 256 + ins; + } if ((ins == GOTO) || (ins == GOTO_W)) { Integer reg = groupToIterator.get(id); - if (reg != null) + if (reg != null) { loops.put(reg, new Loop(getPC(), gotoAddr)); + } } } } @@ -358,13 +365,46 @@ int gotoOp = CodeByteUtils.getbyte(code, nextPC); if ((gotoOp == Constants.GOTO) || (gotoOp == Constants.GOTO_W)) { int target = nextPC + CodeByteUtils.getshort(code, nextPC + 1); - if (target > loop.getLoopFinish()) + if (target > loop.getLoopFinish()) { return true; + } } return false; } + /* + * This attempts to see if there is some form of a return statement + * following the collection modifying statement in the loop. It is a bad + * cheat, because, we may allow a POP, or an ALOAD/ILOAD etc before the + * return. this is sloppy tho as it might be a multibyte instruction. It + * also might be a complex piece of code to load the return, or the method + * may not allow returns. But hopefully it's better than it was. + */ + private boolean returnFollows(Loop loop, boolean couldSeePop) { + + byte[] code = getCode().getCode(); + int nextPC = getNextPC(); + + int nextOp = CodeByteUtils.getbyte(code, nextPC++); + + if ((nextOp >= Constants.IRETURN) && (nextOp <= Constants.RETURN)) { + return true; + } else if ((couldSeePop) && (nextOp == Constants.POP)) { + nextOp = CodeByteUtils.getbyte(code, nextPC++); + if ((nextOp >= Constants.IRETURN) && (nextOp <= Constants.RETURN)) { + return true; + } + } + + nextOp = CodeByteUtils.getbyte(code, nextPC++); + if ((nextOp >= Constants.IRETURN) && (nextOp <= Constants.RETURN)) { + return true; + } + + return false; + } + private boolean isCollection(String className) { try { JavaClass cls = Repository.lookupClass(className); @@ -379,14 +419,15 @@ Comparable<?> groupElement = null; int reg = itm.getRegisterNumber(); - if (reg >= 0) + if (reg >= 0) { groupElement = Integer.valueOf(reg); - else { + } else { XField field = itm.getXField(); if (field != null) { int regLoad = itm.getFieldLoadedFromRegister(); - if (regLoad >= 0) - groupElement = field.getName() + ":{" + regLoad + "}"; + if (regLoad >= 0) { + groupElement = field.getName() + ":{" + regLoad + '}'; + } } } @@ -396,8 +437,9 @@ private int findCollectionGroup(OpcodeStack.Item itm, boolean addIfNotFound) { Integer id = (Integer) itm.getUserValue(); - if (id != null) + if (id != null) { return id.intValue(); + } Comparable<?> groupElement = getGroupElement(itm); if (groupElement != null) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -44,11 +44,19 @@ static { internalPackages.add("com/sun/"); + internalPackages.add("org/apache/commons/digester/annotations/internal"); internalPackages.add("org/apache/xerces/"); internalPackages.add("org/apache/xalan/"); - externalPackages.add("com/sun/jersey"); - externalPackages.add("com/sun/mail"); - externalPackages.add("com/sun/xml/xsom"); + internalPackages.add("org/mockito/internal/"); + internalPackages.add("org/springframework/asm/"); + internalPackages.add("org/springframework/cglib/"); + internalPackages.add("org/springframework/objenesis/"); + internalPackages.add("com/sun/org/apache/xerces/"); + internalPackages.add("com/sun/org/apache/xalan/"); + internalPackages.add("com/sun/xml/internal/"); + externalPackages.add("com/sun/jersey/"); + externalPackages.add("com/sun/mail/"); + externalPackages.add("com/sun/xml/"); externalPackages.add("org/apache/xerces/xni/"); externalPackages.add("org/apache/xerces/xs/"); externalPackages.add("org/apache/xalan/extensions"); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -125,6 +125,11 @@ riskyClassNames.add("java/io/DataInputStream"); riskyClassNames.add("java/io/ObjectInputStream"); riskyClassNames.add("java/util/Calendar"); + riskyClassNames.add("com/google/common/collect/Lists"); + riskyClassNames.add("com/google/common/collect/Sets"); + riskyClassNames.add("com/google/common/collect/Maps"); + riskyClassNames.add("com/google/common/collect/Queues"); + String userNameProp = System.getProperty(PRMC_RISKY_CLASS_USER_KEY); if (userNameProp != null) { String[] userNames = userNameProp.split("\\s*,\\s*"); @@ -143,7 +148,7 @@ /** * constructs a PRMC detector given the reporter to report bugs on - * + * * @param bugReporter * the sync of bug reports */ @@ -234,8 +239,9 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); fieldSource = (String) item.getUserValue(); - if (fieldSource == null) + if (fieldSource == null) { fieldSource = ""; + } } fieldMethodCalls.remove(fieldSource + ":" + getNameConstantOperand()); } else if (seen == GETFIELD) { @@ -288,8 +294,9 @@ mc = localMethodCalls.get(Integer.valueOf(reg)); } else if (field != null) { String fieldSource = (String) obj.getUserValue(); - if (fieldSource == null) + if (fieldSource == null) { fieldSource = ""; + } mc = fieldMethodCalls.get(fieldSource + ":" + field.getName()); } else { return; @@ -326,8 +333,9 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); fieldSource = (String) item.getUserValue(); - if (fieldSource == null) + if (fieldSource == null) { fieldSource = ""; + } } fieldMethodCalls.remove(fieldSource + ":" + field.getName()); @@ -343,8 +351,9 @@ } else if (field != null) { OpcodeStack.Item obj = stack.getStackItem(parmCount); String fieldSource = (String) obj.getUserValue(); - if (fieldSource == null) + if (fieldSource == null) { fieldSource = ""; + } fieldMethodCalls.put(fieldSource + ":" + field.getName(), new MethodCall(methodName, signature, parmConstants, pc, ln)); } } @@ -364,7 +373,7 @@ /** * returns the bug priority based on metrics about the method - * + * * @param methodName * TODO * @param mi @@ -372,17 +381,21 @@ * @return the bug priority */ private static int getBugPriority(String methodName, MethodInfo mi) { - if ((mi.getNumBytes() >= highByteCountLimit) || (mi.getNumMethodCalls() >= highMethodCallLimit)) + if ((mi.getNumBytes() >= highByteCountLimit) || (mi.getNumMethodCalls() >= highMethodCallLimit)) { return HIGH_PRIORITY; + } - if (Values.STATIC_INITIALIZER.equals(methodName)) + if (Values.STATIC_INITIALIZER.equals(methodName)) { return LOW_PRIORITY; + } - if ((mi.getNumBytes() >= normalByteCountLimit) || (mi.getNumMethodCalls() >= normalMethodCallLimit)) + if ((mi.getNumBytes() >= normalByteCountLimit) || (mi.getNumMethodCalls() >= normalMethodCallLimit)) { return NORMAL_PRIORITY; + } - if ((mi.getNumBytes() == 0) || (mi.getNumMethodCalls() == 0)) + if ((mi.getNumBytes() == 0) || (mi.getNumMethodCalls() == 0)) { return LOW_PRIORITY; + } return EXP_PRIORITY; } @@ -414,22 +427,25 @@ /** * returns the source line number for the pc, or just the pc if the line * number table doesn't exist - * + * * @param pc * current pc * @return the line number */ private int getLineNumber(int pc) { LineNumberTable lnt = getMethod().getLineNumberTable(); - if (lnt == null) + if (lnt == null) { return pc; + } LineNumber[] lns = lnt.getLineNumberTable(); - if (lns == null) + if (lns == null) { return pc; + } - if (pc > lns[lns.length - 1].getStartPC()) + if (pc > lns[lns.length - 1].getStartPC()) { return lns[lns.length - 1].getLineNumber(); + } int lo = 0; int hi = lns.length - 2; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -400,7 +400,7 @@ if (cmr instanceof ConstantMethodref) { ConstantMethodref toStringMR = (ConstantMethodref) cmr; String toStringCls = toStringMR.getClass(pool); - if (toStringCls.startsWith("java.lang.&&StringBu")) { + if (toStringCls.startsWith("java.lang.StringBu")) { int consIndex = CodeByteUtils.getbyte(bytes, lastPCs[2] + 1); Constant c = pool.getConstant(consIndex); if (c instanceof ConstantString) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseVarArgs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseVarArgs.java 2015-08-16 23:23:57 UTC (rev 1781) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseVarArgs.java 2015-08-22 22:14:18 UTC (rev 1782) @@ -1,17 +1,17 @@ /* * fb-contrib - Auxiliary detectors for Java programs * Copyright (C) 2005-2015 Dave Brosius - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -106,9 +106,9 @@ public void report() { } - private static boolean hasSimilarParms(Type[] argTypes) { + private static boolean hasSimilarParms(Type... argTypes) { - for (int i = 0; i < argTypes.length - 1; i++) { + for (int i = 0; i < (argTypes.length - 1); i++) { if (argTypes[i].getSignature().startsWith("[")) { return true; } @@ -119,7 +119,7 @@ baseType = baseType.substring(1); } - for (int i = 0; i < argTypes.length - 1; i++) { + for (int i = 0; i < (argTypes.length - 1); i++) { if (argTypes[i].getSignature().equals(baseType)) { return true; } @@ -131,14 +131,16 @@ private boolean isInherited(Method m) throws ClassNotFoundException { JavaClass[] infs = javaClass.getAllInterfaces(); for (JavaClass inf : infs) { - if (hasMethod(inf, m)) + if (hasMethod(inf, m)) { return true; + } } JavaClass[] sups = javaClass.getSuperClasses(); for (JavaClass sup : sups) { - if (hasMethod(sup, m)) + if (hasMethod(sup, m)) { return true; + } } return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2015-08-16 23:24:00
|
Revision: 1781 http://sourceforge.net/p/fb-contrib/code/1781 Author: dbrosius Date: 2015-08-16 23:23:57 +0000 (Sun, 16 Aug 2015) Log Message: ----------- sync from githuh Added Paths: ----------- trunk/fb-contrib/samples/UTAO_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java Removed Paths: ------------- trunk/fb-contrib/samples/JAO_Sample.java trunk/fb-contrib/samples/samples.fb trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java Deleted: trunk/fb-contrib/samples/JAO_Sample.java =================================================================== --- trunk/fb-contrib/samples/JAO_Sample.java 2015-08-16 23:20:38 UTC (rev 1780) +++ trunk/fb-contrib/samples/JAO_Sample.java 2015-08-16 23:23:57 UTC (rev 1781) @@ -1,58 +0,0 @@ -import junit.framework.TestCase; - -import org.junit.Assert; -import org.junit.Test; - -public class JAO_Sample extends TestCase { - - public void testExactDoubles(double d1, double d2) { - Assert.assertEquals(d1, d2); - } - - public void testTrue(boolean b) { - Assert.assertEquals(true, b); - } - - public void testFalse(boolean b) { - Assert.assertEquals("Wow this is bad", false, b); - } - - public void testWrongOrder(int i) { - Assert.assertEquals(i, 10); - } - - public void testAutoBoxNotNull(int i) { - Assert.assertNotNull(i); - Assert.assertNotNull(i == 3); - } - - public void testAssertUsed(String s) { - assert s != null; - } - - public void testUseAssertEquals(String s, String s2) { - Assert.assertTrue(s.equals(s2)); - Assert.assertTrue(s.length() == s.length()); - } - - public void test3ArgNP(float foo, int boo) { - Assert.assertEquals(1.0f, foo, 0.1); - Assert.assertEquals(20, boo, 0); - - } -} - -class New { - @Test - public void nada() { - } - - @Test - public void aha() { - check("hello", "world"); - } - - private void check(String a, String b) { - Assert.assertEquals(a, b); - } -} Added: trunk/fb-contrib/samples/UTAO_Sample.java =================================================================== --- trunk/fb-contrib/samples/UTAO_Sample.java (rev 0) +++ trunk/fb-contrib/samples/UTAO_Sample.java 2015-08-16 23:23:57 UTC (rev 1781) @@ -0,0 +1,102 @@ +import org.junit.Assert; +import org.junit.Test; + +import junit.framework.TestCase; + +public class UTAO_Sample extends TestCase { + + public void testExactDoubles(double d1, double d2) { + Assert.assertEquals(d1, d2); + } + + public void testTrue(boolean b) { + Assert.assertEquals(true, b); + } + + public void testFalse(boolean b) { + Assert.assertEquals("Wow this is bad", false, b); + } + + public void testWrongOrder(int i) { + Assert.assertEquals(i, 10); + } + + public void testAutoBoxNotNull(int i) { + Assert.assertNotNull(i); + Assert.assertNotNull(i == 3); + } + + public void testAssertUsed(String s) { + assert s != null; + } + + public void testUseAssertEquals(String s, String s2) { + Assert.assertTrue(s.equals(s2)); + Assert.assertTrue(s.length() == s.length()); + } + + public void test3ArgNP(float foo, int boo) { + Assert.assertEquals(1.0f, foo, 0.1); + Assert.assertEquals(20, boo, 0); + + } +} + +class New { + @Test + public void nada() { + } + + @Test + public void aha() { + check("hello", "world"); + } + + private void check(String a, String b) { + Assert.assertEquals(a, b); + } +} + +class TestNG { + @org.testng.annotations.Test + public void nada() { + } + + @org.testng.annotations.Test + public void testTrue(boolean b) { + org.testng.Assert.assertEquals(b, true); + } + + @org.testng.annotations.Test + public void testFalse(boolean b) { + org.testng.Assert.assertEquals(b, false, "Wow this is bad"); + } + + @org.testng.annotations.Test + public void testWrongOrder(int i) { + org.testng.Assert.assertEquals(10, i); + } + + @org.testng.annotations.Test + public void testAutoBoxNotNull(int i) { + org.testng.Assert.assertNotNull(i); + org.testng.Assert.assertNotNull(i == 3); + } + + @org.testng.annotations.Test + public void testAssertUsed(String s) { + assert s != null; + } + + @org.testng.annotations.Test + public void testUseAssertEquals(String s, String s2) { + org.testng.Assert.assertTrue(s.equals(s2)); + org.testng.Assert.assertTrue(s.length() == s.length()); + } + + @org.testng.annotations.Test + public void test3ArgNP(float foo, int boo) { + Assert.assertEquals(foo, 1.0f, 0.1); + Assert.assertEquals(boo, 20, 0); + } +} Property changes on: trunk/fb-contrib/samples/UTAO_Sample.java ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Deleted: trunk/fb-contrib/samples/samples.fb =================================================================== --- trunk/fb-contrib/samples/samples.fb 2015-08-16 23:20:38 UTC (rev 1780) +++ trunk/fb-contrib/samples/samples.fb 2015-08-16 23:23:57 UTC (rev 1781) @@ -1,10 +0,0 @@ -[Jar files] -. -[Source dirs] -. -[Aux classpath entries] -./lib/jsp-api.jar -./lib/junit.jar -./lib/servlet-api.jar -[Options] -relative_paths=true Deleted: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2015-08-16 23:20:38 UTC (rev 1780) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2015-08-16 23:23:57 UTC (rev 1781) @@ -1,287 +0,0 @@ -/* - * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2015 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.detect; - -import org.apache.bcel.Repository; -import org.apache.bcel.classfile.AnnotationEntry; -import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.generic.Type; - -import com.mebigfatguy.fbcontrib.utils.BugType; -import com.mebigfatguy.fbcontrib.utils.TernaryPatcher; - -import edu.umd.cs.findbugs.BugInstance; -import edu.umd.cs.findbugs.BugReporter; -import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.OpcodeStack; -import edu.umd.cs.findbugs.OpcodeStack.CustomUserValue; -import edu.umd.cs.findbugs.ba.ClassContext; - -/** looks for odd uses of the Assert class of the JUnit framework */ -@CustomUserValue -public class JUnitAssertionOddities extends BytecodeScanningDetector -{ - private enum State {SAW_NOTHING, SAW_IF_ICMPNE, SAW_ICONST_1, SAW_GOTO, SAW_ICONST_0, SAW_EQUALS}; - - private static final String TESTCASE_CLASS = "junit.framework.TestCase"; - private static final String TEST_CLASS = "org.junit.Test"; - private static final String TEST_ANNOTATION_SIGNATURE = "Lorg/junit/Test;"; - private static final String OLD_ASSERT_CLASS = "junit/framework/Assert"; - private static final String NEW_ASSERT_CLASS = "org/junit/Assert"; - - private BugReporter bugReporter; - private JavaClass testCaseClass; - private JavaClass testAnnotationClass; - private JavaClass cls; - private OpcodeStack stack; - private boolean isTestCaseDerived; - private boolean isAnnotationCapable; - private String clsName; - private boolean sawAssert; - private State state; - - /** - * constructs a JOA detector given the reporter to report bugs on - * @param bugReporter the sync of bug reports - */ - public JUnitAssertionOddities(BugReporter bugReporter) { - this.bugReporter = bugReporter; - - try { - testCaseClass = Repository.lookupClass(TESTCASE_CLASS); - } catch (ClassNotFoundException cnfe) { - testCaseClass = null; - } - try { - testAnnotationClass = Repository.lookupClass(TEST_CLASS); - } catch (ClassNotFoundException cnfe) { - testAnnotationClass = null; - } - } - - /** - * override the visitor to see if this class could be a test class - * - * @param classContext the context object of the currently parsed class - */ - @Override - public void visitClassContext(ClassContext classContext) { - try { - cls = classContext.getJavaClass(); - clsName = cls.getClassName().replace('.', '/'); - isTestCaseDerived = ((testCaseClass != null) && cls.instanceOf(testCaseClass)); - isAnnotationCapable = (cls.getMajor() >= 5) && (testAnnotationClass != null); - if (isTestCaseDerived || isAnnotationCapable) { - stack = new OpcodeStack(); - super.visitClassContext(classContext); - } - } catch (ClassNotFoundException cnfe) { - bugReporter.reportMissingClass(cnfe); - } finally { - stack = null; - } - } - - @Override - public void visitCode(Code obj) { - Method m = getMethod(); - boolean isTestMethod = isTestCaseDerived && m.getName().startsWith("test"); - - if (!isTestMethod && isAnnotationCapable) { - AnnotationEntry[] annotations = m.getAnnotationEntries(); - if (annotations != null) { - for (AnnotationEntry annotation : annotations) { - if (annotation.isRuntimeVisible() && TEST_ANNOTATION_SIGNATURE.equals(annotation.getAnnotationType())) { - isTestMethod = true; - break; - } - } - } - } - - if (isTestMethod) { - stack.resetForMethodEntry(this); - state = State.SAW_NOTHING; - sawAssert = false; - super.visitCode(obj); - -// if (!sawAssert) { -// bugReporter.reportBug(new BugInstance(this, BugType.JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT.name(), LOW_PRIORITY) -// .addClass(this) -// .addMethod(this)); -// } - } - } - - @Override - public void sawOpcode(int seen) { - String userValue = null; - - try { - stack.precomputation(this); - - if (seen == INVOKESTATIC) { - String clsName = getClassConstantOperand(); - if (OLD_ASSERT_CLASS.equals(clsName) || NEW_ASSERT_CLASS.equals(clsName)) { - sawAssert = true; - String methodName = getNameConstantOperand(); - if ("assertEquals".equals(methodName)) { - String signature = getSigConstantOperand(); - Type[] argTypes = Type.getArgumentTypes(signature); - if ((argTypes.length == 2) || (argTypes.length ==3)) { - - if (stack.getStackDepth() >= 2) { - OpcodeStack.Item item1 = stack.getStackItem(1); - Object cons1 = item1.getConstant(); - if ((cons1 != null) && (argTypes[argTypes.length-1].equals(Type.BOOLEAN)) && (argTypes[argTypes.length-2].equals(Type.BOOLEAN))) { - bugReporter.reportBug(new BugInstance(this, BugType.JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT.name(), NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - return; - } - OpcodeStack.Item item0 = stack.getStackItem(0); - if ((item0.getConstant() != null) && (item1.getConstant() == null) && ((argTypes.length == 2) || !isFloatingPtPrimitive(item0.getSignature()))) { - bugReporter.reportBug(new BugInstance(this, BugType.JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT.name(), NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - return; - } - if (argTypes[argTypes.length-1].equals(Type.OBJECT) && argTypes[argTypes.length-2].equals(Type.OBJECT)) { - if ("Ljava/lang/Double;".equals(item0.getSignature()) && "Ljava/lang/Double;".equals(item1.getSignature())) { - bugReporter.reportBug(new BugInstance(this, BugType.JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE.name(), NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - return; - } - } - } - } - } else if ("assertNotNull".equals(methodName)) { - if (stack.getStackDepth() > 0) { - if ("valueOf".equals(stack.getStackItem(0).getUserValue())) { - bugReporter.reportBug(new BugInstance(this, BugType.JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL.name(), NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } else if ("assertTrue".equals(methodName)) { - if ((state == State.SAW_ICONST_0) || (state == State.SAW_EQUALS)) { - bugReporter.reportBug(new BugInstance(this, BugType.JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS.name(), NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } else { - String methodName = getNameConstantOperand(); - String sig = getSigConstantOperand(); - if (clsName.startsWith("java/lang/") - && "valueOf".equals(methodName) - && (sig.indexOf(")Ljava/lang/") >= 0)) { - userValue = "valueOf"; - } - } - } else if (seen == ATHROW) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item item = stack.getStackItem(0); - String throwClass = item.getSignature(); - if ("Ljava/lang/AssertionError;".equals(throwClass)) { - bugReporter.reportBug(new BugInstance(this, BugType.JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED.name(), NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - sawAssert = true; - } - } - } - - switch (state) { - case SAW_NOTHING: - case SAW_EQUALS: - if (seen == IF_ICMPNE) - state = State.SAW_IF_ICMPNE; - else - state = State.SAW_NOTHING; - break; - - case SAW_IF_ICMPNE: - if (seen == ICONST_1) - state = State.SAW_ICONST_1; - else - state = State.SAW_NOTHING; - break; - - case SAW_ICONST_1: - if (seen == GOTO) - state = State.SAW_GOTO; - else - state = State.SAW_NOTHING; - break; - - case SAW_GOTO: - if (seen == ICONST_0) - state = State.SAW_ICONST_0; - else - state = State.SAW_NOTHING; - break; - - default: - state = State.SAW_NOTHING; - break; - } - - if ((seen == INVOKEVIRTUAL) || (seen == INVOKESTATIC) || (seen == INVOKESPECIAL)) { - String lcName = getNameConstantOperand().toLowerCase(); - if (seen == INVOKEVIRTUAL) { - String sig = getSigConstantOperand(); - if ("equals".equals(lcName) && "(Ljava/lang/Object;)Z".equals(sig)) { - state = State.SAW_EQUALS; - } - } - - //assume that if you call a method in the unit test class, or call a method with assert of verify in them - //it's possibly doing asserts for you. Yes this is a hack - - if (clsName.equals(getClassConstantOperand()) || lcName.contains("assert") || lcName.contains("verify")) { - sawAssert = true; - } - } - - - } finally { - TernaryPatcher.pre(stack, seen); - stack.sawOpcode(this, seen); - TernaryPatcher.post(stack, seen); - if ((userValue != null) && (stack.getStackDepth() > 0)) { - OpcodeStack.Item item = stack.getStackItem(0); - item.setUserValue(userValue); - } - } - } - - public boolean isFloatingPtPrimitive(String signature) { - return "D".equals(signature) || "F".equals(signature); - } -} Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java 2015-08-16 23:23:57 UTC (rev 1781) @@ -0,0 +1,359 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2015 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.AnnotationEntry; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; + +import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.TernaryPatcher; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.OpcodeStack.CustomUserValue; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** looks for odd uses of the Assert class of the JUnit and TestNG framework */ +@CustomUserValue +public class UnitTestAssertionOddities extends BytecodeScanningDetector { + private enum State { + SAW_NOTHING, SAW_IF_ICMPNE, SAW_ICONST_1, SAW_GOTO, SAW_ICONST_0, SAW_EQUALS + }; + + private enum TestFrameworkType { + UNKNOWN, JUNIT, TESTNG; + } + + private static final String TESTCASE_CLASS = "junit.framework.TestCase"; + private static final String TEST_CLASS = "org.junit.Test"; + private static final String TEST_ANNOTATION_SIGNATURE = "Lorg/junit/Test;"; + private static final String OLD_ASSERT_CLASS = "junit/framework/Assert"; + private static final String NEW_ASSERT_CLASS = "org/junit/Assert"; + + private static final String TESTNG_CLASS = "org.testng.annotations.Test"; + private static final String TESTNG_ANNOTATION_SIGNATURE = "Lorg/testng/annotations/Test;"; + private static final String NG_ASSERT_CLASS = "org/testng/Assert"; + private static final String NG_JUNIT_ASSERT_CLASS = "org/testng/AssertJUnit"; + + private BugReporter bugReporter; + private JavaClass testCaseClass; + private JavaClass testAnnotationClass; + private JavaClass testNGAnnotationClass; + private OpcodeStack stack; + private boolean isTestCaseDerived; + private boolean isAnnotationCapable; + private String clsName; + private boolean sawAssert; + private State state; + private TestFrameworkType frameworkType; + + /** + * constructs a JOA detector given the reporter to report bugs on + * + * @param bugReporter + * the sync of bug reports + */ + public UnitTestAssertionOddities(BugReporter bugReporter) { + this.bugReporter = bugReporter; + + try { + testCaseClass = Repository.lookupClass(TESTCASE_CLASS); + } catch (ClassNotFoundException cnfe) { + testCaseClass = null; + } + try { + testAnnotationClass = Repository.lookupClass(TEST_CLASS); + } catch (ClassNotFoundException cnfe) { + testAnnotationClass = null; + } + + try { + testNGAnnotationClass = Repository.lookupClass(TESTNG_CLASS); + } catch (ClassNotFoundException cnfe) { + testNGAnnotationClass = null; + } + } + + /** + * override the visitor to see if this class could be a test class + * + * @param classContext + * the context object of the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + JavaClass cls = classContext.getJavaClass(); + clsName = cls.getClassName().replace('.', '/'); + isTestCaseDerived = (testCaseClass != null) && cls.instanceOf(testCaseClass); + isAnnotationCapable = (cls.getMajor() >= 5) && ((testAnnotationClass != null) || (testNGAnnotationClass != null)); + if (isTestCaseDerived || isAnnotationCapable) { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } finally { + stack = null; + } + } + + @Override + public void visitCode(Code obj) { + Method m = getMethod(); + frameworkType = isTestCaseDerived && m.getName().startsWith("test") ? TestFrameworkType.JUNIT : TestFrameworkType.UNKNOWN; + + if ((frameworkType == TestFrameworkType.UNKNOWN) && isAnnotationCapable) { + AnnotationEntry[] annotations = m.getAnnotationEntries(); + if (annotations != null) { + for (AnnotationEntry annotation : annotations) { + String annotationType = annotation.getAnnotationType(); + if (annotation.isRuntimeVisible()) { + if (TEST_ANNOTATION_SIGNATURE.equals(annotationType)) { + frameworkType = TestFrameworkType.JUNIT; + break; + } else if (TESTNG_ANNOTATION_SIGNATURE.equals(annotationType)) { + frameworkType = TestFrameworkType.TESTNG; + break; + } + } + } + } + } + + if (frameworkType != TestFrameworkType.UNKNOWN) { + stack.resetForMethodEntry(this); + state = State.SAW_NOTHING; + sawAssert = false; + super.visitCode(obj); + + if (!sawAssert) { + bugReporter.reportBug(new BugInstance(this, frameworkType == TestFrameworkType.JUNIT ? BugType.UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT.name() + : BugType.UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT.name(), LOW_PRIORITY).addClass(this).addMethod(this)); + } + } + } + + @Override + public void sawOpcode(int seen) { + String userValue = null; + + try { + stack.precomputation(this); + + if (seen == INVOKESTATIC) { + String clsName = getClassConstantOperand(); + if (OLD_ASSERT_CLASS.equals(clsName) || NEW_ASSERT_CLASS.equals(clsName) || NG_JUNIT_ASSERT_CLASS.equals(clsName)) { + sawAssert = true; + String methodName = getNameConstantOperand(); + if ("assertEquals".equals(methodName)) { + String signature = getSigConstantOperand(); + Type[] argTypes = Type.getArgumentTypes(signature); + if ((argTypes.length == 2) || (argTypes.length == 3)) { + + if (stack.getStackDepth() >= 2) { + OpcodeStack.Item expectedItem = stack.getStackItem(1); + Object cons1 = expectedItem.getConstant(); + if ((cons1 != null) && argTypes[argTypes.length - 1].equals(Type.BOOLEAN) + && argTypes[argTypes.length - 2].equals(Type.BOOLEAN)) { + bugReporter.reportBug(new BugInstance(this, BugType.UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + return; + } + OpcodeStack.Item item0 = stack.getStackItem(0); + if ((item0.getConstant() != null) && (expectedItem.getConstant() == null) + && ((argTypes.length == 2) || !isFloatingPtPrimitive(item0.getSignature()))) { + bugReporter.reportBug(new BugInstance(this, BugType.UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + return; + } + if (argTypes[argTypes.length - 1].equals(Type.OBJECT) && argTypes[argTypes.length - 2].equals(Type.OBJECT)) { + if ("Ljava/lang/Double;".equals(item0.getSignature()) && "Ljava/lang/Double;".equals(expectedItem.getSignature())) { + bugReporter + .reportBug(new BugInstance(this, BugType.UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + return; + } + } + } + } + } else if ("assertNotNull".equals(methodName)) { + if (stack.getStackDepth() > 0) { + if ("valueOf".equals(stack.getStackItem(0).getUserValue())) { + bugReporter.reportBug(new BugInstance(this, BugType.UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + } + } + } else if ("assertTrue".equals(methodName)) { + if ((state == State.SAW_ICONST_0) || (state == State.SAW_EQUALS)) { + bugReporter.reportBug(new BugInstance(this, BugType.UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + } + } + } else if (NG_ASSERT_CLASS.equals(clsName)) { + sawAssert = true; + String methodName = getNameConstantOperand(); + if ("assertEquals".equals(methodName)) { + String signature = getSigConstantOperand(); + Type[] argTypes = Type.getArgumentTypes(signature); + if ((argTypes.length == 2) || (argTypes.length == 3)) { + + OpcodeStack.Item actualItem, expectedItem; + if ((argTypes.length == 2) && (stack.getStackDepth() >= 2)) { + expectedItem = stack.getStackItem(0); + actualItem = stack.getStackItem(1); + } else if ((argTypes.length == 3) && (stack.getStackDepth() >= 3)) { + expectedItem = stack.getStackItem(1); + actualItem = stack.getStackItem(2); + } else { + return; + } + + Object cons1 = expectedItem.getConstant(); + if ((cons1 != null) && argTypes[argTypes.length - 1].equals(Type.BOOLEAN) && argTypes[argTypes.length - 2].equals(Type.BOOLEAN)) { + bugReporter.reportBug(new BugInstance(this, BugType.UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + return; + } + if ((actualItem.getConstant() != null) && (expectedItem.getConstant() == null) + && ((argTypes.length == 2) || !isFloatingPtPrimitive(actualItem.getSignature()))) { + bugReporter.reportBug(new BugInstance(this, BugType.UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + return; + } + if (argTypes[argTypes.length - 1].equals(Type.OBJECT) && argTypes[argTypes.length - 2].equals(Type.OBJECT)) { + if ("Ljava/lang/Double;".equals(actualItem.getSignature()) && "Ljava/lang/Double;".equals(expectedItem.getSignature())) { + bugReporter.reportBug(new BugInstance(this, BugType.UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + return; + } + } + } + } else if ("assertNotNull".equals(methodName)) { + if (stack.getStackDepth() > 0) { + if ("valueOf".equals(stack.getStackItem(0).getUserValue())) { + bugReporter.reportBug(new BugInstance(this, BugType.UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + } + } + } else if ("assertTrue".equals(methodName)) { + if ((state == State.SAW_ICONST_0) || (state == State.SAW_EQUALS)) { + bugReporter.reportBug(new BugInstance(this, BugType.UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + } + } + } else { + String methodName = getNameConstantOperand(); + String sig = getSigConstantOperand(); + if (clsName.startsWith("java/lang/") && "valueOf".equals(methodName) && (sig.indexOf(")Ljava/lang/") >= 0)) { + userValue = "valueOf"; + } + } + } else if (seen == ATHROW) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + String throwClass = item.getSignature(); + if ("Ljava/lang/AssertionError;".equals(throwClass)) { + bugReporter.reportBug(new BugInstance(this, + frameworkType == TestFrameworkType.JUNIT ? BugType.UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED.name() + : BugType.UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED.name(), + NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this)); + sawAssert = true; + } + } + } + + switch (state) { + case SAW_NOTHING: + case SAW_EQUALS: + if (seen == IF_ICMPNE) { + state = State.SAW_IF_ICMPNE; + } else { + state = State.SAW_NOTHING; + } + break; + + case SAW_IF_ICMPNE: + if (seen == ICONST_1) { + state = State.SAW_ICONST_1; + } else { + state = State.SAW_NOTHING; + } + break; + + case SAW_ICONST_1: + if (seen == GOTO) { + state = State.SAW_GOTO; + } else { + state = State.SAW_NOTHING; + } + break; + + case SAW_GOTO: + if (seen == ICONST_0) { + state = State.SAW_ICONST_0; + } else { + state = State.SAW_NOTHING; + } + break; + + default: + state = State.SAW_NOTHING; + break; + } + + if ((seen == INVOKEVIRTUAL) || (seen == INVOKESTATIC) || (seen == INVOKESPECIAL)) { + String lcName = getNameConstantOperand().toLowerCase(); + if (seen == INVOKEVIRTUAL) { + String sig = getSigConstantOperand(); + if ("equals".equals(lcName) && "(Ljava/lang/Object;)Z".equals(sig)) { + state = State.SAW_EQUALS; + } + } + + // assume that if you call a method in the unit test class, or + // call a method with assert of verify in them + // it's possibly doing asserts for you. Yes this is a hack + + if (clsName.equals(getClassConstantOperand()) || lcName.contains("assert") || lcName.contains("verify")) { + sawAssert = true; + } + } + + } finally { + TernaryPatcher.pre(stack, seen); + stack.sawOpcode(this, seen); + TernaryPatcher.post(stack, seen); + if ((userValue != null) && (stack.getStackDepth() > 0)) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(userValue); + } + } + } + + public boolean isFloatingPtPrimitive(String signature) { + return "D".equals(signature) || "F".equals(signature); + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2015-08-16 23:20:43
|
Revision: 1780 http://sourceforge.net/p/fb-contrib/code/1780 Author: dbrosius Date: 2015-08-16 23:20:38 +0000 (Sun, 16 Aug 2015) Log Message: ----------- sync from githuh Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.properties 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/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/ABC_Sample.java trunk/fb-contrib/samples/AIOB_Sample.java trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/samples/BED_Sample.java trunk/fb-contrib/samples/CBC_Sample.java trunk/fb-contrib/samples/CD_Sample.java trunk/fb-contrib/samples/CIS_Sample.java trunk/fb-contrib/samples/CNC_Sample.java trunk/fb-contrib/samples/COM_Sample.java trunk/fb-contrib/samples/CRF_Sample.java trunk/fb-contrib/samples/CSI_Sample.java trunk/fb-contrib/samples/CTU_Sample.java trunk/fb-contrib/samples/CU_Sample.java trunk/fb-contrib/samples/DRE_Sample.java trunk/fb-contrib/samples/EXS_Sample.java trunk/fb-contrib/samples/FCBL_Sample.java trunk/fb-contrib/samples/HCP_Sample.java trunk/fb-contrib/samples/HES_Sample.java trunk/fb-contrib/samples/ICA_Sample.java trunk/fb-contrib/samples/ISB_Sample.java trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/samples/LO_Sample.java trunk/fb-contrib/samples/LSC_Sample.java trunk/fb-contrib/samples/LSYC_Sample.java trunk/fb-contrib/samples/MDM_Sample.java trunk/fb-contrib/samples/MRC_Sample.java trunk/fb-contrib/samples/MUC_Sample.java trunk/fb-contrib/samples/NAB_Sample.java trunk/fb-contrib/samples/NMCS_Sample.java trunk/fb-contrib/samples/OCP_Sample.java trunk/fb-contrib/samples/OPM_Sample.java trunk/fb-contrib/samples/PCAIL_Sample.java trunk/fb-contrib/samples/PMB_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/samples/SCII_Sample.java trunk/fb-contrib/samples/SCRV_Sample.java trunk/fb-contrib/samples/SC_Sample.java trunk/fb-contrib/samples/SG_Sample.java trunk/fb-contrib/samples/SLS_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/SUA_Sample.java trunk/fb-contrib/samples/UCPM_Sample.java trunk/fb-contrib/samples/UMTP_Sample.java trunk/fb-contrib/samples/UP_Sample.java trunk/fb-contrib/samples/UVA_Sample.java trunk/fb-contrib/samples/WEM_Sample.java trunk/fb-contrib/samples/WOC_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/StatisticsKey.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.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/CharsetIssues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassImpersonatingString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.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/ConflatingResourcesAndFiles.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.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/ContainsBasedConditional.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.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/HangingExecutors.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.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/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/LocalTypeDetector.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/MissingMethodsDetector.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.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/OverlyPermissiveMethod.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/PoorMansEnum.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/StackedTryBlocks.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/SuspiciousLoopSearch.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/Unjitable.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/UnusedParameter.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/AttributesUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CollectionUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/OpcodeUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/PublicAPI.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/TernaryPatcher.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/ToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java trunk/fb-contrib/yank.xls Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/.classpath 2015-08-16 23:20:38 UTC (rev 1780) @@ -2,7 +2,7 @@ <classpath> <classpathentry excluding="**/*.*" kind="src" path="etc"/> <classpathentry kind="src" path="src"/> - <classpathentry excluding="lib/" kind="src" path="samples"/> + <classpathentry excluding="lib/" kind="src" output="target/classes/samples" path="samples"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="lib" path="lib/backport-util-concurrent-3.1.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/> @@ -26,5 +26,6 @@ <classpathentry kind="lib" path="lib/findbugs-3.0.1.jar" sourcepath="lib/sources/findbugs-3.0.1-sources.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> <classpathentry kind="lib" path="lib/junit-4.12.jar"/> - <classpathentry kind="output" path="classes"/> + <classpathentry kind="lib" path="lib/testng-6.9.6.jar"/> + <classpathentry kind="output" path="target/classes/main"/> </classpath> Modified: trunk/fb-contrib/build.properties =================================================================== --- trunk/fb-contrib/build.properties 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/build.properties 2015-08-16 23:20:38 UTC (rev 1780) @@ -6,6 +6,6 @@ source.. = src/,\ etc/,\ samples/ -output.. = classes/ +output.. = target/classes/main proxy.server = Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/build.xml 2015-08-16 23:20:38 UTC (rev 1780) @@ -7,40 +7,33 @@ <property file="version.properties" /> <property name="src.dir" value="${basedir}/src" /> - <property name="classes.dir" value="${basedir}/classes" /> <property name="lib.dir" value="${basedir}/lib" /> <property name="etc.dir" value="${basedir}/etc" /> + <property name="target.dir" value="${basedir}/target" /> <property name="samples.dir" value="${basedir}/samples" /> - <property name="javadoc.dir" value="${basedir}/javadoc" /> + <property name="main.classes.dir" value="${target.dir}/classes/main" /> + <property name="samples.classes.dir" value="${target.dir}/classes/samples" /> + <property name="javadoc.dir" value="${target.dir}/javadoc" /> <property name="htdocs.dir" value="${basedir}/htdocs" /> <property name="javac.source" value="1.6" /> <property name="javac.target" value="1.6" /> <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="6.2.0" /> + <property name="fb-contrib.version" value="6.3.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> <target name="clean" description="removes all generated collateral"> - <delete dir="${classes.dir}" /> - <delete dir="${javadoc.dir}" /> + <delete dir="${target.dir}" /> <delete file="${htdocs.dir}/bugdescriptions.html" /> - <delete file="${basedir}/fb-contrib-${fb-contrib.version}.jar" /> - <delete file="${basedir}/fb-contrib-src-${fb-contrib.version}.zip" /> - <delete> - <fileset dir="${samples.dir}"> - <include name="**/*.class" /> - </fileset> - </delete> - <delete dir="${basedir}/plugin" /> </target> <target name="infra_jars" description="pull jars needed to build fb-contrib to ${user.dir}/.ant/lib"> <mkdir dir="${user.home}/.ant/lib" /> <get src="http://repo1.maven.org/maven2/com/mebigfatguy/yank/yank/1.4.0/yank-1.4.0.jar" dest="${user.home}/.ant/lib"/> <get src="https://bitbucket.org/klubick/bugrankcheckstyle/downloads/bug-rank-check-style-1.0.0.jar" dest="${user.home}/.ant/lib"/> - <get src="http://repo1.maven.org/maven2/com/mebigfatguy/vcsversion/vcsversion/0.2.0/vcsversion-0.2.0.jar" dest="${user.home}/.ant/lib"/> + <get src="http://repo1.maven.org/maven2/com/mebigfatguy/vcsversion/vcsversion/0.4.0/vcsversion-0.4.0.jar" dest="${user.home}/.ant/lib"/> </target> <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank" unless="no.yank"> @@ -76,7 +69,8 @@ <target name="-init" depends="yank"> <mkdir dir="${lib.dir}" /> - <mkdir dir="${classes.dir}" /> + <mkdir dir="${main.classes.dir}" /> + <mkdir dir="${samples.classes.dir}" /> <mkdir dir="${javadoc.dir}" /> <path id="fb-contrib.classpath"> <pathelement location="${lib.dir}/findbugs-${findbugs.version}.jar" /> @@ -87,6 +81,7 @@ <path id="fb-contrib.samples.classpath"> <pathelement location="${lib.dir}/javax.servlet.jsp-api-${javax.servlet.jsp-api.version}.jar" /> <pathelement location="${lib.dir}/junit-${junit.version}.jar" /> + <pathelement location="${lib.dir}/testng-${testng.version}.jar" /> <pathelement location="${lib.dir}/javax.servlet-api-${javax.servlet-api.version}.jar" /> <pathelement location="${lib.dir}/log4j-${log4j.version}.jar" /> <pathelement location="${lib.dir}/commons-lang3-${commons-lang3.version}.jar" /> @@ -111,19 +106,19 @@ </target> <target name="compile" depends="-init" description="compiles java files"> - <javac srcdir="${src.dir}" destdir="${classes.dir}" source="${javac.source}" target="${javac.target}" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> + <javac srcdir="${src.dir}" destdir="${main.classes.dir}" source="${javac.source}" target="${javac.target}" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> <classpath refid="fb-contrib.classpath" /> </javac> </target> <target name="compile_samples" depends="-init" description="compiles sample problem files"> - <javac srcdir="${samples.dir}" destdir="${samples.dir}" source="1.7" target="1.7" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> + <javac srcdir="${samples.dir}" destdir="${samples.classes.dir}" source="1.7" target="1.7" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> <compilerarg value="-XDignore.symbol.file"/> <classpath refid="fb-contrib.classpath" /> <classpath refid="fb-contrib.samples.classpath" /> </javac> <delete file="${samples.dir}/SJVU_Sample.class" /> - <javac srcdir="${samples.dir}" destdir="${samples.dir}" source="1.4" target="1.4" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> + <javac srcdir="${samples.dir}" destdir="${samples.classes.dir}" source="1.4" target="1.4" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> <include name="SJVU_Sample.java" /> <classpath refid="fb-contrib.classpath" /> <classpath refid="fb-contrib.samples.classpath" /> @@ -132,14 +127,14 @@ <target name="jar" depends="compile" xmlns:vcs="antlib:com.mebigfatguy.vcsversion" description="produces the fb-contrib jar file"> <vcs:vcsversion vcs="git" revisionProperty="_rev_" dateProperty="_date_" branchProperty="_branch_"/> - <jar destfile="${basedir}/fb-contrib-${fb-contrib.version}.jar"> + <jar destfile="${target.dir}/fb-contrib-${fb-contrib.version}.jar"> <fileset dir="etc"> <include name="findbugs.xml" /> <include name="messages*.xml" /> <include name="bugrank.txt" /> <include name="*.license" /> </fileset> - <fileset dir="${classes.dir}"> + <fileset dir="${main.classes.dir}"> <include name="**/*.class" /> </fileset> <fileset dir="${basedir}"> @@ -159,7 +154,7 @@ <attribute name="Bundle-Vendor" value="FB-Contrib Project" /> <attribute name="Require-Bundle" value="edu.umd.cs.findbugs.plugin.eclipse" /> <attribute name="Bundle-ActivationPolicy" value="lazy" /> - <attribute name="Export-Package" value="com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect, com.mebigfatguy.fbcontrib.debug" /> + <attribute name="Export-Package" value="com.mebigfatguy.fbcontrib, com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect, com.mebigfatguy.fbcontrib.debug, com.mebigfatguy.fbcontrib.utils" /> <attribute name="Import-Package" value="edu.umd.cs.findbugs, edu.umd.cs.findbugs.ba, edu.umd.cs.findbugs.bcel, edu.umd.cs.findbugs.visitclass, org.apache.bcel, org.apache.bcel.classfile, org.apache.bcel.generic" /> </manifest> </jar> @@ -170,7 +165,7 @@ </target> <target name="srczip" description="builds the source distribution zip file"> - <zip destfile="${basedir}/fb-contrib-src-${fb-contrib.version}.zip"> + <zip destfile="${target.dir}/fb-contrib-src-${fb-contrib.version}.zip"> <fileset dir="${basedir}"> <include name="**/*.java" /> <include name="**/*.xml" /> @@ -196,7 +191,7 @@ <target name="install" depends="build" description="installs the plugin into FindBugs"> <echo message="Findbugs: ${findbugs.dir}/plugin"/> <copy todir="${findbugs.dir}/plugin"> - <fileset dir="${basedir}"> + <fileset dir="${target.dir}"> <include name="fb-contrib-${fb-contrib.version}.jar" /> </fileset> </copy> @@ -206,9 +201,9 @@ <target name="sonatype" depends="release" description="prepare an artifact bundle for sonatype"> <mkdir dir="${sonatype.dir}"/> - <copy todir="${sonatype.dir}" file="${basedir}/fb-contrib-${fb-contrib.version}.jar"/> - <copy tofile="${sonatype.dir}/fb-contrib-${fb-contrib.version}-sources.jar" file="${basedir}/fb-contrib-src-${fb-contrib.version}.zip"/> - <jar destfile="${sonatype.dir}/fb-contrib-${fb-contrib.version}-javadoc.jar" basedir="${basedir}" includes="javadoc/**"/> + <copy todir="${sonatype.dir}" file="${target.dir}/fb-contrib-${fb-contrib.version}.jar"/> + <copy tofile="${sonatype.dir}/fb-contrib-${fb-contrib.version}-sources.jar" file="${target.dir}/fb-contrib-src-${fb-contrib.version}.zip"/> + <jar destfile="${sonatype.dir}/fb-contrib-${fb-contrib.version}-javadoc.jar" basedir="${target.dir}" includes="javadoc/**"/> <copy tofile="${sonatype.dir}/fb-contrib-${fb-contrib.version}.pom" file="${basedir}/pom.xml"/> <exec executable="gpg"> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/etc/bugrank.txt 2015-08-16 23:20:38 UTC (rev 1780) @@ -27,6 +27,7 @@ +0 BugPattern CLI_CONSTANT_LIST_INDEX +0 BugPattern CNC_COLLECTION_NAMING_CONFUSION +0 BugPattern COM_COPIED_OVERRIDDEN_METHOD ++0 BugPattern COM_PARENT_DELEGATED_CALL +0 BugPattern CRF_CONFLATING_RESOURCES_AND_FILES +0 BugPattern CSBTS_COMMONS_STRING_BUILDER_TOSTRING +0 BugPattern CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING @@ -68,13 +69,6 @@ +0 BugPattern ISB_TOSTRING_APPENDING +0 BugPattern ITC_INHERITANCE_TYPE_CHECKING +2 BugPattern ITU_INAPPROPRIATE_TOSTRING_USE -+0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT -+0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED -+0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT -+0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL -+0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE -+2 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT -+0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS +0 BugPattern JVR_JDBC_VENDOR_RELIANCE +0 BugPattern LEST_LOST_EXCEPTION_STACK_TRACE +0 BugPattern LGO_LINGERING_GRAPHICS_OBJECT @@ -217,8 +211,23 @@ +0 BugPattern URV_UNRELATED_RETURN_VALUES +0 BugPattern USBR_UNNECESSARY_STORE_BEFORE_RETURN +0 BugPattern USS_USE_STRING_SPLIT ++0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT ++0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED ++0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT ++0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL ++0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE ++2 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT ++0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS ++0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT ++0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED ++0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT ++0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL ++0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE ++2 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT ++0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS +0 BugPattern UTA_USE_TO_ARRAY +0 BugPattern UVA_USE_VAR_ARGS ++0 BugPattern WEM_OBSCURING_EXCEPTION +0 BugPattern WEM_WEAK_EXCEPTION_MESSAGING +0 BugPattern WOC_WRITE_ONLY_COLLECTION_FIELD +0 BugPattern WOC_WRITE_ONLY_COLLECTION_LOCAL Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/etc/findbugs.xml 2015-08-16 23:20:38 UTC (rev 1780) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -34,7 +34,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" /> @@ -83,7 +83,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryStoreBeforeReturn" speed="fast" reports="USBR_UNNECESSARY_STORE_BEFORE_RETURN" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.CopiedOverriddenMethod" speed="fast" reports="COM_COPIED_OVERRIDDEN_METHOD" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.CopiedOverriddenMethod" speed="fast" reports="COM_COPIED_OVERRIDDEN_METHOD,COM_PARENT_DELEGATED_CALL" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayBasedCollections" speed="fast" reports="ABC_ARRAY_BASED_COLLECTIONS" /> @@ -171,12 +171,12 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingFunctionSemantics" speed="fast" reports="CFS_CONFUSING_FUNCTION_SEMANTICS" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.JUnitAssertionOddities" speed="fast" - reports="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT,JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE,JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT,JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED,JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS,JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnitTestAssertionOddities" speed="fast" + reports="UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT,UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE,UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT,UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED,UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS,UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT,UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT,UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE,UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT,UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED,UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS,UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT," /> <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousCloneAlgorithm" speed="fast" reports="SCA_SUSPICIOUS_CLONE_ALGORITHM" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.WeakExceptionMessaging" speed="fast" reports="WEM_WEAK_EXCEPTION_MESSAGING" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.WeakExceptionMessaging" speed="fast" reports="WEM_WEAK_EXCEPTION_MESSAGING,WEM_OBSCURING_EXCEPTION" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousClusteredSessionSupport" speed="fast" reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" /> @@ -285,13 +285,13 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles" speed="fast" reports="CRF_CONFLATING_RESOURCES_AND_FILES" /> - <!-- COMMENT OUT FOR POINT RELEASE + <!-- COMMENT OUT FOR POINT RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod" speed="fast" reports="OPM_OVERLY_PERMISSIVE_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ClassImpersonatingString" speed="fast" reports="CIS_STRING_PARSING_A_FIELD,CIS_TOSTRING_STORED_IN_FIELD" /> - COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -328,6 +328,7 @@ <BugPattern abbrev="NAB" type="NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION" category="PERFORMANCE" /> <BugPattern abbrev="USBR" type="USBR_UNNECESSARY_STORE_BEFORE_RETURN" category="STYLE" /> <BugPattern abbrev="COM" type="COM_COPIED_OVERRIDDEN_METHOD" category="STYLE" /> + <BugPattern abbrev="COM" type="COM_PARENT_DELEGATED_CALL" category="STYLE" /> <BugPattern abbrev="ABC" type="ABC_ARRAY_BASED_COLLECTIONS" category="CORRECTNESS" /> <BugPattern abbrev="ODN" type="ODN_ORPHANED_DOM_NODE" category="CORRECTNESS" /> <BugPattern abbrev="AOM" type="AOM_ABSTRACT_OVERRIDDEN_METHOD" category="CORRECTNESS" /> @@ -416,15 +417,23 @@ <BugPattern abbrev="EXS" type="EXS_EXCEPTION_SOFTENING_NO_CHECKED" category="STYLE" /> <BugPattern abbrev="EXS" type="EXS_EXCEPTION_SOFTENING_RETURN_FALSE" category="STYLE" /> <BugPattern abbrev="CFS" type="CFS_CONFUSING_FUNCTION_SEMANTICS" category="STYLE" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT" category="STYLE" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE" category="STYLE" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT" category="STYLE" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" category="CORRECTNESS" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED" category="CORRECTNESS" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS" category="CORRECTNESS" /> - <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT" category="CORRECTNESS" /> - <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT" category="STYLE" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE" category="STYLE" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT" category="STYLE" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT" category="STYLE" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE" category="STYLE" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT" category="STYLE" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS" category="CORRECTNESS" /> + <BugPattern abbrev="UTAO" type="UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT" category="CORRECTNESS" /> + <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" /> <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" /> + <BugPattern abbrev="WEM" type="WEM_OBSCURING_EXCEPTION" category="STYLE" /> <BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_CLASS" category="CORRECTNESS" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/etc/messages.xml 2015-08-16 23:20:38 UTC (rev 1780) @@ -851,13 +851,13 @@ </Details> </Detector> - <Detector class="com.mebigfatguy.fbcontrib.detect.JUnitAssertionOddities"> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnitTestAssertionOddities"> <Details> <![CDATA[ - <p>Looks for junit test case methods that use assertions with odd parameters. + <p>Looks for junit or testng test case methods that use assertions with odd parameters. Including in this is: <ul> - <li>Passing a constant as the second (actual) parameter</li> + <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> <li>Passing true or false as the first parameter instead of using assertTrue, or assertFalse</li> <li>Using the assert keyword</li> @@ -2189,6 +2189,17 @@ ]]> </Details> </BugPattern> + + <BugPattern type="COM_PARENT_DELEGATED_CALL"> + <ShortDescription>Method merely delegates to it's superclass's version</ShortDescription> + <LongDescription>Method {1} merely delegates to it's superclass's version</LongDescription> + <Details> + <![CDATA[ + <p>This method is implemented to just delegate it's implementation by calling + the superclass method with the same signature. This method can just be removed.</p> + ]]> + </Details> + </BugPattern> <BugPattern type="ABC_ARRAY_BASED_COLLECTIONS"> <ShortDescription>Method uses array as basis of collection</ShortDescription> @@ -3332,8 +3343,8 @@ </BugPattern> <BugPattern type="MRC_METHOD_RETURNS_CONSTANT"> - <ShortDescription>Private method only returns one constant value</ShortDescription> - <LongDescription>Private method {1} only returns one constant value</LongDescription> + <ShortDescription>Private or static method only returns one constant value</ShortDescription> + <LongDescription>Private or static method {1} only returns one constant value</LongDescription> <Details> <![CDATA[ <p>This private or static method only returns one constant value. As this method is private or static, @@ -3431,9 +3442,9 @@ </Details> </BugPattern> - <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT"> - <ShortDescription>Method passes constant to second (actual) assertion parameter</ShortDescription> - <LongDescription>Method {1} passes constant to second (actual) assertion parameter</LongDescription> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT"> + <ShortDescription>Junit test method passes constant to second (actual) assertion parameter</ShortDescription> + <LongDescription>Junit test method {1} passes constant to second (actual) assertion parameter</LongDescription> <Details> <![CDATA[ <p>This method calls assert passing a constant value as the second of the two values. The assert @@ -3443,9 +3454,9 @@ </Details> </BugPattern> - <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE"> - <ShortDescription>Method asserts that two doubles are exactly equal</ShortDescription> - <LongDescription>Method {1} asserts that two doubles are exactly equal</LongDescription> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE"> + <ShortDescription>Junit test method asserts that two doubles are exactly equal</ShortDescription> + <LongDescription>Junit test method {1} asserts that two doubles are exactly equal</LongDescription> <Details> <![CDATA[ <p>This method calls assert with two doubles or Doubles. Due to the imprecision of doubles, you @@ -3454,9 +3465,9 @@ </Details> </BugPattern> - <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT"> - <ShortDescription>Method asserts that a value is true or false</ShortDescription> - <LongDescription>Method {1} asserts that a value is true or false</LongDescription> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT"> + <ShortDescription>Junit test method asserts that a value is true or false</ShortDescription> + <LongDescription>Junit test method {1} asserts that a value is true or false</LongDescription> <Details> <![CDATA[ <p>This method asserts that a value is equal to true or false. It is simpler to just @@ -3465,9 +3476,9 @@ </Details> </BugPattern> - <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL"> - <ShortDescription>Method asserts that an auto-boxed value is not null</ShortDescription> - <LongDescription>Method {1} asserts that an auto-boxed value is not null</LongDescription> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL"> + <ShortDescription>Junit test method asserts that an auto-boxed value is not null</ShortDescription> + <LongDescription>Junit test method {1} asserts that an auto-boxed value is not null</LongDescription> <Details> <![CDATA[ <p>This method asserts that a primitive value that was autoboxed into a boxed primitive was not @@ -3477,9 +3488,9 @@ </Details> </BugPattern> - <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED"> - <ShortDescription>Method uses Java asserts rather than a junit assertion</ShortDescription> - <LongDescription>Method {1} uses Java asserts rather than a junit assertion</LongDescription> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED"> + <ShortDescription>Junit test method uses Java asserts rather than a junit assertion</ShortDescription> + <LongDescription>Junit test method {1} uses Java asserts rather than a junit assertion</LongDescription> <Details> <![CDATA[ <p>This method uses a Java assert to assure that a certain state is in effect. As this is @@ -3489,9 +3500,9 @@ </Details> </BugPattern> - <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS"> - <ShortDescription>Method passes boolean expression to Assert.assertTrue</ShortDescription> - <LongDescription>Method {1} passes boolean expression to Assert.assertTrue</LongDescription> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS"> + <ShortDescription>Junit test method passes boolean expression to Assert.assertTrue</ShortDescription> + <LongDescription>Junit test method {1} passes boolean expression to Assert.assertTrue</LongDescription> <Details> <![CDATA[ <p>This method evaluates a boolean expression and passes that to Assert.assertTrue. It is better @@ -3501,9 +3512,9 @@ </Details> </BugPattern> - <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT"> - <ShortDescription>Method appears to have no assertions</ShortDescription> - <LongDescription>Method {1} appears to have no assertions</LongDescription> + <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT"> + <ShortDescription>Junit test method appears to have no assertions</ShortDescription> + <LongDescription>Junit test method {1} appears to have no assertions</LongDescription> <Details> <![CDATA[ <p>This JUnit test method has no assertions. While a unit test could still be valid if it relies on whether @@ -3513,7 +3524,90 @@ ]]> </Details> </BugPattern> + + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT"> + <ShortDescription>TestNG test method passes constant to first (actual) assertion parameter</ShortDescription> + <LongDescription>TestNG test method {1} passes constant to forst (actual) assertion parameter</LongDescription> + <Details> + <![CDATA[ + <p>This method calls assert passing a constant value as the first of the two values. The assert + method assumes that the expected value is the second parameter, and so it appears that the order + of values has been swapped here.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE"> + <ShortDescription>TestNG test method asserts that two doubles are exactly equal</ShortDescription> + <LongDescription>TestNG test method {1} asserts that two doubles are exactly equal</LongDescription> + <Details> + <![CDATA[ + <p>This method calls assert with two doubles or Doubles. Due to the imprecision of doubles, you + should be using the assert method that takes a range parameter that gives a range of error.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT"> + <ShortDescription>TestNG test method asserts that a value is true or false</ShortDescription> + <LongDescription>TestNG test method {1} asserts that a value is true or false</LongDescription> + <Details> + <![CDATA[ + <p>This method asserts that a value is equal to true or false. It is simpler to just + use assertTrue, or assertFalse, instead.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL"> + <ShortDescription>TestNG test method asserts that an auto-boxed value is not null</ShortDescription> + <LongDescription>TestNG test method {1} asserts that an auto-boxed value is not null</LongDescription> + <Details> + <![CDATA[ + <p>This method asserts that a primitive value that was autoboxed into a boxed primitive was not + null. This will never happen, as primitives are never null, and thus the autoboxed value isn't + either.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED"> + <ShortDescription>TestNG test method uses Java asserts rather than a testng assertion</ShortDescription> + <LongDescription>TestNG test method {1} uses Java asserts rather than a testng assertion</LongDescription> + <Details> + <![CDATA[ + <p>This method uses a Java assert to assure that a certain state is in effect. As this is + a testng test it makes more sense to either check this condition with a testng assert, or allow + a following exception to occur.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS"> + <ShortDescription>TestNG test method passes boolean expression to Assert.assertTrue</ShortDescription> + <LongDescription>TestNG test method {1} passes boolean expression to Assert.assertTrue</LongDescription> + <Details> + <![CDATA[ + <p>This method evaluates a boolean expression and passes that to Assert.assertTrue. It is better + to pass the two values that are being equated to the Assert.assertEquals method so that the + TestNG failure method is more meaningful of the intended test.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT"> + <ShortDescription>TestNG test method appears to have no assertions</ShortDescription> + <LongDescription>TestNG test method {1} appears to have no assertions</LongDescription> + <Details> + <![CDATA[ + <p>This TestNG test method has no assertions. While a unit test could still be valid if it relies on whether + or not an exception is thrown, it is usually a sign of a weak test if there are no assertions. It is also + possible that assertions occur in a called method that is not seen by this detector, but this makes the logic of + this test more difficult to reason about.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="SCA_SUSPICIOUS_CLONE_ALGORITHM"> <ShortDescription>Clone method stores a new value to member field of source object</ShortDescription> <LongDescription>Clone method {1} stores a new value to member field of source object</LongDescription> @@ -3538,6 +3632,20 @@ ]]> </Details> </BugPattern> + + <BugPattern type="WEM_OBSCURING_EXCEPTION"> + <ShortDescription>Method throws a java.lang.Exception that wraps a more useful exception</ShortDescription> + <LongDescription>Method {1} throws a java.lang.Exception that wraps a more useful exception</LongDescription> + <Details> + <![CDATA[ + <p>This method catches an exception and generates a new exception of type java.lang.Exception, passing the + original exception as the new Exception's cause. If the original Exception was actually an java.lang.Error, this + is dubious as you should not be handling errors. If the original exception is a more specific exception, there is no + reason to wrap it in an exception of the java.lang.Exception class, and just obfuscates the type of error that is occuring. + </p> + ]]> + </Details> + </BugPattern> <BugPattern type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT"> <ShortDescription>Method modifies http session attribute without calling setAttribute</ShortDescription> @@ -4883,7 +4991,7 @@ <BugCode abbrev="MOM">Misleading Overload Model</BugCode> <BugCode abbrev="EXS">Exception Softening</BugCode> <BugCode abbrev="CFS">Confusing Function Semantics</BugCode> - <BugCode abbrev="JAO">JUnit Assertion Oddities</BugCode> + <BugCode abbrev="UTAO">Unit Test Assertion Oddities</BugCode> <BugCode abbrev="SCA">Suspicious Clone Algorithm</BugCode> <BugCode abbrev="WEM">Weak Exception Messaging</BugCode> <BugCode abbrev="SCSS">Suspicious Clustered Session Support</BugCode> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/htdocs/index.shtml 2015-08-16 23:20:38 UTC (rev 1780) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 6.2.0 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 6.2.1 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on @@ -429,8 +429,8 @@ Looks for implementation of clone where an assignment is made to a field of the source object. It is likely that that store should have occurred on the cloned object, as the clone operation is almost always considered read only.</li> - <li><b>[JAO] JUnit Assertion Oddities</b><br/> - Looks for junit test case methods that use assertions with odd parameters. Things such as, + <li><b>[UTAO] Unit Test Assertion Oddities</b><br/> + Looks for junit or testng test case methods that use assertions with odd parameters. Things such as, passing a constant as the second (actual) parameter, not using the three parameter version of asserts for doubles, or passing true or false as the first parameter instead of using assertTrue, or assertFalse.</li> Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/htdocs/repository.html 2015-08-16 23:20:38 UTC (rev 1780) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>6.0.0</td></tr> + <tr><td><b>Version:</b></td><td>6.2.1</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/pom.xml 2015-08-16 23:20:38 UTC (rev 1780) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>6.2.0</version> + <version>6.3.0</version> <prerequisites> <maven>2.2.1</maven> @@ -70,6 +70,9 @@ <name>Thrawn</name> <email>she...@ya...</email> </contributor> + <contributor> + <name>Juan Martín Sotuyo Dodero</name> + </contributor> </contributors> <licenses> @@ -137,6 +140,7 @@ <build> <sourceDirectory>${basedir}/src</sourceDirectory> + <outputDirectory>${basedir}/target/classes/main</outputDirectory> <resources> <resource> <directory>${basedir}</directory> Modified: trunk/fb-contrib/samples/ABC_Sample.java =================================================================== --- trunk/fb-contrib/samples/ABC_Sample.java 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/samples/ABC_Sample.java 2015-08-16 23:20:38 UTC (rev 1780) @@ -28,7 +28,7 @@ public UseComparator() { testComp = new TreeMap<byte[], byte[]>(new Comparator<byte[]>() { - @Override + @Override public int compare(byte[] b1, byte[] b2) { return b1.length - b2.length; } Modified: trunk/fb-contrib/samples/AIOB_Sample.java =================================================================== --- trunk/fb-contrib/samples/AIOB_Sample.java 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/samples/AIOB_Sample.java 2015-08-16 23:20:38 UTC (rev 1780) @@ -10,11 +10,11 @@ a[4] = 2; fa[4] = 2; } - + public void testOutOfBoundsGuard() { int[] a = new int[4]; - if (a.length > 4){ + if (a.length > 4) { a[4] = 2; } } Modified: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/samples/BAS_Sample.java 2015-08-16 23:20:38 UTC (rev 1780) @@ -6,6 +6,9 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.Future; @SuppressWarnings("all") public class BAS_Sample { @@ -165,22 +168,48 @@ return null; } - + public void testFPNestedIfs(Map<String, String> x, int i, boolean b) { - - String s = x.get("hello"); - - if (i == 0) { - if (b) { - System.out.println(s); - } - } else if (i == 1) { - System.out.println(s); - } else if (i == 2) { - System.out.println(s); - } + + String s = x.get("hello"); + + if (i == 0) { + if (b) { + System.out.println(s); + } + } else if (i == 1) { + System.out.println(s); + } else if (i == 2) { + System.out.println(s); + } } + public boolean testFPFuture(boolean b) { + ExecutorService s = new ForkJoinPool(); + Future f = s.submit(new Runnable() { + public void run() { + } + }); + if (b) { + if (f.isDone()) { + return true; + } + } + + return false; + } + + public int testFPTwoCatches(List<Integer> x) throws Exception { + String msg = "This is a test"; + try { + return x.size() * x.get(0); + } catch (NullPointerException e) { + throw new Exception(msg + "NPE", e); + } catch (IndexOutOfBoundsException e) { + throw new Exception(msg + "IIOBE", e); + } + } + static class Holder { int member; } Modified: trunk/fb-contrib/samples/BED_Sample.java =================================================================== --- trunk/fb-contrib/samples/BED_Sample.java 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/samples/BED_Sample.java 2015-08-16 23:20:38 UTC (rev 1780) @@ -24,17 +24,17 @@ env.put("name", name); DirContext context = new InitialDirContext(env); } - + public void doesTheNasty() throws FileNotFoundException, IOException { - + } - + public void doesTheNasty2() throws IOException, FileNotFoundException { - + } - + public void fpJustAwful() throws IOException, Exception { - + } private void badThrow() throws SQLException { Modified: trunk/fb-contrib/samples/CBC_Sample.java =================================================================== --- trunk/fb-contrib/samples/CBC_Sample.java 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/samples/CBC_Sample.java 2015-08-16 23:20:38 UTC (rev 1780) @@ -1,45 +1,47 @@ public class CBC_Sample { - private static final Integer ONE = Integer.valueOf(1); - private static final Integer TWO = Integer.valueOf(2); - private static final Integer THREE = Integer.valueOf(3); - - enum Giant {Fee, Fi, Fo, Fum }; - - public void testCBCStrings(String x) { - if (x.equals("foo") || x.equals("bar") || x.equals("baz")) { - System.out.println("yup"); - } - } - - public void testCBCClass(Class<?> x) { - if (x.equals(String.class) || x.equals(Integer.class) || x.equals(Long.class)) { - System.out.println("yup"); - } - } - - public void testCBCEnum(Giant x) { - if (x.equals(Giant.Fee) || x.equals(Giant.Fi) || x.equals(Giant.Fo) || x.equals(Giant.Fum)) { - System.out.println("yup"); - } - } - - public void testCBCEnumDoubleEquals(Giant x) { - if ((x == Giant.Fee) || (x ==Giant.Fi) || (x == Giant.Fo) || (x == Giant.Fum)) { - System.out.println("yup"); - } - } - - public void testCBCInteger(Integer x) { - if (x.equals(ONE) || x.equals(TWO) || x.equals(THREE)) { - System.out.println("yup"); - } - } - - public void testCBCPrimitiveInt(int x) { - if ((x == 1) || (x == 2) || (x == 3)) { - System.out.println("yup"); - } - } + private static final Integer ONE = Integer.valueOf(1); + private static final Integer TWO = Integer.valueOf(2); + private static final Integer THREE = Integer.valueOf(3); + + enum Giant { + Fee, Fi, Fo, Fum + }; + + public void testCBCStrings(String x) { + if (x.equals("foo") || x.equals("bar") || x.equals("baz")) { + System.out.println("yup"); + } + } + + public void testCBCClass(Class<?> x) { + if (x.equals(String.class) || x.equals(Integer.class) || x.equals(Long.class)) { + System.out.println("yup"); + } + } + + public void testCBCEnum(Giant x) { + if (x.equals(Giant.Fee) || x.equals(Giant.Fi) || x.equals(Giant.Fo) || x.equals(Giant.Fum)) { + System.out.println("yup"); + } + } + + public void testCBCEnumDoubleEquals(Giant x) { + if ((x == Giant.Fee) || (x == Giant.Fi) || (x == Giant.Fo) || (x == Giant.Fum)) { + System.out.println("yup"); + } + } + + public void testCBCInteger(Integer x) { + if (x.equals(ONE) || x.equals(TWO) || x.equals(THREE)) { + System.out.println("yup"); + } + } + + public void testCBCPrimitiveInt(int x) { + if ((x == 1) || (x == 2) || (x == 3)) { + System.out.println("yup"); + } + } } Modified: trunk/fb-contrib/samples/CD_Sample.java =================================================================== --- trunk/fb-contrib/samples/CD_Sample.java 2015-05-31 14:59:57 UTC (rev 1779) +++ trunk/fb-contrib/samples/CD_Sample.java 2015-08-16 23:20:38 UTC (rev 1780) @@ -1,7 +1,7 @@ public class CD_Sample { Child c = new Child();; - + public void cdTest() { c.childTest(); } @@ -9,7 +9,7 @@ class Child { SubChild sc = new SubChild(); - + public void childTest() { sc.subChildTest(); } @@ -17,26 +17,47 @@ class SubChild { CD_Sample cds = new CD_Sample(); - + public void subChildTest() { cds.toString(); } } class Mammooth { - private int x; - - static class Builder { - private int x; - - public void setX(int x) { - this.x = x; - } - - public Mammooth build() { - Mammooth m = new Mammooth(); - m.x = x; - return m; - } - } + private int x; + + static class Builder { + private int x; + + public void setX(int x) { + this.x = x; + } + + public Mammooth build() { + Mammooth m = new Mammooth(); + m.x = x; + return m; + } + } } + +class SuspectBuilderUse { + private int data; + + public static class Builder { + + int data; + + public void setData(int data) { + this.data = data; + } + } + + public SuspectBuilderUse(Builder b) { + this.data = b.data; + } + + ... [truncated message content] |
From: <dbr...@us...> - 2015-05-31 15:00:00
|
Revision: 1779 http://sourceforge.net/p/fb-contrib/code/1779 Author: dbrosius Date: 2015-05-31 14:59:57 +0000 (Sun, 31 May 2015) 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/CD_Sample.java trunk/fb-contrib/samples/JAO_Sample.java trunk/fb-contrib/samples/OPM_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/BugType.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/build.xml 2015-05-31 14:59:57 UTC (rev 1779) @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="6.1.0" /> + <property name="fb-contrib.version" value="6.2.0" /> <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 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/etc/bugrank.txt 2015-05-31 14:59:57 UTC (rev 1779) @@ -73,6 +73,7 @@ +0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT +0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL +0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE ++2 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT +0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS +0 BugPattern JVR_JDBC_VENDOR_RELIANCE +0 BugPattern LEST_LOST_EXCEPTION_STACK_TRACE Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/etc/findbugs.xml 2015-05-31 14:59:57 UTC (rev 1779) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -34,7 +34,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" /> @@ -172,7 +172,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingFunctionSemantics" speed="fast" reports="CFS_CONFUSING_FUNCTION_SEMANTICS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.JUnitAssertionOddities" speed="fast" - reports="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT,JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE,JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT,JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED,JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS" /> + reports="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT,JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE,JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT,JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL,JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED,JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS,JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousCloneAlgorithm" speed="fast" reports="SCA_SUSPICIOUS_CLONE_ALGORITHM" /> @@ -277,21 +277,21 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConflictingTimeUnits" speed="fast" reports="CTU_CONFLICTING_TIME_UNITS" /> - <!-- COMMENT OUT FOR POINT RELEASE --> - <Detector class="com.mebigfatguy.fbcontrib.detect.CharsetIssues" speed="fast" reports="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET,CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING,CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ContainsBasedConditional" speed="fast" reports="CBC_CONTAINS_BASED_CONDITIONAL" /> - + + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousLoopSearch" speed="fast" reports="SLS_SUSPICIOUS_LOOP_SEARCH" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles" speed="fast" reports="CRF_CONFLATING_RESOURCES_AND_FILES" /> + + <!-- COMMENT OUT FOR POINT RELEASE + <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod" speed="fast" reports="OPM_OVERLY_PERMISSIVE_METHOD" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.ClassImpersonatingString" speed="fast" reports="CIS_STRING_PARSING_A_FIELD,CIS_TOSTRING_STORED_IN_FIELD" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.ClassImpersonatingString" speed="fast" reports="CIS_STRING_PARSING_A_FIELD,CIS_TOSTRING_STORED_IN_FIELD" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousLoopSearch" speed="fast" reports="SLS_SUSPICIOUS_LOOP_SEARCH" /> - - <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles" speed="fast" reports="CRF_CONFLATING_RESOURCES_AND_FILES" /> - - <!-- COMMENT OUT FOR POINT RELEASE --> + COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -399,8 +399,8 @@ <BugPattern abbrev="SPP" type="SPP_NON_USEFUL_TOSTRING" category="STYLE" /> <BugPattern abbrev="SPP" type="SPP_TOSTRING_ON_STRING" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_STRING_BUILDER" category="CORRECTNESS" /> - <BugPattern abbrev="SPP" type="SPP_CONVERSION_OF_STRING_LITERAL" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SPP" type="SPP_STATIC_FORMAT_STRING" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SPP" type="SPP_CONVERSION_OF_STRING_LITERAL" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_STATIC_FORMAT_STRING" category="CORRECTNESS" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> @@ -422,6 +422,7 @@ <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" category="CORRECTNESS" /> <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED" category="CORRECTNESS" /> <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS" category="CORRECTNESS" /> + <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT" category="CORRECTNESS" /> <BugPattern abbrev="SCA" type="SCA_SUSPICIOUS_CLONE_ALGORITHM" category="CORRECTNESS" /> <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" /> <BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" /> @@ -507,14 +508,14 @@ <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL" category="CORRECTNESS"/> <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD" category="CORRECTNESS"/> <BugPattern abbrev="CTU" type="CTU_CONFLICTING_TIME_UNITS" category="CORRECTNESS" /> - <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="CBC" type="CBC_CONTAINS_BASED_CONDITIONAL" category="STYLE" experimental="true"/> + <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET" category="CORRECTNESS"/> + <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME" category="CORRECTNESS"/> + <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING" category="CORRECTNESS"/> + <BugPattern abbrev="CBC" type="CBC_CONTAINS_BASED_CONDITIONAL" category="STYLE"/> <BugPattern abbrev="OPM" type="OPM_OVERLY_PERMISSIVE_METHOD" category="STYLE" experimental="true" /> <BugPattern abbrev="CIS" type="CIS_STRING_PARSING_A_FIELD" category="STYLE" experimental="true" /> <BugPattern abbrev="CIS" type="CIS_TOSTRING_STORED_IN_FIELD" category="STYLE" experimental="true" /> - <BugPattern abbrev="SLS" type="SLS_SUSPICIOUS_LOOP_SEARCH" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="CRF" type="CRF_CONFLATING_RESOURCES_AND_FILES" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SLS" type="SLS_SUSPICIOUS_LOOP_SEARCH" category="CORRECTNESS" /> + <BugPattern abbrev="CRF" type="CRF_CONFLATING_RESOURCES_AND_FILES" category="CORRECTNESS" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/etc/messages.xml 2015-05-31 14:59:57 UTC (rev 1779) @@ -3500,6 +3500,19 @@ ]]> </Details> </BugPattern> + + <BugPattern type="JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT"> + <ShortDescription>Method appears to have no assertions</ShortDescription> + <LongDescription>Method {1} appears to have no assertions</LongDescription> + <Details> + <![CDATA[ + <p>This JUnit test method has no assertions. While a unit test could still be valid if it relies on whether + or not an exception is thrown, it is usually a sign of a weak test if there are no assertions. It is also + possible that assertions occur in a called method that is not seen by this detector, but this makes the logic of + this test more difficult to reason about.</p> + ]]> + </Details> + </BugPattern> <BugPattern type="SCA_SUSPICIOUS_CLONE_ALGORITHM"> <ShortDescription>Clone method stores a new value to member field of source object</ShortDescription> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/htdocs/index.shtml 2015-05-31 14:59:57 UTC (rev 1779) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 6.0.1 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 6.2.0 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on @@ -77,22 +77,15 @@ </div> <hr/> - <img id="git_image" src="flip2.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> + <img id="git_image" src="flip1.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> Detectors added in git<br/> - <div id="git" style="display:block;"> + <div id="git" style="display:none;"> <ul> <li><b>[STB] Stacked Try Blocks</b><br/> Looks for two or more try catch blocks that are consecutive and catch the same kind of exception, and throw the same exception always. These blocks can be coalesced into one. </li> - <li><b>[CSI] Charset Issues</b><br/> - Looks for issues related to manually specified charsets by using string literals. - </li> - <li><b>[CBC] Contains based Conditional</b><br/> - Looks for complex if expressions made up of multiple conditions joined by OR, whereit is much cleaner - to build a static set of the possible values, and use the contains method on that set. - </li> <li><b>[OPM] Overly Permissive Method</b><br/> 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. @@ -101,7 +94,21 @@ Looks for string fields that appear to be built with parsing or calling toString() on another object, or from objects that are fields. </li> - <li><b>[SLS] Suspicious Loop Search</b><br/> + </ul> + </div> + <hr/> + <img id="v6_2_0_image" src="flip2.gif" onClick="toggleBlock('v6_2_0', 'v6_2_0_image');" align="top"/> + Detectors added in v6.2.0<br/> + <div id="v6_2_0" style="display:block;"> + <ul> + <li><b>[CSI] Charset Issues</b><br/> + Looks for issues related to manually specified charsets by using string literals. + </li> + <li><b>[CBC] Contains based Conditional</b><br/> + Looks for complex if expressions made up of multiple conditions joined by OR, whereit is much cleaner + to build a static set of the possible values, and use the contains method on that set. + </li> + <li><b>[SLS] Suspicious Loop Search</b><br/> Looks for loops where an equality check is made and a variable is set because of it. It would seem once the item is found, the loop can be terminated, but is not. </li> @@ -110,14 +117,13 @@ In the case of classpath URIs, this may work if the classpath is resolving to a folder, but will fall for jar files. </li> - </ul> - </div> - + </ul> + </div> <hr/> - <img id="v6_0_0_image" src="flip1.gif" onClick="toggleBlock('v6_0_0', 'v6_0_0_image');" align="top"/> Detectors added in v6.0.0<br/> <div id="v6_0_0" style="display:none;"> + <ul> <li><b>[PSC] Presize Collections</b><br/> Looks for methods that create and populate collections, and while knowing the end size of those collections, does not pre allocate the collection Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/pom.xml 2015-05-31 14:59:57 UTC (rev 1779) @@ -8,8 +8,12 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>6.1.0</version> - + <version>6.2.0</version> + + <prerequisites> + <maven>2.2.1</maven> + </prerequisites> + <parent> <groupId>org.sonatype.oss</groupId> <artifactId>oss-parent</artifactId> @@ -20,7 +24,7 @@ <description>An auxiliary findbugs.sourceforge.net plugin for java bug detectors that fall outside the narrow scope of detectors to be packaged with the product itself.</description> <url>http://fb-contrib.mebigfatguy.com</url> <inceptionYear>2005</inceptionYear> - + <developers> <developer> <id>dbrosius</id> @@ -62,6 +66,10 @@ <contributor> <name>Philippe Arteau</name> </contributor> + <contributor> + <name>Thrawn</name> + <email>she...@ya...</email> + </contributor> </contributors> <licenses> @@ -70,13 +78,13 @@ <url>http://www.gnu.org/licenses/lgpl.txt</url> </license> </licenses> - + <scm> - <connection>scm:svn:https://fb-contrib.svn.sourceforge.net/svnroot/fb-contrib/trunk/</connection> - <developerConnection>scm:svn:https://fb-contrib.svn.sourceforge.net/svnroot/fb-contrib/trunk/</developerConnection> - <url>http://fb-contrib.svn.sourceforge.net/viewvc/fb-contrib/trunk/</url> + <connection>scm:git:https://github.com/mebigfatguy/fb-contrib/</connection> + <developerConnection>scm:git:https://github.com/mebigfatguy/fb-contrib/</developerConnection> + <url>https://github.com/mebigfatguy/fb-contrib/</url> </scm> - + <mailingLists> <mailingList> <name>fb-contrib-commit</name> @@ -85,7 +93,7 @@ <post>fb-...@li...</post> <archive>http://sourceforge.net/mailarchive/forum.php?forum_name=fb-contrib-commit</archive> </mailingList> - + <mailingList> <name>fb-contrib-discuss</name> <subscribe>https://lists.sourceforge.net/mailman/listinfo/fb-contrib-discuss</subscribe> @@ -94,17 +102,18 @@ <archive>http://sourceforge.net/mailarchive/forum.php?forum_name=fb-contrib-discuss</archive> </mailingList> </mailingLists> - + <issueManagement> - <system>SourceForge.net Tracker</system> - <url>http://sourceforge.net/tracker/?group_id=147536</url> + <system>GitHub</system> + <url>https://github.com/mebigfatguy/fb-contrib/issues/</url> </issueManagement> - + <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <maven.build.timestamp.format>E MMM d hh:mm:ss yyyy XX</maven.build.timestamp.format> </properties> - + <dependencies> <dependency> <groupId>com.google.code.findbugs</groupId> @@ -117,13 +126,13 @@ <artifactId>bcel-findbugs</artifactId> <version>6.0</version> <scope>provided</scope> - </dependency> + </dependency> <dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>annotations</artifactId> <version>3.0.0</version> <scope>provided</scope> - </dependency> + </dependency> </dependencies> <build> @@ -132,6 +141,7 @@ <resource> <directory>${basedir}</directory> <includes> + <include>plugin.xml</include> <include>license.txt</include> </includes> </resource> @@ -149,67 +159,109 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> - <version>2.3</version> + <version>2.5</version> </plugin> <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> + <version>1.3</version> + </plugin> + + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.1</version> + <version>3.1</version> + <configuration> + <compilerArgument>-Xlint</compilerArgument> + </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> - <version>2.5</version> + <version>2.8.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.3</version> + <version>2.5.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.3</version> + <version>2.5</version> + <configuration> + <archive> + <manifestEntries> + <fb-contrib-version>${project.version}</fb-contrib-version> + <Main-Class>com.mebigfatguy.fbcontrib.FBContrib</Main-Class> + <git-revision>${scmBranch} ${buildNumber} ${maven.build.timestamp}</git-revision> + <Eclipse-RegisterBuddy>edu.umd.cs.findbugs.plugin.eclipse</Eclipse-RegisterBuddy> + <Bundle-ManifestVersion>2</Bundle-ManifestVersion> + <Bundle-Name>fb-contrib plugin</Bundle-Name> + <Bundle-SymbolicName>fb-contrib; singleton:=true</Bundle-SymbolicName> + <Bundle-Version>${project.version}</Bundle-Version> + <Bundle-ClassPath>.</Bundle-ClassPath> + <Bundle-Vendor>FB-Contrib Project</Bundle-Vendor> + <Require-Bundle>edu.umd.cs.findbugs.plugin.eclipse</Require-Bundle> + <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy> + <Export-Package>com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect, com.mebigfatguy.fbcontrib.debug</Export-Package> + <Import-Package>edu.umd.cs.findbugs, edu.umd.cs.findbugs.ba, edu.umd.cs.findbugs.bcel, edu.umd.cs.findbugs.visitclass, org.apache.bcel, org.apache.bcel.classfile, org.apache.bcel.generic</Import-Package> + </manifestEntries> + </archive> + </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> - <version>2.1.2</version> + <version>2.7</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.4.1</version> + <version>2.6</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> - <version>2.0.1</version> + <version>3.3</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>2.1.1</version> + <version>2.2.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.4.3</version> + <version>2.17</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> + <executions> + <execution> + <phase>validate</phase> + <goals> + <goal>create</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> Modified: trunk/fb-contrib/samples/CD_Sample.java =================================================================== --- trunk/fb-contrib/samples/CD_Sample.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/samples/CD_Sample.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -22,3 +22,21 @@ cds.toString(); } } + +class Mammooth { + private int x; + + static class Builder { + private int x; + + public void setX(int x) { + this.x = x; + } + + public Mammooth build() { + Mammooth m = new Mammooth(); + m.x = x; + return m; + } + } +} Modified: trunk/fb-contrib/samples/JAO_Sample.java =================================================================== --- trunk/fb-contrib/samples/JAO_Sample.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/samples/JAO_Sample.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -1,7 +1,8 @@ +import junit.framework.TestCase; + import org.junit.Assert; +import org.junit.Test; -import junit.framework.TestCase; - public class JAO_Sample extends TestCase { public void testExactDoubles(double d1, double d2) { @@ -40,3 +41,18 @@ } } + +class New { + @Test + public void nada() { + } + + @Test + public void aha() { + check("hello", "world"); + } + + private void check(String a, String b) { + Assert.assertEquals(a, b); + } +} Modified: trunk/fb-contrib/samples/OPM_Sample.java =================================================================== --- trunk/fb-contrib/samples/OPM_Sample.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/samples/OPM_Sample.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -1,3 +1,5 @@ +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -22,16 +24,27 @@ List<String> l = getFoo(new ArrayList<String>()); } + @Override public List<String> getFoo(List<String> l) { return l; } public void fpUncalledDontReport() { + fpHasRTAnnotation(); } + @RT + public void fpHasRTAnnotation() { + } + } abstract class OPMSuper { public abstract List<String> getFoo(List<String> l); } + +@Retention(RetentionPolicy.RUNTIME) +@interface RT { + +} Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -298,6 +298,7 @@ rootScopeBlock.addChild(sb); } else { sb.pushUpLoadStores(); + sb.setStart(pc); } } else { sb = new ScopeBlock(pc, target); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -69,6 +69,7 @@ private OpcodeStack stack; private Set<String> declaredCheckedExceptions; private boolean classIsFinal; + private boolean classIsAnonymous; public BogusExceptionDeclaration(BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -87,7 +88,9 @@ if ((runtimeExceptionClass != null) && (exceptionClass != null)) { stack = new OpcodeStack(); declaredCheckedExceptions = new HashSet<String>(6); - classIsFinal = classContext.getJavaClass().isFinal(); + JavaClass cls = classContext.getJavaClass(); + classIsFinal = cls.isFinal(); + classIsAnonymous = cls.isAnonymous(); super.visitClassContext(classContext); } } finally { @@ -107,9 +110,14 @@ declaredCheckedExceptions.clear(); stack.resetForMethodEntry(this); Method method = getMethod(); + + if (method.isSynthetic()) { + return; + } + ExceptionTable et = method.getExceptionTable(); if (et != null) { - if (classIsFinal || method.isStatic() || method.isPrivate() || method.isFinal() || ((Values.CONSTRUCTOR.equals(method.getName()) && !isAnonymousInnerCtor(method, getThisClass())))) { + if (classIsFinal || classIsAnonymous || method.isStatic() || method.isPrivate() || method.isFinal() || ((Values.CONSTRUCTOR.equals(method.getName()) && !isAnonymousInnerCtor(method, getThisClass())))) { String[] exNames = et.getExceptionNames(); for (String exName : exNames) { try { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -78,6 +78,9 @@ if (refClsName.startsWith(clsName) && (clsName.indexOf('$') >= 0)) return; + + if (isStaticChild(clsName, refClsName) || isStaticChild(refClsName, clsName)) + return; Set<String> dependencies = dependencyGraph.get(clsName); if (dependencies == null) { @@ -117,6 +120,15 @@ dependencyGraph.clear(); } + private boolean isStaticChild(String child, String parent) { + if (!child.startsWith(parent)) { + return false; + } + + String extra = child.substring(parent.length()); + return ((extra.charAt(0) == '.') && (extra.indexOf('.', 1) < 0)); + } + private void removeDependencyLeaves() { boolean changed = true; while (changed) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -56,6 +56,13 @@ ignorableInterfaces.add("java.lang.Cloneable"); ignorableInterfaces.add("java.lang.Comparable"); } + + private static final Comparator<Map.Entry<String, Set<Integer>>> ACCESS_COUNT_COMPARATOR = new Comparator<Map.Entry<String, Set<Integer>>>() { + @Override + public int compare(final Map.Entry<String, Set<Integer>> entry1, final Map.Entry<String, Set<Integer>> entry2) { + return entry2.getValue().size() - entry1.getValue().size(); + } + }; private final BugReporter bugReporter; private OpcodeStack stack; @@ -138,12 +145,7 @@ if (clsAccessCount.size() > 0) { Map.Entry<String, Set<Integer>>[]envies = clsAccessCount.entrySet().toArray(new Map.Entry[clsAccessCount.size()]); - Arrays.sort(envies, new Comparator<Map.Entry<String, Set<Integer>>>() { - @Override - public int compare(final Map.Entry<String, Set<Integer>> entry1, final Map.Entry<String, Set<Integer>> entry2) { - return entry2.getValue().size() - entry1.getValue().size(); - } - }); + Arrays.sort(envies, ACCESS_COUNT_COMPARATOR); Map.Entry<String, Set<Integer>> bestEnvyEntry = envies[0]; int bestEnvyCount = bestEnvyEntry.getValue().size(); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2012 Bhaskar Maddala + * Copyright (C) 2012-2015 Bhaskar Maddala * * 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/JUnitAssertionOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -20,15 +20,9 @@ import org.apache.bcel.Repository; import org.apache.bcel.classfile.AnnotationEntry; -import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.Code; -import org.apache.bcel.classfile.Constant; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantUtf8; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.RuntimeVisibleAnnotations; -import org.apache.bcel.classfile.Unknown; import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.BugType; @@ -47,7 +41,6 @@ { private enum State {SAW_NOTHING, SAW_IF_ICMPNE, SAW_ICONST_1, SAW_GOTO, SAW_ICONST_0, SAW_EQUALS}; - private static final String RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations"; private static final String TESTCASE_CLASS = "junit.framework.TestCase"; private static final String TEST_CLASS = "org.junit.Test"; private static final String TEST_ANNOTATION_SIGNATURE = "Lorg/junit/Test;"; @@ -57,9 +50,12 @@ private BugReporter bugReporter; private JavaClass testCaseClass; private JavaClass testAnnotationClass; + private JavaClass cls; private OpcodeStack stack; private boolean isTestCaseDerived; private boolean isAnnotationCapable; + private String clsName; + private boolean sawAssert; private State state; /** @@ -89,7 +85,8 @@ @Override public void visitClassContext(ClassContext classContext) { try { - JavaClass cls = classContext.getJavaClass(); + cls = classContext.getJavaClass(); + clsName = cls.getClassName().replace('.', '/'); isTestCaseDerived = ((testCaseClass != null) && cls.instanceOf(testCaseClass)); isAnnotationCapable = (cls.getMajor() >= 5) && (testAnnotationClass != null); if (isTestCaseDerived || isAnnotationCapable) { @@ -109,36 +106,12 @@ boolean isTestMethod = isTestCaseDerived && m.getName().startsWith("test"); if (!isTestMethod && isAnnotationCapable) { - Attribute[] atts = m.getAttributes(); - for (Attribute att : atts) { - ConstantPool cp = att.getConstantPool(); - Constant c = cp.getConstant(att.getNameIndex()); - if (c instanceof ConstantUtf8) { - String name = ((ConstantUtf8) c).getBytes(); - if (RUNTIME_VISIBLE_ANNOTATIONS.equals(name)) { - if (att instanceof Unknown) { - Unknown unAtt = (Unknown)att; - byte[] bytes = unAtt.getBytes(); - int constantPoolIndex = bytes[3] & 0x000000FF; - c = cp.getConstant(constantPoolIndex); - if (c instanceof ConstantUtf8) { - name = ((ConstantUtf8) c).getBytes(); - if (TEST_ANNOTATION_SIGNATURE.equals(name)) { - isTestMethod = true; - break; - } - } - } else if (att instanceof RuntimeVisibleAnnotations) { - RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) att; - - AnnotationEntry[] entries = rva.getAnnotationEntries(); - for (AnnotationEntry entry : entries) { - if (TEST_ANNOTATION_SIGNATURE.equals(entry.getAnnotationType())) { - isTestMethod = true; - break; - } - } - } + AnnotationEntry[] annotations = m.getAnnotationEntries(); + if (annotations != null) { + for (AnnotationEntry annotation : annotations) { + if (annotation.isRuntimeVisible() && TEST_ANNOTATION_SIGNATURE.equals(annotation.getAnnotationType())) { + isTestMethod = true; + break; } } } @@ -147,7 +120,14 @@ if (isTestMethod) { stack.resetForMethodEntry(this); state = State.SAW_NOTHING; + sawAssert = false; super.visitCode(obj); + +// if (!sawAssert) { +// bugReporter.reportBug(new BugInstance(this, BugType.JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT.name(), LOW_PRIORITY) +// .addClass(this) +// .addMethod(this)); +// } } } @@ -161,6 +141,7 @@ if (seen == INVOKESTATIC) { String clsName = getClassConstantOperand(); if (OLD_ASSERT_CLASS.equals(clsName) || NEW_ASSERT_CLASS.equals(clsName)) { + sawAssert = true; String methodName = getNameConstantOperand(); if ("assertEquals".equals(methodName)) { String signature = getSigConstantOperand(); @@ -231,6 +212,7 @@ .addClass(this) .addMethod(this) .addSourceLine(this)); + sawAssert = true; } } } @@ -269,13 +251,22 @@ state = State.SAW_NOTHING; break; } - - if (seen == INVOKEVIRTUAL) { - String methodName = getNameConstantOperand(); - String sig = getSigConstantOperand(); - if ("equals".equals(methodName) && "(Ljava/lang/Object;)Z".equals(sig)) { - state = State.SAW_EQUALS; - } + + if ((seen == INVOKEVIRTUAL) || (seen == INVOKESTATIC) || (seen == INVOKESPECIAL)) { + String lcName = getNameConstantOperand().toLowerCase(); + if (seen == INVOKEVIRTUAL) { + String sig = getSigConstantOperand(); + if ("equals".equals(lcName) && "(Ljava/lang/Object;)Z".equals(sig)) { + state = State.SAW_EQUALS; + } + } + + //assume that if you call a method in the unit test class, or call a method with assert of verify in them + //it's possibly doing asserts for you. Yes this is a hack + + if (clsName.equals(getClassConstantOperand()) || lcName.contains("assert") || lcName.contains("verify")) { + sawAssert = true; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -385,6 +385,8 @@ /** * informs the missing method detector that a field should no longer be considered special + * + * @param name the name of the field */ protected void clearSpecialField(String name) { fieldSpecialObjects.remove(name); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -23,6 +23,7 @@ import org.apache.bcel.Constants; import org.apache.bcel.Repository; +import org.apache.bcel.classfile.AnnotationEntry; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; @@ -84,8 +85,10 @@ @Override public void visitCode(Code obj) { - stack.resetForMethodEntry(this); - super.visitCode(obj); + if (!hasRuntimeAnnotations(getMethod())) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } } @Override @@ -140,6 +143,19 @@ } } + private boolean hasRuntimeAnnotations(Method obj) { + AnnotationEntry[] annotations = obj.getAnnotationEntries(); + if (annotations != null) { + for (AnnotationEntry entry : annotations) { + if (entry.isRuntimeVisible()) { + return true; + } + } + } + + return false; + } + /** * checks to see if an instance method is called on the 'this' object * @param sig the signature of the method called to find the called-on object @@ -175,11 +191,11 @@ StatisticsKey key = entry.getKey(); - if (isOverlyPermissive(declaredAccess, mi)) { + if (isOverlyPermissive(declaredAccess)) { try { if (!isDerived(Repository.lookupClass(key.getClassName()), key)) { - BugInstance bi = new BugInstance(this, BugType.OPM_OVERLY_PERMISSIVE_METHOD.name(), NORMAL_PRIORITY) + BugInstance bi = new BugInstance(this, BugType.OPM_OVERLY_PERMISSIVE_METHOD.name(), LOW_PRIORITY) .addClass(key.getClassName()) .addMethod(key.getClassName(), key.getMethodName(), key.getSignature(), (declaredAccess & Constants.ACC_STATIC) != 0); @@ -195,12 +211,11 @@ } } - private static boolean isOverlyPermissive(int declaredAccess, MethodInfo mi) { + private static boolean isOverlyPermissive(int declaredAccess) { if ((declaredAccess & Constants.ACC_PUBLIC) != 0) { return true; } - //TODO: add more permission checks return false; } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -1031,12 +1031,12 @@ do { for (Method m : cls.getMethods()) { - if (m.getName().equals("toString") && m.getSignature().equals("()Ljava/lang/String;")) { + if ("toString".equals(m.getName()) && "()Ljava/lang/String;".equals(m.getSignature())) { return true; } } cls = cls.getSuperClass(); - } while (!cls.getClassName().equals("java.lang.Object")); + } while (!"java.lang.Object".equals(cls.getClassName())); return false; } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -51,7 +51,6 @@ import java.util.concurrent.LinkedBlockingDeque; import org.apache.bcel.classfile.Method; -import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.SignatureUtils; @@ -148,7 +147,6 @@ */ @Override public void visitMethod(Method obj) { - Type[] parms = Type.getArgumentTypes(obj.getSignature()); firstLocalRegister = SignatureUtils.getFirstRegisterSlot(obj); super.visitMethod(obj); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/BugType.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/BugType.java 2015-05-26 03:14:28 UTC (rev 1778) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/BugType.java 2015-05-31 14:59:57 UTC (rev 1779) @@ -106,6 +106,7 @@ JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL, JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE, JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS, + JAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT, JVR_JDBC_VENDOR_RELIANCE, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2015-05-26 03:14:31
|
Revision: 1778 http://sourceforge.net/p/fb-contrib/code/1778 Author: dbrosius Date: 2015-05-26 03:14:28 +0000 (Tue, 26 May 2015) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/samples/LO_Sample.java trunk/fb-contrib/samples/NAB_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/samples/WOC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.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/OverlyPermissiveMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousLoopSearch.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/ToString.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/build.xml 2015-05-26 03:14:28 UTC (rev 1778) @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="6.0.1" /> + <property name="fb-contrib.version" value="6.1.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/etc/findbugs.xml 2015-05-26 03:14:28 UTC (rev 1778) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -34,7 +34,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" /> @@ -277,7 +277,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConflictingTimeUnits" speed="fast" reports="CTU_CONFLICTING_TIME_UNITS" /> - <!-- COMMENT OUT FOR POINT RELEASE + <!-- COMMENT OUT FOR POINT RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.CharsetIssues" speed="fast" reports="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET,CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING,CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME" /> @@ -291,7 +291,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles" speed="fast" reports="CRF_CONFLATING_RESOURCES_AND_FILES" /> - COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/etc/messages.xml 2015-05-26 03:14:28 UTC (rev 1778) @@ -40,6 +40,10 @@ sb.append(a + b); return sb.toString(); </pre> + You should use the .append method to append values + <pre> + sb.append(a).append(b); + </pre> <p>It is a fast detector.</p> ]]> </Details> @@ -2863,8 +2867,8 @@ </BugPattern> <BugPattern type="SPP_STRINGBUFFER_WITH_EMPTY_STRING"> - <ShortDescription>Method passes empty string to StringBuffer of StringBuilder constructor</ShortDescription> - <LongDescription>Method {1} passes empty string to StringBuffer of StringBuilder constructor</LongDescription> + <ShortDescription>Method passes an empty string to StringBuffer of StringBuilder constructor</ShortDescription> + <LongDescription>Method {1} passes an empty string to StringBuffer of StringBuilder constructor</LongDescription> <Details> <![CDATA[ <p>This method calls the StringBuffer or StringBuilder constructor passing in a constant empty string (""). Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/htdocs/index.shtml 2015-05-26 03:14:28 UTC (rev 1778) @@ -68,9 +68,12 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 6.0.0 available for download - <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-6.0.0.jar/download">here</a>.</p> - <p style="font-weight: bold;">This version requires FindBugs 3.0 or better</p> + <p style="font-weight: bold;">The latest version of fb-contrib is 6.0.1 available for download + <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> + <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> + <p style="font-weight: bold;">Please note that active development for this project is now done on + github. If this site seems behind, please <a href="http://github.com/mebigfatguy/fb-contrib">check there</a>. + I will try to keep this site up to date, but I'd appreciate a poke if you see something missing.</p> </div> <hr/> @@ -98,6 +101,15 @@ Looks for string fields that appear to be built with parsing or calling toString() on another object, or from objects that are fields. </li> + <li><b>[SLS] Suspicious Loop Search</b><br/> + Looks for loops where an equality check is made and a variable is set because of it. + It would seem once the item is found, the loop can be terminated, but is not. + </li> + <li><b>[CRF] Conflating Resources and Files</b><br/> + Looks for code that uses the File api on URI/URLs where the reference is not a file based one. + In the case of classpath URIs, this may work if the classpath is resolving to a folder, but will + fall for jar files. + </li> </ul> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/pom.xml 2015-05-26 03:14:28 UTC (rev 1778) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>6.0.1</version> + <version>6.1.0</version> <parent> <groupId>org.sonatype.oss</groupId> Modified: trunk/fb-contrib/samples/BAS_Sample.java =================================================================== --- trunk/fb-contrib/samples/BAS_Sample.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/samples/BAS_Sample.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -165,6 +165,21 @@ return null; } + + public void testFPNestedIfs(Map<String, String> x, int i, boolean b) { + + String s = x.get("hello"); + + if (i == 0) { + if (b) { + System.out.println(s); + } + } else if (i == 1) { + System.out.println(s); + } else if (i == 2) { + System.out.println(s); + } + } static class Holder { int member; Modified: trunk/fb-contrib/samples/LO_Sample.java =================================================================== --- trunk/fb-contrib/samples/LO_Sample.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/samples/LO_Sample.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -20,6 +20,8 @@ private static Logger l4 = Logger.getLogger(ActionEvent.class.getName()); //no tag private static Logger l5 = Logger.getLogger(LO_Sample.class.getName()); + //no tag + private static Logger l6 = Logger.getLogger("my.nasty.logger.LOGGER"); //no tag private Logger someLocalLogger; Modified: trunk/fb-contrib/samples/NAB_Sample.java =================================================================== --- trunk/fb-contrib/samples/NAB_Sample.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/samples/NAB_Sample.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -128,4 +128,9 @@ public Boolean testBooleanReturns() { return true; } + + public Integer testfpTernary(Integer i, int[] data) { + Integer j = (i == null) ? data.length : i; + return j; + } } Modified: trunk/fb-contrib/samples/PRMC_Sample.java =================================================================== --- trunk/fb-contrib/samples/PRMC_Sample.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/samples/PRMC_Sample.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -1,4 +1,5 @@ import java.nio.ByteBuffer; +import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.HashSet; @@ -41,6 +42,11 @@ Factory.getInstance().fo(); Factory.getInstance().fum(); } + + public void repeatedEmptyArrays() { + System.out.println(Arrays.asList(new Integer[0])); + System.out.println(Arrays.asList(new Integer[0])); + } static class Factory { private static Factory f = new Factory(); @@ -106,6 +112,11 @@ SAMPLE2 = new PRMC_Sample(); SAMPLE2.setValue(5); } + + public void fpAsListLiterals() { + System.out.println(Arrays.asList("foo")); + System.out.println(Arrays.asList("bar")); + } public void setValue(int i) { } Modified: trunk/fb-contrib/samples/WOC_Sample.java =================================================================== --- trunk/fb-contrib/samples/WOC_Sample.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/samples/WOC_Sample.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -1,5 +1,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -18,6 +19,11 @@ private final List<String> fpList = new ArrayList<String>(); private List<String> fp1 = new ArrayList<String>(); private List<String> fp2 = new ArrayList<String>(); + private List<String> fp3; + + public WOC_Sample(List<String> x) { + fp3 = x; + } public void testWOCSimple() { //tag WOC_WRITE_ONLY_COLLECTION_LOCAL @@ -141,6 +147,13 @@ } l.add("Hello there"); } + + public void fpClone(List<Data> l) { + HashSet<String> s = new HashSet<>(); + for (Data d : l) { + d.ss = (Set<String>) s.clone(); + } + } public static class FpContains { private List<String> fpSetList; @@ -161,4 +174,12 @@ } } } + + public void fpAddToCtorParm(String x) { + fp3.add(x); + } + + private class Data { + Set<String> ss; + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -102,9 +102,10 @@ } /** - * implements the Detector with a nop + * implements the Detector with a noop */ @Override public void report() { + //not used, part of the Detector interface } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -139,7 +139,7 @@ case BIPUSH: case SIPUSH: - size = getIntConstant(); + size = Integer.valueOf(getIntConstant()); sizeSet = true; break; @@ -212,7 +212,7 @@ int reg = arrayItem.getRegisterNumber(); if ((reg >= 0) && !initializedRegs.get(reg)) { - nullStoreToLocation.put(Integer.valueOf(reg), getPC()); + nullStoreToLocation.put(Integer.valueOf(reg), Integer.valueOf(getPC())); } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -298,8 +298,6 @@ rootScopeBlock.addChild(sb); } else { sb.pushUpLoadStores(); - sb.setStart(pc); - sb.setFinish(target); } } else { sb = new ScopeBlock(pc, target); @@ -370,7 +368,7 @@ rootScopeBlock.addChild(sb); } else if (seen == MONITOREXIT) { if (monitorSyncPCs.size() > 0) { - ScopeBlock sb = findSynchronizedScopeBlock(rootScopeBlock, monitorSyncPCs.get(0)); + ScopeBlock sb = findSynchronizedScopeBlock(rootScopeBlock, monitorSyncPCs.get(0).intValue()); if (sb != null) sb.setFinish(pc); monitorSyncPCs.remove(monitorSyncPCs.size() - 1); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -249,5 +249,6 @@ */ @Override public void report() { + // not used, supplied to support the Detector interface } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -81,6 +81,7 @@ */ @Override public void report() { + // not used, required by the Detector interface } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -80,6 +80,7 @@ exceptionClasses.add(Repository.lookupClass("java/util/concurrent/CopyOnWriteArrayList")); exceptionClasses.add(Repository.lookupClass("java/util/concurrent/CopyOnWriteArraySet")); } catch (ClassNotFoundException cnfe) { + //don't have a bugReporter yet, so do nothing } collectionMethods = new HashSet<String>(3); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -46,6 +46,7 @@ setCls = Repository.lookupClass("java/util/Set"); mapCls = Repository.lookupClass("java/util/Map"); } catch (ClassNotFoundException cnfe) { + // np bugReporter yet, so ignore } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -370,6 +370,7 @@ if (loggingClassName != null) { //first look at the constant passed in loggingClassName = loggingClassName.replace('.', '/'); + loggingPriority = LOW_PRIORITY; } else if (userValue instanceof String){ //try the user value, which may have been set by a call to Foo.class.getName() loggingClassName = (String) userValue; @@ -383,6 +384,7 @@ if (loggingClassName != null) { loggingClassName = loggingClassName.replace('.', '/'); } + loggingPriority = LOW_PRIORITY; } } } else if ("org/apache/commons/logging/LogFactory".equals(callingClsName) && "getLog".equals(mthName)) { @@ -400,6 +402,7 @@ if (loggingClassName != null) { loggingClassName = loggingClassName.replace('.', '/'); } + loggingPriority = LOW_PRIORITY; } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -121,7 +121,7 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); - int register = item.getRegisterNumber(); + Integer register = Integer.valueOf(item.getRegisterNumber()); if (registerConstants.containsKey(register) && (registerConstants.get(register) == null)) { methodSuspect = false; return; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -360,6 +360,10 @@ item.setUserValue(null); } + protected OpcodeStack getStack() { + return stack; + } + /** * Checks to see if any of the locals or fields that we are tracking are passed into * another method. If they are, we clear out our tracking of them, because we can't @@ -378,6 +382,13 @@ } } + + /** + * informs the missing method detector that a field should no longer be considered special + */ + protected void clearSpecialField(String name) { + fieldSpecialObjects.remove(name); + } protected abstract BugInstance makeFieldBugInstance(); protected abstract BugInstance makeLocalBugInstance(); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -18,6 +18,7 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.BitSet; import java.util.HashMap; import java.util.Map; @@ -29,15 +30,16 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; -import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.bcel.OpcodeStackDetector; /** * Looks for methods that pass a primitive wrapper class object, to the * same classes Constructor. */ -public class NeedlessAutoboxing extends BytecodeScanningDetector +public class NeedlessAutoboxing extends OpcodeStackDetector { - enum State {SEEN_NOTHING, SEEN_VALUE, SEEN_VALUEOFSTRING, SEEN_PARSE, SEEN_CTOR, SEEN_VALUEOFPRIMITIVE, SEEN_GOTO, SEEN_ICONST, SEEN_GETSTATIC} + enum State {SEEN_NOTHING, SEEN_VALUE, SEEN_VALUEOFSTRING, SEEN_PARSE, SEEN_CTOR, SEEN_VALUEOFPRIMITIVE, SEEN_ICONST, SEEN_GETSTATIC} private static final Map<String, String[]> boxClasses = new HashMap<String, String[]>(); static { @@ -65,6 +67,7 @@ private BugReporter bugReporter; private State state; private String boxClass; + private BitSet ternaryPCs; /** * constructs a NAB detector given the reporter to report bugs on @@ -73,18 +76,33 @@ public NeedlessAutoboxing(BugReporter bugReporter) { this.bugReporter = bugReporter; } - + @Override + public void visitClassContext(ClassContext classContext) { + try { + ternaryPCs = new BitSet(); + super.visitClassContext(classContext); + } finally { + ternaryPCs = null; + } + } + @Override public void visitMethod(Method obj) { state = State.SEEN_NOTHING; + ternaryPCs.clear(); } @Override public void sawOpcode(int seen) { + if (ternaryPCs.get(getPC())) { + ternaryPCs.clear(getPC()); + state = State.SEEN_NOTHING; + return; + } + switch (state) { case SEEN_NOTHING: - case SEEN_GOTO: if (seen == INVOKEVIRTUAL) { boxClass = getClassConstantOperand(); String[] boxSigs = boxClasses.get(boxClass); @@ -135,7 +153,10 @@ state = State.SEEN_GETSTATIC; } } else if ((seen == GOTO) || (seen == GOTO_W)) { - state = State.SEEN_GOTO; + if (stack.getStackDepth() > 0) { + ternaryPCs.set(getBranchTarget()); + } + state = State.SEEN_NOTHING; } break; @@ -254,6 +275,6 @@ state = State.SEEN_NOTHING; sawOpcode(seen); break; - } + } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -43,6 +43,7 @@ try { serializableClass = Repository.lookupClass("java/io/Serializable"); } catch (ClassNotFoundException cnfe) { + // no bugReporter here, so do nothing } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -254,7 +254,7 @@ } private static String getDeclaredAccessValue(int declaredAccess) { - return DECLARED_ACCESS.get(declaredAccess & (Constants.ACC_PRIVATE|Constants.ACC_PROTECTED|Constants.ACC_PUBLIC)); + return DECLARED_ACCESS.get(Integer.valueOf(declaredAccess & (Constants.ACC_PRIVATE|Constants.ACC_PROTECTED|Constants.ACC_PUBLIC))); } private static Object getRequiredAccessValue(MethodInfo mi) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -66,14 +66,10 @@ } } } - } } catch (ClassNotFoundException cnfe) { - - } finally { - + bugReporter.reportMissingClass(cnfe); } - } /** @@ -132,5 +128,6 @@ @Override public void report() { + // Unused, requirement of the Detector interface } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -247,11 +247,14 @@ } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE) || (seen == INVOKESTATIC)) { String signature = getSigConstantOperand(); int parmCount = Type.getArgumentTypes(signature).length; - int neededStackSize = parmCount - ((seen == INVOKESTATIC) ? 1 : 0); + int neededStackSize = parmCount - ((seen == INVOKESTATIC) ? 0 : 1); if (stack.getStackDepth() > neededStackSize) { Object[] parmConstants = new Object[parmCount]; for (int i = 0; i < parmCount; i++) { OpcodeStack.Item parm = stack.getStackItem(i); + if ((parm.getSignature().charAt(0) == '[') && (!Values.ZERO.equals(parm.getConstant()))) { + return; + } parmConstants[i] = parm.getConstant(); if (parmConstants[i] == null) { return; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -113,7 +113,7 @@ bugReporter.reportBug(new BugInstance(this, BugType.PSC_PRESIZE_COLLECTIONS.name(), NORMAL_PRIORITY) .addClass(this) .addMethod(this) - .addSourceLine(this, pcs.get(0))); + .addSourceLine(this, pcs.get(0).intValue())); } } } @@ -161,7 +161,7 @@ lines = new ArrayList<Integer>(); allocToAddPCs.put(allocNum, lines); } - lines.add(getPC()); + lines.add(Integer.valueOf(getPC())); } } } @@ -180,7 +180,7 @@ lines = new ArrayList<Integer>(); allocToAddPCs.put(allocNum, lines); } - lines.add(getPC()); + lines.add(Integer.valueOf(getPC())); } } } @@ -219,7 +219,7 @@ Integer allocLoc = allocLocation.get(entry.getKey()); if ((allocLoc != null) && (allocLoc.intValue() < target)) { List<Integer> pcs = entry.getValue(); - for (Integer pc : pcs) { + for (int pc : pcs) { if (pc > target) { int numDownBranches = countDownBranches(target, pc); if (numDownBranches == 1) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -697,7 +697,7 @@ Integer stackOffset = methodsThatAreSillyOnStringLiterals.get(methodName + signature); if (stackOffset != null) { - if (stack.getStackDepth() > stackOffset) { + if (stack.getStackDepth() > stackOffset.intValue()) { OpcodeStack.Item itm = stack.getStackItem(stackOffset.intValue()); Object constant = itm.getConstant(); @@ -996,7 +996,7 @@ Object constant = item.getConstant(); if (constant instanceof Double) { - Double v = (Double) constant; + double v = ((Double) constant).doubleValue(); if ((v != 0.0) && (v != 1.0)) { bugReporter.reportBug(new BugInstance(this, BugType.SPP_USE_BIGDECIMAL_STRING_CTOR.name(), NORMAL_PRIORITY) .addClass(this) Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -105,6 +105,7 @@ */ @Override public void report() { + // Unused, requirement of the Detector interface } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -47,6 +47,7 @@ compareClasses.put(Repository.lookupClass("java/lang/Comparable"), "compareTo:1:I"); compareClasses.put(Repository.lookupClass("java/util/Comparator"), "compare:2:I"); } catch (ClassNotFoundException cnfe) { + //don't have a bugReporter yet, so do nothing } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -228,6 +228,7 @@ try { is.close(); } catch (IOException ioe) { + // don't care } } } @@ -302,7 +303,7 @@ return null; } - private static File getRTJarFromProperty(int requestedVersion) { + private static File getRTJarFromProperty(Integer requestedVersion) { String jdkHome = System.getProperty(SJVU_JDKHOME + "." + HUMAN_VERSIONS.get(requestedVersion)); if (jdkHome == null) return null; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousLoopSearch.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousLoopSearch.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousLoopSearch.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -38,6 +38,12 @@ import edu.umd.cs.findbugs.ba.ClassContext; +/** + * looks for loops where an equality check is made and a variable is set because of it. + * It would seem once the item is found, the loop can be terminated, however the code + * continues on, looking for more matches. It is possible the code is looking for the last + * match, but if this we case, a reverse iterator might be more effective. + */ public class SuspiciousLoopSearch extends BytecodeScanningDetector { enum State {SAW_NOTHING, SAW_EQUALS, SAW_IFEQ, SAW_ASSIGNMENT }; @@ -135,7 +141,7 @@ bugReporter.reportBug(new BugInstance(this, BugType.SLS_SUSPICIOUS_LOOP_SEARCH.name(), NORMAL_PRIORITY) .addClass(this) .addMethod(this) - .addSourceLine(this, storeRegs.values().iterator().next())); + .addSourceLine(this, storeRegs.values().iterator().next().intValue())); } } storeRegs.clear(); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -50,10 +50,15 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.LinkedBlockingDeque; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; + import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.SignatureUtils; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.OpcodeStack.CustomUserValue; /** @@ -109,7 +114,6 @@ nonInformationalMethods.add("addFirst"); nonInformationalMethods.add("addLast"); nonInformationalMethods.add("clear"); - nonInformationalMethods.add("clone"); nonInformationalMethods.add("ensureCapacity"); nonInformationalMethods.add("insertElementAt"); nonInformationalMethods.add("push"); @@ -125,6 +129,8 @@ nonInformationalMethods.add("setSize"); nonInformationalMethods.add("trimToSize"); } + + private int firstLocalRegister; /** * constructs a WOC detector given the reporter to report bugs on @@ -134,7 +140,35 @@ super(bugReporter); } + /** + * overrides the visitor to see what how many register slots are taken by + * parameters. + * + * @param obj the currently parsed method + */ @Override + public void visitMethod(Method obj) { + Type[] parms = Type.getArgumentTypes(obj.getSignature()); + firstLocalRegister = SignatureUtils.getFirstRegisterSlot(obj); + super.visitMethod(obj); + } + + @Override + public void sawOpcode(int seen) { + if (seen == PUTFIELD) { + OpcodeStack stack = getStack(); + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + int reg = item.getRegisterNumber(); + if ((reg >= 0) && (reg < firstLocalRegister)) { + clearSpecialField(getNameConstantOperand()); + } + } + } + super.sawOpcode(seen); + } + + @Override protected BugInstance makeFieldBugInstance() { return new BugInstance(this, BugType.WOC_WRITE_ONLY_COLLECTION_FIELD.name(), NORMAL_PRIORITY); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -180,7 +180,25 @@ return parmSigs; } + + /** + * returns the first open register slot after parameters + * + * @param m the method for which you want the parameters + * @return the first available register slot + */ + public static int getFirstRegisterSlot(Method m) { + Type[] parms = m.getArgumentTypes(); + int first = m.isStatic() ? 0 : 1; + for (Type t : parms) { + String signature = t.getSignature(); + first += ("J".equals(signature) || "D".equals(signature)) ? 2 : 1; + } + + return first; + } + public static boolean compareGenericSignature(String genericSignature, String regularSignature) { Type[] regParms = Type.getArgumentTypes(regularSignature); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/ToString.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/ToString.java 2015-05-06 00:39:22 UTC (rev 1777) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/ToString.java 2015-05-26 03:14:28 UTC (rev 1778) @@ -59,7 +59,7 @@ StringBuilder sb = new StringBuilder(100); Class<?> cls = o.getClass(); - int identityHC = System.identityHashCode(o); + Integer identityHC = Integer.valueOf(System.identityHashCode(o)); sb.append(cls.getSimpleName()).append('[').append(identityHC).append("]{"); if (!visitedObjects.contains(identityHC)) { @@ -87,6 +87,7 @@ } } } catch (Exception e) { + // if we get an exception show as much as we can get } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2015-05-06 00:39:24
|
Revision: 1777 http://sourceforge.net/p/fb-contrib/code/1777 Author: dbrosius Date: 2015-05-06 00:39:22 +0000 (Wed, 06 May 2015) Log Message: ----------- Release 6.0.1 Added Paths: ----------- tags/v6_0_1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2015-05-06 00:34:38
|
Revision: 1776 http://sourceforge.net/p/fb-contrib/code/1776 Author: dbrosius Date: 2015-05-06 00:34:33 +0000 (Wed, 06 May 2015) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.properties trunk/fb-contrib/build.xml trunk/fb-contrib/etc/bugdescriptions.xsl trunk/fb-contrib/etc/bugrank.txt trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/findbugsplugin.xsd trunk/fb-contrib/etc/messagecollection.xsd trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/plugin.xml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/AIOB_Sample.java trunk/fb-contrib/samples/BED_Sample.java trunk/fb-contrib/samples/CNC_Sample.java trunk/fb-contrib/samples/EXS_Sample.java trunk/fb-contrib/samples/FCBL_Sample.java trunk/fb-contrib/samples/ICA_Sample.java trunk/fb-contrib/samples/MDM_Sample.java trunk/fb-contrib/samples/MRC_Sample.java trunk/fb-contrib/samples/OCP_Sample.java trunk/fb-contrib/samples/PMB_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/SUA_Sample.java trunk/fb-contrib/samples/UCPM_Sample.java trunk/fb-contrib/samples/UVA_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.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/CircularDependencies.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/CollectionNamingConfusion.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/ConflictingTimeUnits.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/ContraVariantArrayAssignment.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/HangingExecutors.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.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/LocalTypeDetector.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/MissingMethodsDetector.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.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/PoorMansEnum.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/StackedTryBlocks.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/Unjitable.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/UnusedParameter.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/AttributesUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CollectionUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/OpcodeUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/TernaryPatcher.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/samples/CBC_Sample.java trunk/fb-contrib/samples/CIS_Sample.java trunk/fb-contrib/samples/CRF_Sample.java trunk/fb-contrib/samples/CSI_Sample.java trunk/fb-contrib/samples/OPM_Sample.java trunk/fb-contrib/samples/SLS_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/StatisticsKey.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/package.html trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CharsetIssues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassImpersonatingString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflatingResourcesAndFiles.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContainsBasedConditional.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousLoopSearch.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/PublicAPI.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/ToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/user.properties.example Property Changed: ---------------- trunk/fb-contrib/samples/ABC_Sample.java trunk/fb-contrib/samples/ACEM_Sample.java trunk/fb-contrib/samples/AFBR_Sample.java trunk/fb-contrib/samples/AOM_Sample.java trunk/fb-contrib/samples/AWCBR_Sample.java trunk/fb-contrib/samples/BAS_Sample.java trunk/fb-contrib/samples/BSB_Sample.java trunk/fb-contrib/samples/CAO_Sample.java trunk/fb-contrib/samples/CBX_Sample.java trunk/fb-contrib/samples/CE_Sample.java trunk/fb-contrib/samples/CLI_Sample.java trunk/fb-contrib/samples/COM_Sample.java trunk/fb-contrib/samples/DDC_Sample.java trunk/fb-contrib/samples/DLC_Sample.java trunk/fb-contrib/samples/DRE_Sample.java trunk/fb-contrib/samples/DWI_Sample.java trunk/fb-contrib/samples/FCBL_Sample.java trunk/fb-contrib/samples/FPL_Sample.java trunk/fb-contrib/samples/FP_Sample.java trunk/fb-contrib/samples/ISB_Sample.java trunk/fb-contrib/samples/ITC_Sample.java trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/package.html Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2014-07-26 03:46:13 UTC (rev 1775) +++ trunk/fb-contrib/.classpath 2015-05-06 00:34:33 UTC (rev 1776) @@ -4,11 +4,9 @@ <classpathentry kind="src" path="src"/> <classpathentry excluding="lib/" kind="src" path="samples"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> <classpathentry kind="lib" path="lib/backport-util-concurrent-3.1.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/> <classpathentry kind="lib" path="lib/javax.servlet-api-3.1.0.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/javax.servlet.jsp-api-2.3.1.jar"/> <classpathentry kind="lib" path="lib/commons-lang3-3.3.jar"/> @@ -19,7 +17,14 @@ <classpathentry kind="lib" path="lib/httpclient-4.3.4.jar"/> <classpathentry kind="lib" path="lib/annotations-3.0.0.jar"/> <classpathentry kind="lib" path="lib/asm-debug-all-5.0.2.jar"/> - <classpathentry kind="lib" path="lib/bcel-findbugs-6.0.jar"/> - <classpathentry kind="lib" path="lib/findbugs-3.0.0.jar"/> + <classpathentry kind="lib" path="lib/bcel-findbugs-6.0.jar" sourcepath="lib/sources/bcel-findbugs-6.0-sources.jar"> + <attributes> + <attribute name="javadoc_location" value="http://commons.apache.org/proper/commons-bcel/apidocs/"/> + </attributes> + </classpathentry> + <classpathentry kind="lib" path="lib/commons-codec-1.6.jar"/> + <classpathentry kind="lib" path="lib/findbugs-3.0.1.jar" sourcepath="lib/sources/findbugs-3.0.1-sources.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> + <classpathentry kind="lib" path="lib/junit-4.12.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.properties =================================================================== --- trunk/fb-contrib/build.properties 2014-07-26 03:46:13 UTC (rev 1775) +++ trunk/fb-contrib/build.properties 2015-05-06 00:34:33 UTC (rev 1776) @@ -9,5 +9,3 @@ output.. = classes/ proxy.server = - -findbugs.dir=/home/dave/dev/findbugs/findbugs Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2014-07-26 03:46:13 UTC (rev 1775) +++ trunk/fb-contrib/build.xml 2015-05-06 00:34:33 UTC (rev 1776) @@ -1,6 +1,6 @@ <!-- fb-contrib Ant build script. Dave Brosius --> -<project name="fb-contrib" default="info"> +<project name="fb-contrib" default="default"> <property file="user.properties" /> <property file="build.properties" /> @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="6.0.0" /> + <property name="fb-contrib.version" value="6.0.1" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -36,9 +36,16 @@ <delete dir="${basedir}/plugin" /> </target> + <target name="infra_jars" description="pull jars needed to build fb-contrib to ${user.dir}/.ant/lib"> + <mkdir dir="${user.home}/.ant/lib" /> + <get src="http://repo1.maven.org/maven2/com/mebigfatguy/yank/yank/1.4.0/yank-1.4.0.jar" dest="${user.home}/.ant/lib"/> + <get src="https://bitbucket.org/klubick/bugrankcheckstyle/downloads/bug-rank-check-style-1.0.0.jar" dest="${user.home}/.ant/lib"/> + <get src="http://repo1.maven.org/maven2/com/mebigfatguy/vcsversion/vcsversion/0.2.0/vcsversion-0.2.0.jar" dest="${user.home}/.ant/lib"/> + </target> + <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank" unless="no.yank"> <mkdir dir="${lib.dir}" /> - <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true"> + <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true" separateClassifierTypes="true"> <server url="http://repo1.maven.org/maven2" /> <generateVersions propertyFileName="${basedir}/version.properties" /> </yank:yank> @@ -47,13 +54,27 @@ <target name="info"> <echo message="fb-contrib - a findbugs plugin"/> <echo message=""/> - <echo message=" this project uses yank (https://github.com/mebigfatguy/yank) for dependency management"/> - <echo message=" download yank.jar and place in ant/lib directory"/> + <echo message=" This project requires three jars to build fb-contrib: yank, bug-rank-check-style and vcsversion" /> + <echo message=""/> + <echo message=" This project uses yank (https://github.com/mebigfatguy/yank) for dependency management"/> + <echo message=" download yank.jar and place in ~/.ant/lib directory"/> <echo message=" http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.mebigfatguy.yank%22"/> - <antcall target="install"/> + + <echo message="===="/> + <echo message=" Additionally, this project uses bug-rank-check-style to validate etc/bugrank.txt"/> + <echo message=" bug-rank-check-style-1.0.0.jar can be downloaded at https://bitbucket.org/klubick/bugrankcheckstyle/downloads"/> + <echo message=" and put in ~/.ant/lib alongside yank"/> + <echo message="===="/> + <echo message=" Finally, this project uses vcsversion to inject the git version information into the manifest file"/> + <echo message=" and can be downloaded and placed in ~/.ant/lib as well"/> + <echo message=" http://search.maven.org/#search%7Cga%7C1%7Cvcsversion"/> + <echo message="===="/> + <echo message=" This task can be automated by running ant infra_jars"/> </target> + + <target name="default" depends="info, install"/> - <target name="-init" depends="yank" description="prepares repository for a build"> + <target name="-init" depends="yank"> <mkdir dir="${lib.dir}" /> <mkdir dir="${classes.dir}" /> <mkdir dir="${javadoc.dir}" /> @@ -75,15 +96,18 @@ <pathelement location="${lib.dir}/httpclient-cache-${httpclient-cache.version}.jar" /> <pathelement location="${lib.dir}/httpcore-${httpcore.version}.jar" /> <pathelement location="${lib.dir}/httpclient-${httpclient.version}.jar" /> + <pathelement location="${lib.dir}/commons-codec-${commons-codec.version}.jar" /> </path> </target> <target name="validate_xml" depends="-init" description="validates the xml files"> + <taskdef name="bug-rank-check-style" classname="text.style.check.BugRankCheckStyleTask"/> <xmlvalidate lenient="false" failonerror="yes"> <attribute name="http://apache.org/xml/features/validation/schema" value="true" /> <attribute name="http://xml.org/sax/features/namespaces" value="true" /> <fileset dir="${etc.dir}" includes="*.xml" /> </xmlvalidate> + <bug-rank-check-style findbugsxml="etc/findbugs.xml" failOnMissingDetector="false" /> </target> <target name="compile" depends="-init" description="compiles java files"> @@ -106,7 +130,8 @@ </javac> </target> - <target name="jar" depends="compile" description="produces the fb-contrib jar file"> + <target name="jar" depends="compile" xmlns:vcs="antlib:com.mebigfatguy.vcsversion" description="produces the fb-contrib jar file"> + <vcs:vcsversion vcs="git" revisionProperty="_rev_" dateProperty="_date_" branchProperty="_branch_"/> <jar destfile="${basedir}/fb-contrib-${fb-contrib.version}.jar"> <fileset dir="etc"> <include name="findbugs.xml" /> @@ -124,6 +149,7 @@ <manifest> <attribute name="fb-contrib-version" value="${fb-contrib.version}" /> <attribute name="Main-Class" value="com.mebigfatguy.fbcontrib.FBContrib" /> + <attribute name="git-revision" value="${_branch_} ${_rev_} ${_date_}" /> <attribute name="Eclipse-RegisterBuddy" value="edu.umd.cs.findbugs.plugin.eclipse" /> <attribute name="Bundle-ManifestVersion" value="2" /> <attribute name="Bundle-Name" value="fb-contrib plugin" /> @@ -134,7 +160,7 @@ <attribute name="Require-Bundle" value="edu.umd.cs.findbugs.plugin.eclipse" /> <attribute name="Bundle-ActivationPolicy" value="lazy" /> <attribute name="Export-Package" value="com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect, com.mebigfatguy.fbcontrib.debug" /> - <attribute name="Import-Package" value="edu.umd.cs.findbugs, edu.umd.cs.findbugs.ba, edu.umd.cs.findbugs.bceledu.umd.cs.findbugs.visitclass, org.apache.bcel, org.apache.bcel.classfile, org.apache.bcel.generic" /> + <attribute name="Import-Package" value="edu.umd.cs.findbugs, edu.umd.cs.findbugs.ba, edu.umd.cs.findbugs.bcel, edu.umd.cs.findbugs.visitclass, org.apache.bcel, org.apache.bcel.classfile, org.apache.bcel.generic" /> </manifest> </jar> </target> @@ -160,7 +186,7 @@ <target name="javadoc" depends="-init" description="build the javadoc for the project"> <javadoc packagenames="com.mebigfatguy.*" sourcepath="${src.dir}" classpathref="fb-contrib.classpath" destdir="${javadoc.dir}" windowtitle="fb-contrib api"> <doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle> - <bottom><![CDATA[<i>Copyright © 2005-2014 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> + <bottom><![CDATA[<i>Copyright © 2005-2015 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> </javadoc> </target> Modified: trunk/fb-contrib/etc/bugdescriptions.xsl =================================================================== --- trunk/fb-contrib/etc/bugdescriptions.xsl 2014-07-26 03:46:13 UTC (rev 1775) +++ trunk/fb-contrib/etc/bugdescriptions.xsl 2015-05-06 00:34:33 UTC (rev 1776) @@ -40,6 +40,11 @@ <xsl:for-each select="//BugPattern[starts-with(@type,$abbrev)]"> <xsl:sort select="."/> <li> + <a> + <xsl:attribute name="name"> + <xsl:value-of select="@type"/> + </xsl:attribute> + </a> <div class="bugcode"> <xsl:value-of select="@type"/> </div> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2014-07-26 03:46:13 UTC (rev 1775) +++ trunk/fb-contrib/etc/bugrank.txt 2015-05-06 00:34:33 UTC (rev 1776) @@ -1,135 +1,223 @@ -0 BugPattern ISB_INEFFICIENT_STRING_BUFFERING -0 BugPattern ISB_EMPTY_STRING_APPENDING -0 BugPattern SCI_SYNCHRONIZED_COLLECTION_ITERATORS -0 BugPattern CC_CYCLOMATIC_COMPLEXITY -0 BugPattern OCP_OVERLY_CONCRETE_PARAMETER -0 BugPattern LII_LIST_INDEXED_ITERATING -0 BugPattern UCC_UNRELATED_COLLECTION_CONTENTS -0 BugPattern DRE_DECLARED_RUNTIME_EXCEPTION -0 BugPattern CE_CLASS_ENVY -0 BugPattern LSC_LITERAL_STRING_COMPARISON -0 BugPattern PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS -0 BugPattern DLC_DUBIOUS_LIST_COLLECTION -0 BugPattern PL_PARALLEL_LISTS -0 BugPattern FP_FINAL_PARAMETERS -0 BugPattern ACEM_ABSTRACT_CLASS_EMPTY_METHODS -0 BugPattern MAC_MANUAL_ARRAY_COPY -0 BugPattern FPL_FLOATING_POINT_LOOPS -0 BugPattern NCMU_NON_COLLECTION_METHOD_USE -0 BugPattern CAO_CONFUSING_AUTOBOXED_OVERLOADING -0 BugPattern AFBR_ABNORMAL_FINALLY_BLOCK_RETURN -0 BugPattern SMII_STATIC_METHOD_INSTANCE_INVOCATION -0 BugPattern STS_SPURIOUS_THREAD_STATES -0 BugPattern NAB_NEEDLESS_AUTOBOXING_CTOR -0 BugPattern NAB_NEEDLESS_BOXING_STRING_CTOR -0 BugPattern NAB_NEEDLESS_AUTOBOXING_VALUEOF -0 BugPattern NAB_NEEDLESS_BOXING_PARSE -0 BugPattern NAB_NEEDLESS_BOXING_VALUEOF -0 BugPattern NAB_NEEDLESS_BOX_TO_UNBOX -0 BugPattern NAB_NEEDLESS_BOX_TO_CAST -0 BugPattern NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION -0 BugPattern USBR_UNNECESSARY_STORE_BEFORE_RETURN -0 BugPattern COM_COPIED_OVERRIDDEN_METHOD -0 BugPattern ABC_ARRAY_BASED_COLLECTIONS -0 BugPattern ODN_ORPHANED_DOM_NODE -0 BugPattern AOM_ABSTRACT_OVERRIDDEN_METHOD -0 BugPattern CBX_CUSTOM_BUILT_XML -0 BugPattern BSB_BLOATED_SYNCHRONIZED_BLOCK -0 BugPattern CLI_CONSTANT_LIST_INDEX -0 BugPattern SCR_SLOPPY_CLASS_REFLECTION -0 BugPattern AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE -0 BugPattern SG_SLUGGISH_GUI -0 BugPattern NIR_NEEDLESS_INSTANCE_RETRIEVAL -0 BugPattern DDC_DOUBLE_DATE_COMPARISON -0 BugPattern SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT -0 BugPattern JVR_JDBC_VENDOR_RELIANCE -0 BugPattern PMB_POSSIBLE_MEMORY_BLOAT -0 BugPattern LSYC_LOCAL_SYNCHRONIZED_COLLECTION -0 BugPattern FCBL_FIELD_COULD_BE_LOCAL -0 BugPattern NOS_NON_OWNED_SYNCHRONIZATION -0 BugPattern NRTL_NON_RECYCLEABLE_TAG_LIB -0 BugPattern S508C_NULL_LAYOUT -0 BugPattern S508C_NO_SETLABELFOR -0 BugPattern S508C_NO_SETSIZE -0 BugPattern S508C_NON_ACCESSIBLE_JCOMPONENT -0 BugPattern S508C_SET_COMP_COLOR -0 BugPattern UEC_USE_ENUM_COLLECTIONS -0 BugPattern SIL_SQL_IN_LOOP -0 BugPattern NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION -0 BugPattern ITC_INHERITANCE_TYPE_CHECKING -0 BugPattern SACM_STATIC_ARRAY_CREATED_IN_METHOD -0 BugPattern PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS -0 BugPattern UTA_USE_TO_ARRAY -0 BugPattern LEST_LOST_EXCEPTION_STACK_TRACE -0 BugPattern UCPM_USE_CHARACTER_PARAMETERIZED_METHOD -0 BugPattern TR_TAIL_RECURSION -0 BugPattern URV_UNRELATED_RETURN_VALUES -0 BugPattern URV_CHANGE_RETURN_TYPE -0 BugPattern URV_INHERITED_METHOD_WITH_RELATED_TYPES -0 BugPattern PIS_POSSIBLE_INCOMPLETE_SERIALIZATION -0 BugPattern SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES -0 BugPattern SPP_NEGATIVE_BITSET_ITEM -0 BugPattern SPP_INTERN_ON_CONSTANT -0 BugPattern SPP_NO_CHAR_SB_CTOR -0 BugPattern SPP_USE_MATH_CONSTANT -0 BugPattern SPP_STUTTERED_ASSIGNMENT -0 BugPattern SPP_USE_ISNAN -0 BugPattern SPP_USE_BIGDECIMAL_STRING_CTOR -0 BugPattern SPP_STRINGBUFFER_WITH_EMPTY_STRING -0 BugPattern SPP_EQUALS_ON_ENUM -0 BugPattern SPP_INVALID_BOOLEAN_NULL_CHECK -0 BugPattern SPP_USE_CHARAT -0 BugPattern SPP_USELESS_TERNARY -0 BugPattern SPP_SUSPECT_STRING_TEST -0 BugPattern SPP_USE_STRINGBUILDER_LENGTH -0 BugPattern SPP_INVALID_CALENDAR_COMPARE -0 BugPattern SPP_USE_CONTAINSKEY -0 BugPattern SPP_USE_ISEMPTY -0 BugPattern SPP_USE_GETPROPERTY -0 BugPattern SPP_SERIALVER_SHOULD_BE_PRIVATE -0 BugPattern SPP_USELESS_CASING -0 BugPattern SPP_CONVERSION_OF_STRING_LITERAL -0 BugPattern BAS_BLOATED_ASSIGNMENT_SCOPE -0 BugPattern SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR -0 BugPattern DWI_DELETING_WHILE_ITERATING -0 BugPattern DWI_MODIFYING_WHILE_ITERATING -0 BugPattern USS_USE_STRING_SPLIT -0 BugPattern SJVU_SUSPICIOUS_JDK_VERSION_USE -0 BugPattern UAA_USE_ADD_ALL -0 BugPattern MRC_METHOD_RETURNS_CONSTANT -0 BugPattern NCS_NEEDLESS_CUSTOM_SERIALIZATION -0 BugPattern MOM_MISLEADING_OVERLOAD_MODEL -0 BugPattern EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS -0 BugPattern EXS_EXCEPTION_SOFTENING_HAS_CHECKED -0 BugPattern EXS_EXCEPTION_SOFTENING_NO_CHECKED -0 BugPattern CFS_CONFUSING_FUNCTION_SEMANTICS -0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT -0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE -0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT -0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL -0 BugPattern SCA_SUSPICIOUS_CLONE_ALGORITHM -0 BugPattern WEM_WEAK_EXCEPTION_MESSAGING -0 BugPattern SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT -0 BugPattern LO_SUSPECT_LOG_CLASS -0 BugPattern LO_SUSPECT_LOG_PARAMETER -0 BugPattern IICU_INCORRECT_INTERNAL_CLASS_USE -0 BugPattern DSOC_DUBIOUS_SET_OF_COLLECTIONS -0 BugPattern BED_BOGUS_EXCEPTION_DECLARATION -0 BugPattern UNNC_UNNECESSARY_NEW_NULL_CHECK -0 BugPattern DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN -0 BugPattern SMA_STUTTERED_METHOD_ARGUMENTS -0 BugPattern TBP_TRISTATE_BOOLEAN_PATTERN -0 BugPattern SUA_SUSPICIOUS_UNINITIALIZED_ARRAY -0 BugPattern ITU_INAPPROPRIATE_TOSTRING_USE -0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING -0 BugPattern OC_OVERZEALOUS_CASTING -0 BugPattern PDP_POORLY_DEFINED_PARAMETER -0 BugPattern NSE_NON_SYMMETRIC_EQUALS -0 BugPattern CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT -0 BugPattern NFF_NON_FUNCTIONAL_FIELD -0 BugPattern CEBE_COMMONS_EQUAL_BUILDER_TOEQUALS --2 BugPattern HE_LOCAL_EXECUTOR_SERVICE --4 BugPattern HE_EXECUTOR_NEVER_SHUTDOWN --2 BugPattern HE_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN -0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD -0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL \ No newline at end of file ++0 BugPattern ABC_ARRAY_BASED_COLLECTIONS ++2 BugPattern ACEM_ABSTRACT_CLASS_EMPTY_METHODS ++0 BugPattern AFBR_ABNORMAL_FINALLY_BLOCK_RETURN ++0 BugPattern AIOB_ARRAY_INDEX_OUT_OF_BOUNDS ++0 BugPattern AIOB_ARRAY_STORE_TO_NULL_REFERENCE ++0 BugPattern AOM_ABSTRACT_OVERRIDDEN_METHOD ++0 BugPattern AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE ++0 BugPattern BAS_BLOATED_ASSIGNMENT_SCOPE ++0 BugPattern BED_BOGUS_EXCEPTION_DECLARATION ++0 BugPattern BED_HIERARCHICAL_EXCEPTION_DECLARATION ++0 BugPattern BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS ++2 BugPattern BSB_BLOATED_SYNCHRONIZED_BLOCK ++0 BugPattern CAAL_CONFUSING_ARRAY_AS_LIST ++0 BugPattern CAO_CONFUSING_AUTOBOXED_OVERLOADING ++0 BugPattern CBC_CONTAINS_BASED_CONDITIONAL ++0 BugPattern CBX_CUSTOM_BUILT_XML ++0 BugPattern CCNE_COMPARE_CLASS_EQUALS_NAME ++2 BugPattern CC_CYCLOMATIC_COMPLEXITY ++2 BugPattern CD_CIRCULAR_DEPENDENCY ++0 BugPattern CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS ++0 BugPattern CEBE_COMMONS_EQUAL_BUILDER_TOEQUALS ++2 BugPattern CE_CLASS_ENVY ++0 BugPattern CFS_CONFUSING_FUNCTION_SEMANTICS ++0 BugPattern CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE ++0 BugPattern CIS_STRING_PARSING_A_FIELD ++0 BugPattern CIS_TOSTRING_STORED_IN_FIELD ++0 BugPattern CLI_CONSTANT_LIST_INDEX ++0 BugPattern CNC_COLLECTION_NAMING_CONFUSION ++0 BugPattern COM_COPIED_OVERRIDDEN_METHOD ++0 BugPattern CRF_CONFLATING_RESOURCES_AND_FILES ++0 BugPattern CSBTS_COMMONS_STRING_BUILDER_TOSTRING ++0 BugPattern CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING ++0 BugPattern CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET ++0 BugPattern CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME ++0 BugPattern CTU_CONFLICTING_TIME_UNITS ++0 BugPattern CU_CLONE_USABILITY_MISMATCHED_RETURN ++0 BugPattern CU_CLONE_USABILITY_OBJECT_RETURN ++0 BugPattern CU_CLONE_USABILITY_THROWS ++0 BugPattern CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT ++0 BugPattern CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT ++0 BugPattern DDC_DOUBLE_DATE_COMPARISON ++0 BugPattern DLC_DUBIOUS_LIST_COLLECTION ++0 BugPattern DRE_DECLARED_RUNTIME_EXCEPTION ++0 BugPattern DSOC_DUBIOUS_SET_OF_COLLECTIONS ++0 BugPattern DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN ++0 BugPattern DWI_DELETING_WHILE_ITERATING ++0 BugPattern DWI_MODIFYING_WHILE_ITERATING ++0 BugPattern EXS_EXCEPTION_SOFTENING_HAS_CHECKED ++0 BugPattern EXS_EXCEPTION_SOFTENING_NO_CHECKED ++0 BugPattern EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS ++0 BugPattern EXS_EXCEPTION_SOFTENING_RETURN_FALSE ++0 BugPattern FCBL_FIELD_COULD_BE_LOCAL ++0 BugPattern FPL_FLOATING_POINT_LOOPS ++6 BugPattern FP_FINAL_PARAMETERS ++0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD ++0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL ++0 BugPattern HES_EXECUTOR_NEVER_SHUTDOWN ++0 BugPattern HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN ++4 BugPattern HES_LOCAL_EXECUTOR_SERVICE ++0 BugPattern ICA_INVALID_CONSTANT_ARGUMENT ++0 BugPattern IICU_INCORRECT_INTERNAL_CLASS_USE ++0 BugPattern IKNC_INCONSISTENT_HTTP_ATTRIBUTE_CASING ++0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING ++0 BugPattern IPU_IMPROPER_PROPERTIES_USE ++0 BugPattern IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY ++0 BugPattern ISB_EMPTY_STRING_APPENDING ++0 BugPattern ISB_INEFFICIENT_STRING_BUFFERING ++0 BugPattern ISB_TOSTRING_APPENDING ++0 BugPattern ITC_INHERITANCE_TYPE_CHECKING ++2 BugPattern ITU_INAPPROPRIATE_TOSTRING_USE ++0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT ++0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED ++0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT ++0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL ++0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE ++0 BugPattern JAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS ++0 BugPattern JVR_JDBC_VENDOR_RELIANCE ++0 BugPattern LEST_LOST_EXCEPTION_STACK_TRACE ++0 BugPattern LGO_LINGERING_GRAPHICS_OBJECT ++2 BugPattern LII_LIST_INDEXED_ITERATING ++0 BugPattern LO_APPENDED_STRING_IN_FORMAT_STRING ++0 BugPattern LO_EXCEPTION_WITH_LOGGER_PARMS ++0 BugPattern LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS ++0 BugPattern LO_INVALID_FORMATTING_ANCHOR ++0 BugPattern LO_LOGGER_LOST_EXCEPTION_STACK_TRACE ++0 BugPattern LO_STUTTERED_MESSAGE ++0 BugPattern LO_SUSPECT_LOG_CLASS ++0 BugPattern LO_SUSPECT_LOG_PARAMETER ++2 BugPattern LSC_LITERAL_STRING_COMPARISON ++0 BugPattern LSYC_LOCAL_SYNCHRONIZED_COLLECTION ++2 BugPattern MAC_MANUAL_ARRAY_COPY ++0 BugPattern MDM_BIGDECIMAL_EQUALS ++0 BugPattern MDM_INETADDRESS_GETLOCALHOST ++0 BugPattern MDM_LOCK_ISLOCKED ++0 BugPattern MDM_PROMISCUOUS_SERVERSOCKET ++0 BugPattern MDM_RANDOM_SEED ++0 BugPattern MDM_RUNFINALIZATION ++0 BugPattern MDM_RUNTIME_EXIT_OR_HALT ++0 BugPattern MDM_SECURERANDOM ++0 BugPattern MDM_SETDEFAULTLOCALE ++0 BugPattern MDM_SIGNAL_NOT_SIGNALALL ++0 BugPattern MDM_STRING_BYTES_ENCODING ++0 BugPattern MDM_THREAD_FAIRNESS ++0 BugPattern MDM_THREAD_PRIORITIES ++0 BugPattern MDM_THREAD_YIELD ++0 BugPattern MDM_WAIT_WITHOUT_TIMEOUT ++2 BugPattern MOM_MISLEADING_OVERLOAD_MODEL ++0 BugPattern MRC_METHOD_RETURNS_CONSTANT ++0 BugPattern MUC_MODIFYING_UNMODIFIABLE_COLLECTION ++0 BugPattern NAB_NEEDLESS_AUTOBOXING_CTOR ++0 BugPattern NAB_NEEDLESS_AUTOBOXING_VALUEOF ++0 BugPattern NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION ++0 BugPattern NAB_NEEDLESS_BOXING_PARSE ++0 BugPattern NAB_NEEDLESS_BOXING_STRING_CTOR ++0 BugPattern NAB_NEEDLESS_BOXING_VALUEOF ++0 BugPattern NAB_NEEDLESS_BOX_TO_CAST ++0 BugPattern NAB_NEEDLESS_BOX_TO_UNBOX ++0 BugPattern NCMU_NON_COLLECTION_METHOD_USE ++0 BugPattern NCS_NEEDLESS_CUSTOM_SERIALIZATION ++2 BugPattern NFF_NON_FUNCTIONAL_FIELD ++2 BugPattern NIR_NEEDLESS_INSTANCE_RETRIEVAL ++0 BugPattern NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION ++0 BugPattern NOS_NON_OWNED_SYNCHRONIZATION ++0 BugPattern NPMC_NON_PRODUCTIVE_METHOD_CALL ++0 BugPattern NRTL_NON_RECYCLEABLE_TAG_LIB ++0 BugPattern NSE_NON_SYMMETRIC_EQUALS ++0 BugPattern OCP_OVERLY_CONCRETE_PARAMETER ++0 BugPattern OC_OVERZEALOUS_CASTING ++0 BugPattern ODN_ORPHANED_DOM_NODE ++0 BugPattern OPM_OVERLY_PERMISSIVE_METHOD ++0 BugPattern PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP ++2 BugPattern PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS ++0 BugPattern PDP_POORLY_DEFINED_PARAMETER ++0 BugPattern PIS_POSSIBLE_INCOMPLETE_SERIALIZATION ++0 BugPattern PL_PARALLEL_LISTS ++0 BugPattern PMB_INSTANCE_BASED_THREAD_LOCAL ++0 BugPattern PMB_POSSIBLE_MEMORY_BLOAT ++0 BugPattern PME_POOR_MANS_ENUM ++0 BugPattern PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS ++0 BugPattern PSC_PRESIZE_COLLECTIONS ++0 BugPattern PUS_POSSIBLE_UNSUSPECTED_SERIALIZATION ++0 BugPattern ROOM_REFLECTION_ON_OBJECT_METHODS ++0 BugPattern S508C_APPENDED_STRING ++0 BugPattern S508C_NON_ACCESSIBLE_JCOMPONENT ++0 BugPattern S508C_NON_TRANSLATABLE_STRING ++0 BugPattern S508C_NO_SETLABELFOR ++0 BugPattern S508C_NO_SETSIZE ++0 BugPattern S508C_NULL_LAYOUT ++0 BugPattern S508C_SET_COMP_COLOR ++0 BugPattern SACM_STATIC_ARRAY_CREATED_IN_METHOD ++0 BugPattern SCA_SUSPICIOUS_CLONE_ALGORITHM ++0 BugPattern SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR ++0 BugPattern SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR ++0 BugPattern SCI_SYNCHRONIZED_COLLECTION_ITERATORS ++0 BugPattern SCR_SLOPPY_CLASS_REFLECTION ++0 BugPattern SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT ++0 BugPattern SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES ++0 BugPattern SEC_SIDE_EFFECT_CONSTRUCTOR ++0 BugPattern SGSU_SUSPICIOUS_GETTER_SETTER_USE ++0 BugPattern SG_SLUGGISH_GUI ++0 BugPattern SIL_SQL_IN_LOOP ++0 BugPattern SJVU_SUSPICIOUS_JDK_VERSION_USE ++0 BugPattern SLS_SUSPICIOUS_LOOP_SEARCH ++0 BugPattern SMA_STUTTERED_METHOD_ARGUMENTS ++0 BugPattern SMII_STATIC_METHOD_INSTANCE_INVOCATION ++0 BugPattern SNG_SUSPICIOUS_NULL_FIELD_GUARD ++0 BugPattern SNG_SUSPICIOUS_NULL_LOCAL_GUARD ++0 BugPattern SPP_CONVERSION_OF_STRING_LITERAL ++0 BugPattern SPP_DOUBLE_APPENDED_LITERALS ++0 BugPattern SPP_EMPTY_CASING ++0 BugPattern SPP_EQUALS_ON_ENUM ++0 BugPattern SPP_EQUALS_ON_STRING_BUILDER ++0 BugPattern SPP_INTERN_ON_CONSTANT ++0 BugPattern SPP_INVALID_BOOLEAN_NULL_CHECK ++0 BugPattern SPP_INVALID_CALENDAR_COMPARE ++0 BugPattern SPP_NEGATIVE_BITSET_ITEM ++0 BugPattern SPP_NON_ARRAY_PARM ++0 BugPattern SPP_NON_USEFUL_TOSTRING ++0 BugPattern SPP_NO_CHAR_SB_CTOR ++0 BugPattern SPP_NULL_BEFORE_INSTANCEOF ++0 BugPattern SPP_SERIALVER_SHOULD_BE_PRIVATE ++0 BugPattern SPP_STATIC_FORMAT_STRING ++0 BugPattern SPP_STRINGBUFFER_WITH_EMPTY_STRING ++0 BugPattern SPP_STRINGBUILDER_IS_MUTABLE ++0 BugPattern SPP_STUTTERED_ASSIGNMENT ++0 BugPattern SPP_SUSPECT_STRING_TEST ++0 BugPattern SPP_TEMPORARY_TRIM ++0 BugPattern SPP_TOSTRING_ON_STRING ++0 BugPattern SPP_USELESS_CASING ++0 BugPattern SPP_USELESS_TERNARY ++0 BugPattern SPP_USE_BIGDECIMAL_STRING_CTOR ++0 BugPattern SPP_USE_CHARAT ++0 BugPattern SPP_USE_CONTAINSKEY ++0 BugPattern SPP_USE_GET0 ++0 BugPattern SPP_USE_GETPROPERTY ++0 BugPattern SPP_USE_ISEMPTY ++0 BugPattern SPP_USE_ISNAN ++0 BugPattern SPP_USE_MATH_CONSTANT ++0 BugPattern SPP_USE_STRINGBUILDER_LENGTH ++0 BugPattern STB_STACKED_TRY_BLOCKS ++2 BugPattern STS_SPURIOUS_THREAD_STATES ++0 BugPattern SUA_SUSPICIOUS_UNINITIALIZED_ARRAY ++0 BugPattern SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT ++0 BugPattern TBP_TRISTATE_BOOLEAN_PATTERN ++0 BugPattern TR_TAIL_RECURSION ++0 BugPattern UAA_USE_ADD_ALL ++0 BugPattern UCC_UNRELATED_COLLECTION_CONTENTS ++0 BugPattern UCPM_USE_CHARACTER_PARAMETERIZED_METHOD ++0 BugPattern UEC_USE_ENUM_COLLECTIONS ++0 BugPattern UJM_UNJITABLE_METHOD ++0 BugPattern UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER ++0 BugPattern UNNC_UNNECESSARY_NEW_NULL_CHECK ++0 BugPattern UP_UNUSED_PARAMETER ++0 BugPattern URV_CHANGE_RETURN_TYPE ++0 BugPattern URV_INHERITED_METHOD_WITH_RELATED_TYPES ++0 BugPattern URV_UNRELATED_RETURN_VALUES ++0 BugPattern USBR_UNNECESSARY_STORE_BEFORE_RETURN ++0 BugPattern USS_USE_STRING_SPLIT ++0 BugPattern UTA_USE_TO_ARRAY ++0 BugPattern UVA_USE_VAR_ARGS ++0 BugPattern WEM_WEAK_EXCEPTION_MESSAGING ++0 BugPattern WOC_WRITE_ONLY_COLLECTION_FIELD ++0 BugPattern WOC_WRITE_ONLY_COLLECTION_LOCAL Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2014-07-26 03:46:13 UTC (rev 1775) +++ trunk/fb-contrib/etc/findbugs.xml 2015-05-06 00:34:33 UTC (rev 1776) @@ -149,7 +149,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri" speed="fast" - reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL" /> + reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL,SPP_STATIC_FORMAT_STRING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -167,7 +167,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.MisleadingOverloadModel" speed="fast" reports="MOM_MISLEADING_OVERLOAD_MODEL" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.ExceptionSoftening" speed="moderate" reports="EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS,EXS_EXCEPTION_SOFTENING_HAS_CHECKED,EXS_EXCEPTION_SOFTENING_NO_CHECKED" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.ExceptionSoftening" speed="moderate" reports="EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS,EXS_EXCEPTION_SOFTENING_HAS_CHECKED,EXS_EXCEPTION_SOFTENING_NO_CHECKED,EXS_EXCEPTION_SOFTENING_RETURN_FALSE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingFunctionSemantics" speed="fast" reports="CFS_CONFUSING_FUNCTION_SEMANTICS" /> @@ -186,7 +186,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.DubiousSetOfCollections" speed="moderate" reports="DSOC_DUBIOUS_SET_OF_COLLECTIONS" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.BogusExceptionDeclaration" speed="moderate" reports="BED_BOGUS_EXCEPTION_DECLARATION" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.BogusExceptionDeclaration" speed="moderate" reports="BED_BOGUS_EXCEPTION_DECLARATION,BED_HIERARCHICAL_EXCEPTION_DECLARATION" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryNewNullCheck" speed="fast" reports="UNNC_UNNECESSARY_NEW_NULL_CHECK" /> @@ -277,9 +277,22 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConflictingTimeUnits" speed="fast" reports="CTU_CONFLICTING_TIME_UNITS" /> - <!-- COMMENT OUT FOR POINT RELEASE --> - <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE + <Detector class="com.mebigfatguy.fbcontrib.detect.CharsetIssues" speed="fast" reports="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET,CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING,CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ContainsBasedConditional" speed="fast" reports="CBC_CONTAINS_BASED_CONDITIONAL" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod" speed="fast" reports="OPM_OVERLY_PERMISSIVE_METHOD" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ClassImpersonatingString" speed="fast" reports="CIS_STRING_PARSING_A_FIELD,CIS_TOSTRING_STORED_IN_FIELD" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousLoopSearch" speed="fast" reports="SLS_SUSPICIOUS_LOOP_SEARCH" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles" speed="fast" reports="CRF_CONFLATING_RESOURCES_AND_FILES" /> + + COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -387,6 +400,7 @@ <BugPattern abbrev="SPP" type="SPP_TOSTRING_ON_STRING" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_STRING_BUILDER" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_CONVERSION_OF_STRING_LITERAL" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SPP" type="SPP_STATIC_FORMAT_STRING" category="CORRECTNESS" experimental="true" /> <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" /> @@ -400,6 +414,7 @@ <BugPattern abbrev="EXS" type="EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS" category="STYLE" /> <BugPattern abbrev="EXS" type="EXS_EXCEPTION_SOFTENING_HAS_CHECKED" category="STYLE" /> <BugPattern abbrev="EXS" type="EXS_EXCEPTION_SOFTENING_NO_CHECKED" category="STYLE" /> + <BugPattern abbrev="EXS" type="EXS_EXCEPTION_SOFTENING_RETURN_FALSE" category="STYLE" /> <BugPattern abbrev="CFS" type="CFS_CONFUSING_FUNCTION_SEMANTICS" category="STYLE" /> <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT" category="STYLE" /> <BugPattern abbrev="JAO" type="JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE" category="STYLE" /> @@ -421,6 +436,7 @@ <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" /> <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" /> + <BugPattern abbrev="BED" type="BED_HIERARCHICAL_EXCEPTION_DECLARATION" category="CORRECTNESS" /> <BugPattern abbrev="UNNC" type="UNNC_UNNECESSARY_NEW_NULL_CHECK" category="CORRECTNESS" /> <BugPattern abbrev="DTEP" type="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" category="STYLE" /> <BugPattern abbrev="SMA" type="SMA_STUTTERED_METHOD_ARGUMENTS" category="STYLE" /> @@ -476,19 +492,29 @@ <BugPattern abbrev="PSC" type="PSC_PRESIZE_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="UMTP" type="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" category="CORRECTNESS" /> <BugPattern abbrev="NPMC" type="NPMC_NON_PRODUCTIVE_METHOD_CALL" category="CORRECTNESS" /> - <BugPattern abbrev="AIOB" type="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="AIOB" type="AIOB_ARRAY_STORE_TO_NULL_REFERENCE" category="CORRECTNESS" experimental="true" /> + <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" experimental="true" /> - <BugPattern abbrev="PME" type="PME_POOR_MANS_ENUM" category="STYLE" experimental="true" /> - <BugPattern abbrev="UP" type="UP_UNUSED_PARAMETER" category="STYLE" experimental="true" /> + <BugPattern abbrev="CNC" type="CNC_COLLECTION_NAMING_CONFUSION" category="STYLE" /> + <BugPattern abbrev="PME" type="PME_POOR_MANS_ENUM" category="STYLE" /> + <BugPattern abbrev="UP" type="UP_UNUSED_PARAMETER" category="STYLE" /> <BugPattern abbrev="CD" type="CD_CIRCULAR_DEPENDENCY" category="CORRECTNESS" /> - <BugPattern abbrev="MUC" type="MUC_MODIFYING_UNMODIFIABLE_COLLECTION" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="UJM" type="UJM_UNJITABLE_METHOD" category="PERFORMANCE" experimental="true" /> - <BugPattern abbrev="HES" type="HES_EXECUTOR_NEVER_SHUTDOWN" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="HES" type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="HES" type="HES_LOCAL_EXECUTOR_SERVICE" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="CTU" type="CTU_CONFLICTING_TIME_UNITS" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="MUC" type="MUC_MODIFYING_UNMODIFIABLE_COLLECTION" category="CORRECTNESS" /> + <BugPattern abbrev="UJM" type="UJM_UNJITABLE_METHOD" category="PERFORMANCE" /> + <BugPattern abbrev="HES" type="HES_EXECUTOR_NEVER_SHUTDOWN" category="CORRECTNESS" /> + <BugPattern abbrev="HES" type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN" category="CORRECTNESS" /> + <BugPattern abbrev="HES" type="HES_LOCAL_EXECUTOR_SERVICE" category="CORRECTNESS" /> + <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL" category="CORRECTNESS"/> + <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD" category="CORRECTNESS"/> + <BugPattern abbrev="CTU" type="CTU_CONFLICTING_TIME_UNITS" category="CORRECTNESS" /> + <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="CSI" type="CSI_CHAR_SET_ISSUES_UNKNOWN_ENCODING" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="CBC" type="CBC_CONTAINS_BASED_CONDITIONAL" category="STYLE" experimental="true"/> + <BugPattern abbrev="OPM" type="OPM_OVERLY_PERMISSIVE_METHOD" category="STYLE" experimental="true" /> + <BugPattern abbrev="CIS" type="CIS_STRING_PARSING_A_FIELD" category="STYLE" experimental="true" /> + <BugPattern abbrev="CIS" type="CIS_TOSTRING_STORED_IN_FIELD" category="STYLE" experimental="true" /> + <BugPattern abbrev="SLS" type="SLS_SUSPICIOUS_LOOP_SEARCH" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="CRF" type="CRF_CONFLATING_RESOURCES_AND_FILES" category="CORRECTNESS" experimental="true" /> + </FindbugsPlugin> Modified: trunk/fb-contrib/etc/findbugsplugin.xsd =================================================================== --- trunk/fb-contrib/etc/findbugsplugin.xsd 2014-07-26 03:46:13 UTC (rev 1775) +++ trunk/fb-contrib/etc/findbugsplugin.xsd 2015-05-06 00:34:33 UTC (rev 1776) @@ -1,12 +1,11 @@ -<?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - + <xsd:simpleType name="ClassType"> <xsd:restriction base="xsd:string"> - <xsd:pattern value="[A-Za-z_][A-Za-z0-9_]*(.[A-Za-z_][A-Za-z0-9_]*)*"/> + <xsd:pattern value="[A-Za-z_][A-Za-z0-9_]*(.[A-Za-z_][A-Za-z0-9_]*)*"/> </xsd:restriction> </xsd:simpleType> - + <xsd:simpleType name="SpeedType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="fast"/> @@ -14,46 +13,99 @@ <xsd:enumeration value="slow"/> </xsd:restriction> </xsd:simpleType> - + <xsd:simpleType name="BugPatternListType"> <xsd:restriction base="xsd:string"> <xsd:pattern value="[A-Za-z0-9_]*(,[A-Za-z0-9_]*)*"/> </xsd:restriction> </xsd:simpleType> - + <xsd:simpleType name="IdentifierType"> <xsd:restriction base="xsd:string"> <xsd:pattern value="[A-Za-z0-9_]*"/> </xsd:restriction> </xsd:simpleType> + + + <xsd:complexType name="CloudType"> + <xsd:sequence> + <xsd:element name="Property" minOccurs="0" maxOccurs="unbounded" > + <xsd:complexType> + <xsd:simpleContent> + <xsd:extension base="xsd:string"> + <xsd:attribute name="key" type="xsd:string" /> + </xsd:extension> + </xsd:simpleContent> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + <xsd:attribute name="id" type="ClassType"/> + <xsd:attribute name="cloudClass" type="ClassType"/> + <xsd:attribute name="usernameClass" type="ClassType"/> + <xsd:attribute name="disabled" type="xsd:boolean" use="optional"/> + <xsd:attribute name="onlineStorage" type="xsd:boolean" use="optional"/> + <xsd:attribute name="hidden" type="xsd:boolean" use="optional"/> + </xsd:complexType> + + <xsd:complexType name="PluginComponentType"> + <xsd:sequence> + <xsd:element name="Property" minOccurs="0" maxOccurs="unbounded" > + <xsd:complexType> + <xsd:simpleContent> + <xsd:extension base="xsd:string"> + <xsd:attribute name="key" type="xsd:string" /> + </xsd:extension> + </xsd:simpleContent> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + <xsd:attribute name="id" type="ClassType"/> + <xsd:attribute name="componentKind" type="ClassType"/> + <xsd:attribute name="componentClass" type="ClassType"/> + <xsd:attribute name="disabled" type="xsd:boolean" use="optional"/> + </xsd:complexType> + + <xsd:complexType name="FindBugsMainType"> + <xsd:attribute name="class" type="ClassType"/> + <xsd:attribute name="cmd" type="xsd:string"/> + <xsd:attribute name="kind" type="xsd:string" use="optional"/> + <xsd:attribute name="analysis" type="xsd:boolean" use="optional"/> + </xsd:complexType> - <xsd:simpleType name="CategoryType"> - <xsd:restriction base="xsd:string"> - <xsd:enumeration value="CORRECTNESS"/> - <xsd:enumeration value="I18N"/> - <xsd:enumeration value="MALICIOUS_CODE"/> - <xsd:enumeration value="MT_CORRECTNESS"/> - <xsd:enumeration value="PERFORMANCE"/> - <xsd:enumeration value="STYLE"/> - </xsd:restriction> - </xsd:simpleType> - <xsd:complexType name="DetectorType"> <xsd:attribute name="class" type="ClassType"/> - <xsd:attribute name="speed" type="SpeedType"/> + <xsd:attribute name="speed" type="SpeedType" use="optional"/> <xsd:attribute name="reports" type="BugPatternListType"/> - <xsd:attribute name="requirejre" type="xsd:string"/> + <xsd:attribute name="requirejre" type="xsd:string" use="optional"/> <xsd:attribute name="disabled" type="xsd:boolean" use="optional"/> <xsd:attribute name="hidden" type="xsd:boolean" use="optional"/> </xsd:complexType> - + + <xsd:complexType name="EngineRegistrarType"> + <xsd:attribute name="class" type="ClassType"/> + </xsd:complexType> + <xsd:complexType name="BugPatternType"> <xsd:attribute name="abbrev" type="IdentifierType"/> <xsd:attribute name="type" type="xsd:ID"/> - <xsd:attribute name="category" type="CategoryType"/> + <xsd:attribute name="category" type="IdentifierType"/> <xsd:attribute name="experimental" type="xsd:boolean" use="optional"/> + <xsd:attribute name="cweid" type="xsd:positiveInteger" use="optional"/> + <xsd:attribute name="deprecated" type="xsd:boolean" use="optional"/> </xsd:complexType> + <xsd:complexType name="BugCodeType"> + <xsd:attribute name="abbrev" type="IdentifierType"/> + <xsd:attribute name="cweid" type="xsd:positiveInteger" use="optional"/> + <xsd:attribute name="hidden" type="xsd:boolean" use="optional"/> + </xsd:complexType> + + <xsd:complexType name="BugCategoryType"> + <xsd:attribute name="category" type="IdentifierType"/> + <xsd:attribute name="hidden" type="xsd:boolean" use="optional"/> + </xsd:complexType> + + <xsd:simpleType name="DetectorCategoryType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="reporting"/> @@ -61,29 +113,36 @@ <xsd:enumeration value="interprocedural"/> </xsd:restriction> </xsd:simpleType> - + <xsd:complexType name="SingleDetectorSelectorType"> <xsd:attribute name="class" type="ClassType" use="required"/> </xsd:complexType> - + <xsd:complexType name="DetectorCategorySelectorType"> <xsd:attribute name="name" type="DetectorCategoryType" use="required"/> <xsd:attribute name="spanplugins" type="xsd:boolean" use="optional" default="false"/> </xsd:complexType> + <xsd:complexType name="DetectorSubtypesSelectorType"> + <xsd:attribute name="super" type="ClassType" use="required"/> + <xsd:attribute name="spanplugins" type="xsd:boolean" use="optional" default="false"/> + </xsd:complexType> + <xsd:complexType name="OrderingConstraintType"> <xsd:sequence> <xsd:choice> <xsd:element name="Earlier" type="SingleDetectorSelectorType"></xsd:element> <xsd:element name="EarlierCategory" type="DetectorCategorySelectorType"></xsd:element> + <xsd:element name="EarlierSubtypes" type="DetectorSubtypesSelectorType"></xsd:element> </xsd:choice> <xsd:choice> <xsd:element name="Later" type="SingleDetectorSelectorType"></xsd:element> <xsd:element name="LaterCategory" type="DetectorCategorySelectorType"></xsd:element> + <xsd:element name="LaterSubtypes" type="DetectorSubtypesSelectorType"></xsd:element> </xsd:choice> </xsd:sequence> </xsd:complexType> - + <xsd:complexType name="OrderingConstraintListType"> <xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="unbounded"> @@ -93,22 +152,48 @@ </xsd:sequence> </xsd:complexType> + <xsd:complexType name="GlobalOptionsType"> + <xsd:sequence> + <xsd:element name="Property" minOccurs="0" maxOccurs="unbounded" > + <xsd:complexType> + <xsd:simpleContent> + <xsd:extension base="xsd:string"> + <xsd:attribute name="key" type="xsd:string" /> + </xsd:extension> + </xsd:simpleContent> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="FindBugsPluginType" mixed="true"> <xsd:sequence> + <xsd:element name="GlobalOptions" type="GlobalOptionsType" minOccurs="0" maxOccurs="1"/> + <xsd:element name="Cloud" type="CloudType" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element name="PluginComponent" type="PluginComponentType" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element name="FindBugsMain" type="FindBugsMainType" minOccurs="0" ma... [truncated message content] |
From: <dbr...@us...> - 2014-07-26 03:46:20
|
Revision: 1775 http://sourceforge.net/p/fb-contrib/code/1775 Author: dbrosius Date: 2014-07-26 03:46:13 +0000 (Sat, 26 Jul 2014) Log Message: ----------- Version 6.0.0 Added Paths: ----------- tags/v6_0_0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2014-07-26 03:41:11
|
Revision: 1774 http://sourceforge.net/p/fb-contrib/code/1774 Author: dbrosius Date: 2014-07-26 03:40:55 +0000 (Sat, 26 Jul 2014) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/.classpath 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/htdocs/repository.html trunk/fb-contrib/plugin.xml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/ABC_Sample.java trunk/fb-contrib/samples/COM_Sample.java trunk/fb-contrib/samples/CU_Sample.java trunk/fb-contrib/samples/HES_Sample.java trunk/fb-contrib/samples/ISB_Sample.java trunk/fb-contrib/samples/JVR_Sample.java trunk/fb-contrib/samples/LO_Sample.java trunk/fb-contrib/samples/LSYC_Sample.java trunk/fb-contrib/samples/MDM_Sample.java trunk/fb-contrib/samples/NPMC_Sample.java trunk/fb-contrib/samples/NSE_Sample.java trunk/fb-contrib/samples/OCP_Sample.java trunk/fb-contrib/samples/PCAIL_Sample.java trunk/fb-contrib/samples/PMB_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/samples/SCA_Sample.java trunk/fb-contrib/samples/SCII_Sample.java trunk/fb-contrib/samples/SCRV_Sample.java trunk/fb-contrib/samples/SC_Sample.java trunk/fb-contrib/samples/SMA_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/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.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/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/CircularDependencies.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/CollectionNamingConfusion.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/ConstantListIndex.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.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/FieldCouldBeLocal.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.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/InvalidConstantArgument.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/LiteralStringComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.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/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/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.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/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/UnboundMethodTemplateParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.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/AttributesUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CollectionUtils.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/samples/HCP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/.classpath 2014-07-26 03:40:55 UTC (rev 1774) @@ -5,18 +5,21 @@ <classpathentry excluding="lib/" kind="src" path="samples"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> - <classpathentry kind="lib" path="lib/asm-tree-3.3.1.jar"/> <classpathentry kind="lib" path="lib/backport-util-concurrent-3.1.jar"/> - <classpathentry kind="lib" path="lib/bcel-2.0.2.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/> <classpathentry kind="lib" path="lib/javax.servlet-api-3.1.0.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/findbugs-2.0.3.jar" sourcepath="/home/dave/.m2/repository/com/google/code/findbugs/findbugs/2.0.3/findbugs-2.0.3-sources.jar"/> - <classpathentry kind="lib" path="lib/annotations-2.0.3.jar"/> <classpathentry kind="lib" path="lib/javax.servlet.jsp-api-2.3.1.jar"/> <classpathentry kind="lib" path="lib/commons-lang3-3.3.jar"/> - <classpathentry kind="lib" path="lib/slf4j-api-1.7.6.jar"/> + <classpathentry kind="lib" path="lib/slf4j-api-1.7.7.jar"/> <classpathentry kind="lib" path="lib/guava-17.0.jar"/> + <classpathentry kind="lib" path="lib/httpclient-cache-4.3.4.jar"/> + <classpathentry kind="lib" path="lib/httpcore-4.3.2.jar"/> + <classpathentry kind="lib" path="lib/httpclient-4.3.4.jar"/> + <classpathentry kind="lib" path="lib/annotations-3.0.0.jar"/> + <classpathentry kind="lib" path="lib/asm-debug-all-5.0.2.jar"/> + <classpathentry kind="lib" path="lib/bcel-findbugs-6.0.jar"/> + <classpathentry kind="lib" path="lib/findbugs-3.0.0.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/build.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -13,12 +13,12 @@ <property name="samples.dir" value="${basedir}/samples" /> <property name="javadoc.dir" value="${basedir}/javadoc" /> <property name="htdocs.dir" value="${basedir}/htdocs" /> - <property name="javac.source" value="1.5" /> - <property name="javac.target" value="1.5" /> + <property name="javac.source" value="1.6" /> + <property name="javac.target" value="1.6" /> <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="5.2.1" /> + <property name="fb-contrib.version" value="6.0.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -36,9 +36,9 @@ <delete dir="${basedir}/plugin" /> </target> - <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank"> + <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank" unless="no.yank"> <mkdir dir="${lib.dir}" /> - <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true" separateClassifierTypes="true"> + <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true"> <server url="http://repo1.maven.org/maven2" /> <generateVersions propertyFileName="${basedir}/version.properties" /> </yank:yank> @@ -59,9 +59,9 @@ <mkdir dir="${javadoc.dir}" /> <path id="fb-contrib.classpath"> <pathelement location="${lib.dir}/findbugs-${findbugs.version}.jar" /> - <pathelement location="${lib.dir}/bcel-${bcel.version}.jar" /> + <pathelement location="${lib.dir}/bcel-findbugs-${bcel-findbugs.version}.jar" /> <pathelement location="${lib.dir}/annotations-${annotations.version}.jar" /> - <pathelement location="${lib.dir}/asm-tree-${asm-tree.version}.jar" /> + <pathelement location="${lib.dir}/asm-debug-all-${asm-debug-all.version}.jar" /> </path> <path id="fb-contrib.samples.classpath"> <pathelement location="${lib.dir}/javax.servlet.jsp-api-${javax.servlet.jsp-api.version}.jar" /> @@ -72,6 +72,9 @@ <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" /> + <pathelement location="${lib.dir}/httpclient-cache-${httpclient-cache.version}.jar" /> + <pathelement location="${lib.dir}/httpcore-${httpcore.version}.jar" /> + <pathelement location="${lib.dir}/httpclient-${httpclient.version}.jar" /> </path> </target> @@ -165,6 +168,7 @@ </target> <target name="install" depends="build" description="installs the plugin into FindBugs"> + <echo message="Findbugs: ${findbugs.dir}/plugin"/> <copy todir="${findbugs.dir}/plugin"> <fileset dir="${basedir}"> <include name="fb-contrib-${fb-contrib.version}.jar" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/etc/bugrank.txt 2014-07-26 03:40:55 UTC (rev 1774) @@ -88,6 +88,7 @@ 0 BugPattern SPP_USE_GETPROPERTY 0 BugPattern SPP_SERIALVER_SHOULD_BE_PRIVATE 0 BugPattern SPP_USELESS_CASING +0 BugPattern SPP_CONVERSION_OF_STRING_LITERAL 0 BugPattern BAS_BLOATED_ASSIGNMENT_SCOPE 0 BugPattern SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR 0 BugPattern DWI_DELETING_WHILE_ITERATING @@ -129,4 +130,6 @@ 0 BugPattern CEBE_COMMONS_EQUAL_BUILDER_TOEQUALS -2 BugPattern HE_LOCAL_EXECUTOR_SERVICE -4 BugPattern HE_EXECUTOR_NEVER_SHUTDOWN --2 BugPattern HE_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN \ No newline at end of file +-2 BugPattern HE_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN +0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD +0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL \ No newline at end of file Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/etc/findbugs.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -149,7 +149,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri" speed="fast" - reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING" /> + reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -157,7 +157,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UseSplit" speed="fast" reports="USS_USE_STRING_SPLIT" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousJDKVersionUse" speed="slow" reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" disabled="true" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousJDKVersionUse" speed="slow" reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UseAddAll" speed="fast" reports="UAA_USE_ADD_ALL" /> @@ -264,9 +264,7 @@ <Detector class="com.mebigfatguy.fbcontrib.collect.CollectMethodsReturningImmutableCollections" speed="fast" reports="" hidden="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection" speed="fast" reports="MUC_MODIFYING_UNMODIFIABLE_COLLECTION"/> - - <!-- 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" /> @@ -274,10 +272,13 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Unjitable" speed="fast" reports="UJM_UNJITABLE_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.HangingExecutors" speed="fast" reports="HES_EXECUTOR_NEVER_SHUTDOWN,HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN,HES_LOCAL_EXECUTOR_SERVICE"/> + + <Detector class="com.mebigfatguy.fbcontrib.detect.HttpClientProblems" speed="fast" reports="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD,HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL"/> <Detector class="com.mebigfatguy.fbcontrib.detect.ConflictingTimeUnits" speed="fast" reports="CTU_CONFLICTING_TIME_UNITS" /> - COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -384,6 +385,8 @@ <BugPattern abbrev="SPP" type="SPP_NULL_BEFORE_INSTANCEOF" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_NON_USEFUL_TOSTRING" category="STYLE" /> <BugPattern abbrev="SPP" type="SPP_TOSTRING_ON_STRING" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_STRING_BUILDER" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_CONVERSION_OF_STRING_LITERAL" category="CORRECTNESS" experimental="true" /> <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" /> @@ -485,5 +488,7 @@ <BugPattern abbrev="HES" type="HES_EXECUTOR_NEVER_SHUTDOWN" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="HES" type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="HES" type="HES_LOCAL_EXECUTOR_SERVICE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD" category="CORRECTNESS" experimental="true"/> <BugPattern abbrev="CTU" type="CTU_CONFLICTING_TIME_UNITS" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/etc/messages.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -214,7 +214,7 @@ <Details> <![CDATA[ <p>Looks for methods that use floating point indexes for loops. Since floating point - math is inprecise, rounding errors will occur each time through the loop causing + 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 the correct floating point value from the index.</p> <p>It is a fast detector</p> @@ -226,7 +226,7 @@ <Details> <![CDATA[ <p>Looks for method calls to collection classes where the method is not defined by the Collections - interface, and an equivalent method exists in the interface. Examples include:<br> + interface, and an equivalent method exists in the interface. Examples include:<br/> <table border="1"> <tr><th>Old Method</th><th>New Method</th></tr> <tr><td>Hashtable.contains</td><td>Map.containsValue</td></tr> @@ -624,7 +624,7 @@ <![CDATA[ <p>Looks for code that builds an array of values from a collection, by manually looping over the elements of the collection, and adding them to the array. It is simpler and - cleaner to use mycollection.toArray(new type[mycollection.size()].</p> + cleaner to use mycollection.toArray(new type[mycollection.size()]).</p> <p>It is a fast detector</p> ]]> </Details> @@ -1204,7 +1204,7 @@ <![CDATA[ <p>This detector looks for creation of java.awt.Graphics object that do not have the .dispose() method called on them when finished. These objects will be cleaned up by - the Garbage collector, bug given the likelyhood that large numbers of these objects can + 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> <p>It is a fast detector</p> ]]> @@ -1418,18 +1418,28 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.HangingExecutors"> <Details> <![CDATA[ - <p>Single detector for hanging ExecutorServices, that is, ExecutorServices that never get a call to shutdown, which + <p>Three detectors for hanging ExecutorServices, that is, ExecutorServices that never get a call to shutdown, which can potentially cause the JVM to not exit.</p> <p>It is a fast detector</p> ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.HttpClientProblems"> + <Details> + <![CDATA[ + <p>The HttpRequests from the apache.httpComponents have some little-known quirks about them. + This is a set of detectors that helps guard against resource starvation.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.Unjitable"> <Details> <![CDATA[ <p>This detector looks for methods that are longer than 8000 bytes. Methods this - long are automatically disqualified by the jit for compilation and will always be + long are automatically disqualified by the JIT for compilation and will always be emulated. Consider breaking this method up to avoid this, if performance is important.</p> <p>It is a fast detector.</p> ]]> @@ -1458,9 +1468,40 @@ <LongDescription>Method {1} passes simple concatenating string in StringBuffer or StringBuilder append</LongDescription> <Details> <![CDATA[ - <p>This method uses StringBuffer or StringBuilder's append method to concatenate strings. However, it passes the result + <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 StringBuffer or StringBuilder class.</p> + 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/> + <code> + StringBuilder sb = new StringBuilder();<br/> + for (Map.Entry<Integer, String> e : map.entrySet()) {<br/> + sb.append(e.getKey() + e.getValue()); //bug detected here<br/> + }<br/> + </code><br/> + + gets automatically turned into something like: <br/> + <code> + StringBuilder sb = new StringBuilder();<br/> + for (Map.Entry<Integer, String> e : map.entrySet()) {<br/> + StringBuilder tempBuilder = new StringBuilder();<br/> + tempBuilder.append(e.getKey());<br/> + tempBuilder.append(e.getValue());<br/> + sb.append(tempBuilder.toString()); //this isn't too efficient<br/> + }<br/> + </code><br/> + + which involves a temporary <code>StringBuilder</code>, which is completely unneccessary. To prevent this from happening, simply do:<br/> + + <code> + StringBuilder sb = new StringBuilder();<br/> + for (Map.Entry<Integer, String> e : map.entrySet()) {<br/> + sb.append(e.getKey()); <br/> + sb.append(e.getValue());<br/> + }<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -1483,9 +1524,31 @@ <LongDescription>Method {1} concatenates the result of a toString() call</LongDescription> <Details> <![CDATA[ - <p>This method concatenates the output of a toString() call into a StringBuffer/Builder. + <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 NullPointerExceptions, and is easier to read.</p> + 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, so you may see this bug even when you don't use <code>StringBuilder</code>s explicitly. + </p> + + <p> + Instead of: <br/> + <code> + StringBuilder builder = ... <br/> + builder.append(someObj.toString());<br/> + ... <br/> + System.out.println("Problem with the object :" + someObj.toString());<br/> + </code> + just do: <br/> + <code> + StringBuilder builder = ... <br/> + builder.append(someObj);<br/> + ... <br/> + System.out.println("Problem with the object :" + someObj);<br/> + </code> + to avoid the possibility of <code>NullPointerException</code>s when someObj is <code>null</code>. + </p> ]]> </Details> </BugPattern> @@ -1504,7 +1567,7 @@ <BugPattern type="CC_CYCLOMATIC_COMPLEXITY"> <ShortDescription>Method is excessively complex</ShortDescription> - <LongDescription>Method {1} is excessively complex</LongDescription> + <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 @@ -1586,12 +1649,12 @@ <p>This line is in the form of <br/> <code>String str = ...<br/> str.equals("someOtherString");<br/> - //or</br> + //or<br/> str.compareTo("someOtherString");</code></p> <p>A <code>NullPointerException</code> may occur if the String variable <code>str</code> is <code>null</code>. If instead the code was restructured to<br/> <code>String str = ...<br/> "someOtherString".equals(str);<br/> - //or</br> + //or<br/> "someOtherString".compareTo(str);</code><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 @@ -1785,8 +1848,24 @@ <LongDescription>Method {1} passes parsed string to primitive wrapper constructor</LongDescription> <Details> <![CDATA[ - <p>This method passes a primitive value retrieved from a BoxedPrimitive.parseBoxedPrimitive("1") call to - the same class's constructor. It is simpler to just pass the string to the BoxedPrimitives constructor.</p> + <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> + <p>Instead of something like:<br/> + <code> + Boolean bo = new Boolean(Boolean.parseBoolean("true")); <br/> + Float f = new Float(Float.parseFloat("1.234"));<br/> + </code> + Simply do: <br/> + <code> + Boolean bo = new Boolean("true"); <br/> + Float f = new Float("1.234");<br/> + </code> + or, to be more memory efficient: <br/> + <code> + Boolean bo = Boolean.valueOf("true"); <br/> + Float f = Float.valueOf("1.234");<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -1810,8 +1889,27 @@ <![CDATA[ <p>This method passes a String to a wrapped primitive object's valueOf method, which in turn calls 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(myString) + to a primitive value, it is simpler to use the BoxedPrimitive.parseBoxedPrimitive(String) method. </p> + + <p>Instead of something like:<br/> + <code> + public int someMethod(String data) {<br/> + long l = Long.valueOf(data).longValue(); <br/> + float f = Float.valueOf(data).floatValue(); <br/> + return Integer.valueOf(data); // There is an implicit .intValue() call<br/> + }<br/> + </code> + Simply do: <br/> + <code> + public int someMethod(String data) {<br/> + long l = Long.parseLong(data); <br/> + float f = Float.parseFloat(data); <br/> + return Integer.parseInt(data); <br/> + }<br/> + </code> + </p> + ]]> </Details> </BugPattern> @@ -1823,8 +1921,19 @@ <![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 - to a boxed primitive object, it is simpler to use the BoxedPrimitive.valueOf(myString) - method.</p> + to a boxed primitive object, it is simpler to use the BoxedPrimitive.valueOf(String) method.</p> + + <p>Instead of something like:<br/> + <code> + Boolean bo = Boolean.valueOf(Boolean.parseBoolean("true")); <br/> + Float f = Float.valueOf(Float.parseFloat("1.234"));<br/> + </code> + Simply do: <br/> + <code> + Boolean bo = Boolean.valueOf("true"); <br/> + Float f = Float.valueOf("1.234");<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -1836,17 +1945,18 @@ <![CDATA[ <p>This method constructs a Boxed Primitive from a primitive only to call the primitiveValue() method to convert it back to a primitive. Just use the primitive value instead.</p> - <pre> - primitive i = new BoxedPrimitive(1).primitiveValue(); - </pre> - or - <pre> - primitive i = BoxedPrimitive.valueOf(1).primitiveValue(); - </pre> - should just use - <pre> - primitive i = 1; - </pre> + <p>Instead of something like:<br/> + <code> + boolean bo = new Boolean(true).booleanValue(); <br/> + float f = new Float(1.234f).floatValue();<br/> + </code> + Simply do: <br/> + <code> + boolean bo = true; <br/> + float f = 1.234f;<br/> + </code> + </p> + ]]> </Details> </BugPattern> @@ -1857,18 +1967,24 @@ <Details> <![CDATA[ <p>This method constructs a Boxed Primitive from a primitive only to call the primitiveValue() method to - cast the value to another primitive type. It is simpler to just use casting</p> - <pre> - primitive i = new BoxedPrimitive(1.0).primitiveValue(); - </pre> - or - <pre> - primitive i = BoxedPrimitive.valueOf(1.0).primitiveValue(); - </pre> - should just use - <pre> - primitive i = (primitive)1.0; - </pre> + cast the value to another primitive type. It is simpler to just use casting.</p> + <p>Instead of something like:<br/> + <code> + double someDouble = ...<br/> + float f = new Double(someDouble).floatValue();<br/> + <br/> + int someInt = ...<br/> + byte b = new Integer(someInt).byteValue();<br/> + </code> + Simply do: <br/> + <code> + double someDouble = ...<br/> + float f = (float) someDouble;<br/> + <br/> + int someInt = ...<br/> + byte b = (byte)someInt;<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -1879,16 +1995,39 @@ <Details> <![CDATA[ <p>This method assigns a Boxed boolean constant to a primitive boolean variable, or assigns a primitive boolean - constant to a Boxed boolean variable. Use the correct constant for the variable desired. Use</p> - <pre> - boolean b = true; - boolean b = false; - </pre> - or - <pre> - Boolean b = Boolean.TRUE; + constant to a Boxed boolean variable. Use the correct constant for the variable desired. Use <br/> + <code> + boolean b = true;<br/> + boolean b = false;<br/> + </code> + or <br/> + <code> + Boolean b = Boolean.TRUE;<br/> Boolean b = Boolean.FALSE; - </pre> + </code> + </p> + + <p>Be aware that this boxing happens automatically when you might not expect it. For example, <br/> + <code> + Map<String, Boolean> statusMap = ... <br/> + <br/> + public Boolean someMethod() {<br/> + statusMap.put("foo", true); //the "true" here is boxed<br/> + return false; //the "false" here is boxed<br/> + }<br/> + </code> + has two cases of this needless autoboxing. This can be made more efficient by simply substituting + in the constant values: <br/> + + <code> + Map<String, Boolean> statusMap = ... <br/> + <br/> + public Boolean someMethod() {<br/> + statusMap.put("foo", Boolean.TRUE); <br/> + return Boolean.FALSE; <br/> + }<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -2037,7 +2176,7 @@ <![CDATA[ <p>This method calls a method to load a reference to an object, and then only uses it to load a static member of that instance's class. It is simpler and - better performant to just load the static field from the class itself.</p> + more performant to just load the static field from the class itself.</p> ]]> </Details> </BugPattern> @@ -2049,29 +2188,31 @@ <![CDATA[ <p>This method compares dates with two comparisons, rather than using the reverse comparison. So this pattern</p> - <pre> - if ((date1.equals( date2 )) || (date1.after( date2 ))) - </pre> - could become - <pre> - if (date1.compareTo( date2 ) >= 0) - </pre> - and - <pre> - if ((date1.equals( date2 )) || (date1.before( date2 ))) - </pre> - could become - <pre> - if (date1.compareTo( date2 ) <= 0) - </pre> - and - <pre> - if ((date1.before( date2 )) || (date1.after( date2 ))) - </pre> - could become - <pre> - if (!date1.equals( date2 )) - </pre> + <code> + if ((date1.equals( date2 )) || (date1.after( date2 )))<br/> + </code> + could become:<br/> + <code> + if (date1.compareTo( date2 ) >= 0) <br/> + </code> + <br/> + and<br/> + <code> + if ((date1.equals( date2 )) || (date1.before( date2 ))) <br/> + </code> + could become <br/> + <code> + if (date1.compareTo( date2 ) <= 0) <br/> + </code> + <br/> + and<br/> + <code> + if ((date1.before( date2 )) || (date1.after( date2 ))) <br/> + </code> + could become<br/> + <code> + if (!date1.equals( date2 ))<br/> + </code> ]]> </Details> </BugPattern> @@ -2152,7 +2293,7 @@ <Details> <![CDATA[ <p>This method creates a synchronized collection and store the reference to it - in a local variable. As local variables are by definition threadsafe, it seems + in a local variable. As local variables are by definition thread-safe, it seems questionable that this collection needs to be synchronized.</p> <p> <table> @@ -2297,7 +2438,7 @@ <Details> <![CDATA[ <p>This class uses an ordinary set or map collection and uses an enum class as the key type. - It is better performant to use the JDK 1.5 EnumSet or EnumMap classes.</p> + It is more performant to use the JDK 1.5 EnumSet or EnumMap classes.</p> ]]> </Details> </BugPattern> @@ -2399,9 +2540,31 @@ <LongDescription>Method {1} passes constant String of length 1 to character overridden method</LongDescription> <Details> <![CDATA[ - <p>This method passes a constant literal String of length 1 as a parameter to a method, that - exposes a similar method that takes a character. It is simpler and more expedient to handle one - character, rather than pass a string.</p> + <p>This method passes a constant literal <code>String</code> of length 1 as a parameter to a method, that + exposes a similar method that takes a <code>char</code>. It is simpler and more expedient to handle one + character, rather than a <code>String</code.</p> + + <p> + Instead of making calls like: <br/> + <code> + String myString = ... <br/> + if (myString.indexOf("e") != -1) {<br/> + int i = myString.lastIndexOf("e");<br/> + ...<br/> + return myString.replace("m","z");<br/> + }<br/> + </code> + Replace the single letter <code>String</code>s with their <code>char</code> equivalents like so:<br/> + + <code> + String myString = ... <br/> + if (myString.indexOf('e') != -1) {<br/> + int i = myString.lastIndexOf('e');<br/> + ...<br/> + return myString.replace('m','z');<br/> + }<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -2595,14 +2758,15 @@ <![CDATA[ <p>This method attempts to check for null by just referring to the variable name as would be done in C++. This ordinarily would be considered a compile error, except the - variable in question is a Boolean, which does an auto unbox to boolean.</p> - <pre> - if (b && b.booleanValue()) - </pre> - should be - <pre> - if ((b != null) && b.booleanValue()) - </pre> + variable in question is a Boolean, which does an auto unbox to boolean. + <code><br/> + if (b && b.booleanValue())<br/> + </code> + should be<br/> + <code> + if ((b != null) && b.booleanValue())<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -2798,8 +2962,32 @@ <LongDescription>Method {1} appends two literal strings back to back to a StringBuilder</LongDescription> <Details> <![CDATA[ - <p>This method appends two literal strings to a StringBuilder back to back. This can be done with just - one append call, and may avoid intermediate reallocations of the StringBuilders backing store.</p> + <p>This method appends two literal strings to a <code>StringBuilder</code> back to back. + Modern compilers will optimize something like:<br/> + <code> + public static final string CONST_VAL = "there";<br/> + ...<br/> + String str = "Hello" + " "+ CONST_VAL + " " +"world!";<br/> + </code> + to: <br/> + <code> + public static final string CONST_VAL = "there";<br/> + ...<br/> + String str = "Hello there world!";<br/> + </code> + This means the concatenation is done during compile time, not at runtime, so there's <b>no need</b> to do: <br/> + <code> + public static final string CONST_VAL = "there";<br/> + ...<br/> + StringBuilder sb = new StringBuilder("Hello").append(" ").append(CONST_VAL).append(" ").append("world!");<br/> + String str = sb.toString();<br/> + </code> + which is harder to read and will result in more complex bytecode. + </p> + + <p> + Simply append your constants with the "+" symbol, don't append them with <code>StringBuilder.append()</code>. + </p> ]]> </Details> </BugPattern> @@ -2836,6 +3024,42 @@ ]]> </Details> </BugPattern> + + <BugPattern type="SPP_CONVERSION_OF_STRING_LITERAL"> + <ShortDescription>Method converts a String literal</ShortDescription> + <LongDescription>Method {1} calls {3} on a String Literal</LongDescription> + <Details> + <![CDATA[ + <p>This methods calls a converting method like <code>toLowerCase()</code> or <code>trim</code> + on a <code>String</code> literal. You should make the transformation yourself and use the transformed literal.</p> + + <p> + For example, instead of :<br/> + <code> + return "ThisIsAConstantString ".toLowerCase().trim(); <br/> + </code> + just do <br/> + <code> + return "thisisaconstantstring"; <br/> + </code> + for shorter and easier to read code. An exception might be made when locale-specific transformations need to be done (in the case of <code>toUpperCase()</code> and <code>toLowerCase()</code>. + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="SPP_EQUALS_ON_STRING_BUILDER"> + <ShortDescription>Method calls equals(Object o) on a StringBuilder or StringBuffer</ShortDescription> + <LongDescription>Method {1} calls equals(Object o) on a StringBuilder or StringBuffer</LongDescription> + <Details> + <![CDATA[ + <p>This method calls equals on a StringBuilder or StringBuffer. Surprisingly, these classes do not override + the equals method from Object, and so equals is just defined to be == (or same references). This is most + likely not what you would like. If you wish to check that the strings have the same characters, you need to + call toString() on these object and compare them as Strings. + ]]> + </Details> + </BugPattern> <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> @@ -3148,7 +3372,7 @@ <BugPattern type="LO_SUSPECT_LOG_CLASS"> <ShortDescription>Method specifies an unrelated class when allocating a Logger</ShortDescription> - <LongDescription>Method {1} specifies an unrelated class when allocating a Logger</LongDescription> + <LongDescription>Method {1} specifies an unrelated class when allocating a Logger. Saw "{3}", expected "{4}".</LongDescription> <Details> <![CDATA[ <p>This method creates a Logger by passing in a specification for a class that is unrelated @@ -3212,7 +3436,7 @@ <LongDescription>Method {1} creates exception with logger parameter markers in message</LongDescription> <Details> <![CDATA[ - <pThis method creates an standard exception passing a message string which contains an slf4j style + <p>This method creates a standard exception passing a message string which contains an slf4j style parameter marker '{}'. This marker will not be translated as it is not processed by the Exception class. </p> ]]> @@ -3224,7 +3448,7 @@ <LongDescription>Method {1} passes a concatenated string to Slf4j's format string</LongDescription> <Details> <![CDATA[ - <p>This method uses an slf4j logger to log a string, where the first (format) string is created using concatenation. + <p>This method uses an Slf4j logger to log a string, where the first (format) string is created using concatenation. You should use {} markers to inject dynamic content into the string, so that String building is delayed until the actual log string is needed. If the log level is high enough that this log statement isn't used, then the appends will never be executed. @@ -3425,13 +3649,13 @@ <p>This method contains a contravariant array assignment. Since arrays are mutable data structures, their use must be restricted to covariant or invariant usage.</p> - <pre> - class A {} - class B extends A {} - - B[] b = new B[2]; - A[] a = b; - </pre> + <code> + class A {}<br/> + class B extends A {}<br/> + <br/> + B[] b = new B[2];<br/> + A[] a = b;<br/> + </code> ]]> </Details> </BugPattern> @@ -3444,14 +3668,14 @@ <p>This method contains a contravariant array element assignment. Since arrays are mutable data structures, their use must be restricted to covariant or invariant usage.</p> - <pre> - class A {} - class B extends A {} - - B[] b = new B[2]; - A[] a = b; - a[0] = new A(); // results in ArrayStoreException (Runtime) - </pre> + <code> + class A {}<br/> + class B extends A {}<br/> + <br/> + B[] b = new B[2];<br/> + A[] a = b;<br/> + a[0] = new A(); // results in ArrayStoreException (Runtime)<br/> + </code> ]]> </Details> </BugPattern> @@ -3588,7 +3812,7 @@ <LongDescription>Method {1} sleeps without timeout when calling {2}</LongDescription> <Details> <![CDATA[ - <p>Calling <code>{2}</code> without timeout could block forever. Consider using a timeout to detect deadlocks or performance problems. Thread.join() Object.wait() Condition.await() Lock.lock() Lock.lockInterruptibly()</p> + <p>Calling one of the following methods without timeout could block forever. Consider using a timeout to detect deadlocks or performance problems. Methods: Thread.join(), Object.wait(), Condition.await(), Lock.lock(), Lock.lockInterruptibly(), ReentrantLock.lock(), ReentrantLock.lockInterruptibly()</p> ]]> </Details> </BugPattern> @@ -3866,8 +4090,8 @@ </BugPattern> <BugPattern type="CU_CLONE_USABILITY_MISMATCHED_RETURN"> - <ShortDescription>Clone method declares it returns an type different then the owning class</ShortDescription> - <LongDescription>Clone method {1} declares it returns an type different then the owning class</LongDescription> + <ShortDescription>Clone method declares it returns a type different then the owning class</ShortDescription> + <LongDescription>Clone method {1} declares it returns a type different then the owning class</LongDescription> <Details> <![CDATA[ <p>This class implements the Cloneable interface but defines its clone method to return a type @@ -3977,7 +4201,7 @@ <Details> <![CDATA[ <p>This class defines a field or local collection variable with a name that contains a different type - of collection in its name. An example woutd be a Set<User> called userList. This is confusing to the reader, + of collection in its name. An example would be a Set<User> called userList. This is confusing to the reader, and likely caused by a previous refactor of type, without changing the name.</p> ]]> </Details> @@ -4050,7 +4274,7 @@ <p>Even though there are some exceptions to this, particularly when a custom <code>ThreadFactory</code> is provided, or for <code>ThreadPoolExecutor</code>s with <code>allowsCoreThreadTimeOut()</code> set to true, - it is good practice to explictly shutdown the <code>ExecutorService</code> when its utility is done.</p> + it is good practice to explicitly shutdown the <code>ExecutorService</code> when its utility is done.</p> ]]> </Details> </BugPattern> @@ -4069,7 +4293,7 @@ </Details> </BugPattern> -<BugPattern type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN"> + <BugPattern type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN"> <ShortDescription>An ExecutorService isn't shutdown before the reference to it is lost</ShortDescription> <LongDescription>ExecutorService {2} is replaced with another ExecutorService without being shutdown, potentially preventing the entire JVM from shutting down</LongDescription> <Details> @@ -4102,7 +4326,7 @@ <p>Even though there are some exceptions to this, particularly when a custom <code>ThreadFactory</code> is provided, or for <code>ThreadPoolExecutor</code>s with <code>allowsCoreThreadTimeOut()</code> set to true, - it is good practice to explictly shutdown the <code>ExecutorService</code> at the end of execution, or + it is good practice to explicitly shutdown the <code>ExecutorService</code> at the end of execution, or when it is being replaced.</p> <p><b>Note:</b> <code>ExecutorService</code>s are generally created once in a program's lifecycle. If you find yourself @@ -4111,6 +4335,101 @@ ]]> </Details> </BugPattern> + + <BugPattern type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD"> + <ShortDescription>Unreleased HttpRequest network resources (field)</ShortDescription> + <LongDescription>The HttpRequest field {1} does not release its network resources, which could freeze the running code</LongDescription> + <Details> + <![CDATA[ + <p>FindBugs has detected an <code>org.apache.http.HttpRequest</code> (e.g. <code>HttpGet</code>, <code>HttpPost</code>, etc) + that didn't release its associated resources. Code like the following: <br/> + <code> + private HttpGet httpGet; <br/> + ...</br> + public String requestInfo(URI u) {</br> + this.httpGet = new HttpGet(u);</br> + try(CloseableHttpResponse response = client.execute(httpGet);) {</br> + return getResponseAsString(response);</br> + }</br> + catch (IOException e) ( </br> + e.printStackTrace();</br> + }</br> + return null;</br> + }</br> + </code> + will freeze after a few requests, usually with no indication as to why. </p> + + <p> + The reason this code freezes is because <code>org.apache.http.HttpRequest</code>s need explicitly release their connection + with a call to either <code>reset()</code> or <code>releaseConnection()</code>. The above example can be easily fixed:<br/> + <code> + private HttpGet httpGet; <br/> + ...</br> + public String requestInfo(URI u) {</br> + this.httpGet = new HttpGet(u);</br> + try(CloseableHttpResponse response = client.execute(httpGet);) {</br> + return getResponseAsString(response);</br> + }</br> + catch (IOException e) ( </br> + e.printStackTrace();</br> + }</br> + <b>finally {</br> + this.httpGet.reset();</br> + }</b></br> + return null;</br> + }</br> + </code> + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL"> + <ShortDescription>Unreleased HttpRequest network resources (local)</ShortDescription> + <LongDescription>The local HttpRequest {1} does not release its network resources before being garbage collected, which could freeze the running code</LongDescription> + <Details> + <![CDATA[ + <p>FindBugs has detected an <code>org.apache.http.HttpRequest</code> (e.g. <code>HttpGet</code>, <code>HttpPost</code>, etc) + that didn't release its associated resources. Code like the following: <br/> + <code> + public String requestInfo(URI u) {</br> + HttpGet httpGet = new HttpGet(u);</br> + try(CloseableHttpResponse response = client.execute(httpGet);) {</br> + return getResponseAsString(response);</br> + }</br> + catch (IOException e) ( </br> + e.printStackTrace();</br> + }</br> + return null;</br> + }</br> + </code> + will freeze after a few requests, usually with no indication as to why. </p> + + <p> + The reason this code freezes is because <code>org.apache.http.HttpRequest</code>s need explicitly release their connection + with a call to either <code>reset()</code> or <code>releaseConnection()</code>, <b>even if the request is a local</b>. + The garbage collector will not release these resources, leading to the frustrating freezing scenario described above. + + <br/>The above example can be easily fixed:<br/> + <code> + public String requestInfo(URI u) {</br> + HttpGet httpGet = new HttpGet(u);</br> + try(CloseableHttpResponse response = client.execute(httpGet);) {</br> + return getResponseAsString(response);</br> + }</br> + catch (IOException e) ( </br> + e.printStackTrace();</br> + }</br> + <b>finally {</br> + httpGet.reset();</br> + }</b></br> + return null;</br> + }</br> + </code> + </p> + ]]> + </Details> + </BugPattern> <BugPattern type="UJM_UNJITABLE_METHOD"> <ShortDescription>This method is too long to be compiled by the JIT</ShortDescription> @@ -4258,5 +4577,6 @@ <BugCode abbrev="MUC">Modifying Unmodifiable Collection</BugCode> <BugCode abbrev="UJM">Unjitable method</BugCode> <BugCode abbrev="HES">Hanging ExecutorService</BugCode> + <BugCode abbrev="HCP">HttpClient Problems</BugCode> <BugCode abbrev="CTU">Conflicting Time Units</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/htdocs/index.shtml 2014-07-26 03:40:55 UTC (rev 1774) @@ -68,11 +68,12 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 5.2.0 available for download - <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.2.0.jar/download">here</a>.</p> + <p style="font-weight: bold;">The latest version of fb-contrib is 6.0.0 available for download + <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-6.0.0.jar/download">here</a>.</p> + <p style="font-weight: bold;">This version requires FindBugs 3.0 or better</p> </div> - <hr/> + <hr/> <img id="git_image" src="flip1.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> Detectors added in git<br/> <div id="git" style="display:none;"> @@ -82,6 +83,14 @@ same kind of exception, and throw the same exception always. These blocks can be coalesced into one. </li> + </ul> + </div> + + <hr/> + + <img id="v6_0_0_image" src="flip2.gif" onClick="toggleBlock('v6_0_0', 'v6_0_0_image');" align="top"/> + Detectors added in v6.0.0<br/> + <div id="v6_0_0" style="display:block;"> <li><b>[PSC] Presize Collections</b><br/> Looks for methods that create and populate collections, and while knowing the end size of those collections, does not pre allocate the collection @@ -110,12 +119,17 @@ Looks for methods that perform arithmetic operations on values representing time where the time unit is incompatible, ie adding a millisecond value to a nanosecond value. </li> + <li><b>[HCP] Http Client Problems</b><br/> + The HttpRequests from the apache.httpComponents have some little-known quirks about them. + This is a set of detectors that helps guard against resource starvation.<br/> + <span style="color: #0000FF;">--contributed by Kevin Lubick - THANKS!</span> + </li> </ul> </div> <hr/> - <img id="v5_2_0_image" src="flip2.gif" onClick="toggleBlock('v5_2_0', 'v5_2_0_image');" align="top"/> + <img id="v5_2_0_image" src="flip1.gif" onClick="toggleBlock('v5_2_0', 'v5_2_0_image');" align="top"/> Detectors added in v5.2.0<br/> - <div id="git" style="display:block;"> + <div id="v5_2_0" style="display:none;"> <ul> <li><b>[CNC] Collection Naming Confusion</b><br/> Looks for fields and local variables that have Map, Set, List in their names Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/htdocs/repository.html 2014-07-26 03:40:55 UTC (rev 1774) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>5.2.0</td></tr> + <tr><td><b>Version:</b></td><td>6.0.0</td></tr> </table> </div> Modified: trunk/fb-contrib/plugin.xml =================================================================== --- trunk/fb-contrib/plugin.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/plugin.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> -<plugin id="fb-contrib" name="fb-contrib" version="5.2.0"> +<plugin id="fb-contrib" name="fb-contrib" version="6.0.0"> <extension point="edu.umd.cs.findbugs.plugin.eclipse.findbugsPlugins"> <findbugsPlugin fbPluginId="com.mebigfatguy.fbcontrib" libraryPath="."></findbugsPlugin> </extension> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/pom.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>5.2.1</version> + <version>6.0.0</version> <parent> <groupId>org.sonatype.oss</groupId> @@ -106,7 +106,7 @@ <dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>findbugs</artifactId> - <version>2.0.3</version> + <version>3.0.0</version> <scope>provided</scope> </dependency> </dependencies> @@ -198,8 +198,8 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.5</source> - <target>1.5</target> + <source>1.6</source> + <target>1.6</target> </configuration> </plugin> </plugins> Modified: trunk/fb-contrib/samples/ABC_Sample.java =================================================================== --- trunk/fb-contrib/samples/ABC_Sample.java 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/samples/ABC_Sample.java 2014-07-26 03:40:55 UTC (rev 1774) @@ -28,6 +28,7 @@ public UseComparator() { testComp = new TreeMap<byte[], byte[]>(new Comparator<byte[]>() { + @Override public int compare(byte[] b1, byte[] b2) { return b1.length - b2.length; } Modified: trunk/fb-contrib/samples/COM_Sample.java =================================================================== --- trunk/fb-contrib/samples/COM_Sample.java 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/samples/COM_Sample.java 2014-07-26 03:40:55 UTC (rev 1774) @@ -46,11 +46,13 @@ } abstract class c1 implements Inf { + @Override public void m1() { } } abstract class c2 extends c1 { + @Override public void m2() { } } Modified: trunk/fb-contrib/samples/CU_Sample.java =================================================================== --- trunk/fb-contrib/samples/CU_Sample.java 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/samples/CU_Sample.java 2014-07-26 03:40:55 UTC (rev 1774... [truncated message content] |
From: <dbr...@us...> - 2014-05-24 04:13:26
|
Revision: 1773 http://sourceforge.net/p/fb-contrib/code/1773 Author: dbrosius Date: 2014-05-24 04:13:22 +0000 (Sat, 24 May 2014) Log Message: ----------- Version 5.2.1 Added Paths: ----------- tags/v5_2_1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2014-05-24 04:08:33
|
Revision: 1772 http://sourceforge.net/p/fb-contrib/code/1772 Author: dbrosius Date: 2014-05-24 04:08:28 +0000 (Sat, 24 May 2014) Log Message: ----------- prepared for version 5.2.1 release Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.properties 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/LSYC_Sample.java trunk/fb-contrib/samples/ROOM_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/InvalidConstantArgument.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/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/samples/CTU_Sample.java trunk/fb-contrib/samples/HES_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalTypeDetector.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Unjitable.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/OpcodeUtils.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/.classpath 2014-05-24 04:08:28 UTC (rev 1772) @@ -15,8 +15,8 @@ <classpathentry kind="lib" path="lib/findbugs-2.0.3.jar" sourcepath="/home/dave/.m2/repository/com/google/code/findbugs/findbugs/2.0.3/findbugs-2.0.3-sources.jar"/> <classpathentry kind="lib" path="lib/annotations-2.0.3.jar"/> <classpathentry kind="lib" path="lib/javax.servlet.jsp-api-2.3.1.jar"/> - <classpathentry kind="lib" path="lib/guava-16.0.1.jar" sourcepath="lib/guava-16.0.1-sources.jar"/> <classpathentry kind="lib" path="lib/commons-lang3-3.3.jar"/> <classpathentry kind="lib" path="lib/slf4j-api-1.7.6.jar"/> + <classpathentry kind="lib" path="lib/guava-17.0.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.properties =================================================================== --- trunk/fb-contrib/build.properties 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/build.properties 2014-05-24 04:08:28 UTC (rev 1772) @@ -9,3 +9,5 @@ output.. = classes/ proxy.server = + +findbugs.dir=/home/dave/dev/findbugs/findbugs Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/build.xml 2014-05-24 04:08:28 UTC (rev 1772) @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="5.3.0" /> + <property name="fb-contrib.version" value="5.2.1" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -38,7 +38,7 @@ <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank"> <mkdir dir="${lib.dir}" /> - <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true"> + <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true" separateClassifierTypes="true"> <server url="http://repo1.maven.org/maven2" /> <generateVersions propertyFileName="${basedir}/version.properties" /> </yank:yank> @@ -91,7 +91,8 @@ <target name="compile_samples" depends="-init" description="compiles sample problem files"> <javac srcdir="${samples.dir}" destdir="${samples.dir}" source="1.7" target="1.7" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> - <classpath refid="fb-contrib.classpath" /> + <compilerarg value="-XDignore.symbol.file"/> + <classpath refid="fb-contrib.classpath" /> <classpath refid="fb-contrib.samples.classpath" /> </javac> <delete file="${samples.dir}/SJVU_Sample.class" /> @@ -164,8 +165,7 @@ </target> <target name="install" depends="build" description="installs the plugin into FindBugs"> - <property environment="env" /> - <copy todir="${env.FINDBUGS_HOME}/plugin"> + <copy todir="${findbugs.dir}/plugin"> <fileset dir="${basedir}"> <include name="fb-contrib-${fb-contrib.version}.jar" /> </fileset> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/etc/bugrank.txt 2014-05-24 04:08:28 UTC (rev 1772) @@ -126,4 +126,7 @@ 0 BugPattern NSE_NON_SYMMETRIC_EQUALS 0 BugPattern CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT 0 BugPattern NFF_NON_FUNCTIONAL_FIELD -0 BugPattern CEBE_COMMONS_EQUAL_BUILDER_TOEQUALS \ No newline at end of file +0 BugPattern CEBE_COMMONS_EQUAL_BUILDER_TOEQUALS +-2 BugPattern HE_LOCAL_EXECUTOR_SERVICE +-4 BugPattern HE_EXECUTOR_NEVER_SHUTDOWN +-2 BugPattern HE_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN \ No newline at end of file Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/etc/findbugs.xml 2014-05-24 04:08:28 UTC (rev 1772) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -34,7 +34,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" /> @@ -264,14 +264,21 @@ <Detector class="com.mebigfatguy.fbcontrib.collect.CollectMethodsReturningImmutableCollections" speed="fast" reports="" hidden="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection" speed="fast" reports="MUC_MODIFYING_UNMODIFIABLE_COLLECTION"/> + - <!-- 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" /> - <!-- COMMENT OUT FOR POINT RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.Unjitable" speed="fast" reports="UJM_UNJITABLE_METHOD" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.HangingExecutors" speed="fast" reports="HES_EXECUTOR_NEVER_SHUTDOWN,HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN,HES_LOCAL_EXECUTOR_SERVICE"/> + <Detector class="com.mebigfatguy.fbcontrib.detect.ConflictingTimeUnits" speed="fast" reports="CTU_CONFLICTING_TIME_UNITS" /> + + COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -474,4 +481,9 @@ <BugPattern abbrev="UP" type="UP_UNUSED_PARAMETER" category="STYLE" experimental="true" /> <BugPattern abbrev="CD" type="CD_CIRCULAR_DEPENDENCY" category="CORRECTNESS" /> <BugPattern abbrev="MUC" type="MUC_MODIFYING_UNMODIFIABLE_COLLECTION" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="UJM" type="UJM_UNJITABLE_METHOD" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="HES" type="HES_EXECUTOR_NEVER_SHUTDOWN" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="HES" type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="HES" type="HES_LOCAL_EXECUTOR_SERVICE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="CTU" type="CTU_CONFLICTING_TIME_UNITS" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/etc/messages.xml 2014-05-24 04:08:28 UTC (rev 1772) @@ -178,6 +178,12 @@ <p>Looks for methods that correctly do not write to a parameter. To help document this, and to perhaps help the JVM optimize the invocation of this method, you should consider defining these parameters 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. It's only use + is to clarify the coders 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> + <p>It is a slow detector</p> ]]> </Details> @@ -1384,7 +1390,7 @@ <Details> <![CDATA[ <p>Looks for private or static methods that have parameters that aren't used. These parameters - can be removed.</p> + can be removed, assuming the method isn't used through reflection.</p> <p>It is fast detector</p> ]]> </Details> @@ -1409,6 +1415,38 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.HangingExecutors"> + <Details> + <![CDATA[ + <p>Single detector for hanging ExecutorServices, that is, ExecutorServices that never get a call to shutdown, which + can potentially cause the JVM to not exit.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.Unjitable"> + <Details> + <![CDATA[ + <p>This detector looks for methods that are longer than 8000 bytes. Methods this + long are automatically disqualified by the jit for compilation and will always be + emulated. Consider breaking this method up to avoid this, if performance is important.</p> + <p>It is a fast detector.</p> + ]]> + </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, ie adding a millisecond value to a nanosecond value. + </p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> </Detector> @@ -1592,22 +1630,43 @@ <LongDescription>Class {0} defines two or more one for one associated lists or arrays</LongDescription> <Details> <![CDATA[ - <p>This class appears to maintain two or more lists or arrays who's contains is related one-for-one - through the index of the list or array. Consider creating a separate class to hold all the related + <p>This class appears to maintain two or more lists or arrays whose contents are related in a parallel way. That is, + you have something like:<br/> + <code> + List<String> words = new ArrayList<String>();<br/> + List<Integer> wordCounts = new ArrayList<String>();<br/> + </code> + where the elements of the list at index 0 are related, the elements at index 1 are related and so on. </p> + <p> + Consider creating a separate class to hold all the related pieces of information, and adding instances of this class to just one list or array, or if just two values, use - a Map to associate one value with the other.</p> + a Map to associate one value with the other like:<br/> + <code> + private class WordAndCount{public String word; public int count} + List<WordAndCount> wordsAndCounts = new ArrayList<WordAndCount>();<br/> + <br/> + //or, for just two elements<br/> + Map<String,Integer> wordCounts = new HashMap<String,Integer>();<br/> + </code> + + </p> ]]> </Details> </BugPattern> <BugPattern type="FP_FINAL_PARAMETERS"> <ShortDescription>Method does not define a parameter as final, but could</ShortDescription> - <LongDescription>Method {1} does not define a parameter as final, but could</LongDescription> + <LongDescription>Method {1} does not define one or more parameters as final, but could</LongDescription> <Details> <![CDATA[ - <p>This method correctly does not write to a parameter. To help document this, and to perhaps + <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. It's only use + is to clarify the coders 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> </BugPattern> @@ -2041,13 +2100,33 @@ </BugPattern> <BugPattern type="PMB_POSSIBLE_MEMORY_BLOAT"> - <ShortDescription>Class defines static field that appears to allow memory bloat</ShortDescription> - <LongDescription>Class {0} defines static field that appears to allow memory bloat</LongDescription> + <ShortDescription>Potential memory bloat in static field</ShortDescription> + <LongDescription>Class {0} defines static field "{2}" which appears to allow memory bloat</LongDescription> <Details> <![CDATA[ - <p>This class defines static fields that are collections or StringBuffers that do not - appear to have any way to clear or reduce their size. This is a potential cause of - memory bloat.</p> + <p>This class defines static fields that are <code>Collection</code>s, <code>StringBuffer</code>s, or <code>StringBuilder</code>s + that do not appear to have any way to clear or reduce their size. That is, a collection is defined + and has method calls like <br/> + {<code>add()</code>, <code>append()</code>, <code>offer()</code>, <code>put()</code>, ...} <br/> + with no method calls to removal methods like<br/> + {<code>clear()</code>, <code>delete()</code>, <code>pop()</code>, <code>remove()</code>, ...}<br/> + This means that the collection in question can only ever increase in size, which is + a potential cause of memory bloat.</p> + + <p> + If this collection is a list, set or otherwise of static things (e.g. a List<String> for month names), consider + adding all of the elements in a static initializer, which can only be called once:<br/> + <code> + private static List<String> monthNames = new ArrayList<String>();<br/> + static {<br/> + monthNames.add("January");<br/> + monthNames.add("February");<br/> + monthNames.add("March");<br/> + ...<br/> + } + </code> + </p> + ]]> </Details> </BugPattern> @@ -3954,7 +4033,110 @@ ]]> </Details> </BugPattern> + + <BugPattern type="HES_EXECUTOR_NEVER_SHUTDOWN"> + <ShortDescription>ExecutorService field doesn't ever get shutdown</ShortDescription> + <LongDescription>ExecutorService {2} is instantiated, but never shutdown, potentially preventing the entire JVM from shutting down</LongDescription> + <Details> + <![CDATA[ + <p>Most <code>ExecutorService</code> objects must be explicitly shutdown, + otherwise, their internal threads can prolong the running of the JVM, even when everything + else has stopped.</p> + + <p>FindBugs has detected that there are no calls to either the <code>shutdown()</code> or <code>shutdownNow()</code> + method, and thus, the <code>ExecutorService</code> is not guaranteed to ever terminate. This is especially + problematic for <code>Executors.newFixedThreadPool()</code> and most of the other convenience methods in + the <code>Executors</code> class.</p> + + <p>Even though there are some exceptions to this, particularly when a custom <code>ThreadFactory</code> is + provided, or for <code>ThreadPoolExecutor</code>s with <code>allowsCoreThreadTimeOut()</code> set to true, + it is good practice to explictly shutdown the <code>ExecutorService</code> when its utility is done.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="HES_LOCAL_EXECUTOR_SERVICE"> + <ShortDescription>Suspicious Local Executor Service</ShortDescription> + <LongDescription>ExecutorService is created as a local variable, which is unusual</LongDescription> + <Details> + <![CDATA[ + <p><code>ExecutorService</code>s are typically instantiated as fields so that many tasks can be executed on a controlled number of <code>Thread</code>s across many method calls. Therefore, it is unusual for <code>ExecutorService</code>s to be a local variable, where tasks will be added only one time, in the enclosing method. </p> + + <p>Furthermore, when a local <code>ExecutorService</code> reaches the end of scope and goes up for garbage collection, the internal <code>Thread</code>s are not necessarily terminated and can prevent the JVM from ever shutting down.</p> + + <p>Consider making this local variable a field and create a method that will explicitly shutdown the <code>ExecutorService</code></p> + ]]> + </Details> + </BugPattern> +<BugPattern type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN"> + <ShortDescription>An ExecutorService isn't shutdown before the reference to it is lost</ShortDescription> + <LongDescription>ExecutorService {2} is replaced with another ExecutorService without being shutdown, potentially preventing the entire JVM from shutting down</LongDescription> + <Details> + <![CDATA[ + <p>Most <code>ExecutorService</code> objects must be explicitly shutdown, otherwise, their internal threads can prevent the JVM from ever shutting down, even when everything else has stopped.</p> + + <p>FindBugs has detected that something like the following is happening:<br/> + <code> + ExecutorService executor = ... //e.g. Executors.newCachedThreadPool();<br/> + ...<br/> + public void reset() {<br/> + this.executor = Executors.newCachedThreadPool(); <br/> + this.executor.execute(new SampleExecutable()); <br/> + }<br/> + </code> + For normal objects, losing the last reference to them like this would trigger the object to be cleaned up + in garbage collection. For <code>ExecutorService</code>s, this isn't enough to terminate the internal threads in the + thread pool, and the <code>ExecutorService</code> isn't guaranteed to shutdown, causing the JVM to never stop. <br/> + To fix this, simply add a call to <code>shutdown()</code> like this:<br/> + <code> + ExecutorService executor = ... //e.g. Executors.newCachedThreadPool();<br/> + ...<br/> + public void reset() {<br/> + <b> this.executor.shutDown();</b> <br/> + this.executor = Executors.newCachedThreadPool(); <br/> + this.executor.execute(new SampleExecutable()); <br/> + } + </code> + </p> + + <p>Even though there are some exceptions to this, particularly when a custom <code>ThreadFactory</code> is + provided, or for <code>ThreadPoolExecutor</code>s with <code>allowsCoreThreadTimeOut()</code> set to true, + it is good practice to explictly shutdown the <code>ExecutorService</code> at the end of execution, or + when it is being replaced.</p> + + <p><b>Note:</b> <code>ExecutorService</code>s are generally created once in a program's lifecycle. If you find yourself + replacing the <code>ExecutorService</code>, perhaps you may consider restructuring your code to use calls like + <code>awaitTermination()</code> or <code>Future</code>s/<code>Callable</code>s to avoid recreating the <code>ExecutorService</code>.</p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="UJM_UNJITABLE_METHOD"> + <ShortDescription>This method is too long to be compiled by the JIT</ShortDescription> + <LongDescription>This method {1} is too long to be compiled by the JIT</LongDescription> + <Details> + <![CDATA[ + <p>This method is longer than 8000 bytes. By default the JIT will not attempt to compile this method no matter + how hot it is, and so this method will always be interpreted. If performance is important, you should consider + breaking this method up in smaller chunks. (And probably a good idea for readability too!). + ]]> + </Details> + </BugPattern> + + <BugPattern type="CTU_CONFLICTING_TIME_UNITS"> + <ShortDescription>This method performs arithmetic operations on time values with different units</ShortDescription> + <LongDescription>This method performs arithmetic operations on time values with different units</LongDescription> + <Details> + <![CDATA[ + <p>This method takes two values that appear to be representing time, and performs arithmetic operations on this + two values directly, even though it appears that the two values are representing different time units, such as + adding a millisecond value to a nanosecond value. You should convert the two values to the same time unit before + performing this calculation in order for it to be meaningful. + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -4074,4 +4256,7 @@ <BugCode abbrev="UP">Unused Parameter</BugCode> <BugCode abbrev="CD">Circular Dependencies</BugCode> <BugCode abbrev="MUC">Modifying Unmodifiable Collection</BugCode> + <BugCode abbrev="UJM">Unjitable method</BugCode> + <BugCode abbrev="HES">Hanging ExecutorService</BugCode> + <BugCode abbrev="CTU">Conflicting Time Units</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/htdocs/index.shtml 2014-05-24 04:08:28 UTC (rev 1772) @@ -89,7 +89,8 @@ on the garbage collector. </li> <li><b>[AIOB] Array Index Out of Bounds</b><br/> - Looks for questionable load/stores to array elements.<ul> + Looks for questionable load/stores to array elements. + <ul> <li> Looks for accesses to array elements using literal values that are known to be outside the bounds of the array. This mistake will cause an ArrayIndexOutOfBoundsException to occur at runtime.</li> @@ -98,6 +99,17 @@ </li> </ul> </li> + <li><b>[UJM] Unjitable Methods</b><br/> + Looks for methods that are too big that the JIT will not compile them no matter how often they are run + </li> + <li><b>[HE] Hangable Executors</b><br/> + Looks for executors that are never shutdown, which will not allow the application to terminate<br/> + <span style="color: #0000FF;">--contributed by Kevin Lubick - THANKS!</span> + </li> + <li><b>[CTU] Conflicting Time Units</b><br/> + Looks for methods that perform arithmetic operations on values representing time + where the time unit is incompatible, ie adding a millisecond value to a nanosecond value. + </li> </ul> </div> <hr/> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/pom.xml 2014-05-24 04:08:28 UTC (rev 1772) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>5.3.0</version> + <version>5.2.1</version> <parent> <groupId>org.sonatype.oss</groupId> Added: trunk/fb-contrib/samples/CTU_Sample.java =================================================================== --- trunk/fb-contrib/samples/CTU_Sample.java (rev 0) +++ trunk/fb-contrib/samples/CTU_Sample.java 2014-05-24 04:08:28 UTC (rev 1772) @@ -0,0 +1,26 @@ +import java.util.concurrent.TimeUnit; + + +public class CTU_Sample { + + public long simpleMillisAndNanos() { + long millis = System.currentTimeMillis(); + long nanos = System.nanoTime(); + + return millis + nanos; + } + + public long badUseOfConvert() { + long secs = TimeUnit.SECONDS.convert(1000, TimeUnit.MILLISECONDS); + long millis = System.currentTimeMillis(); + + return secs + millis; + } + + public long fpHandConversions() { + long millis = System.currentTimeMillis(); + long secs = TimeUnit.SECONDS.convert(1, TimeUnit.HOURS); + + return millis * 1000 + secs; + } +} Property changes on: trunk/fb-contrib/samples/CTU_Sample.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/fb-contrib/samples/HES_Sample.java =================================================================== --- trunk/fb-contrib/samples/HES_Sample.java (rev 0) +++ trunk/fb-contrib/samples/HES_Sample.java 2014-05-24 04:08:28 UTC (rev 1772) @@ -0,0 +1,370 @@ +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; + +//Expected bug count: 12 +//5 HE_EXECUTOR_NEVER_SHUTDOWN +//4 HE_LOCAL_EXECUTOR_SERVICE +//3 HE_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN +public class HES_Sample { + + + public static void main(String[] args) { + LocalExecutorProblem p = new LocalExecutorProblem(); + p.task(); + + System.out.println("Should end"); + } +} + +class SampleExecutable implements Runnable { + @Override + public void run() { + System.out.println("Hello"); + } + + //Dummy method with throws to simulate something potentially throwing exception + public static void methodThrows() throws Exception{ + if (Math.random()<.5) + throw new Exception("There was a problem with the RNG"); + } + +} + +class SingleThreadExecutorProblem { + //tag + private ExecutorService executor; + + public SingleThreadExecutorProblem() { + this.executor = Executors.newSingleThreadExecutor(); + } + + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + +} + +class SingleThreadExecutorGood { + //no tag + private ExecutorService executor; + + public SingleThreadExecutorGood() { + this.executor = Executors.newSingleThreadExecutor(); + } + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + public void shutDown() { + executor.shutdown(); + } +} +class SingleThreadExecutorGood1 { + //no tag + private ExecutorService executor; + + public SingleThreadExecutorGood1() { + this.executor = Executors.newSingleThreadExecutor(); + } + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + public void shutDown() { + executor.shutdownNow(); + } +} +class SingleThreadExecutorGood2 { + //no tag + private ExecutorService executor; + + public SingleThreadExecutorGood2() { + this.executor = Executors.newSingleThreadExecutor(); + } + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + public void shutDown() { + try { + executor.awaitTermination(30, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + executor.shutdown(); + } +} + +class SingleThreadExecutorTryProblem { + //this won't get tagged as of version 2.2 If given more thought, this could be implemented + private ExecutorService executor; + + public SingleThreadExecutorTryProblem() { + this.executor = Executors.newSingleThreadExecutor(); + } + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + public void shutDown() { + try { + executor.awaitTermination(30, TimeUnit.SECONDS); + executor.shutdown(); //this doesn't count as shutdown, so it should be tagged. + //probably with a different bug + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } +} + +class FixedThreadPoolProblem { + //tag + private ExecutorService executor; + + public FixedThreadPoolProblem() { + this.executor = Executors.newFixedThreadPool(3); + } + + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + +} + +class CachedThreadPoolMehProblem { + //tag - this is bad practice, even though JVM will exit after 60 seconds + private ExecutorService executor; + + public CachedThreadPoolMehProblem() { + this.executor = Executors.newCachedThreadPool(); + } + + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + +} + +class SingleThreadExecutorThreadFactoryMehProblem { + //tag - this is bad practice, even though the threads will terminate + private ExecutorService executor; + + public SingleThreadExecutorThreadFactoryMehProblem() { + this.executor = Executors.newSingleThreadExecutor(new ThreadFactory() { + @Override + public Thread newThread(Runnable arg0) { + Thread t = new Thread(arg0); + t.setDaemon(true); + return t; + } + }); + } + + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + +} + +class ScheduledThreadPoolProblem { + //tag + private ExecutorService executor; + + public ScheduledThreadPoolProblem() { + this.executor = Executors.newScheduledThreadPool(1); + } + + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + +} + +class ReplacementExecutorProblem { + private ExecutorService executor; + + public ReplacementExecutorProblem() { + this.executor = Executors.newScheduledThreadPool(1); + executor.execute(new SampleExecutable()); + } + + public void reset() { + + executor.execute(new SampleExecutable()); + //tag (the old executor won't get picked up for garbage collection) + this.executor = Executors.newScheduledThreadPool(1); + executor.execute(new SampleExecutable()); + try { + executor.awaitTermination(1, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public void test() { + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + + public void shutDown() { + executor.shutdownNow(); + } + +} + +class ReplacementExecutorGood { + private ExecutorService executor; + + public ReplacementExecutorGood() { + this.executor = Executors.newScheduledThreadPool(1); + executor.execute(new SampleExecutable()); + } + + public void reset() { + //no tag + this.executor.shutdown(); + + this.executor = Executors.newScheduledThreadPool(1); + executor.execute(new SampleExecutable()); + try { + executor.awaitTermination(1, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + executor.shutdown(); + } + +} + +class ReplacementExecutorBad2 { + private ExecutorService executor; + + public ReplacementExecutorBad2() { + this.executor = Executors.newScheduledThreadPool(1); + executor.execute(new SampleExecutable()); + } + + public void reset() { + //tag, because shutdown in other method isn't forced to be called + this.executor = Executors.newScheduledThreadPool(1); + + } + + public void shutDown() { + this.executor.shutdown(); + } + + public void task() { + executor.execute(new SampleExecutable()); + try { + executor.awaitTermination(1, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + +} + +class ReplacementExecutorGood2 { + private ExecutorService executor; + + public ReplacementExecutorGood2() { + this.executor = Executors.newScheduledThreadPool(1); + executor.execute(new SampleExecutable()); + } + + public void reset() { + System.out.println("Pretest"); + if (executor == null) { + //no tag, the null check indicates some thought that another threadpool won't get left behind + this.executor = Executors.newScheduledThreadPool(1); + } + //tag (this one is no long under the "good graces" of the null check + this.executor = Executors.newCachedThreadPool(); + } + + public void shutDown() { + this.executor.shutdown(); + //no tag + this.executor = null; + } + + public void task() { + executor.execute(new SampleExecutable()); + try { + executor.awaitTermination(1, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + +} + + +class LocalExecutorProblem { + + public void task() { + //tag + ExecutorService executor = Executors.newSingleThreadExecutor(); + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + +} + +class LocalExecutorProblem1 { + + public void task() { + //tag + ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() { + + @Override + public Thread newThread(Runnable arg0) { + return new Thread(arg0); + } + }); + executor.execute(new SampleExecutable()); + executor.execute(new SampleExecutable()); + } + +} + +class LocalExecutorProblem2 { + + public void task() { + //tag (checking for mislabeled objects) + Object executor = Executors.newCachedThreadPool(new ThreadFactory() { + + @Override + public Thread newThread(Runnable arg0) { + return new Thread(arg0); + } + }); + + System.out.println(executor); + } + +} + +class LocalExecutorProblem3 { + + public void task() { + //tag + ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); + + System.out.println(executor); + } + +} + + + Property changes on: trunk/fb-contrib/samples/HES_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/LSYC_Sample.java =================================================================== --- trunk/fb-contrib/samples/LSYC_Sample.java 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/samples/LSYC_Sample.java 2014-05-24 04:08:28 UTC (rev 1772) @@ -1,3 +1,4 @@ +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Hashtable; @@ -28,6 +29,12 @@ List<String> a = Collections.synchronizedList(ls); syncfield = a; } + + public List<String> getList() { + // don't report + return Collections.synchronizedList(new ArrayList<String>()); + + } public Map<String, Map<String, String>> test4() { // report as low @@ -47,5 +54,10 @@ buffer.append("Findbugs "); return buffer.toString(); } + + public String printString2() { + //no tag, but probably should. + return new StringBuffer().append("Hello").append("World").toString(); + } } Modified: trunk/fb-contrib/samples/ROOM_Sample.java =================================================================== --- trunk/fb-contrib/samples/ROOM_Sample.java 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/samples/ROOM_Sample.java 2014-05-24 04:08:28 UTC (rev 1772) @@ -1,32 +1,32 @@ import java.lang.reflect.Method; public class ROOM_Sample { - public static final Class[] STATIC_NO_ARGS = new Class[0]; - public final Class[] NO_ARGS = new Class[0]; + public static final Class<?>[] STATIC_NO_ARGS = new Class[0]; + public final Class<?>[] NO_ARGS = new Class[0]; public void testRoomWithLocals() throws Exception { - Class c = Class.forName("java.lang.Object"); + Class<?> c = Class.forName("java.lang.Object"); Method m = c.getMethod("equals", Object.class); String s = (String) m.invoke(this, new ROOM_Sample()); } public void testRoomWithField() throws Exception { - Class c = Class.forName("java.lang.Object"); + Class<?> c = Class.forName("java.lang.Object"); Method m = c.getMethod("toString", NO_ARGS); String s = (String) m.invoke(this, (Object[]) null); } public void testRoomWithStatic() throws Exception { - Class c = Class.forName("java.lang.Object"); + Class<?> c = Class.forName("java.lang.Object"); Method m = c.getMethod("hashCode", STATIC_NO_ARGS); String s = (String) m.invoke(this, (Object[]) null); } public void testRoomWithNull() throws Exception { - Class c = Class.forName("java.lang.Object"); + Class<?> c = Class.forName("java.lang.Object"); Method m = c.getMethod("notify", (Class[]) null); String s = (String) m.invoke(this, (Object[]) null); Modified: trunk/fb-contrib/samples/samples.fbp =================================================================== --- trunk/fb-contrib/samples/samples.fbp 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/samples/samples.fbp 2014-05-24 04:08:28 UTC (rev 1772) @@ -1,15 +1,15 @@ <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/guava-16.0.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/junit-4.11.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/log4j-1.2.17.jar</AuxClasspathEntry> + <Jar>.</Jar> + <AuxClasspathEntry>../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/commons-collections-3.2.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/guava-16.0.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/junit-4.11.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/log4j-1.2.17.jar</AuxClasspathEntry> <AuxClasspathEntry>../lib/commons-lang3-3.3.jar</AuxClasspathEntry> <AuxClasspathEntry>../lib/slf4j-api-1.7.6.jar</AuxClasspathEntry> - <SrcDir>././.</SrcDir> + <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 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2014-05-24 04:08:28 UTC (rev 1772) @@ -28,7 +28,6 @@ { 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 2014-04-13 01:38:42 UTC (rev 1771) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java 2014-05-24 04:08:28 UTC (rev 1772) @@ -42,7 +42,6 @@ private OpcodeStack stack = new OpcodeStack(); private PrintWriter pw = null; - @SuppressWarnings("unused") public OCSDebugger(BugReporter bugReporter) { } Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java 2014-05-24 04:08:28 UTC (rev 1772) @@ -0,0 +1,198 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2014 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.classfile.Code; +import org.apache.bcel.generic.Type; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.OpcodeStack.CustomUserValue; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for methods that perform arithmetic operations on values representing time + * where the time unit is incompatible, ie adding a millisecond value to a nanosecond value. + */ +@CustomUserValue +public class ConflictingTimeUnits extends BytecodeScanningDetector { + + private enum Units { NANOS, MICROS, MILLIS, SECONDS, MINUTES, HOURS, DAYS, CALLER }; + + private static Map<String, Units> TIME_UNIT_GENERATING_METHODS = new HashMap<String, Units>(); + static { + TIME_UNIT_GENERATING_METHODS.put("java/lang/System.currentTimeMillis()J", Units.MILLIS); + TIME_UNIT_GENERATING_METHODS.put("java/lang/System.nanoTime()J", Units.NANOS); + TIME_UNIT_GENERATING_METHODS.put("java/sql/Timestamp.getTime()J", Units.MILLIS); + TIME_UNIT_GENERATING_METHODS.put("java/sql/Timestamp.getNanos()I", Units.NANOS); + TIME_UNIT_GENERATING_METHODS.put("java/util/Date.getTime()J", Units.MILLIS); + TIME_UNIT_GENERATING_METHODS.put("java/util/concurrent/TimeUnit.toNanos(J)J", Units.NANOS); + TIME_UNIT_GENERATING_METHODS.put("java/util/concurrent/TimeUnit.toMicros(J)J", Units.MICROS); + TIME_UNIT_GENERATING_METHODS.put("java/util/concurrent/TimeUnit.toSeconds(J)J", Units.SECONDS); + TIME_UNIT_GENERATING_METHODS.put("java/util/concurrent/TimeUnit.toMinutes(J)J", Units.MINUTES); + TIME_UNIT_GENERATING_METHODS.put("java/util/concurrent/TimeUnit.toHours(J)J", Units.HOURS); + TIME_UNIT_GENERATING_METHODS.put("java/util/concurrent/TimeUnit.toDays(J)J", Units.DAYS); + TIME_UNIT_GENERATING_METHODS.put("java/util/concurrent/TimeUnit.excessNanos(JJ)I", Units.NANOS); + TIME_UNIT_GENERATING_METHODS.put("java/util/concurrent/TimeUnit.convert(JLjava/util/concurrent/TimeUnit;)J", Units.CALLER); + TIME_UNIT_GENERATING_METHODS.put("edu/emory/matchcs/backport/java/util/concurrent/TimeUnit.toNanos(J)J", Units.NANOS); + TIME_UNIT_GENERATING_METHODS.put("edu/emory/matchcs/backport/java/util/concurrent/TimeUnit.toMicros(J)J", Units.MICROS); + TIME_UNIT_GENERATING_METHODS.put("edu/emory/matchcs/backport/java/util/concurrent/TimeUnit.toSeconds(J)J", Units.SECONDS); + TIME_UNIT_GENERATING_METHODS.put("edu/emory/matchcs/backport/java/util/concurrent/TimeUnit.toMinutes(J)J", Units.MINUTES); + TIME_UNIT_GENERATING_METHODS.put("edu/emory/matchcs/backport/java/util/concurrent/TimeUnit.toHours(J)J", Units.HOURS); + TIME_UNIT_GENERATING_METHODS.put("edu/emory/matchcs/backport/java/util/concurrent/TimeUnit.toDays(J)J", Units.DAYS); + TIME_UNIT_GENERATING_METHODS.put("edu/emory/matchcs/backport/java/util/concurrent/TimeUnit.excessNanos(JJ)I", Units.NANOS); + TIME_UNIT_GENERATING_METHODS.put("edu/emory/matchcs/backport/java/util/concurrent/TimeUnit.convert(JLjava/util/concurrent/TimeUnit;)J", Units.CALLER); + TIME_UNIT_GENERATING_METHODS.put("org/joda/time/base/BaseDuration.getMillis()J", Units.MILLIS); + TIME_UNIT_GENERATING_METHODS.put("org/joda/time/base/BaseInterval.getEndMillis()J", Units.MILLIS); + TIME_UNIT_GENERATING_METHODS.put("org/joda/time/base/BaseInterval.getStartMillis()J", Units.MILLIS); + } + + private static Map<String, Units> TIMEUNIT_TO_UNITS = new HashMap<String, Units>(); + static { + TIMEUNIT_TO_UNITS.put("NANOSECONDS", Units.NANOS); + TIMEUNIT_TO_UNITS.put("MICROSECONDS", Units.MICROS); + TIMEUNIT_TO_UNITS.put("MILLISECONDS", Units.MILLIS); + TIMEUNIT_TO_UNITS.put("SECONDS", Units.SECONDS); + TIMEUNIT_TO_UNITS.put("MINUTES", Units.MINUTES); + TIMEUNIT_TO_UNITS.put("HOURS", Units.HOURS); + TIMEUNIT_TO_UNITS.put("DAYS", Units.DAYS); + } + + private BugReporter bugReporter; + private OpcodeStack stack; + + /** + * constructs a CTU detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public ConflictingTimeUnits(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * overrides the visitor to reset the stack + * + * @param classContext the context object of the currently parsed class + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + stack = null; + } + } + + /** + * overrides the visitor to resets the stack for this method. + * + * @param obj the context object for the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } + + /** + * overrides the visitor to look for operations on two time unit values that are conflicting + */ + @Override + public void sawOpcode(int seen) { + Units unit = null; + try { + stack.precomputation(this); + + switch (seen) { + case INVOKEVIRTUAL: + case INVOKEINTERFACE: + case INVOKESTATIC: + String methodCall = getClassConstantOperand() + "." + getNameConstantOperand() + getSigConstantOperand(); + unit = TIME_UNIT_GENERATING_METHODS.get(methodCall); + if (unit == Units.CALLER) { + int offset = Type.getArgumentTypes(getSigConstantOperand()).length; + if (stack.getStackDepth() > offset) { + OpcodeStack.Item item = stack.getStackItem(offset); + unit = (Units) item.getUserValue(); + } else { + unit = null; + } + } + break; + + case GETSTATIC: + String clsName = getClassConstantOperand(); + if ("java/util/concurrent/TimeUnit".equals(clsName) + || "edu/emory/matchcs/backport/java/util/concurrent/TimeUnit".equals(clsName)) { + unit = TIMEUNIT_TO_UNITS.get(getNameConstantOperand()); + } + break; + + + case L2I: + case I2L: + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + unit = (Units) item.getUserValue(); + } + break; + + case IADD: + case ISUB: + case IMUL: + case IDIV: + case IREM: + case LADD: + case LSUB: + case LMUL: + case LDIV: + case LREM: + if (stack.getStackDepth() > 1) { + OpcodeStack.Item arg1 = stack.getStackItem(0); + OpcodeStack.Item arg2 = stack.getStackItem(1); + + Units u1 = (Units) arg1.getUserValue(); + Units u2 = (Units) arg2.getUserValue(); + + if ((u1 != null) && (u2 != null) && (u1 != u2)) { + bugReporter.reportBug(new BugInstance(this, "CTU_CONFLICTING_TIME_UNITS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this) + .addString(u1.toString()) + .addString(u2.toString())); + } + } + break; + } + } finally { + stack.sawOpcode(this, seen); + if ((unit != null) && (stack.getStackDepth() > 0)) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(unit); + } + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java 2014-05-24 04:08:28 UTC (rev 1772) @@ -0,0 +1,312 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2014 Kevin Lubick + * Copyright (C) 2005-2014 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.Detector; +import edu.umd.cs.findbugs.FieldAnnotation; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.Priorities; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.ba.XFactory; +import edu.umd.cs.findbugs.ba.XField; + +/** + * looks for executors that are never shutdown, which will not allow the application to terminate + */ +public class HangingExecutors extends BytecodeScanningDetector { + + private static final Set<String> hangableSig = new HashSet<String>(); + + static { + hangableSig.add("Ljava/util/concurrent/ExecutorService;"); + } + + + private static final Set<String> shutdownMethods = new HashSet<String>(); + + static { + shutdownMethods.add("shutdown"); + shutdownMethods.add("shutdownNow"); + } + + + private final BugReporter bugReporter; + private Map<XField, FieldAnnotation> hangingFieldCandidates; + private Map<XField, Integer> exemptExecutors; + private OpcodeStack stack; + private String methodName; + + private LocalHangingExecutor localHEDetector; + + + + public HangingExecutors(BugReporter reporter) { + this.bugReporter=reporter; + this.localHEDetector = new LocalHangingExecutor(this, reporter); + } + + + /** + * finds ExecutorService objects that don't get a call to the terminating methods, + * and thus, never appear to be shutdown properly (the threads exist until shutdown is called) + * + * @param classContext the class context object of the currently parsed java class + */ + @Override + public void visitClassContext(ClassContext classContext) { + localHEDetector.visitClassContext(classContext); + try { + hangingFieldCandidates = new HashMap<XField, FieldAnnotation>(); + exemptExecutors = new HashMap<XField, Integer>(); + parseFieldsForHangingCandidates(classContext); + + if (!hangingFieldCandidates.isEmpty()) { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + + reportHangingExecutorFieldBugs(); + } + } finally { + stack = null; + hangingFieldCandidates = null; + exemptExecutors = null; + } + + } + + private void parseFieldsForHangingCandidates(ClassContext classContext) { + JavaClass cls = classContext.getJavaClass(); + Field[] fields = cls.getFields(); + for (Field f : fields) { + String sig = f.getSignature(); + if (hangableSig.contains(sig)) { + hangingFieldCandidates.put(XFactory.createXField(cls.getClassName(), f.getName(), f.getSignature(), f.isStatic()), FieldAnnotation.fromBCELField(cls, f)); + } + } + } + + private void reportHangingExecutorFieldBugs() { + for (Entry<XField, FieldAnnotation> entry : hangingFieldCandidates.entrySet()) { + FieldAnnotation fieldAn = entry.getValue(); + if (fieldAn != null) { + bugReporter.reportBug(new BugInstance(this, "HES_EXECUTOR_NEVER_SHUTDOWN", NORMAL_PRIORITY) + .addClass(this) + .addField(fieldAn) + .addField(entry.getKey())); + } + } + } + + /** + * implements the visitor to reset the opcode stack + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + stack.resetForMethodEntry(this); + exemptExecutors.clear(); + if ("<clinit>".equals(methodName) || "<init>".equals(methodName)) + return; + + if (!hangingFieldCandidates.isEmpty()) + super.visitCode(obj); + } + + /** + * implements the visitor to collect the method name + * + * @param obj the context object of the currently parsed method + */ + @Override + public void visitMethod(Method obj) { + methodName = obj.getName(); + } + + /** + * Browses for calls to shutdown() and shutdownNow(), and if they happen, remove + * the hanging candidate, as there is a chance it will be called. + * + * @param seen the opcode of the currently parsed instruction + */ + @Override + public void sawOpcode(int seen) { + try { + stack.precomputation(this); + + if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) { + String sig = getSigConstantOperand(); + int argCount = Type.getArgumentTypes(sig).length; + if (stack.getStackDepth() > argCount) { + OpcodeStack.Item invokeeItem = stack.getStackItem(argCount); + XField fieldOnWhichMethodIsInvoked = invokeeItem.getXField(); + if (fieldOnWhichMethodIsInvoked != null) { + removeCandidateIfShutdownCalled(fieldOnWhichMethodIsInvoked); + addExemptionIfShutdownCalled(fieldOnWhichMethodIsInvoked); + } + } + } + //TODO Should not include private methods + else if (seen == ARETURN) { + removeFieldsThatGetReturned(); + } + else if (seen == PUTFIELD) { + XField f = getXFieldOperand(); + if ("Ljava/util/concurrent/ExecutorService;".equals(f.getSignature()) && !checkException(f)) { + bugReporter.reportBug(new BugInstance(this, "HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN", Priorities.HIGH_PRIORITY) + .addClass(this) + .addMethod(this) + .addField(f) + .addSourceLine(this)); + } + //after it's been replaced, it no longer uses its exemption. + exemptExecutors.remove(f); + } + else if (seen == IFNONNULL) { + OpcodeStack.Item nullCheckItem = stack.getStackItem(0); + XField fieldWhichWasNullChecked = nullCheckItem.getXField(); + if (fieldWhichWasNullChecked != null) { + exemptExecutors.put(fieldWhichWasNullChecked, getPC() + getBranchOffset()); + } + } + } + finally { + stack.sawOpcode(this, seen); + } + } + + + private boolean checkException(XField f) { + if (!exemptExecutors.containsKey(f)) + return false; + int i = exemptExecutors.get(f).intValue(); + + return i == -1 || getPC() < i; + } + + private void removeFieldsThatGetReturned() { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item returnItem = stack.getStackItem(0); + XField field = returnItem.getXField(); + if (field != null) { + hangingFieldCandidates.remove(field); + } + } + } + + private void addExemptionIfShutdownCalled(XField fieldOnWhichMethodIsInvoked) { + String methodBeingInvoked = getNameConstantOperand(); + if (shutdownMethods.contains(methodBeingInvoked)) { + exemptExecutors.put(fieldOnWhichMethodIsInvoked, -1); + } + } + + + private void removeCandidateIfShutdownCalled(XField fieldOnWhichMethodIsInvoked) { + if (hangingFieldCandidates.containsKey(fieldOnWhichMethodIsInvoked)) { + String methodBeingInvoked = getNameConstantOperand(); + if (shutdownMethods.contains(methodBeingInvoked)) { + hangingFieldCandidates.remove(fieldOnWhichMethodIsInvoked); + } + } + } + +} + + +class LocalHangingExecutor extends LocalTypeDetector { + + private static final Map<String, Set<String>> watchedClassMethods = new HashMap<String, Set<String>>(); + private static final Map<String, Integer> syncCtors = new HashMap<String, Integer>(); + static { + Set<String> forExecutors = new HashSet<String>(); + forExecutors.add("newCachedThreadPool"); + forExecutors.add("newFixedThreadPool"); + forExecutors.add("newScheduledThreadPool"); + forExecutors.add("newSingleThreadExecutor"); + + + watchedClassMethods.put("java/util/concurrent/Executors", forExecutors); + + + syncCtors.put("java/util/concurrent/ThreadPoolExecutor", Integer.valueOf(Constants.MAJOR_1_5)); + syncCtors.put("java/util/concurrent/ScheduledThreadPoolExecutor", Integer.valueOf(Constants.MAJOR_1_5)); + } + + private BugReporter bugReporter; + private Detector delegatingDetector; + + public LocalHangingExecutor(Detector delegatingDetector, BugReporter reporter) { + this.bugReporter = reporter; + this.delegatingDetector = delegatingDetector; + } + + @Override + protected Map<String, Integer> getWatchedConstructors() { + return syncCtors; + } + + @Override + protected Map<String, Set<String>> getWatchedClassMethods() { + return watchedClassMethods; + } + + @Override + protected void reportBug(RegisterInfo cri) { + //very important to report the bug under the top, parent detector, otherwise it gets filtered out + bugReporter.reportBug(new BugInstance(delegatingDetector, "HES_LOCAL_EXECUTOR_SERVICE", Priorities.HIGH_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(cri.getSourceLineAnnotation())); + + + } + @Override + public void visitClassContext(ClassContext classContext) { + super.visi... [truncated message content] |
From: <dbr...@us...> - 2014-04-13 01:38:48
|
Revision: 1771 http://sourceforge.net/p/fb-contrib/code/1771 Author: dbrosius Date: 2014-04-13 01:38:42 +0000 (Sun, 13 Apr 2014) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/LSC_Sample.java trunk/fb-contrib/samples/OCP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.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/BogusExceptionDeclaration.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java Removed Paths: ------------- trunk/fb-contrib/lib/ Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/build.xml 2014-04-13 01:38:42 UTC (rev 1771) @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="5.2.0" /> + <property name="fb-contrib.version" value="5.3.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -73,11 +73,6 @@ <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" /> - <mkdir dir="${classes.dir}/com/mebigfatguy/fbcontrib" /> - <mkdir dir="${classes.dir}/com/mebigfatguy/fbcontrib/detect" /> - <echo message="*.class" file="${classes.dir}/com/mebigfatguy/fbcontrib/detect/.cvsignore" /> </target> <target name="validate_xml" depends="-init" description="validates the xml files"> @@ -95,7 +90,7 @@ </target> <target name="compile_samples" depends="-init" description="compiles sample problem files"> - <javac srcdir="${samples.dir}" destdir="${samples.dir}" source="1.5" target="1.5" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> + <javac srcdir="${samples.dir}" destdir="${samples.dir}" source="1.7" target="1.7" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false"> <classpath refid="fb-contrib.classpath" /> <classpath refid="fb-contrib.samples.classpath" /> </javac> @@ -135,6 +130,7 @@ <attribute name="Require-Bundle" value="edu.umd.cs.findbugs.plugin.eclipse" /> <attribute name="Bundle-ActivationPolicy" value="lazy" /> <attribute name="Export-Package" value="com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect, com.mebigfatguy.fbcontrib.debug" /> + <attribute name="Import-Package" value="edu.umd.cs.findbugs, edu.umd.cs.findbugs.ba, edu.umd.cs.findbugs.bceledu.umd.cs.findbugs.visitclass, org.apache.bcel, org.apache.bcel.classfile, org.apache.bcel.generic" /> </manifest> </jar> </target> @@ -150,8 +146,9 @@ <include name="**/*.xml" /> <include name="**/*.xsd" /> <include name="**/*.license" /> - <include name="**/*.txt" /> - <include name="lib/*.jar" /> + <include name="**/*.txt" /> + <include name="**/*.md" /> + <include name="**/*.xls" /> </fileset> </zip> </target> @@ -159,7 +156,7 @@ <target name="javadoc" depends="-init" description="build the javadoc for the project"> <javadoc packagenames="com.mebigfatguy.*" sourcepath="${src.dir}" classpathref="fb-contrib.classpath" destdir="${javadoc.dir}" windowtitle="fb-contrib api"> <doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle> - <bottom><![CDATA[<i>Copyright © 2005-2012 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> + <bottom><![CDATA[<i>Copyright © 2005-2014 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> </javadoc> </target> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/etc/findbugs.xml 2014-04-13 01:38:42 UTC (rev 1771) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -34,7 +34,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" /> @@ -265,12 +265,12 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection" speed="fast" reports="MUC_MODIFYING_UNMODIFIABLE_COLLECTION"/> - <!-- 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" /> - COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/etc/messages.xml 2014-04-13 01:38:42 UTC (rev 1771) @@ -1545,9 +1545,19 @@ <LongDescription>Method {1} makes literal string comparisons passing the literal as an argument</LongDescription> <Details> <![CDATA[ - <p>This method calls the equals or compareTo methods on a String variable passing in a String literal. - A NullPointerException may occur if the string variable is null. If instead the method was called on - the string literal, and the variable was passed as an argument, this exception could never happen.</p> + <p>This line is in the form of <br/> + <code>String str = ...<br/> + str.equals("someOtherString");<br/> + //or</br> + str.compareTo("someOtherString");</code></p> + <p>A <code>NullPointerException</code> may occur if the String variable <code>str</code> is <code>null</code>. If instead the code was restructured to<br/> + <code>String str = ...<br/> + "someOtherString".equals(str);<br/> + //or</br> + "someOtherString".compareTo(str);</code><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 + <code>compareTo()</code> check for <code>null</code>.</p> ]]> </Details> </BugPattern> @@ -3888,8 +3898,8 @@ <Details> <![CDATA[ <p>This class defines a field or local collection variable with a name that contains a different type - of collection in its name. This is confusing to the reader, and likely caused by a previous refactor of - type, without changing the name.</p> + of collection in its name. An example woutd be a Set<User> called userList. This is confusing to the reader, + and likely caused by a previous refactor of type, without changing the name.</p> ]]> </Details> </BugPattern> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/htdocs/index.shtml 2014-04-13 01:38:42 UTC (rev 1771) @@ -123,7 +123,7 @@ </li> <li><b>[MUC] Modifying Unmodifiable Collection</b><br/> Looks for code that attempts to modify a collection that is or may be - defined as immutable. or instance, being returned from Arrays.asList(). Doing so will cause exceptions at runtime. + defined as immutable. for instance, being returned from Arrays.asList(). Doing so will cause exceptions at runtime. </li> </ul> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/pom.xml 2014-04-13 01:38:42 UTC (rev 1771) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>5.2.0</version> + <version>5.3.0</version> <parent> <groupId>org.sonatype.oss</groupId> @@ -56,6 +56,9 @@ <contributor> <name>Philipp Wiesemann</name> </contributor> + <contributor> + <name>Kevin Lubick</name> + </contributor> </contributors> <licenses> Modified: trunk/fb-contrib/samples/LSC_Sample.java =================================================================== --- trunk/fb-contrib/samples/LSC_Sample.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/samples/LSC_Sample.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -1,22 +1,173 @@ + public class LSC_Sample { + public static final String CONSTANT_VAL_STRING = "GoodBye"; + private static final String CONSTANT_VAL_STRING2 = "GoodBye2"; + + enum Planets { + EARTH,MARS,VENUS, JUPITER; + } + public boolean test1(String s) { + //tag return s.equals("Hello"); } public boolean test2(String s) { + //no tag return "Hello".equals(s); } public boolean test3(String s1, String s2) { + //no tag return s1.equals(s2); } public int test4(String s) { + //tag return s.compareTo("Hello"); } public int test5(String s) { + //no tag return "Hello".compareTo(s); } + + public int test6(String s) { + //tag + return s.compareTo(CONSTANT_VAL_STRING); + } + + public int test7(String s) { + //no tag + return CONSTANT_VAL_STRING.compareTo(s); + } + + public int test8(String s) { + //tag + return s.compareTo(CONSTANT_VAL_STRING2); + } + + public int test9(String s) { + //no tag + return CONSTANT_VAL_STRING2.compareTo(s); + } + + public static int test10(String s) { + switch (s) { + case "Hello": + return 1; + case CONSTANT_VAL_STRING: + return 2; + + } + + switch (s) { //two in a row to check the correct switch offsets + case "Hello2": + return 1; + case CONSTANT_VAL_STRING+"2": + return 2; + default: + return 3; + } + } + + + public static int test11(String s, String s2) { + //no tag + switch (s) { + case "Switch1": + return 1; + case "switch2": + return 2; + case "switch3": + //tag + if (s2.equalsIgnoreCase("Foo6")) { + return 5; + } + } + + //tag + if (s.equals("Foo7")) { + return 3; + } + System.out.println(s); + return 4; + + } + + public static int test12(int n, String s2) { + switch (n) { //this is probably a table lookup + case 1: + return 1; + case 2: + return 2; + case 3: + case 4: + //tag + if (s2.equalsIgnoreCase("Foo6")) { + return 5; + } + } + + //tag + if (s2.equals("Foo7")) { + return 3; + } + System.out.println(s2); + return 4; + + } + + public static int test13(Planets p, String s2) { + switch (p) { + case EARTH: + return 1; + case MARS: + return 2; + case JUPITER: + //tag + if (s2.equalsIgnoreCase("Foo6")) { + return 5; + } + default: + break; + } + + //tag + if (s2.equals("Foo7")) { + return 3; + } + System.out.println(s2); + return 4; + + } + + /* + * Tried really hard to get a false negative, by manipulating this switch to look like a + * string switch. Couldn't make it happen. + */ + public static int test14(String s2) { + switch (s2.hashCode()) { + case 1: + return 1; + case 2: + return 2; + case 3: + case 99: //forces this to also be a lookup table, like the strings + //tag + if (s2.equalsIgnoreCase("Foo6")) { + return 5; + } + } + + //tag + if (s2.equals("Foo7")) { + return 3; + } + System.out.println(s2); + return 4; + + } + } \ No newline at end of file Modified: trunk/fb-contrib/samples/OCP_Sample.java =================================================================== --- trunk/fb-contrib/samples/OCP_Sample.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/samples/OCP_Sample.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -6,6 +6,8 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.Serializable; +import java.sql.Date; +import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; @@ -98,3 +100,12 @@ public void usesOCP(LinkedList<String> ll) { } } + +class fpOverride { + public static final Comparator<Date> COMPARATOR = new Comparator<Date>() { + + public int compare(Date o1, Date o2) { + return o1.getYear() - o2.getYear(); + } + }; +} \ No newline at end of file Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -69,7 +69,7 @@ /** * constructs a CMRIC detector given the reporter to report bugs on * - * @param bugReporter + * @param reporter * the sync of bug reports */ public CollectMethodsReturningImmutableCollections(BugReporter reporter) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -19,6 +19,9 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.BitSet; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; @@ -43,6 +46,7 @@ private OpcodeStack stack; private BitSet initializedRegs; private BitSet modifyRegs; + private Map<Integer, Integer> nullStoreToLocation; /** * constructs an AIOB detector given the reporter to report bugs on @@ -58,10 +62,13 @@ stack = new OpcodeStack(); initializedRegs = new BitSet(); modifyRegs = new BitSet(); + nullStoreToLocation = new HashMap<Integer, Integer>(); super.visitClassContext(classContext); } finally { stack = null; initializedRegs = null; + modifyRegs = null; + nullStoreToLocation = null; } } @@ -77,10 +84,15 @@ initializedRegs.set(arg); arg += ("J".equals(argSig) || "D".equals(argSig)) ? 2 : 1; } + nullStoreToLocation.clear(); super.visitCode(obj); - initializedRegs.clear(); - modifyRegs.clear(); + for (Integer pc : nullStoreToLocation.values()) { + bugReporter.reportBug(new BugInstance(this, "AIOB_ARRAY_STORE_TO_NULL_REFERENCE", HIGH_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this, pc.intValue())); + } } public void sawOpcode(int seen) { @@ -189,10 +201,7 @@ int reg = arrayItem.getRegisterNumber(); if ((reg >= 0) && !initializedRegs.get(reg)) { - bugReporter.reportBug(new BugInstance(this, "AIOB_ARRAY_STORE_TO_NULL_REFERENCE", HIGH_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + nullStoreToLocation.put(Integer.valueOf(reg), getPC()); } } } @@ -237,8 +246,33 @@ initializedRegs.set(getRegisterOperand()); } break; + + case IFEQ: + case IFNE: + case IFLT: + case IFGE: + case IFGT: + case IFLE: + case IF_ICMPEQ: + case IF_ICMPNE: + case IF_ICMPLT: + case IF_ICMPGE: + case IF_ICMPGT: + case IF_ICMPLE: + case IF_ACMPEQ: + case IF_ACMPNE: + case GOTO: + case GOTO_W: + int branchTarget = getBranchTarget(); + Iterator<Map.Entry<Integer, Integer>> it = nullStoreToLocation.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry<Integer, Integer> entry = it.next(); + int pc = entry.getValue().intValue(); + if ((branchTarget < pc) && (initializedRegs.get(entry.getKey().intValue()))) + it.remove(); + } } - + } finally { stack.sawOpcode(this, seen); if (sizeSet) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -55,21 +55,21 @@ stack.precomputation(this); switch (seen) { - case INVOKESTATIC: { - String className = getClassConstantOperand(); - if (className.startsWith("edu/emory/mathcs/backport/")) { - reportBug(); + case INVOKESTATIC: { + String className = getClassConstantOperand(); + if (className.startsWith("edu/emory/mathcs/backport/")) { + reportBug(); + } } - } break; - case INVOKESPECIAL: { - String className = getClassConstantOperand(); - String methodName = getNameConstantOperand(); - if (className.startsWith("edu/emory/mathcs/backport/") - && methodName.equals("<init>")) { - reportBug(); + + case INVOKESPECIAL: { + String className = getClassConstantOperand(); + String methodName = getNameConstantOperand(); + if (className.startsWith("edu/emory/mathcs/backport/") && "<init>".equals(methodName)) { + reportBug(); + } } - } break; } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -26,6 +26,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.CodeException; @@ -52,6 +54,7 @@ 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<Pattern> dangerousAssignmentMethodPatterns = new HashSet<Pattern>(1); static { dangerousAssignmentClassSources.add("java/io/BufferedInputStream"); @@ -61,12 +64,17 @@ dangerousAssignmentClassSources.add("java/io/BufferedReader"); dangerousAssignmentClassSources.add("java/io/FileReader"); dangerousAssignmentClassSources.add("java/io/Reader"); + dangerousAssignmentClassSources.add("javax/nio/channels/Channel"); + dangerousAssignmentClassSources.add("io/netty/channel/Channel"); + dangerousAssignmentMethodSources.add("java/lang/System.currentTimeMillis()J"); dangerousAssignmentMethodSources.add("java/lang/System.nanoTime()J"); dangerousAssignmentMethodSources.add("java/util/Calendar.get(I)I"); 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"); + + dangerousAssignmentMethodPatterns.add(Pattern.compile(".*serial.*", Pattern.CASE_INSENSITIVE)); } BugReporter bugReporter; @@ -932,7 +940,19 @@ } String key = clsName + "." + getNameConstantOperand() + getSigConstantOperand(); - return dangerousAssignmentMethodSources.contains(key); + if (dangerousAssignmentMethodSources.contains(key)) { + return true; + } + + for (Pattern p : dangerousAssignmentMethodPatterns) { + Matcher m = p.matcher(key); + if (m.matches()) { + return true; + } + } + + + return false; } static class UserObject { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -68,10 +68,10 @@ /** - * constructs a BED detector given the reporter to report bugs on + * overrides the visitor to create the opcode stack * - * @param bugReporter - * the sync of bug reports + * @param classContext the context object of the currently parsed class + * */ @Override public void visitClassContext(ClassContext classContext) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -95,7 +95,7 @@ public void visitCode(Code obj) { try { Method m = getMethod(); - if (m.isPublic() && !m.isSynthetic() && m.getName().equals("clone") && (m.getArgumentTypes().length == 0)) { + if (m.isPublic() && !m.isSynthetic() && "clone".equals(m.getName()) && (m.getArgumentTypes().length == 0)) { String returnClsName = m.getReturnType().getSignature(); returnClsName = returnClsName.substring(1, returnClsName.length() - 1).replaceAll("/", "."); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -192,7 +192,7 @@ if (loop != null) { int pc = getPC(); if (loop.hasPC(pc)) { - boolean breakFollows = breakFollows(loop, !Type.getReturnType(signature).getSignature().equals("V")); + boolean breakFollows = breakFollows(loop, !"V".equals(Type.getReturnType(signature).getSignature())); if (!breakFollows) { bugReporter.reportBug(new BugInstance(this, "DWI_DELETING_WHILE_ITERATING", NORMAL_PRIORITY) @@ -218,7 +218,7 @@ if (loop != null) { int pc = getPC(); if (loop.hasPC(pc)) { - boolean breakFollows = breakFollows(loop, !Type.getReturnType(signature).getSignature().equals("V")); + boolean breakFollows = breakFollows(loop, !"V".equals(Type.getReturnType(signature).getSignature())); if (!breakFollows) { bugReporter.reportBug(new BugInstance(this, "DWI_MODIFYING_WHILE_ITERATING", NORMAL_PRIORITY) .addClass(this) @@ -497,12 +497,12 @@ static class GroupPair { private Set<Comparable<?>> groupMembers; - private String collectionClass; + private String colClass; public GroupPair(Comparable<?> member, String cls) { groupMembers = new HashSet<Comparable<?>>(); groupMembers.add(member); - collectionClass = cls; + colClass = cls; } public void addMember(Comparable<?> member) { @@ -518,12 +518,12 @@ } public boolean isStandardCollection() { - return (collectionClass == null) || !collectionClass.contains("/concurrent/"); + return (colClass == null) || !colClass.contains("/concurrent/"); } @Override public String toString() { - return groupMembers + ((collectionClass == null) ? "" : collectionClass); + return groupMembers + ((colClass == null) ? "" : colClass); } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -99,7 +99,7 @@ firstLocalReg = isStatic ? 0 : 1; for (Type p : parms) { String parmSig = p.getSignature(); - firstLocalReg += (parmSig.equals("J") || parmSig.equals("D")) ? 2 : 1; + firstLocalReg += ("J".equals(parmSig) || "D".equals(parmSig)) ? 2 : 1; } sourceLines = getSourceLines(obj); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -19,6 +19,8 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.BitSet; +import java.util.HashSet; +import java.util.Set; import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; @@ -34,15 +36,30 @@ * looks for methods that compare strings against literal strings, where the literal string * is passed as the parameter. If the .equals or .compareTo is called on the literal itself, passing * the variable as the parameter, you avoid the possibility of a NullPointerException. + * + * Updated for 1.7 to not throw false positives for string-based switch statements (which are susceptible to + * NPEs). String-based switch generate String.equals(Constant) bytecodes, and thus, must be accounted for */ public class LiteralStringComparison extends BytecodeScanningDetector { + //offsets to detect for a string switch + private static final int HASH_CODE_PC_OFFSET = 3; + private static final int DUP_PC_OFFSET = 5; + private static final int STRING_SWITCH_OFFSET = 3; + + private BugReporter bugReporter; private OpcodeStack stack; - + + private Set<Integer> stringBasedSwitchFalsePositives; + + int lastDupSeen; + int lastStringHashCodeSeen; + + /** - * constructs a LSC detector given the reporter to report bugs on - * @param bugReporter the sync of bug reports + * constructs a LSC detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports */ public LiteralStringComparison(final BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -57,12 +74,16 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); + + stringBasedSwitchFalsePositives = new HashSet<Integer>(); super.visitClassContext(classContext); } finally { stack = null; + stringBasedSwitchFalsePositives.clear(); + stringBasedSwitchFalsePositives = null; } } - + /** * looks for methods that contain a LDC or LDC_W opcodes * @@ -73,7 +94,7 @@ BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return (bytecodeSet != null) && (bytecodeSet.get(Constants.LDC) || bytecodeSet.get(Constants.LDC_W)); } - + /** * overrides the visitor to reset the opcode stack * @@ -83,10 +104,14 @@ public void visitCode(final Code obj) { if (prescreen(getMethod())) { stack.resetForMethodEntry(this); + lastDupSeen=-10; + lastStringHashCodeSeen=-10; + stringBasedSwitchFalsePositives.clear(); + super.visitCode(obj); } } - + /** * looks for strings comparisons where the stack object is a literal * @@ -95,31 +120,67 @@ @Override public void sawOpcode(final int seen) { try { - stack.precomputation(this); - + stack.precomputation(this); + if ((seen == INVOKEVIRTUAL) && "java/lang/String".equals(getClassConstantOperand())) { - String calledMethodName = getNameConstantOperand(); - String calledMethodSig = getSigConstantOperand(); - - if (("equals".equals(calledMethodName) && "(Ljava/lang/Object;)Z".equals(calledMethodSig)) - || ("compareTo".equals(calledMethodName) && "(Ljava/lang/String;)I".equals(calledMethodSig)) - || ("equalsIgnoreCase".equals(calledMethodName) && "(Ljava/lang/String;)Z".equals(calledMethodSig))) { - - if (stack.getStackDepth() > 0) { - OpcodeStack.Item itm = stack.getStackItem(0); - Object constant = itm.getConstant(); - if ((constant != null) && constant.getClass().equals(String.class)) { - bugReporter.reportBug( new BugInstance( this, "LSC_LITERAL_STRING_COMPARISON", LOW_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } + handleMethodOnString(); + } + else if (seen == DUP) { + lastDupSeen = getPC(); } + else if (seen == LOOKUPSWITCH) { + handleLookupSwitch(); + } } finally { stack.sawOpcode(this, seen); } } + + private void handleLookupSwitch() { + int pc = getPC(); + //This setup, with a dup 5 bytes before and a hashcode call 3 bytes before is a near-sure-fire + //way to detect a string-based switch + if (pc-lastStringHashCodeSeen == HASH_CODE_PC_OFFSET && pc - lastDupSeen == DUP_PC_OFFSET) { + addFalsePositivesForStringSwitch(getSwitchOffsets(),pc); + } + } + + private void addFalsePositivesForStringSwitch(int[] switchOffsets, int pc) { + for (Integer i:switchOffsets) { + //string-based switches + stringBasedSwitchFalsePositives.add(pc + i.intValue() + STRING_SWITCH_OFFSET); + } + } + + private void handleMethodOnString() { + String calledMethodName = getNameConstantOperand(); + String calledMethodSig = getSigConstantOperand(); + + if (("equals".equals(calledMethodName) && "(Ljava/lang/Object;)Z".equals(calledMethodSig)) + || ("compareTo".equals(calledMethodName) && "(Ljava/lang/String;)I".equals(calledMethodSig)) + || ("equalsIgnoreCase".equals(calledMethodName) && "(Ljava/lang/String;)Z".equals(calledMethodSig))) { + + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + Object constant = itm.getConstant(); + if ((constant != null) && constant.getClass().equals(String.class)) { + if (stringBasedSwitchFalsePositives.contains(getPC())) { + System.out.println("Ignoring false positive LSC"); + } + else { + bugReporter.reportBug( new BugInstance( this, "LSC_LITERAL_STRING_COMPARISON", HIGH_PRIORITY) //very confident + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + + } + } + } + else if ("hashCode".equals(calledMethodName)) { + lastStringHashCodeSeen = getPC(); + } + } + } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -244,7 +244,7 @@ } } else if (((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) && (THROWABLE_CLASS != null)) { String mthName = getNameConstantOperand(); - if (mthName.equals("getMessage")) { + if ("getMessage".equals(mthName)) { String callingClsName = getClassConstantOperand(); JavaClass cls = Repository.lookupClass(callingClsName); if (cls.instanceOf(THROWABLE_CLASS)) { @@ -321,9 +321,9 @@ } } - } else if (mthName.equals("toString")) { + } else if ("toString".equals(mthName)) { String callingClsName = getClassConstantOperand(); - if ((callingClsName.equals("java/lang/StringBuilder") || callingClsName.equals("java/lang/StringBuffer"))) { + if (("java/lang/StringBuilder".equals(callingClsName) || "java/lang/StringBuffer".equals(callingClsName))) { seenMethodName = mthName; } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -63,7 +63,8 @@ /** * constructs a MUC detector given the reporter to report bugs on - * @param bugReporter the sync of bug reports + * + * @param reporter the sync of bug reports */ public ModifyingUnmodifiableCollection(BugReporter reporter) { bugReporter = reporter; @@ -71,7 +72,8 @@ /** * overrides the visitor to setup and tear down the opcode stack - * @parm context the context object of the currently parse java class + * + * @param context the context object of the currently parse java class */ @Override public void visitClassContext(ClassContext context) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -389,7 +389,7 @@ OpcodeStack.Item item = stack.getStackItem(0); String mName = (String) item.getUserValue(); if (mName != null) { - if (mName.equals("trim")) { + if ("trim".equals(mName)) { item.setUserValue(null); } else { Matcher m = APPEND_PATTERN.matcher(mName); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -138,7 +138,7 @@ String sig = getSigConstantOperand(); if (sig.startsWith("()")) { propType = sig.substring("()".length()); - if (!propType.equals("V")) { + if (!"V".equals(propType)) { propName = getNameConstantOperand(); if (propName.startsWith("get")) { propName = propName.substring("get".length()); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -70,7 +70,7 @@ public void visitMethod(Method obj) { Attribute[] attributes = obj.getAttributes(); for (Attribute a : attributes) { - if (a.getName().equals("Signature")) { + if ("Signature".equals(a.getName())) { TemplateSignature ts = parseSignatureAttribute((Signature) a); if (ts != null) { for (String templateParm : ts.templateParameters) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java 2014-03-18 05:59:32 UTC (rev 1770) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java 2014-04-13 01:38:42 UTC (rev 1771) @@ -135,8 +135,8 @@ .addClass(this) .addMethod(this) .addString("Parameter " + regToParm.get(reg) + ": " + parmName)); - reg = unusedParms.nextSetBit(reg+1); } + reg = unusedParms.nextSetBit(reg+1); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2014-03-18 05:59:35
|
Revision: 1770 http://sourceforge.net/p/fb-contrib/code/1770 Author: dbrosius Date: 2014-03-18 05:59:32 +0000 (Tue, 18 Mar 2014) Log Message: ----------- Version 5.2.0 Added Paths: ----------- tags/v5_2_0/trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2014-03-18 05:58:28
|
Revision: 1769 http://sourceforge.net/p/fb-contrib/code/1769 Author: dbrosius Date: 2014-03-18 05:58:25 +0000 (Tue, 18 Mar 2014) Log Message: ----------- comment out 'in progress' detectors before release Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2014-03-18 05:56:28 UTC (rev 1768) +++ trunk/fb-contrib/etc/findbugs.xml 2014-03-18 05:58:25 UTC (rev 1769) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -34,7 +34,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" /> @@ -265,12 +265,12 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection" speed="fast" reports="MUC_MODIFYING_UNMODIFIABLE_COLLECTION"/> - <!-- 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" /> - <!-- COMMENT OUT FOR POINT RELEASE --> + COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2014-03-18 05:56:34
|
Revision: 1768 http://sourceforge.net/p/fb-contrib/code/1768 Author: dbrosius Date: 2014-03-18 05:56:28 +0000 (Tue, 18 Mar 2014) Log Message: ----------- Version 5.2.0 Added Paths: ----------- tags/v5_2_0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2014-03-18 05:52:27
|
Revision: 1767 http://sourceforge.net/p/fb-contrib/code/1767 Author: dbrosius Date: 2014-03-18 05:52:22 +0000 (Tue, 18 Mar 2014) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/plugin.xml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/LO_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorMansEnum.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/TernaryPatcher.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/samples/CD_Sample.java trunk/fb-contrib/samples/MUC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CollectionUtils.java Removed Paths: ------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/MapEntry.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/.classpath 2014-03-18 05:52:22 UTC (rev 1767) @@ -12,11 +12,11 @@ <classpathentry kind="lib" path="lib/javax.servlet-api-3.1.0.jar"/> <classpathentry kind="lib" path="lib/junit-4.11.jar"/> <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/> - <classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/> - <classpathentry kind="lib" path="lib/findbugs-2.0.3.jar"/> - <classpathentry kind="lib" path="lib/guava-15.0.jar"/> + <classpathentry kind="lib" path="lib/findbugs-2.0.3.jar" sourcepath="/home/dave/.m2/repository/com/google/code/findbugs/findbugs/2.0.3/findbugs-2.0.3-sources.jar"/> <classpathentry kind="lib" path="lib/annotations-2.0.3.jar"/> - <classpathentry kind="lib" path="lib/commons-lang3-3.2.jar"/> <classpathentry kind="lib" path="lib/javax.servlet.jsp-api-2.3.1.jar"/> + <classpathentry kind="lib" path="lib/guava-16.0.1.jar" sourcepath="lib/guava-16.0.1-sources.jar"/> + <classpathentry kind="lib" path="lib/commons-lang3-3.3.jar"/> + <classpathentry kind="lib" path="lib/slf4j-api-1.7.6.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/build.xml 2014-03-18 05:52:22 UTC (rev 1767) @@ -18,7 +18,7 @@ <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="5.0.3" /> + <property name="fb-contrib.version" value="5.2.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/etc/findbugs.xml 2014-03-18 05:52:22 UTC (rev 1767) @@ -11,11 +11,16 @@ <Earlier class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" /> <LaterCategory name="reporting" spanplugins="true" /> </SplitPass> + <SplitPass> + <Earlier class="com.mebigfatguy.fbcontrib.collect.CollectMethodsReturningImmutableCollections" /> + <LaterCategory name="reporting" spanplugins="true" /> + </SplitPass> + </OrderingConstraints> <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -25,13 +30,11 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -177,7 +180,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousClusteredSessionSupport" speed="fast" reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE,LO_INVALID_FORMATTING_ANCHOR,LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS,LO_EXCEPTION_WITH_LOGGER_PARMS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE,LO_INVALID_FORMATTING_ANCHOR,LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS,LO_EXCEPTION_WITH_LOGGER_PARMS,LO_APPENDED_STRING_IN_FORMAT_STRING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse" speed="fast" reports="IICU_INCORRECT_INTERNAL_CLASS_USE" /> @@ -248,19 +251,27 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.InvalidConstantArgument" speed="fast" reports="ICA_INVALID_CONSTANT_ARRAY" /> - <!-- COMMENT OUT FOR POINT RELEASE - <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> - <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" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UnusedParameter" speed="fast" reports="UP_UNUSED_PARAMETER" /> - COMMENT OUT FOR POINT RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.CircularDependencies" speed="moderate" reports="CD_CIRCULAR_DEPENDENCY"/> + + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectMethodsReturningImmutableCollections" speed="fast" reports="" hidden="true" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection" speed="fast" reports="MUC_MODIFYING_UNMODIFIABLE_COLLECTION"/> + + <!-- COMMENT OUT FOR POINT RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> + + <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -396,6 +407,7 @@ <BugPattern abbrev="LO" type="LO_INVALID_FORMATTING_ANCHOR" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_EXCEPTION_WITH_LOGGER_PARMS" category="CORRECTNESS" /> + <BugPattern abbrev="LO" type="LO_APPENDED_STRING_IN_FORMAT_STRING" category="PERFORMANCE" /> <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" /> <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" /> @@ -410,11 +422,11 @@ <BugPattern abbrev="OC" type="OC_OVERZEALOUS_CASTING" category="CORRECTNESS" /> <BugPattern abbrev="PDP" type="PDP_POORLY_DEFINED_PARAMETER" category="CORRECTNESS" /> <BugPattern abbrev="NSE" type="NSE_NON_SYMMETRIC_EQUALS" category="CORRECTNESS" /> - <BugPattern abbrev="CVAA" type="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="CVAA" type="CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="CVAA" type="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT" category="CORRECTNESS" /> + <BugPattern abbrev="CVAA" type="CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" category="CORRECTNESS" /> <BugPattern abbrev="NFF" type="NFF_NON_FUNCTIONAL_FIELD" category="CORRECTNESS" /> - <BugPattern abbrev="SNG" type="SNG_SUSPICIOUS_NULL_FIELD_GUARD" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SNG" type="SNG_SUSPICIOUS_NULL_LOCAL_GUARD" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SNG" type="SNG_SUSPICIOUS_NULL_FIELD_GUARD" category="CORRECTNESS" /> + <BugPattern abbrev="SNG" type="SNG_SUSPICIOUS_NULL_LOCAL_GUARD" category="CORRECTNESS" /> <BugPattern abbrev="MDM" type="MDM_RUNTIME_EXIT_OR_HALT" category="CORRECTNESS" /> <BugPattern abbrev="MDM" type="MDM_RUNFINALIZATION" category="CORRECTNESS" /> <BugPattern abbrev="MDM" type="MDM_INETADDRESS_GETLOCALHOST" category="CORRECTNESS" /> @@ -437,10 +449,10 @@ <BugPattern abbrev="WOC" type="WOC_WRITE_ONLY_COLLECTION_LOCAL" category="CORRECTNESS" /> <BugPattern abbrev="WOC" type="WOC_WRITE_ONLY_COLLECTION_FIELD" category="CORRECTNESS" /> <BugPattern abbrev="UVA" type="UVA_USE_VAR_ARGS" category="STYLE" /> - <BugPattern abbrev="PUS" type="PUS_POSSIBLE_UNSUSPECTED_SERIALIZATION" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="SEC" type="SEC_SIDE_EFFECT_CONSTRUCTOR" category="STYLE" experimental="true" /> - <BugPattern abbrev="SGSU" type="SGSU_SUSPICIOUS_GETTER_SETTER_USE" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="LGO" type="LGO_LINGERING_GRAPHICS_OBJECT" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="PUS" type="PUS_POSSIBLE_UNSUSPECTED_SERIALIZATION" category="CORRECTNESS" /> + <BugPattern abbrev="SEC" type="SEC_SIDE_EFFECT_CONSTRUCTOR" category="STYLE" /> + <BugPattern abbrev="SGSU" type="SGSU_SUSPICIOUS_GETTER_SETTER_USE" category="CORRECTNESS" /> + <BugPattern abbrev="LGO" type="LGO_LINGERING_GRAPHICS_OBJECT" category="PERFORMANCE" /> <BugPattern abbrev="STB" type="STB_STACKED_TRY_BLOCKS" category="STYLE" experimental="true" /> <BugPattern abbrev="CEBE" type="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS" category="CORRECTNESS" /> <BugPattern abbrev="CHTH" type="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE" category="CORRECTNESS" /> @@ -454,10 +466,12 @@ <BugPattern abbrev="PSC" type="PSC_PRESIZE_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="UMTP" type="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" category="CORRECTNESS" /> <BugPattern abbrev="NPMC" type="NPMC_NON_PRODUCTIVE_METHOD_CALL" category="CORRECTNESS" /> - <BugPattern abbrev="AIOB" type="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS" category="CORRECTNESS" /> - <BugPattern abbrev="AIOB" type="AIOB_ARRAY_STORE_TO_NULL_REFERENCE" category="CORRECTNESS" /> - <BugPattern abbrev="ICA" type="ICA_INVALID_CONSTANT_ARGUMENT" category="CORRECTNESS" /> - <BugPattern abbrev="CNC" type="CNC_COLLECTION_NAMING_CONFUSION" category="STYLE" /> - <BugPattern abbrev="PME" type="PME_POOR_MANS_ENUM" category="STYLE" /> - <BugPattern abbrev="UP" type="UP_UNUSED_PARAMETER" category="STYLE" /> + <BugPattern abbrev="AIOB" type="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="AIOB" type="AIOB_ARRAY_STORE_TO_NULL_REFERENCE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="ICA" type="ICA_INVALID_CONSTANT_ARGUMENT" category="CORRECTNESS" /> + <BugPattern abbrev="CNC" type="CNC_COLLECTION_NAMING_CONFUSION" category="STYLE" experimental="true" /> + <BugPattern abbrev="PME" type="PME_POOR_MANS_ENUM" category="STYLE" experimental="true" /> + <BugPattern abbrev="UP" type="UP_UNUSED_PARAMETER" category="STYLE" experimental="true" /> + <BugPattern abbrev="CD" type="CD_CIRCULAR_DEPENDENCY" category="CORRECTNESS" /> + <BugPattern abbrev="MUC" type="MUC_MODIFYING_UNMODIFIABLE_COLLECTION" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/etc/messages.xml 2014-03-18 05:52:22 UTC (rev 1767) @@ -20,6 +20,14 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectMethodsReturningImmutableCollections"> + <Details> + <![CDATA[ + <p>Collects method calls that may return immutable collections</p> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering"> <Details> @@ -1381,6 +1389,25 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.CircularDependencies"> + <Details> + <![CDATA[ + <p>This detector looks circular dependencies among classes. </p> + <p>It is a moderately fast detector</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection"> + <Details> + <![CDATA[ + <p>This detector looks for code that attempts to modify a collection that is or may be + defined as immutable. Doing so will cause exceptions at runtime.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> @@ -3102,6 +3129,19 @@ ]]> </Details> </BugPattern> + + <BugPattern type="LO_APPENDED_STRING_IN_FORMAT_STRING"> + <ShortDescription>Method passes a concatenated string to Slf4j's format string</ShortDescription> + <LongDescription>Method {1} passes a concatenated string to Slf4j's format string</LongDescription> + <Details> + <![CDATA[ + <p>This method uses an slf4j logger to log a string, where the first (format) string is created using concatenation. + You should use {} markers to inject dynamic content into the string, so that String building is delayed until the + actual log string is needed. If the log level is high enough that this log statement isn't used, then the appends + will never be executed. + ]]> + </Details> + </BugPattern>' <BugPattern type="IICU_INCORRECT_INTERNAL_CLASS_USE"> <ShortDescription>Class relies on internal API classes</ShortDescription> @@ -3878,6 +3918,32 @@ ]]> </Details> </BugPattern> + + <BugPattern type="CD_CIRCULAR_DEPENDENCY"> + <ShortDescription>Test for circular dependencies among classes</ShortDescription> + <LongDescription>Class {0} has a circular dependency with other classes</LongDescription> + <Details> + <![CDATA[ + <p> + This class has a circular dependency with other classes. This makes building these classes + difficult, as each is dependent on the other to build correctly. Consider using interfaces + to break the hard dependency. + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="MUC_MODIFYING_UNMODIFIABLE_COLLECTION"> + <ShortDescription>This method attempts to modify collection that appears to possibly be immutable</ShortDescription> + <LongDescription>This method {1} attempts to modify collection that appears to possibly be immutable</LongDescription> + <Details> + <![CDATA[ + <p>This method attempts to modify a collection that it got from a source that could potentially have created an + immutable collection, thru Arrays.asList, Collections.unmodifiableXXX, or one of guava's methods. Doing so will cause + an exception, as these collections are not mutable. + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -3996,4 +4062,6 @@ <BugCode abbrev="CNC">Collection Naming Confusion</BugCode> <BugCode abbrev="PME">Poor Mans Enum</BugCode> <BugCode abbrev="UP">Unused Parameter</BugCode> + <BugCode abbrev="CD">Circular Dependencies</BugCode> + <BugCode abbrev="MUC">Modifying Unmodifiable Collection</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/htdocs/index.shtml 2014-03-18 05:52:22 UTC (rev 1767) @@ -68,14 +68,14 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 5.0.3 available for download - <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.0.3.jar/download">here</a>.</p> + <p style="font-weight: bold;">The latest version of fb-contrib is 5.2.0 available for download + <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.2.0.jar/download">here</a>.</p> </div> <hr/> - <img id="git_image" src="flip2.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> + <img id="git_image" src="flip1.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> Detectors added in git<br/> - <div id="git" style="display:block;"> + <div id="git" style="display:none;"> <ul> <li><b>[STB] Stacked Try Blocks</b><br/> Looks for two or more try catch blocks that are consecutive and catch the @@ -88,16 +88,23 @@ to be big enough. This just causes unneeded reallocations putting strain on the garbage collector. </li> - <li><b>[AIOB] Array Index Out of Bounds</b><br/> - Looks for questionable load/stores to array elements.<ul> - <li> - Looks for accesses to array elements using literal values that are known to be outside the bounds of the array. - This mistake will cause an ArrayIndexOutOfBoundsException to occur at runtime.</li> - <li> - Looks for stores to array elements where the array itself appears to have not been allocated. - </li> - </ul> - </li> + <li><b>[AIOB] Array Index Out of Bounds</b><br/> + Looks for questionable load/stores to array elements.<ul> + <li> + Looks for accesses to array elements using literal values that are known to be outside the bounds of the array. + This mistake will cause an ArrayIndexOutOfBoundsException to occur at runtime.</li> + <li> + Looks for stores to array elements where the array itself appears to have not been allocated. + </li> + </ul> + </li> + </ul> + </div> + <hr/> + <img id="v5_2_0_image" src="flip2.gif" onClick="toggleBlock('v5_2_0', 'v5_2_0_image');" align="top"/> + Detectors added in v5.2.0<br/> + <div id="git" style="display:block;"> + <ul> <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. @@ -110,6 +117,14 @@ Looks for private or static methods that have parameters that aren't used. These parameters can be removed. </li> + <li><b>[CD] Circular Dependencies</b><br/> + Looks for class dependencies that where two or more classes rely on each other, either directly or indirectly. + This often signifies an improper data model. Consider using interfaces to break this closed loop. + </li> + <li><b>[MUC] Modifying Unmodifiable Collection</b><br/> + Looks for code that attempts to modify a collection that is or may be + defined as immutable. or instance, being returned from Arrays.asList(). Doing so will cause exceptions at runtime. + </li> </ul> </div> <hr/> Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/htdocs/repository.html 2014-03-18 05:52:22 UTC (rev 1767) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>5.0.3</td></tr> + <tr><td><b>Version:</b></td><td>5.2.0</td></tr> </table> </div> Modified: trunk/fb-contrib/plugin.xml =================================================================== --- trunk/fb-contrib/plugin.xml 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/plugin.xml 2014-03-18 05:52:22 UTC (rev 1767) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> -<plugin> +<plugin id="fb-contrib" name="fb-contrib" version="5.2.0"> <extension point="edu.umd.cs.findbugs.plugin.eclipse.findbugsPlugins"> <findbugsPlugin fbPluginId="com.mebigfatguy.fbcontrib" libraryPath="."></findbugsPlugin> </extension> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/pom.xml 2014-03-18 05:52:22 UTC (rev 1767) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>5.0.3</version> + <version>5.2.0</version> <parent> <groupId>org.sonatype.oss</groupId> Added: trunk/fb-contrib/samples/CD_Sample.java =================================================================== --- trunk/fb-contrib/samples/CD_Sample.java (rev 0) +++ trunk/fb-contrib/samples/CD_Sample.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -0,0 +1,24 @@ + +public class CD_Sample { + Child c = new Child();; + + public void cdTest() { + c.childTest(); + } +} + +class Child { + SubChild sc = new SubChild(); + + public void childTest() { + sc.subChildTest(); + } +} + +class SubChild { + CD_Sample cds = new CD_Sample(); + + public void subChildTest() { + cds.toString(); + } +} Property changes on: trunk/fb-contrib/samples/CD_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/LO_Sample.java =================================================================== --- trunk/fb-contrib/samples/LO_Sample.java 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/samples/LO_Sample.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -41,6 +41,14 @@ public void testInvalidSLF4jParm() { l3.error("This is a problem {0}", "hello"); } + + public void testLogAppending(String s) { + try { + l3.info("Got an error with: " + s); + } catch (Exception e) { + l3.warn("Go a bad error with: " + s, e); + } + } public void testWrongNumberOfParms() { l3.error("This is a problem {}", "hello", "hello"); Added: trunk/fb-contrib/samples/MUC_Sample.java =================================================================== --- trunk/fb-contrib/samples/MUC_Sample.java (rev 0) +++ trunk/fb-contrib/samples/MUC_Sample.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -0,0 +1,45 @@ +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import java.util.Collections; + + +public class MUC_Sample { + + public void testMUC() { + List<String> l = getImmutableList(); + + l.add("Uhoh"); + } + + public void testPossiblyMUC() { + Set<String> s = getPossiblyImmutableSet(Math.random() > 0.5); + + s.add("Yowsers"); + } + + public void testMUCChained() { + List<String> l = getImmutableListChained(); + + l.add("Uhoh"); + } + + public List<String> getImmutableList() { + return Arrays.asList("foo"); + } + + public Set<String> getPossiblyImmutableSet(boolean b) { + if (b) + return Collections.unmodifiableSet(new HashSet<String>()); + + return new HashSet<String>(); + } + + public List<String> getImmutableListChained() { + return getImmutableList(); + } + + +} Property changes on: trunk/fb-contrib/samples/MUC_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/samples.fbp =================================================================== --- trunk/fb-contrib/samples/samples.fbp 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/samples/samples.fbp 2014-03-18 05:52:22 UTC (rev 1767) @@ -1,16 +1,15 @@ <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/javax.servlet-api-3.1.0.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> - <AuxClasspathEntry>../lib/commons-lang3-3.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.servlet.jsp-api-2.3.1.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/guava-16.0.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/junit-4.11.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/log4j-1.2.17.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/commons-lang3-3.3.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/slf4j-api-1.7.6.jar</AuxClasspathEntry> + <SrcDir>././.</SrcDir> <SuppressionFilter> <LastVersion value="-1" relOp="NEQ"/> </SuppressionFilter> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -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,7 +28,7 @@ * @param args standard command line args */ public static void main(final String[] args) { - JOptionPane.showMessageDialog( null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland", "fb-contrib: copyright 2005-2013", JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog( null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland", "fb-contrib: copyright 2005-2014", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } } Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -0,0 +1,200 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2014 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.collect; + +import java.util.HashSet; +import java.util.Set; + +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; + +import com.mebigfatguy.fbcontrib.utils.CollectionUtils; + +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.NonReportingDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.OpcodeStack.CustomUserValue; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * collects methods that return a collection that could be created thru an immutable method + * such as Arrays.aslist, etc. + */ +@CustomUserValue +public class CollectMethodsReturningImmutableCollections extends BytecodeScanningDetector implements NonReportingDetector { + + private static Set<String> IMMUTABLE_PRODUCING_METHODS = new HashSet<String>(); + static { + IMMUTABLE_PRODUCING_METHODS.add("com/google/common/Collect/Maps.immutableEnumMap"); + IMMUTABLE_PRODUCING_METHODS.add("com/google/common/Collect/Maps.unmodifiableMap"); + IMMUTABLE_PRODUCING_METHODS.add("com/google/common/Collect/Sets.immutableEnumSet"); + IMMUTABLE_PRODUCING_METHODS.add("com/google/common/Collect/Sets.immutableCopy"); + IMMUTABLE_PRODUCING_METHODS.add("java/util/Arrays.asList"); + IMMUTABLE_PRODUCING_METHODS.add("java/util/Collections.unmodifiableCollection"); + IMMUTABLE_PRODUCING_METHODS.add("java/util/Collections.unmodifiableSet"); + IMMUTABLE_PRODUCING_METHODS.add("java/util/Collections.unmodifiableSortedSet"); + IMMUTABLE_PRODUCING_METHODS.add("java/util/Collections.unmodifiableMap"); + IMMUTABLE_PRODUCING_METHODS.add("java/util/Collections.unmodifiableList"); + IMMUTABLE_PRODUCING_METHODS.add("edu/emory/mathcs/backport/java/util/Arrays.asList"); + IMMUTABLE_PRODUCING_METHODS.add("edu/emory/mathcs/backport/java/util/Collections.unmodifiableCollection"); + IMMUTABLE_PRODUCING_METHODS.add("edu/emory/mathcs/backport/java/util/Collections.unmodifiableSet"); + IMMUTABLE_PRODUCING_METHODS.add("edu/emory/mathcs/backport/java/util/Collections.unmodifiableSortedSet"); + IMMUTABLE_PRODUCING_METHODS.add("edu/emory/mathcs/backport/java/util/Collections.unmodifiableMap"); + IMMUTABLE_PRODUCING_METHODS.add("edu/emory/mathcs/backport/java/util/Collections.unmodifiableList"); + } + + private BugReporter bugReporter; + private OpcodeStack stack; + private String clsName; + private ImmutabilityType imType; + + /** + * constructs a CMRIC detector given the reporter to report bugs on + * + * @param bugReporter + * the sync of bug reports + */ + public CollectMethodsReturningImmutableCollections(BugReporter reporter) { + bugReporter = reporter; + } + + public void visitClassContext(ClassContext context) { + try { + stack = new OpcodeStack(); + clsName = context.getJavaClass().getClassName(); + super.visitClassContext(context); + } finally { + stack = null; + } + } + + /** + * overrides the visitor to reset the stack for the new method, then checks if the immutability field is set to immutable + * and if so reports it + * + * @param obj the context object of the currently parsed method + */ + public void visitCode(Code obj) { + try { + String signature = Type.getReturnType(getMethod().getSignature()).getSignature(); + if (signature.startsWith("L") && CollectionUtils.isListSetMap(signature.substring(1, signature.length() - 1))) { + stack.resetForMethodEntry(this); + imType = ImmutabilityType.UNKNOWN; + super.visitCode(obj); + + if ((imType == ImmutabilityType.IMMUTABLE) || (imType == ImmutabilityType.POSSIBLY_IMMUTABLE)) { + Method m = getMethod(); + Statistics.getStatistics().addImmutabilityStatus(clsName, m.getName(), m.getSignature(), imType); + } + } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } + } + + /** + * overrides the visitor to look for calls to static methods that are known to return immutable collections + * It records those variabls, and documents if what the method returns is one of those objects. + */ + public void sawOpcode(int seen) { + ImmutabilityType seenImmutable = null; + try { + stack.precomputation(this); + + switch (seen) { + case INVOKESTATIC: { + String className = getClassConstantOperand(); + String methodName = getNameConstantOperand(); + + if (IMMUTABLE_PRODUCING_METHODS.contains(className + '.' + methodName)) { + seenImmutable = ImmutabilityType.IMMUTABLE; + break; + } + } + //$FALL-THROUGH$ + case INVOKEINTERFACE: + case INVOKESPECIAL: + case INVOKEVIRTUAL: { + String className = getClassConstantOperand(); + String methodName = getNameConstantOperand(); + String signature = getSigConstantOperand(); + + MethodInfo mi = Statistics.getStatistics().getMethodStatistics(className, methodName, signature); + seenImmutable = mi.getImmutabilityType(); + if (seenImmutable == ImmutabilityType.UNKNOWN) + seenImmutable = null; + } + break; + + case ARETURN: { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + ImmutabilityType type = (ImmutabilityType) item.getUserValue(); + if (type == null) + type = ImmutabilityType.UNKNOWN; + + switch (imType) { + case UNKNOWN: + + switch (type) { + case IMMUTABLE: + imType = ImmutabilityType.IMMUTABLE; + break; + case POSSIBLY_IMMUTABLE: + imType = ImmutabilityType.POSSIBLY_IMMUTABLE; + break; + default: + imType = ImmutabilityType.MUTABLE; + break; + } + break; + + case IMMUTABLE: + if (type != ImmutabilityType.IMMUTABLE) { + imType = ImmutabilityType.POSSIBLY_IMMUTABLE; + } + break; + + case POSSIBLY_IMMUTABLE: + break; + + case MUTABLE: + if (type == ImmutabilityType.IMMUTABLE) { + imType = ImmutabilityType.POSSIBLY_IMMUTABLE; + } + break; + } + } + break; + } + } + + } finally { + stack.sawOpcode(this, seen); + if (seenImmutable != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(seenImmutable); + } + } + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -41,7 +41,7 @@ byte[] code = obj.getCode(); if (code != null) { super.visitCode(obj); - Statistics.getStatistics().addMethodStatistics(getClassName(), getMethodName(), getMethodSig(), new Statistics.MethodInfo(code.length, numMethodCalls)); + Statistics.getStatistics().addMethodStatistics(getClassName(), getMethodName(), getMethodSig(), obj.getLength(), numMethodCalls); } } Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -0,0 +1,23 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2014 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.collect; + +public enum ImmutabilityType { + UNKNOWN, IMMUTABLE, POSSIBLY_IMMUTABLE, MUTABLE +}; \ No newline at end of file Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -0,0 +1,57 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2014 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.collect; + +public class MethodInfo { + + private short numMethodBytes; + private byte numMethodCalls; + private byte immutabilityOrdinal; + + public int getNumBytes() { + return 0x0000FFFF & numMethodBytes; + } + + public void setNumBytes(int numBytes) { + numMethodBytes = (short) numBytes; + } + + public int getNumMethodCalls() { + return 0x000000FF & numMethodCalls; + } + + public void setNumMethodCalls(int numCalls) { + if (numCalls > 255) { + numCalls = 255; + } + numMethodCalls = (byte) numCalls; + } + + public ImmutabilityType getImmutabilityType() { + return ImmutabilityType.values()[immutabilityOrdinal]; + } + + public void setImmutabilityType(ImmutabilityType imType) { + immutabilityOrdinal = (byte) imType.ordinal(); + } + + public String toString() { + return "NumMethodBytes: " + getNumBytes() + " NumMethodCalls: " + getNumMethodCalls() + " ImmutabilityType: " + getImmutabilityType(); + } +} \ No newline at end of file Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -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 @@ -30,11 +30,12 @@ public class Statistics { private static Statistics statistics = new Statistics(); + private static final MethodInfo NOT_FOUND_METHOD_INFO = new MethodInfo(); - private Map<Long, Long> methodStatistics = new HashMap<Long, Long>(); + private Map<Long, MethodInfo> methodStatistics = new HashMap<Long, MethodInfo>(); + private Statistics() { - } public static Statistics getStatistics() { @@ -45,20 +46,23 @@ methodStatistics.clear(); } - public void addMethodStatistics(String className, String methodName, String signature, MethodInfo methodInfo) { + public void addMethodStatistics(String className, String methodName, String signature, int numBytes, int numMethodCalls) { Long key = getKey(className, methodName, signature); - if (methodStatistics.containsKey(key)) - methodStatistics.put(key, getValue(new MethodInfo())); - else - methodStatistics.put(getKey(className, methodName, signature), getValue(methodInfo)); + MethodInfo mi = methodStatistics.get(key); + if (mi == null) { + mi = new MethodInfo(); + methodStatistics.put(key, mi); + } + + mi.setNumBytes(numBytes); + mi.setNumMethodCalls(numMethodCalls); } public MethodInfo getMethodStatistics(String className, String methodName, String signature) { - Long v = methodStatistics.get(getKey(className, methodName, signature)); - if (v == null) - return new MethodInfo(); - else - return buildMethodInfo(v); + MethodInfo mi = methodStatistics.get(getKey(className, methodName, signature)); + if (mi == null) + return NOT_FOUND_METHOD_INFO; + return mi; } private Long getKey(String className, String methodName, String signature) { @@ -69,35 +73,15 @@ hashCode |= signature.hashCode(); return Long.valueOf(hashCode); } - - private Long getValue(MethodInfo methodInfo) { - long value = methodInfo.numBytes; - value <<= 32; - value |= methodInfo.numMethodCalls; - return Long.valueOf(value); - } - - private MethodInfo buildMethodInfo(Long value) { - MethodInfo mi = new MethodInfo(); - long v = value.longValue(); - mi.numBytes = (int)(v >>> 32); - mi.numMethodCalls = (int)(v & 0x7FFFFFFF); - return mi; - } - - public static class MethodInfo - { - public int numBytes; - public int numMethodCalls; - - public MethodInfo() { - numBytes = 0; - numMethodCalls = 0; - } - - public MethodInfo(int bytes, int calls) { - numBytes = bytes; - numMethodCalls = calls; - } - } + + public void addImmutabilityStatus(String className, String methodName, String signature, ImmutabilityType imType) { + Long key = getKey(className, methodName, signature); + MethodInfo mi = methodStatistics.get(key); + if (mi == null) { + mi = new MethodInfo(); + methodStatistics.put(key, mi); + } + + mi.setImmutabilityType(imType); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -67,6 +67,12 @@ } + /** + * constructs a BED detector given the reporter to report bugs on + * + * @param bugReporter + * the sync of bug reports + */ @Override public void visitClassContext(ClassContext classContext) { try { Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -0,0 +1,208 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2014 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.bcel.classfile.JavaClass; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; + +/** + * looks for classes that have dependencies on each other in a circular way. + * Class initialization can be compromised in this scenario, and usually points to + * a bad data model. Consider using interfaces to break this hard circular dependency. + */ +public class CircularDependencies extends BytecodeScanningDetector { + private Map<String, Set<String>> dependencyGraph = null; + + private BugReporter bugReporter; + + private String clsName; + + /** + * constructs a CD detector given the reporter to report bugs on + * + * @param bugReporter + * the sync of bug reports + */ + public CircularDependencies(BugReporter bugReporter) { + this.bugReporter = bugReporter; + this.dependencyGraph = new HashMap<String, Set<String>>(); + } + + @Override + public void visit(JavaClass obj) { + clsName = obj.getClassName(); + } + + @Override + public void sawOpcode(int seen) { + if ((seen == INVOKESPECIAL) || (seen == INVOKESTATIC) || (seen == INVOKEVIRTUAL)) { + String refClsName = getClassConstantOperand(); + refClsName = refClsName.replace('/', '.'); + if (refClsName.startsWith("java")) + return; + + if (clsName.equals(refClsName)) + return; + + if (clsName.startsWith(refClsName) && (refClsName.indexOf('$') >= 0)) + return; + + if (refClsName.startsWith(clsName) && (clsName.indexOf('$') >= 0)) + return; + + Set<String> dependencies = dependencyGraph.get(clsName); + if (dependencies == null) { + dependencies = new HashSet<String>(); + dependencyGraph.put(clsName, dependencies); + } + + dependencies.add(refClsName); + } + } + + @Override + public void report() { + removeDependencyLeaves(); + + LoopFinder lf = new LoopFinder(); + + while (dependencyGraph.size() > 0) { + String className = dependencyGraph.keySet().iterator().next(); + Set<String> loop = lf.findLoop(dependencyGraph, className); + boolean pruneLeaves; + if (loop != null) { + BugInstance bug = new BugInstance(this, "CD_CIRCULAR_DEPENDENCY", NORMAL_PRIORITY); + for (String loopCls : loop) { + bug.addClass(loopCls); + } + bugReporter.reportBug(bug); + pruneLeaves = removeLoopLinks(loop); + } else { + dependencyGraph.remove(className); + pruneLeaves = true; + } + if (pruneLeaves) + removeDependencyLeaves(); + } + + dependencyGraph.clear(); + } + + private void removeDependencyLeaves() { + boolean changed = true; + while (changed) { + changed = false; + Iterator<Set<String>> it = dependencyGraph.values().iterator(); + while (it.hasNext()) { + Set<String> dependencies = it.next(); + + boolean foundClass = false; + Iterator<String> dit = dependencies.iterator(); + while (dit.hasNext()) { + foundClass = dependencyGraph.containsKey(dit.next()); + if (!foundClass) { + dit.remove(); + changed = true; + } + } + if (dependencies.isEmpty()) { + it.remove(); + changed = true; + } + } + } + } + + private boolean removeLoopLinks(Set<String> loop) { + Set<String> dependencies = null; + for (String className : loop) { + if (dependencies != null) + dependencies.remove(className); + dependencies = dependencyGraph.get(className); + } + if (dependencies != null) + dependencies.remove(loop.iterator().next()); + + boolean removedClass = false; + Iterator<String> cIt = loop.iterator(); + while (cIt.hasNext()) { + String className = cIt.next(); + dependencies = dependencyGraph.get(className); + if (dependencies.isEmpty()) { + cIt.remove(); + removedClass = true; + } + } + return removedClass; + } + + static class LoopFinder { + private Map<String, Set<String>> dGraph = null; + + private String startClass = null; + + private Set<String> visited = null; + + private Set<String> loop = null; + + public Set<String> findLoop(Map<String, Set<String>> dependencyGraph, String startCls) { + dGraph = dependencyGraph; + startClass = startCls; + visited = new HashSet<String>(); + loop = new LinkedHashSet<String>(); + if (findLoop(startClass)) + return loop; + return null; + } + + private boolean findLoop(String curClass) { + if (curClass.contains("$")) + return false; + + Set<String> dependencies = dGraph.get(curClass); + if (dependencies == null) + return false; + + visited.add(curClass); + loop.add(curClass); + for (String depClass : dependencies) { + if (depClass.equals(startClass)) + return true; + + if (visited.contains(depClass)) + continue; + + if (findLoop(depClass)) + return true; + } + loop.remove(curClass); + return false; + } + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -178,5 +178,10 @@ this.register = register; this.appendInvoked = appendInvoked; } + + @Override + public String toString() { + return "register: " + register + " appendInvoked: " + appendInvoked; + } } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2014-02-17 21:28:00 UTC (rev 1766) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java 2014-03-18 05:52:22 UTC (rev 1767) @@ -42,24 +42,26 @@ public class DeclaredRuntimeException extends PreorderVisitor implements Detector { private final BugReporter bugReporter; - private static final Set<String> runtimeExceptions = new HashSet<String>(); private static JavaClass runtimeExceptionClass; static { try { runtimeExceptionClass = Repository.lookupClass("java.lang.RuntimeException"); - runtimeExceptions.add("java.lang.RuntimeException"); } catch (ClassNotFoundException cnfe) { runtimeExceptionClass = null; } } + private final Set<String> runtimeExceptions = new HashSet<String>(); + + /** * constructs a DRE detector given the reporter to report bugs on * @param bugReporter the sync of bug reports */ public DeclaredRuntimeException(final BugReporter bugReporter) { this.bugReporter = bugReporter; + runtimeExceptions.add("java.lang.RuntimeException"); } /** Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebi... [truncated message content] |
From: <dbr...@us...> - 2014-02-17 21:28:05
|
Revision: 1766 http://sourceforge.net/p/fb-contrib/code/1766 Author: dbrosius Date: 2014-02-17 21:28:00 +0000 (Mon, 17 Feb 2014) Log Message: ----------- Version 5.0.3 Added Paths: ----------- tags/v5_0_3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |