Package edu.umd.cs.findbugs
Class AbstractBugReporter
- java.lang.Object
-
- edu.umd.cs.findbugs.AbstractBugReporter
-
- All Implemented Interfaces:
RepositoryLookupFailureCallback
,BugReporter
,IClassObserver
,IErrorLogger
- Direct Known Subclasses:
TextUIBugReporter
public abstract class AbstractBugReporter extends java.lang.Object implements BugReporter
An abstract class which provides much of the functionality required of all BugReporter objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractBugReporter.Error
-
Field Summary
-
Fields inherited from interface edu.umd.cs.findbugs.BugReporter
NORMAL, SILENT
-
-
Constructor Summary
Constructors Constructor Description AbstractBugReporter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addObserver(BugReporterObserver observer)
Add an observer.protected abstract void
doReportBug(BugInstance bugInstance)
Subclasses must override this.protected java.util.Set<java.lang.String>
getMissingClasses()
static java.lang.String
getMissingClassName(java.lang.ClassNotFoundException ex)
ProjectStats
getProjectStats()
Get ProjectStats object used to store statistics about the overall project being analyzed.java.util.Set<AbstractBugReporter.Error>
getQueuedErrors()
protected boolean
isRelaxed()
protected static boolean
isValidMissingClassMessage(java.lang.String message)
void
logError(java.lang.String message)
Log an error that occurs while performing analysis.void
logError(java.lang.String message, java.lang.Throwable e)
Log an error that occurs while performing analysis.protected void
notifyObservers(BugInstance bugInstance)
This should be called when a bug is reported by a subclass.abstract void
reportAnalysisError(AnalysisError error)
Report a queued error.void
reportBug(BugInstance bugInstance)
Report a bug.void
reportBugsFromXml(java.io.InputStream in, Project theProject)
void
reportMissingClass(ClassDescriptor classDescriptor)
Called to report a class lookup failure.void
reportMissingClass(java.lang.ClassNotFoundException ex)
Called to report a class lookup failure.abstract void
reportMissingClass(java.lang.String string)
Report a missing class.void
reportQueuedErrors()
Report any accumulated error messages.void
reportSkippedAnalysis(MethodDescriptor method)
Report that we skipped some analysis of a methodvoid
setErrorVerbosity(int level)
Set the error-reporting verbosity level.void
setIsRelaxed(boolean relaxed)
void
setPriorityThreshold(int threshold)
Set the priority threshold.void
setRankThreshold(int threshold)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.umd.cs.findbugs.BugReporter
finish, getBugCollection
-
Methods inherited from interface edu.umd.cs.findbugs.classfile.IClassObserver
observeClass
-
-
-
-
Method Detail
-
setErrorVerbosity
public void setErrorVerbosity(int level)
Description copied from interface:BugReporter
Set the error-reporting verbosity level.- Specified by:
setErrorVerbosity
in interfaceBugReporter
- Parameters:
level
- the verbosity level
-
setPriorityThreshold
public void setPriorityThreshold(int threshold)
Description copied from interface:BugReporter
Set the priority threshold.- Specified by:
setPriorityThreshold
in interfaceBugReporter
- Parameters:
threshold
- bug instances must be at least as important as this priority to be reported
-
setRankThreshold
public void setRankThreshold(int threshold)
-
setIsRelaxed
public void setIsRelaxed(boolean relaxed)
-
isRelaxed
protected boolean isRelaxed()
-
reportBug
public final void reportBug(@Nonnull BugInstance bugInstance)
Description copied from interface:BugReporter
Report a bug. The implementation may report the bug immediately, or queue it for later.- Specified by:
reportBug
in interfaceBugReporter
- Parameters:
bugInstance
- object describing the bug instance
-
reportBugsFromXml
public final void reportBugsFromXml(@WillClose java.io.InputStream in, Project theProject) throws java.io.IOException, org.dom4j.DocumentException
- Throws:
java.io.IOException
org.dom4j.DocumentException
-
getMissingClassName
@CheckForNull @DottedClassName public static java.lang.String getMissingClassName(java.lang.ClassNotFoundException ex)
-
reportMissingClass
public void reportMissingClass(java.lang.ClassNotFoundException ex)
Description copied from interface:IErrorLogger
Called to report a class lookup failure.- Specified by:
reportMissingClass
in interfaceIErrorLogger
- Parameters:
ex
- a ClassNotFoundException resulting from the class lookup failure
-
isValidMissingClassMessage
protected static final boolean isValidMissingClassMessage(java.lang.String message)
-
reportMissingClass
public void reportMissingClass(ClassDescriptor classDescriptor)
Description copied from interface:IErrorLogger
Called to report a class lookup failure.- Specified by:
reportMissingClass
in interfaceIErrorLogger
- Parameters:
classDescriptor
- ClassDescriptor of a missing class
-
reportSkippedAnalysis
public void reportSkippedAnalysis(MethodDescriptor method)
Report that we skipped some analysis of a method- Specified by:
reportSkippedAnalysis
in interfaceIErrorLogger
- Parameters:
method
-
-
logError
public void logError(java.lang.String message)
Description copied from interface:IErrorLogger
Log an error that occurs while performing analysis.- Specified by:
logError
in interfaceIErrorLogger
- Parameters:
message
- the error message
-
getQueuedErrors
public java.util.Set<AbstractBugReporter.Error> getQueuedErrors()
- Returns:
- the set with all analysis errors reported so far
-
getMissingClasses
protected java.util.Set<java.lang.String> getMissingClasses()
- Returns:
- the set with all missing classes reported so far
-
logError
public void logError(java.lang.String message, java.lang.Throwable e)
Description copied from interface:IErrorLogger
Log an error that occurs while performing analysis.- Specified by:
logError
in interfaceIErrorLogger
- Parameters:
message
- the error messagee
- the exception which is the underlying cause of the error
-
reportQueuedErrors
public void reportQueuedErrors()
Description copied from interface:BugReporter
Report any accumulated error messages.- Specified by:
reportQueuedErrors
in interfaceBugReporter
-
addObserver
public void addObserver(BugReporterObserver observer)
Description copied from interface:BugReporter
Add an observer.- Specified by:
addObserver
in interfaceBugReporter
- Parameters:
observer
- the observer
-
getProjectStats
public ProjectStats getProjectStats()
Description copied from interface:BugReporter
Get ProjectStats object used to store statistics about the overall project being analyzed.- Specified by:
getProjectStats
in interfaceBugReporter
-
notifyObservers
protected void notifyObservers(BugInstance bugInstance)
This should be called when a bug is reported by a subclass.- Parameters:
bugInstance
- the bug to inform observers of
-
doReportBug
protected abstract void doReportBug(BugInstance bugInstance)
Subclasses must override this. It will be called only for bugs which meet the priority threshold.- Parameters:
bugInstance
- the bug to report
-
reportAnalysisError
public abstract void reportAnalysisError(AnalysisError error)
Report a queued error.- Parameters:
error
- the queued error
-
reportMissingClass
public abstract void reportMissingClass(java.lang.String string)
Report a missing class.- Parameters:
string
- the name of the class
-
-