Package edu.umd.cs.findbugs
Class TextUICommandLine
- java.lang.Object
-
- edu.umd.cs.findbugs.config.CommandLine
-
- edu.umd.cs.findbugs.FindBugsCommandLine
-
- edu.umd.cs.findbugs.TextUICommandLine
-
public class TextUICommandLine extends FindBugsCommandLine
Helper class to parse the command line and configure the IFindBugsEngine object. As a side-effect it also configures a DetectorFactoryCollection (to enable and disable detectors as requested).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interface
TextUICommandLine.Chooser
Handling callback for choose() method, used to implement the -chooseVisitors and -choosePlugins options.-
Nested classes/interfaces inherited from class edu.umd.cs.findbugs.config.CommandLine
CommandLine.HelpRequestedException
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
applySuppression
private java.util.Set<java.lang.String>
bugCategorySet
private int
bugReporterType
private ClassScreener
classScreener
private static boolean
DEBUG
private java.util.Set<java.lang.String>
disabledBugReporterDecorators
private static int
EMACS_REPORTER
private java.util.Set<java.lang.String>
enabledBugReporterDecorators
private static int
HTML_REPORTER
private org.slf4j.Logger
logger
private boolean
mergeSimilarWarnings
private boolean
noClassOk
protected java.io.File
outputFile
private java.io.PrintStream
outputStream
(package private) java.util.Map<java.lang.String,java.lang.String>
parsedOptions
private boolean
printConfiguration
private static int
PRINTING_REPORTER
private boolean
printVersion
private int
priorityThreshold
private java.lang.String
projectName
private boolean
quiet
private int
rankThreshold
private java.lang.String
redoAnalysisFile
private boolean
relaxedReportingMode
private java.lang.String
releaseName
private java.util.List<TextUIBugReporter>
reporters
private static int
SARIF_REPORTER
private boolean
scanNestedArchives
private boolean
setExitCode
private boolean
showProgress
private static int
SORTING_REPORTER
private java.lang.String
sourceInfoFile
private java.lang.String
trainingInputDir
private java.lang.String
trainingOutputDir
private java.util.Set<java.nio.file.Path>
usedReporterPaths
private boolean
useLongBugCodes
private boolean
xargs
private static int
XDOCS_REPORTER
private static int
XML_REPORTER
private boolean
xmlWithAbridgedMessages
-
Fields inherited from class edu.umd.cs.findbugs.FindBugsCommandLine
project, projectLoadedFromFile, settingList
-
-
Constructor Summary
Constructors Constructor Description TextUICommandLine()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addAuxClassPathEntries(java.lang.String argument)
Parse the argument as auxclasspath entries and add themboolean
applySuppression()
private void
choose(java.lang.String argument, java.lang.String desc, TextUICommandLine.Chooser chooser)
Common handling code for -chooseVisitors and -choosePlugins options.void
configureEngine(IFindBugsEngine findBugs)
Project
getProject()
private UserPreferences
getUserPreferences()
boolean
getXargs()
private void
handleAnalyzeFromFile(java.lang.String filePath)
Handle -analyzeFromFile command line option by reading jar file names from a file and adding them to the project.private void
handleAuxClassPathFromFile(java.lang.String filePath)
Handle -readAuxFromFile command line option by reading classpath entries from a file and adding them to the project.protected void
handleOption(java.lang.String option, java.lang.String optionExtraPart)
Callback method for handling an option.protected void
handleOptionWithArgument(java.lang.String option, java.lang.String argument)
Callback method for handling an option with an argument.void
handleXArgs()
Handle -xargs command line option by reading jar file names from standard input and adding them to the project.(package private) <T extends TextUIBugReporter>
TextUIBugReporterinitializeReporter(java.lang.String optionExtraPart, java.util.function.Supplier<T> ctor, java.util.function.BiConsumer<T,java.lang.String> handleOptions)
ParseoptionExtraPart
and create a path-associated if it contains the output file path such as":withMessages=path/to/file.extension"
and"=/absolute/path/to/file.extension"
.boolean
justPrintConfiguration()
boolean
justPrintVersion()
boolean
noClassOk()
boolean
quiet()
boolean
setExitCode()
-
Methods inherited from class edu.umd.cs.findbugs.FindBugsCommandLine
getSettingList, isProjectLoadedFromFile, loadProject
-
Methods inherited from class edu.umd.cs.findbugs.config.CommandLine
addOption, addSwitch, addSwitchWithOptionalExtraPart, expandOptionFiles, getAnalysisOptionProperties, makeOptionUnlisted, parse, parse, printUsage, startOptionGroup
-
-
-
-
Field Detail
-
logger
private final org.slf4j.Logger logger
-
DEBUG
private static final boolean DEBUG
-
PRINTING_REPORTER
private static final int PRINTING_REPORTER
- See Also:
- Constant Field Values
-
SORTING_REPORTER
private static final int SORTING_REPORTER
- See Also:
- Constant Field Values
-
XML_REPORTER
private static final int XML_REPORTER
- See Also:
- Constant Field Values
-
EMACS_REPORTER
private static final int EMACS_REPORTER
- See Also:
- Constant Field Values
-
HTML_REPORTER
private static final int HTML_REPORTER
- See Also:
- Constant Field Values
-
XDOCS_REPORTER
private static final int XDOCS_REPORTER
- See Also:
- Constant Field Values
-
SARIF_REPORTER
private static final int SARIF_REPORTER
- See Also:
- Constant Field Values
-
bugReporterType
private int bugReporterType
-
relaxedReportingMode
private boolean relaxedReportingMode
-
useLongBugCodes
private boolean useLongBugCodes
-
showProgress
private boolean showProgress
-
xmlWithAbridgedMessages
private boolean xmlWithAbridgedMessages
-
quiet
private boolean quiet
-
classScreener
private final ClassScreener classScreener
-
enabledBugReporterDecorators
private final java.util.Set<java.lang.String> enabledBugReporterDecorators
-
disabledBugReporterDecorators
private final java.util.Set<java.lang.String> disabledBugReporterDecorators
-
usedReporterPaths
private final java.util.Set<java.nio.file.Path> usedReporterPaths
-
setExitCode
private boolean setExitCode
-
noClassOk
private boolean noClassOk
-
priorityThreshold
private int priorityThreshold
-
rankThreshold
private int rankThreshold
-
outputStream
private java.io.PrintStream outputStream
-
bugCategorySet
private java.util.Set<java.lang.String> bugCategorySet
-
trainingOutputDir
private java.lang.String trainingOutputDir
-
trainingInputDir
private java.lang.String trainingInputDir
-
releaseName
private java.lang.String releaseName
-
projectName
private java.lang.String projectName
-
sourceInfoFile
private java.lang.String sourceInfoFile
-
redoAnalysisFile
private java.lang.String redoAnalysisFile
-
mergeSimilarWarnings
private boolean mergeSimilarWarnings
-
xargs
private boolean xargs
-
scanNestedArchives
private boolean scanNestedArchives
-
applySuppression
private boolean applySuppression
-
printConfiguration
private boolean printConfiguration
-
printVersion
private boolean printVersion
-
parsedOptions
java.util.Map<java.lang.String,java.lang.String> parsedOptions
-
reporters
private java.util.List<TextUIBugReporter> reporters
-
outputFile
@CheckForNull protected java.io.File outputFile
-
-
Method Detail
-
getProject
@Nonnull public Project getProject()
- Overrides:
getProject
in classFindBugsCommandLine
-
getXargs
public boolean getXargs()
-
setExitCode
public boolean setExitCode()
-
noClassOk
public boolean noClassOk()
-
quiet
public boolean quiet()
-
applySuppression
public boolean applySuppression()
-
justPrintConfiguration
public boolean justPrintConfiguration()
-
justPrintVersion
public boolean justPrintVersion()
-
initializeReporter
<T extends TextUIBugReporter> TextUIBugReporter initializeReporter(java.lang.String optionExtraPart, java.util.function.Supplier<T> ctor, java.util.function.BiConsumer<T,java.lang.String> handleOptions)
ParseoptionExtraPart
and create a path-associated if it contains the output file path such as":withMessages=path/to/file.extension"
and"=/absolute/path/to/file.extension"
. Finally configure the created BugReporter with theoptionExtraPart
's configuration information.- Type Parameters:
T
- The implementation type of the to propagate type information betweenctor
andhandleOptions
.- Parameters:
optionExtraPart
- extra part of the specified commandline optionctor
- A supplier for an unconfigured .handleOptions
- A function that can configure the createdBugReporter
instance.- Returns:
- The fully configured reporter, or
null
, if the reporter would output to a file that is already used as a reporter output file.
-
handleOption
protected void handleOption(java.lang.String option, java.lang.String optionExtraPart)
Description copied from class:CommandLine
Callback method for handling an option.- Overrides:
handleOption
in classFindBugsCommandLine
- Parameters:
option
- the optionoptionExtraPart
- the "extra" part of the option (everything after the colon: e.g., "withMessages" in "-xml:withMessages"); the empty string if there was no extra part
-
handleOptionWithArgument
protected void handleOptionWithArgument(java.lang.String option, java.lang.String argument) throws java.io.IOException
Description copied from class:CommandLine
Callback method for handling an option with an argument.- Overrides:
handleOptionWithArgument
in classFindBugsCommandLine
- Parameters:
option
- the optionargument
- the argument- Throws:
java.io.IOException
-
addAuxClassPathEntries
private void addAuxClassPathEntries(java.lang.String argument)
Parse the argument as auxclasspath entries and add them- Parameters:
argument
-
-
choose
private void choose(java.lang.String argument, java.lang.String desc, TextUICommandLine.Chooser chooser)
Common handling code for -chooseVisitors and -choosePlugins options.- Parameters:
argument
- the list of visitors or plugins to be chosendesc
- String describing what is being chosenchooser
- callback object to selectively choose list members
-
configureEngine
public void configureEngine(IFindBugsEngine findBugs) throws java.io.IOException, FilterException
- Throws:
java.io.IOException
FilterException
-
handleXArgs
public void handleXArgs() throws java.io.IOException
Handle -xargs command line option by reading jar file names from standard input and adding them to the project.- Throws:
java.io.IOException
-
handleAuxClassPathFromFile
private void handleAuxClassPathFromFile(java.lang.String filePath) throws java.io.IOException
Handle -readAuxFromFile command line option by reading classpath entries from a file and adding them to the project.- Throws:
java.io.IOException
-
handleAnalyzeFromFile
private void handleAnalyzeFromFile(java.lang.String filePath) throws java.io.IOException
Handle -analyzeFromFile command line option by reading jar file names from a file and adding them to the project.- Throws:
java.io.IOException
-
getUserPreferences
private UserPreferences getUserPreferences()
- Returns:
- Returns the userPreferences.
-
-