[Fb-contrib-commit] SF.net SVN: fb-contrib: [523] trunk/fb-contrib/etc
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-05-09 07:26:05
|
Revision: 523 Author: dbrosius Date: 2006-05-09 00:25:51 -0700 (Tue, 09 May 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=523&view=rev Log Message: ----------- add xml infrastructure for NMCS Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-05-09 07:25:19 UTC (rev 522) +++ trunk/fb-contrib/etc/findbugs.xml 2006-05-09 07:25:51 UTC (rev 523) @@ -195,6 +195,10 @@ speed="fast" reports="SIL_SQL_IN_LOOP" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessMemberCollectionSynchronization" + speed="moderate" + reports="NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -246,4 +250,5 @@ <BugPattern abbrev="S508C" type="S508C_SET_COMP_COLOR" category="CORRECTNESS" /> <BugPattern abbrev="UEC" type="UEC_USE_ENUM_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="SIL" type="SIL_SQL_IN_LOOP" category="PERFORMANCE" experimental="true" /> + <BugPattern abbrev="NMCS" type="NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION" category="PERFORMANCE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-05-09 07:25:19 UTC (rev 522) +++ trunk/fb-contrib/etc/messages.xml 2006-05-09 07:25:51 UTC (rev 523) @@ -557,6 +557,17 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessMemberCollectionSynchronization"> + <Details> + <![CDATA[ + <p>looks for classes that define private synchronized collections as static or instance + members, that are only altered in a static initializer or constructor. Since the multithreaded + use of this collection is read-only, the use of synchronization is unnecessary.</p> + <p>It is a moderately fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -1193,11 +1204,24 @@ as the number of queries may mushroom in fencepost cases. It is probably more performant to loop over the input and collect the key data needed for the query for all items, and issue one query using an in clause, or similar construct, and then loop over this result - set, and fetch all the data at once. + set, and fetch all the data at once.</p> ]]> </Details> </BugPattern> + <BugPattern type="NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION"> + <ShortDescription>Class defines unneeded synchronization on member collection</ShortDescription> + <LongDescription>Class {0} defines unneeded synchronization on member collection</LongDescription> + <Details> + <![CDATA[ + <p>This class defines a private collection member as synchronized. It appears however + that this collection isn't only modified in a static initializer, or constructor. As these + two areas are guaranteed to be thread safe, defining this collection as synchronized is + unnecessary and a potential performance bottleneck.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -1245,4 +1269,5 @@ <BugCode abbrev="S508C">Section 508 Compliance Violations</BugCode> <BugCode abbrev="UEC">Use Enum Collections</BugCode> <BugCode abbrev="SIL">SQL In Loop</BugCode> + <BugCode abbrev="NMCS">Needless Member Collection Synchronization</BugCode> </MessageCollection> \ No newline at end of file Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java 2006-05-09 07:25:19 UTC (rev 522) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java 2006-05-09 07:25:51 UTC (rev 523) @@ -103,7 +103,7 @@ String signature = obj.getSignature(); if (signature.charAt(0) == 'L') { try { - JavaClass cls = Repository.lookupClass(signature); + JavaClass cls = Repository.lookupClass(signature.substring(1, signature.length() - 1)); if (cls.implementationOf(collectionClass)) { FieldAnnotation fa = FieldAnnotation.fromVisitedField(this); if (obj.isStatic()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |