Package edu.umd.cs.findbugs
Class FuzzyBugComparator
java.lang.Object
edu.umd.cs.findbugs.FuzzyBugComparator
- All Implemented Interfaces:
WarningComparator
,Serializable
,Comparator<BugInstance>
A slightly more intellegent way of comparing BugInstances from two versions
to see if they are the "same". Uses class and method hashes to try to handle
renamings, at least for simple cases. (Hashes disabled for the
time being.) Uses opcode context to try to identify code that is the
same, even if it moves within the method. Also compares by bug abbreviation
rather than bug type, since the "same" bug can change type if the context
changes (e.g., "definitely null" to "null on simple path" for a null pointer
dereference). Also, we often change bug types between different versions of
FindBugs.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Filter ignored BugAnnotations from given Iterator. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IdentityHashMap
<BugInstance, BugCollection> Keep track of which BugCollections the various BugInstances have come from.private ClassNameRewriter
private static final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionMap of class hashes to canonicate class names used for comparison purposes. -
Method Summary
Modifier and TypeMethodDescriptionint
compare
(BugInstance lhs, BugInstance rhs) int
compareClasses
(BugCollection lhsCollection, BugCollection rhsCollection, ClassAnnotation lhsClass, ClassAnnotation rhsClass) int
compareClassesByName
(BugCollection lhsCollection, BugCollection rhsCollection, String lhsClassName, String rhsClassName) int
compareMethods
(BugCollection lhsCollection, BugCollection rhsCollection, MethodAnnotation lhsMethod, MethodAnnotation rhsMethod) private static int
compareNullElements
(Object a, Object b) int
compareSourceLines
(BugCollection lhsCollection, BugCollection rhsCollection, SourceLineAnnotation lhs, SourceLineAnnotation rhs) Compare source line annotations.static boolean
ignore
(BugAnnotation annotation) void
registerBugCollection
(BugCollection bugCollection) Register a BugCollection.private String
rewriteClassName
(String className) void
setClassNameRewriter
(ClassNameRewriter classNameRewriter) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
DEBUG
private static final boolean DEBUG- See Also:
-
bugCollectionMap
Keep track of which BugCollections the various BugInstances have come from. -
classNameRewriter
-
significantDescriptionSet
-
-
Constructor Details
-
FuzzyBugComparator
public FuzzyBugComparator()Map of class hashes to canonicate class names used for comparison purposes.
-
-
Method Details
-
registerBugCollection
Register a BugCollection. This allows us to find the class and method hashes for BugInstances to be compared.- Parameters:
bugCollection
- a BugCollection
-
setClassNameRewriter
- Specified by:
setClassNameRewriter
in interfaceWarningComparator
-
compare
- Specified by:
compare
in interfaceComparator<BugInstance>
- Specified by:
compare
in interfaceWarningComparator
-
compareNullElements
-
compareClasses
public int compareClasses(BugCollection lhsCollection, BugCollection rhsCollection, ClassAnnotation lhsClass, ClassAnnotation rhsClass) -
compareClassesByName
public int compareClassesByName(BugCollection lhsCollection, BugCollection rhsCollection, String lhsClassName, String rhsClassName) -
rewriteClassName
- Parameters:
className
-- Returns:
- the rewritten class name
-
compareMethods
public int compareMethods(BugCollection lhsCollection, BugCollection rhsCollection, MethodAnnotation lhsMethod, MethodAnnotation rhsMethod) -
compareSourceLines
public int compareSourceLines(BugCollection lhsCollection, BugCollection rhsCollection, SourceLineAnnotation lhs, SourceLineAnnotation rhs) Compare source line annotations.- Parameters:
lhsCollection
- rhs BugCollectionrhsCollection
- lhs BugCollectionlhs
- a SourceLineAnnotationrhs
- another SourceLineAnnotation- Returns:
- comparison of lhs and rhs
-
ignore
-