Thread: [Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect ArrayBasedCollections.java,1.5,1
Brought to you by:
dbrosius
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6903/src/com/mebigfatguy/fbcontrib/detect Modified Files: ArrayBasedCollections.java ArrayWrappedCallByReference.java BloatedSynchronizedBlock.java ConfusingAutoboxedOverloading.java ConstantListIndex.java CopiedOverriddenMethod.java CustomBuiltXML.java CyclomaticComplexity.java DeclaredRuntimeException.java DubiousListCollection.java FinalParameters.java FloatingPointLoops.java InefficientStringBuffering.java ListIndexedIterating.java LiteralStringComparison.java ManualArrayCopy.java NeedlessAutoboxing.java NeedlessInstanceRetrieval.java NonCollectionMethodUse.java OrphanedDOMNode.java OverlyConcreteParameter.java ParallelLists.java PartiallyConstructedObjectAccess.java SloppyClassReflection.java SluggishGui.java SpuriousThreadStates.java StaticMethodInstanceInvocation.java SyncCollectionIterators.java UnnecessaryStoreBeforeReturn.java UnrelatedCollectionContents.java Log Message: javadoc Index: NonCollectionMethodUse.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonCollectionMethodUse.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- NonCollectionMethodUse.java 4 Jan 2006 02:40:42 -0000 1.4 +++ NonCollectionMethodUse.java 6 Feb 2006 01:36:23 -0000 1.5 @@ -26,6 +26,10 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; +/** + * 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. + */ public class NonCollectionMethodUse extends BytecodeScanningDetector implements StatelessDetector { private static Set<String> oldMethods = new HashSet<String>(); Index: BloatedSynchronizedBlock.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- BloatedSynchronizedBlock.java 1 Feb 2006 06:47:47 -0000 1.15 +++ BloatedSynchronizedBlock.java 6 Feb 2006 01:36:22 -0000 1.16 @@ -32,6 +32,11 @@ import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; +/** + * looks for methods that are implemented using synchronized blocks, but are overly + * synchronized because the beginning of the block only accesses local variables, + * and not member variables, or this. + */ public class BloatedSynchronizedBlock extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; Index: NeedlessAutoboxing.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- NeedlessAutoboxing.java 4 Feb 2006 01:23:06 -0000 1.6 +++ NeedlessAutoboxing.java 6 Feb 2006 01:36:23 -0000 1.7 @@ -28,6 +28,10 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; +/** + * Looks for methods that pass a primitive wrapper class object, to the + * same classes Constructor. + */ public class NeedlessAutoboxing extends BytecodeScanningDetector implements StatelessDetector { private static final int SEEN_NOTHING = 0; Index: CopiedOverriddenMethod.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- CopiedOverriddenMethod.java 17 Jan 2006 04:41:21 -0000 1.6 +++ CopiedOverriddenMethod.java 6 Feb 2006 01:36:22 -0000 1.7 @@ -38,6 +38,9 @@ import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.visitclass.DismantleBytecode; +/** + * Looks for methods that are direct copies of the implementation in the super class + */ public class CopiedOverriddenMethod extends DismantleBytecode implements Detector, StatelessDetector { private BugReporter bugReporter; Index: ArrayWrappedCallByReference.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ArrayWrappedCallByReference.java 31 Jan 2006 02:14:26 -0000 1.4 +++ ArrayWrappedCallByReference.java 6 Feb 2006 01:36:22 -0000 1.5 @@ -31,7 +31,7 @@ import edu.umd.cs.findbugs.StatelessDetector; /** - * Looks for methods that use an array of length one to pass a variable to achieve call + * looks for methods that use an array of length one to pass a variable to achieve call * by pointer ala C++. It is better to define a proper return class type that holds all * the relevant information retrieved from the called method. */ Index: ConfusingAutoboxedOverloading.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ConfusingAutoboxedOverloading.java 4 Jan 2006 02:40:42 -0000 1.7 +++ ConfusingAutoboxedOverloading.java 6 Feb 2006 01:36:22 -0000 1.8 @@ -34,6 +34,19 @@ import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.visitclass.PreorderVisitor; +/** + * looks for methods that have the same signature, except where one uses a + * Character parameter, and the other uses an int, long, float, double parameter. + * Since autoboxing is available in 1.5 one might assume that + * <pre> + * test('a') + * </pre> + * would map to + * <pre> + * public void test(Character c) + * </pre> + * but instead maps to one that takes an int long, float or double. + */ public class ConfusingAutoboxedOverloading extends PreorderVisitor implements Detector, StatelessDetector { private static final int JDK15_MAJOR = 49; Index: ParallelLists.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ParallelLists.java 31 Jan 2006 02:14:26 -0000 1.9 +++ ParallelLists.java 6 Feb 2006 01:36:23 -0000 1.10 @@ -35,6 +35,11 @@ import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * looks for classes that maintain two or more lists or arrays associated one-for-one through the same index + * to hold two or more pieces of related information. It would be better to create a new class that holds + * all of these pieces of information, and place instances of this class in one list. + */ public class ParallelLists extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; Index: SluggishGui.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SluggishGui.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- SluggishGui.java 3 Feb 2006 03:45:20 -0000 1.4 +++ SluggishGui.java 6 Feb 2006 01:36:23 -0000 1.5 @@ -33,6 +33,13 @@ import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * looks for methods that implement awt or swing listeners and perform time + * consuming operations. Doing these operations in the gui thread will cause the + * interface to appear sluggish and non-responsive to the user. It is better to + * use a separate thread to do the time consuming work so that the user + * has a better experience. + */ public class SluggishGui extends BytecodeScanningDetector implements StatelessDetector { private static final Set<String> expensiveCalls = new HashSet<String>(); Index: PartiallyConstructedObjectAccess.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- PartiallyConstructedObjectAccess.java 31 Jan 2006 02:14:26 -0000 1.6 +++ PartiallyConstructedObjectAccess.java 6 Feb 2006 01:36:23 -0000 1.7 @@ -30,6 +30,11 @@ import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * looks for constructors of non final classes that make method calls to non final methods. + * As these methods could be overridden, the overridden method will be accessing an object that + * is only partially constructed, perhaps causing problems. + */ public class PartiallyConstructedObjectAccess extends BytecodeScanningDetector { private BugReporter bugReporter; Index: SpuriousThreadStates.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpuriousThreadStates.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- SpuriousThreadStates.java 31 Jan 2006 02:14:26 -0000 1.7 +++ SpuriousThreadStates.java 6 Feb 2006 01:36:23 -0000 1.8 @@ -27,6 +27,13 @@ import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; +/** + * Looks for methods that call wait, notify or notifyAll on an instance of a + * java.lang.Thread. Since the internal workings of the threads is to synchronize on the + * thread itself, introducing client calls will confuse the thread state of the object + * in question, and will cause spurious thread state changes, either waking threads up + * when not intended, or removing the the thread from the runnable state. + */ public class SpuriousThreadStates extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; Index: DubiousListCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- DubiousListCollection.java 31 Jan 2006 02:14:26 -0000 1.11 +++ DubiousListCollection.java 6 Feb 2006 01:36:23 -0000 1.12 @@ -36,6 +36,11 @@ import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * looks for constructors of non final classes that make method calls to non final methods. + * As these methods could be overridden, the overridden method will be accessing an object that + * is only partially constructed, perhaps causing problems. + */ public class DubiousListCollection extends BytecodeScanningDetector { private static final Integer FIELD_UNKNOWN = new Integer(0); Index: FinalParameters.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- FinalParameters.java 4 Jan 2006 02:40:42 -0000 1.11 +++ FinalParameters.java 6 Feb 2006 01:36:23 -0000 1.12 @@ -43,6 +43,11 @@ import edu.umd.cs.findbugs.ba.SourceFile; import edu.umd.cs.findbugs.ba.SourceFinder; +/** + * 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. + */ public class FinalParameters extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; Index: ArrayBasedCollections.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ArrayBasedCollections.java 31 Jan 2006 02:14:26 -0000 1.5 +++ ArrayBasedCollections.java 6 Feb 2006 01:36:22 -0000 1.6 @@ -32,7 +32,7 @@ import edu.umd.cs.findbugs.ba.ClassContext; /** - * Looks for methods that use arrays for items in the keyset of a map, or as + * looks for methods that use arrays for items in the keyset of a map, or as * an element of a set, or in a list when using the contains method. Since arrays * do not, and cannot define an equals method, reference equality is used for these * collections, which is probably not desired. Index: UnnecessaryStoreBeforeReturn.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- UnnecessaryStoreBeforeReturn.java 4 Jan 2006 02:40:42 -0000 1.6 +++ UnnecessaryStoreBeforeReturn.java 6 Feb 2006 01:36:23 -0000 1.7 @@ -28,6 +28,10 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; +/** + * Looks for methods that store the return result in a local variable, and + * then immediately returns that local variable. + */ public class UnnecessaryStoreBeforeReturn extends BytecodeScanningDetector implements StatelessDetector { private static final int SEEN_NOTHING = 0; Index: FloatingPointLoops.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- FloatingPointLoops.java 4 Jan 2006 02:40:42 -0000 1.8 +++ FloatingPointLoops.java 6 Feb 2006 01:36:23 -0000 1.9 @@ -30,6 +30,12 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; +/** + * looks for methods that use floating point indexes for loops. Since floating point + * math is inprecise, rounding errors will occur each time through the loop causing + * hard to find problems. It is usually better to use integer indexing, and calculating + * the correct floating point value from the index. + */ public class FloatingPointLoops extends BytecodeScanningDetector implements StatelessDetector { private static final int SEEN_LOAD = 1; Index: OrphanedDOMNode.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- OrphanedDOMNode.java 31 Jan 2006 02:14:26 -0000 1.5 +++ OrphanedDOMNode.java 6 Feb 2006 01:36:23 -0000 1.6 @@ -32,6 +32,9 @@ import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; +/** + * Looks for methods that create DOM Nodes but do not add them to any DOM Document. + */ public class OrphanedDOMNode extends BytecodeScanningDetector implements StatelessDetector { private static final Set<String> domCreationMethods = new HashSet<String>(); Index: SloppyClassReflection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SloppyClassReflection.java 20 Jan 2006 06:58:08 -0000 1.1 +++ SloppyClassReflection.java 6 Feb 2006 01:36:23 -0000 1.2 @@ -23,7 +23,6 @@ import org.apache.bcel.classfile.Constant; import org.apache.bcel.classfile.ConstantString; -import org.apache.bcel.classfile.ConstantUtf8; import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.LocalVariableTable; @@ -36,6 +35,13 @@ import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * looks for methods that use Class.forName("XXX") to load a class object + * for a class that is already referenced by this class. It is simpler to just use + * XXX.class, and doing so protects the integrity of this code from such transformations + * as obfuscation. Use of Class.forName should only be used when the class in question + * isn't already statically bound to this context. + */ public class SloppyClassReflection extends BytecodeScanningDetector implements StatelessDetector { private static final int COLLECT = -1; private static final int SEEN_NOTHING = 0; Index: ListIndexedIterating.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- ListIndexedIterating.java 31 Jan 2006 02:14:26 -0000 1.12 +++ ListIndexedIterating.java 6 Feb 2006 01:36:23 -0000 1.13 @@ -31,6 +31,11 @@ import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; +/** + * looks for for loops that iterate over a java.util.List using an integer index, and get, + * rather than using an Iterator. An iterator may perform better depending List implementation, + * but more importantly will allow the code to be converted to other collections type. + */ public class ListIndexedIterating extends BytecodeScanningDetector implements StatelessDetector { private static final int SEEN_NOTHING = 0; Index: SyncCollectionIterators.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- SyncCollectionIterators.java 31 Jan 2006 02:14:26 -0000 1.11 +++ SyncCollectionIterators.java 6 Feb 2006 01:36:23 -0000 1.12 @@ -35,6 +35,12 @@ import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * Looks for use of iterators on synchronized collections built from the Collections class. + * As the collection in question was built thru Collections.synchronizedXXX, an assumption + * is made that this collection must be multithreaded safe. However, iterator access is used, + * which is explicitly unsafe. When iterators are to be used, synchronization should be done manually. + */ public class SyncCollectionIterators extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; Index: LiteralStringComparison.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- LiteralStringComparison.java 31 Jan 2006 02:14:26 -0000 1.8 +++ LiteralStringComparison.java 6 Feb 2006 01:36:23 -0000 1.9 @@ -25,6 +25,11 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; +/** + * 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. + */ public class LiteralStringComparison extends BytecodeScanningDetector { private BugReporter bugReporter; Index: OverlyConcreteParameter.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- OverlyConcreteParameter.java 31 Jan 2006 02:14:26 -0000 1.27 +++ OverlyConcreteParameter.java 6 Feb 2006 01:36:23 -0000 1.28 @@ -42,6 +42,11 @@ import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * looks for parameters that are defined by classes, but only use methods defined by an + * implemented interface or super class. Relying on concrete classes in public signatures causes cohesion, + * and makes low impact changes more difficult. + */ public class OverlyConcreteParameter extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; Index: DeclaredRuntimeException.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- DeclaredRuntimeException.java 4 Jan 2006 02:40:42 -0000 1.9 +++ DeclaredRuntimeException.java 6 Feb 2006 01:36:23 -0000 1.10 @@ -34,6 +34,12 @@ import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.visitclass.PreorderVisitor; +/** + * looks for methods that declare Runtime exceptions in their throws clause. While doing + * so is not illegal, it may represent a misunderstanding as to the exception in question. + * If a RuntimeException is declared, it implies that this exception type is expected to happen, + * which if true, should be handled in code, and not propogated. + */ public class DeclaredRuntimeException extends PreorderVisitor implements Detector, StatelessDetector { private BugReporter bugReporter; Index: UnrelatedCollectionContents.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- UnrelatedCollectionContents.java 31 Jan 2006 02:14:26 -0000 1.12 +++ UnrelatedCollectionContents.java 6 Feb 2006 01:36:23 -0000 1.13 @@ -38,6 +38,14 @@ import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; +/** + * looks for collections or arrays that hold objects that are unrelated thru class or + * interface inheritance other than java.lang.Object. Doing so, makes for brittle code, + * relying either on positional correspondence for type, or a reliance on instanceof to + * determine type. A better design usually can be had by creating a seperate class, + * which defines the different types required, and add an instance of that class to the + * collection, or array. + */ public class UnrelatedCollectionContents extends BytecodeScanningDetector implements StatelessDetector { private static final Set<String> COLLECTION_CLASSES = new HashSet<String>(); Index: CustomBuiltXML.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- CustomBuiltXML.java 31 Jan 2006 02:14:26 -0000 1.7 +++ CustomBuiltXML.java 6 Feb 2006 01:36:22 -0000 1.8 @@ -31,6 +31,12 @@ import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; +/** + * looks for methods that build xml based strings by concatenation strings + * and custom values together. Doing so makes brittle code, that is difficult to + * modify, validate and understand. It is cleaner to create external xml files that are + * transformed at runtime, using parameters set through Transformer.setParameter. + */ public class CustomBuiltXML extends BytecodeScanningDetector implements StatelessDetector { private static final Map<Pattern, Boolean> xmlPatterns = new HashMap<Pattern, Boolean>(); Index: ConstantListIndex.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ConstantListIndex.java 18 Jan 2006 03:23:52 -0000 1.7 +++ ConstantListIndex.java 6 Feb 2006 01:36:22 -0000 1.8 @@ -31,6 +31,12 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; +/** + * looks for methods that access arrays or classes that implement java.util.List + * using a constant integer for the index. This is often a typo intented to be a loop + * variable, but if specific indices mean certain things, perhaps a first class object + * would be a better choice for a container. + */ public class ConstantListIndex extends BytecodeScanningDetector implements StatelessDetector { private static final String MAX_ICONST0_LOOP_DISTANCE_PROPERTY = "fb-contrib.cli.maxloopdistance"; private static final int SEEN_NOTHING = 0; Index: CyclomaticComplexity.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- CyclomaticComplexity.java 4 Jan 2006 02:40:42 -0000 1.9 +++ CyclomaticComplexity.java 6 Feb 2006 01:36:23 -0000 1.10 @@ -36,6 +36,10 @@ import edu.umd.cs.findbugs.ba.EdgeTypes; import edu.umd.cs.findbugs.visitclass.PreorderVisitor; +/** + * Calculates the McCabe Cyclomatic Complexity measure and reports methods that have an + * excessive value. This report value can be set with system property 'fb-contrib.cc.limit'. + */ public class CyclomaticComplexity extends PreorderVisitor implements Detector, StatelessDetector { public static final String LIMIT_PROPERTY = "fb-contrib.cc.limit"; Index: StaticMethodInstanceInvocation.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- StaticMethodInstanceInvocation.java 31 Jan 2006 02:14:26 -0000 1.6 +++ StaticMethodInstanceInvocation.java 6 Feb 2006 01:36:23 -0000 1.7 @@ -32,6 +32,11 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; +/** + * looks for methods that make static method calls using an instance reference. + * For documentation purposes, it is better to call the method using the class name. + * This may represent a change in definition that should be noticed. + */ public class StaticMethodInstanceInvocation extends BytecodeScanningDetector { private BugReporter bugReporter; private OpcodeStack stack = new OpcodeStack(); @@ -55,6 +60,11 @@ return super.clone(); } + /** + * implement the visitor to reset the stack + * + * @param obj the context object of the currently parsed method + */ @Override public void visitMethod(Method obj) { stack.resetForMethodEntry(this); @@ -62,6 +72,11 @@ super.visitMethod(obj); } + /** + * implements the visitor to look for static method calls from instance variables + * + * @param seen the opcode of the currently visited instruction + */ @Override public void sawOpcode(int seen) { try { Index: NeedlessInstanceRetrieval.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- NeedlessInstanceRetrieval.java 6 Feb 2006 00:00:29 -0000 1.6 +++ NeedlessInstanceRetrieval.java 6 Feb 2006 01:36:23 -0000 1.7 @@ -27,6 +27,11 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; +/** + * looks for methods that call a method to retrieve a reference to an object, + * to use to load a constant. It is simpler and more performant to access the + * static variable directly from the class itself. + */ public class NeedlessInstanceRetrieval extends BytecodeScanningDetector implements StatelessDetector { private static final int SEEN_NOTHING = 0; private static final int SEEN_INVOKE = 1; Index: ManualArrayCopy.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ManualArrayCopy.java 4 Jan 2006 02:40:42 -0000 1.4 +++ ManualArrayCopy.java 6 Feb 2006 01:36:23 -0000 1.5 @@ -25,6 +25,10 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.StatelessDetector; +/** + * looks for methods that copy data from one array to another using a loop. It is + * better performing to use System.arraycopy to do such copying as this is a native method. + */ public class ManualArrayCopy extends BytecodeScanningDetector implements StatelessDetector { public static final int SEEN_NOTHING = 0; Index: InefficientStringBuffering.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- InefficientStringBuffering.java 31 Jan 2006 02:14:26 -0000 1.8 +++ InefficientStringBuffering.java 6 Feb 2006 01:36:23 -0000 1.9 @@ -27,6 +27,9 @@ import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.OpcodeStack.Item; +/** + * looks for appending strings inside of calls to StringBuffer or StringBuilder append. + */ public class InefficientStringBuffering extends BytecodeScanningDetector implements StatelessDetector { private BugReporter bugReporter; |