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 interfaceTextUICommandLine.ChooserHandling 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 booleanapplySuppressionprivate java.util.Set<java.lang.String>bugCategorySetprivate intbugReporterTypeprivate ClassScreenerclassScreenerprivate static booleanDEBUGprivate java.util.Set<java.lang.String>disabledBugReporterDecoratorsprivate static intEMACS_REPORTERprivate java.util.Set<java.lang.String>enabledBugReporterDecoratorsprivate static intHTML_REPORTERprivate org.slf4j.Loggerloggerprivate booleanmergeSimilarWarningsprivate booleannoClassOkprotected java.io.FileoutputFileprivate java.io.PrintStreamoutputStream(package private) java.util.Map<java.lang.String,java.lang.String>parsedOptionsprivate booleanprintConfigurationprivate static intPRINTING_REPORTERprivate booleanprintVersionprivate intpriorityThresholdprivate java.lang.StringprojectNameprivate booleanquietprivate intrankThresholdprivate java.lang.StringredoAnalysisFileprivate booleanrelaxedReportingModeprivate java.lang.StringreleaseNameprivate java.util.List<TextUIBugReporter>reportersprivate static intSARIF_REPORTERprivate booleanscanNestedArchivesprivate booleansetExitCodeprivate booleanshowProgressprivate static intSORTING_REPORTERprivate java.lang.StringsourceInfoFileprivate java.lang.StringtrainingInputDirprivate java.lang.StringtrainingOutputDirprivate java.util.Set<java.nio.file.Path>usedReporterPathsprivate booleanuseLongBugCodesprivate booleanxargsprivate static intXDOCS_REPORTERprivate static intXML_REPORTERprivate booleanxmlWithAbridgedMessages-
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 voidaddAuxClassPathEntries(java.lang.String argument)Parse the argument as auxclasspath entries and add thembooleanapplySuppression()private voidchoose(java.lang.String argument, java.lang.String desc, TextUICommandLine.Chooser chooser)Common handling code for -chooseVisitors and -choosePlugins options.voidconfigureEngine(IFindBugsEngine findBugs)ProjectgetProject()private UserPreferencesgetUserPreferences()booleangetXargs()private voidhandleAnalyzeFromFile(java.lang.String filePath)Handle -analyzeFromFile command line option by reading jar file names from a file and adding them to the project.private voidhandleAuxClassPathFromFile(java.lang.String filePath)Handle -readAuxFromFile command line option by reading classpath entries from a file and adding them to the project.protected voidhandleOption(java.lang.String option, java.lang.String optionExtraPart)Callback method for handling an option.protected voidhandleOptionWithArgument(java.lang.String option, java.lang.String argument)Callback method for handling an option with an argument.voidhandleXArgs()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)ParseoptionExtraPartand create a path-associated if it contains the output file path such as":withMessages=path/to/file.extension"and"=/absolute/path/to/file.extension".booleanjustPrintConfiguration()booleanjustPrintVersion()booleannoClassOk()booleanquiet()booleansetExitCode()-
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:
getProjectin 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)
ParseoptionExtraPartand 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 betweenctorandhandleOptions.- Parameters:
optionExtraPart- extra part of the specified commandline optionctor- A supplier for an unconfigured .handleOptions- A function that can configure the createdBugReporterinstance.- 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:CommandLineCallback method for handling an option.- Overrides:
handleOptionin 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.IOExceptionDescription copied from class:CommandLineCallback method for handling an option with an argument.- Overrides:
handleOptionWithArgumentin 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.IOExceptionFilterException
-
handleXArgs
public void handleXArgs() throws java.io.IOExceptionHandle -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.IOExceptionHandle -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.IOExceptionHandle -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.
-
-