edu.umd.cs.findbugs

Class FindBugs

public class FindBugs extends Object implements Constants2, ExitCodes, IFindBugsEngine

An instance of this class is used to apply the selected set of analyses on some collection of Java classes. It also implements the command line interface. Much of the active work has migrated to the FindBugs2 engine, and that should be used instead of FindBugs if possible.

Author: Bill Pugh David Hovemeyer

Field Summary
static booleanDEBUG
static AnalysisFeatureSetting[]DEFAULT_EFFORT
static Set<String>knownURLProtocolSet
Known URL protocols.
static AnalysisFeatureSetting[]LESS_EFFORT
static AnalysisFeatureSetting[]MAX_EFFORT
static AnalysisFeatureSetting[]MIN_EFFORT
static AnalysisFeatureSetting[]MORE_EFFORT
static booleanTIMEDEBUG
static intTIMEQUANTUM
Constructor Summary
FindBugs()
Constructor.
FindBugs(BugReporter bugReporter, Project project)
Constructor.
Method Summary
voidaddClassObserver(IClassObserver classObserver)
voidaddFilter(String filterFileName, boolean include)
static voidconfigureBugCollection(IFindBugsEngine findBugs)
Configure the BugCollection (if the BugReporter being used is constructing one).
static voidconfigureFilter(DelegatingBugReporter bugReporter, String filterFileName, boolean include)
static voidconfigureTrainingDatabases(IFindBugsEngine findBugs)
Configure training databases.
booleanemitTrainingOutput()
voidenableTrainingInput(String trainingInputDir)
voidenableTrainingOutput(String trainingOutputDir)
voidexecute()
intgetBugCount()
BugReportergetBugReporter()
StringgetCurrentClass()
intgetErrorCount()
static StringgetHome()
Get the FindBugs home directory.
intgetMissingClassCount()
ProjectgetProject()
StringgetProjectName()
StringgetReleaseName()
StringgetTrainingInputDir()
StringgetTrainingOutputDir()
UserPreferencesgetUserPreferences()
static booleanisDetectorEnabled(IFindBugsEngine findBugs, DetectorFactory factory)
Determing whether or not given DetectorFactory should be enabled.
static voidmain(String[] argv)
static voidprocessCommandLine(TextUICommandLine commandLine, String[] argv, IFindBugsEngine findBugs)
Process the command line.
voidsetAbridgedMessages(boolean xmlWithAbridgedMessages)
voidsetAnalysisFeatureSettings(AnalysisFeatureSetting[] settingList)
voidsetBugReporter(BugReporter bugReporter)
voidsetClassScreener(IClassScreener classScreener)
voidsetDetectorFactoryCollection(DetectorFactoryCollection detectorFactoryCollection)
static voidsetHome(String home)
Set the FindBugs home directory.
voidsetProgressCallback(FindBugsProgress progressCallback)
voidsetProject(Project project)
voidsetProjectName(String projectName)
voidsetRelaxedReportingMode(boolean relaxedReportingMode)
voidsetReleaseName(String releaseName)
voidsetScanNestedArchives(boolean scanNestedArchives)
voidsetSourceInfoFile(String sourceInfoFile)
voidsetUserPreferences(UserPreferences userPreferences)
static voidshowCommandLineOptions()
Print command line options synopses to stdout.
static voidshowCommandLineOptions(TextUICommandLine commandLine)
static voidshowSynopsis()
booleanuseTrainingInput()

Field Detail

DEBUG

public static final boolean DEBUG

DEFAULT_EFFORT

public static final AnalysisFeatureSetting[] DEFAULT_EFFORT

knownURLProtocolSet

public static final Set<String> knownURLProtocolSet
Known URL protocols. Filename URLs that do not have an explicit protocol are assumed to be files.

LESS_EFFORT

public static final AnalysisFeatureSetting[] LESS_EFFORT

MAX_EFFORT

public static final AnalysisFeatureSetting[] MAX_EFFORT

MIN_EFFORT

public static final AnalysisFeatureSetting[] MIN_EFFORT

MORE_EFFORT

public static final AnalysisFeatureSetting[] MORE_EFFORT

TIMEDEBUG

public static final boolean TIMEDEBUG

TIMEQUANTUM

public static final int TIMEQUANTUM

Constructor Detail

FindBugs

public FindBugs()
Constructor. The setBugReporter() and setProject() methods must be called before this object is used.

FindBugs

public FindBugs(BugReporter bugReporter, Project project)
Constructor.

Parameters: bugReporter the BugReporter object that will be used to report BugInstance objects, analysis errors, class to source mapping, etc. project the Project indicating which files to analyze and the auxiliary classpath to use; note that the FindBugs object will create a private copy of the Project object

Method Detail

addClassObserver

public void addClassObserver(IClassObserver classObserver)

addFilter

public void addFilter(String filterFileName, boolean include)

configureBugCollection

public static void configureBugCollection(IFindBugsEngine findBugs)
Configure the BugCollection (if the BugReporter being used is constructing one).

Parameters: findBugs the IFindBugsEngine

configureFilter

public static void configureFilter(DelegatingBugReporter bugReporter, String filterFileName, boolean include)

configureTrainingDatabases

public static void configureTrainingDatabases(IFindBugsEngine findBugs)
Configure training databases.

Throws: IOException

emitTrainingOutput

public boolean emitTrainingOutput()

enableTrainingInput

public void enableTrainingInput(String trainingInputDir)

enableTrainingOutput

public void enableTrainingOutput(String trainingOutputDir)

execute

public void execute()

getBugCount

public int getBugCount()

getBugReporter

public BugReporter getBugReporter()

getCurrentClass

public String getCurrentClass()

getErrorCount

public int getErrorCount()

getHome

public static String getHome()
Get the FindBugs home directory.

getMissingClassCount

public int getMissingClassCount()

getProject

public Project getProject()

getProjectName

public String getProjectName()

getReleaseName

public String getReleaseName()

getTrainingInputDir

public String getTrainingInputDir()

getTrainingOutputDir

public String getTrainingOutputDir()

getUserPreferences

public UserPreferences getUserPreferences()

isDetectorEnabled

public static boolean isDetectorEnabled(IFindBugsEngine findBugs, DetectorFactory factory)
Determing whether or not given DetectorFactory should be enabled.

Parameters: findBugs the IFindBugsEngine factory the DetectorFactory

Returns: true if the DetectorFactory should be enabled, false otherwise

main

public static void main(String[] argv)

processCommandLine

public static void processCommandLine(TextUICommandLine commandLine, String[] argv, IFindBugsEngine findBugs)
Process the command line.

Parameters: commandLine the TextUICommandLine object which will parse the command line argv the command line arguments findBugs the IFindBugsEngine to configure

Throws: IOException FilterException

setAbridgedMessages

public void setAbridgedMessages(boolean xmlWithAbridgedMessages)

setAnalysisFeatureSettings

public void setAnalysisFeatureSettings(AnalysisFeatureSetting[] settingList)

setBugReporter

public void setBugReporter(BugReporter bugReporter)

setClassScreener

public void setClassScreener(IClassScreener classScreener)

setDetectorFactoryCollection

public void setDetectorFactoryCollection(DetectorFactoryCollection detectorFactoryCollection)

setHome

public static void setHome(String home)
Set the FindBugs home directory.

setProgressCallback

public void setProgressCallback(FindBugsProgress progressCallback)

setProject

public void setProject(Project project)

setProjectName

public void setProjectName(String projectName)

setRelaxedReportingMode

public void setRelaxedReportingMode(boolean relaxedReportingMode)

setReleaseName

public void setReleaseName(String releaseName)

setScanNestedArchives

public void setScanNestedArchives(boolean scanNestedArchives)

setSourceInfoFile

public void setSourceInfoFile(String sourceInfoFile)

setUserPreferences

public void setUserPreferences(UserPreferences userPreferences)

showCommandLineOptions

public static void showCommandLineOptions()
Print command line options synopses to stdout.

showCommandLineOptions

public static void showCommandLineOptions(TextUICommandLine commandLine)

showSynopsis

public static void showSynopsis()

useTrainingInput

public boolean useTrainingInput()
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.