Class SpotBugsOperation


public class SpotBugsOperation extends AbstractProcessOperation<SpotBugsOperation>
Run SpotBugs with the specified arguments.
Since:
1.0
Author:
Erik C. Thauvin
  • Field Details

    • INVALID_SPOTBUGS_LOCATION

      public static final String INVALID_SPOTBUGS_LOCATION
      The error message indicating that the provided SpotBugs location is invalid.
      See Also:
  • Constructor Details

    • SpotBugsOperation

      public SpotBugsOperation()
  • Method Details

    • execute

      Performs the operation.
      Overrides:
      execute in class AbstractProcessOperation<SpotBugsOperation>
      Throws:
      InterruptedException - when the operation was interrupted
      IOException - when an exception occurred during the execution of the process
      FileUtilsErrorException - when an exception occurred during the retrieval of the operation output
      ExitStatusException - when the exit status was changed during the operation
    • executeConstructProcessCommandList

      protected List<String> executeConstructProcessCommandList()
      Part of the execute operation constructs the command list to use for building the process.
      Specified by:
      executeConstructProcessCommandList in class AbstractProcessOperation<SpotBugsOperation>
      Returns:
      a list of strings representing the commands or an empty list if no commands are constructed.
    • fromProject

      public SpotBugsOperation fromProject(BaseProject project)
      Configures a compile operation from a BaseProject.

      Sets the following from the project:

      • analyze to buildMainDirectory
      • auxClasspath to compileMainClasspath
      • nested and timestampNow to true
      • output to reports/spotbugs/spotbugs.xml in the buildDirectory
      • projectName to the project name
      • sarif to {@code reports/spotbugs/spotbugs.sarif) in the</li> {@link BaseProject#buildDirectory() buildDirectory}</li> <li>{@link #sourcePath() sourcePath} to {@link BaseProject#srcMainJavaDirectory() srcMainJavaDirectory} and {@link BaseProject#srcMainResourcesDirectory() srcMainResourceDirectory}</li> </ul> @param project the project to configure the compile operation from @return this operation instance @see #fromProject(BaseProject, boolean)
      Specified by:
      fromProject in class AbstractProcessOperation<SpotBugsOperation>
    • parseIntOrDefault

      public static int parseIntOrDefault(String s, int defaultValue)
      Parses the given string into an integer.

      If the string is null, empty, or cannot be parsed as an integer, it returns the specified default value.

      Parameters:
      s - the string to parse as an integer
      defaultValue - the value to return if parsing fails
      Returns:
      the parsed integer value, or the default value if parsing fails
    • parseIntOrDefault

      public static int parseIntOrDefault(String s)
      Parses the given string into an integer.

      If the string cannot be parsed, returns a default value of -1.

      Parameters:
      s - the string to be parsed into an integer
      Returns:
      the parsed integer value, or -1 if parsing fails
    • adjustExperimental

      public SpotBugsOperation adjustExperimental(boolean adjustExperimental)
      Lower priority of experimental Bug Patterns.
      Parameters:
      adjustExperimental - set to true to lower priority, false otherwise
      Returns:
      this operation
    • adjustExperimental

      public boolean adjustExperimental()
      Returns whether experimental bug patterns will have their priority lowered.
      Returns:
      true if experimental patterns priorities are adjusted, false otherwise
    • adjustPriorities

      public Collection<String> adjustPriorities()
      Returns the collection of adjusted priorities.

      Each element is formatted as: name=value

      Returns:
      a collection containing the adjusted priorities as strings
    • adjustPriority

      public SpotBugsOperation adjustPriority(String name, int priority)
      Adjust the priority of warnings for a given detector (simple or fully qualified class name) or bug pattern, or suppress it completely.

      An unsigned integer sets the priority to an absolute value.

      Note that -1 is equivalent Priority.RAISE, and semantically increases the priority.

      Parameters:
      name - the detector or bug pattern name
      priority - the priority level to adjust
      See Also:
    • adjustPriority

      public SpotBugsOperation adjustPriority(String name, Priority priority)
      Adjust the priority of warnings for a given detector (simple or fully qualified class name) or bug pattern, or suppress it completely.
      Parameters:
      name - the detector or bug pattern name
      priority - the priority level to adjust
      Returns:
      this operation
      See Also:
    • analyze

      public SpotBugsOperation analyze(String... files)
      Specifies files to analyze for bugs.
      Parameters:
      files - array of file paths to analyze
      Returns:
      this operation
      See Also:
    • analyze

      public SpotBugsOperation analyze(File... files)
      Specifies files to analyze for bugs.
      Parameters:
      files - array of files to analyze
      Returns:
      this operation
      See Also:
    • analyze

      public SpotBugsOperation analyze(Path... files)
      Specifies files to analyze for bugs.
      Parameters:
      files - array of files to analyze
      Returns:
      this operation
      See Also:
    • analyze

      public SpotBugsOperation analyze(Collection<?> files)
      Specifies files to analyze for bugs.
      Parameters:
      files - collection of files to analyze
      Returns:
      this operation
      See Also:
    • analyze

      public Collection<File> analyze()
      Returns the collection of files configured to be analyzed.
      Returns:
      a collection containing the files to analyze
    • applySuppression

      public SpotBugsOperation applySuppression(boolean applySuppression)
      Exclude any bugs that match suppression filter loaded from fbp file.
      Parameters:
      applySuppression - set to true to enable, false otherwise
      Returns:
      this operation
    • applySuppression

      public boolean applySuppression()
      Returns whether suppression from filter files is applied.
      Returns:
      true if suppression is applied, false otherwise
    • auxClasspath

      public SpotBugsOperation auxClasspath(String... paths)
      Set the auxiliary classpath for analysis.

      This classpath should include all jar files and directories containing classes that are part of the program being analyzed, but you do not want to have analyzed for bugs.

      Parameters:
      paths - the auxiliary paths to set
      Returns:
      this operation
      See Also:
    • auxClasspath

      public SpotBugsOperation auxClasspath(Collection<String> paths)
      Set the auxiliary classpath for analysis.

      This classpath should include all jar files and directories containing classes that are part of the program being analyzed, but you do not want to have analyzed for bugs.

      Parameters:
      paths - the auxiliary paths to set
      Returns:
      this operation
      See Also:
    • auxClasspath

      public Collection<String> auxClasspath()
      Returns the auxiliary classpath used for analysis.
      Returns:
      a collection containing the auxiliary classpath entries
    • bugCategories

      public SpotBugsOperation bugCategories(String... categories)
      0nly report bugs in given categories.
      Parameters:
      categories - the bug categories
      Returns:
      this operation
      See Also:
    • bugCategories

      public SpotBugsOperation bugCategories(Collection<String> categories)
      0nly report bugs in given categories.
      Parameters:
      categories - the bug categories
      Returns:
      this operation
      See Also:
    • bugCategories

      public Collection<String> bugCategories()
      Returns the configured bug categories to report.
      Returns:
      a collection containing the bug categories
    • bugReporters

      public SpotBugsOperation bugReporters(String... reporters)
      Bug reporter decorators to explicitly enable/disable.

      Prefix the reporter name with - to disable.

      Parameters:
      reporters - the reporters to enable/disable
      Returns:
      this operation
      See Also:
    • bugReporters

      public SpotBugsOperation bugReporters(Collection<String> reporters)
      Bug reporter decorators to explicitly enable/disable.

      Prefix the reporter name with - to disable.

      Parameters:
      reporters - the reporters to enable/disable
      Returns:
      this operation
      See Also:
    • bugReporters

      public Collection<String> bugReporters()
      Returns the collection of bug reporter decorators that are enabled/disabled.
      Returns:
      a collection containing the bug reporters
    • choosePlugins

      public SpotBugsOperation choosePlugins(String... plugins)
      Selectively enable/disable plugins.

      Prefix the plugin name with - to disable.

      Parameters:
      plugins - the plugins to enable/disable
      Returns:
      this operation
      See Also:
    • choosePlugins

      public SpotBugsOperation choosePlugins(Collection<String> plugins)
      Selectively enable/disable plugins.

      Prefix the plugin name with - to disable.

      Parameters:
      plugins - the plugins to enable/disable
      Returns:
      this operation
      See Also:
    • choosePlugins

      public Collection<String> choosePlugins()
      Returns the collection of chosen plugin enable/disable decorators.
      Returns:
      a collection containing the chosen plugin strings
    • chooseVisitors

      public SpotBugsOperation chooseVisitors(String... visitors)
      Selectively enable/disable detectors.

      Prefix the detector name with - to disable.

      Parameters:
      visitors - the visitors to enable/disable
      Returns:
      this operation
      See Also:
    • chooseVisitors

      public SpotBugsOperation chooseVisitors(Collection<String> visitors)
      Selectively enable/disable detectors.

      Prefix the detector name with - to disable.

      Parameters:
      visitors - the visitors to enable/disable
      Returns:
      this operation
      See Also:
    • chooseVisitors

      public Collection<String> chooseVisitors()
      Returns the collection of chosen visitor enable/disable decorators.
      Returns:
      a collection containing the chosen visitor strings
    • debug

      public SpotBugsOperation debug(boolean debug)
      Sets the debug mode for the SpotBugs operation.
      Parameters:
      debug - true to enable, false otherwise
      Returns:
      this operation
    • debug

      public boolean debug()
      Retrieves the debug state.
      Returns:
      true if debug mode is enabled, false otherwise.
    • detailedMessage

      public SpotBugsOperation detailedMessage(boolean detailedMessage)
      Sets whether detailed messages should be printed.
      Parameters:
      detailedMessage - true to enable, false otherwise
      Returns:
      this operation
    • detailedMessage

      public boolean detailedMessage()
      Returns whether detailed messages are enabled.
      Returns:
      true if detailed messages will be printed, false otherwise
    • dontCombineWarnings

      public SpotBugsOperation dontCombineWarnings(boolean dontCombineWarnings)
      Don't combine warnings that differ only in line number.
      Parameters:
      dontCombineWarnings - set to true to enable, false otherwise
      Returns:
      this operation
    • dontCombineWarnings

      public boolean dontCombineWarnings()
      Returns whether warnings that differ only by line number are combined.
      Returns:
      true if warnings are not combined, false otherwise
    • effort

      public SpotBugsOperation effort(Effort effort)
      Set the analysis effort level.

      The Effort.MIN disables several analyses that increase precision but also increase memory consumption. You may want to try this option if you find that SpotBugs with the Effort.LESS still runs out of memory, or takes an unusually long time to complete its analysis.

      The Effort.LESS disables some analyses that increase precision but also increase memory consumption. You may want to try this option if you find that SpotBugs with the Effort.MORE/Effort.DEFAULT runs out of memory, or takes an unusually long time to complete its analysis.

      The Effort.MORE runs several analyses to find bugs, this is the Effort.DEFAULT.

      The Effort.MAX enable analyses which increase precision and find more bugs, but which may require more memory and take more time to complete.

      Parameters:
      effort - the effort level
      Returns:
      this operation
      See Also:
    • effort

      public Effort effort()
      Returns the configured analysis effort level.
      Returns:
      the Effort configured for this operation, or null if none
    • emacs

      public SpotBugsOperation emacs(File file)
      Produce the bug reports in Emacs format.
      Parameters:
      file - the output file
      Returns:
      this operation
      See Also:
    • emacs

      public SpotBugsOperation emacs(Path file)
      Produce the bug reports in Emacs format.
      Parameters:
      file - the output file
      Returns:
      this operation
      See Also:
    • emacs

      public SpotBugsOperation emacs(String file)
      Produce the bug reports in Emacs format.
      Parameters:
      file - the output file
      Returns:
      this operation
      See Also:
    • emacs

      public File emacs()
      Returns the Emacs bug reports file.
      Returns:
      the bug reports file
    • exclude

      public SpotBugsOperation exclude(File excludeFilter)
      Report all bug instances except those matching the filter specified by the filter file.
      Parameters:
      excludeFilter - the filter file
      Returns:
      this operation
      See Also:
    • exclude

      public SpotBugsOperation exclude(String excludeFilter)
      Report all bug instances except those matching the filter specified by the filter file.
      Parameters:
      excludeFilter - the filter file
      Returns:
      this operation
      See Also:
    • exclude

      public SpotBugsOperation exclude(Path excludeFilter)
      Report all bug instances except those matching the filter specified by the filter file.
      Parameters:
      excludeFilter - the filter file
      Returns:
      this operation
      See Also:
    • exclude

      public File exclude()
      Returns the configured filter file used to exclude bugs.
      Returns:
      the exclude filter File, or null if none configured
    • excludeBugs

      public SpotBugsOperation excludeBugs(String excludeFile)
      Exclude bugs that are also reported in the baseline XML output.
      Parameters:
      excludeFile - the exclude file
      Returns:
      this operation
      See Also:
    • excludeBugs

      public SpotBugsOperation excludeBugs(File excludeFile)
      Exclude bugs that are also reported in the baseline XML output.
      Parameters:
      excludeFile - the exclude file
      Returns:
      this operation
      See Also:
    • excludeBugs

      public SpotBugsOperation excludeBugs(Path excludeFile)
      Exclude bugs that are also reported in the baseline XML output.
      Parameters:
      excludeFile - the exclude file
      Returns:
      this operation
      See Also:
    • excludeBugs

      public File excludeBugs()
      Returns the exclude file used to exclude bugs.
      Returns:
      the exclude file
    • experimental

      public SpotBugsOperation experimental(boolean experimental)
      Report of any confidence level including experimental bug patterns.
      Parameters:
      experimental - set to true to enable, false otherwise
      Returns:
      this operation
    • experimental

      public boolean experimental()
      Returns whether experimental bug patterns are included in the report.
      Returns:
      true if experimental patterns are reported, false otherwise
    • fromProject

      public SpotBugsOperation fromProject(BaseProject project, boolean includeTest)
      Configures a compile operation from a BaseProject.

      Sets the following from the project:

      • analyze to buildMainDirectory
      • auxClasspath to compileMainClasspath
      • output to reports/spotbugs/spotbugs.xml in the buildDirectory
      • projectName to the project name
      • sarif to {@code reports/spotbugs/spotbugs.sarif) in the</li> {@link BaseProject#buildDirectory() buildDirectory}</li> * <li>{@link #sourcePath() sourcePath} to {@link BaseProject#srcMainJavaDirectory() srcMainJavaDirectory} and {@link BaseProject#srcMainResourcesDirectory() srcMainResourceDirectory}</li> <li>{@link #timestampNow() timestampNow} to {@code true}</li> </ul> <p> If {@code includeTest} is enabled, the {@code test} directories are also included. </p> @param project the project to configure the compile operation from @param includeTest set to {@code true} to include test directories, {@code false} otherwise @return this operation instance @see #fromProject(BaseProject)
    • high

      public SpotBugsOperation high(boolean high)
      Report only high-priority bugs.
      Parameters:
      high - set to true to enable, false otherwise
      Returns:
      this operation
    • high

      public boolean high()
      Returns whether only high-priority bugs will be reported.
      Returns:
      true if only high-priority bugs are reported, false otherwise
    • home

      public SpotBugsOperation home(String home)
      Specify SpotBugs home directory.
      Parameters:
      home - the home directory
      Returns:
      this operation
      See Also:
    • home

      public SpotBugsOperation home(File home)
      Specify SpotBugs home directory.
      Parameters:
      home - the home directory
      Returns:
      this operation
      See Also:
    • home

      public SpotBugsOperation home(Path home)
      Specify SpotBugs home directory.
      Parameters:
      home - the home directory
      Returns:
      this operation
      See Also:
    • home

      public Path home()
      Returns the SpotBugs home directory.
      Returns:
      the SpotBugs home path, or null if not set
    • html

      public SpotBugsOperation html(File file)
      Generate HTML output.
      Parameters:
      file - the output file
      Returns:
      this operation
      See Also:
    • html

      public SpotBugsOperation html(Path filePath)
      Generate HTML output.
      Parameters:
      filePath - the output file
      Returns:
      this operation
      See Also:
    • html

      public SpotBugsOperation html(String file)
      Generate HTML output.
      Parameters:
      file - the output file
      Returns:
      this operation
      See Also:
    • html

      public File html()
      Returns the HTML output file.
      Returns:
      the HTML output file
    • html

      public SpotBugsOperation html(String file, String stylesheet)
      Generate HTML output.

      By default, SpotBugs will use the default.xsl XSLT stylesheet to generate the HTML: you can find this file in spotbugs.jar, or in the SpotBugs source or binary distributions. Variants of this option include:

      • plain.xsl
      • fancy.xsl
      • fancy-hist.xsl

      The plain.xsl stylesheet does not use JavaScript or DOM, and may work better with older web browsers, or for printing.

      The fancy.xsl stylesheet uses DOM and JavaScript for navigation and CSS for visual presentation.

      The fancy-hist.xsl an evolution of fancy.xsl stylesheet. It makes extensive use of DOM and JavaScript for dynamically filtering the lists of bugs.

      If you want to specify your own XSLT stylesheet to perform the transformation to HTML, specify the option as myStylesheet.xsl, the filename of the stylesheet you want to use.

      Parameters:
      file - the output file
      stylesheet - the stylesheet to use
      Returns:
      this operation
      See Also:
    • html

      public SpotBugsOperation html(Path filePath, String stylesheet)
      Generate HTML output.

      By default, SpotBugs will use the default.xsl XSLT stylesheet to generate the HTML: you can find this file in spotbugs.jar, or in the SpotBugs source or binary distributions. Variants of this option include:

      • plain.xsl
      • fancy.xsl
      • fancy-hist.xsl

      The plain.xsl stylesheet does not use JavaScript or DOM, and may work better with older web browsers, or for printing.

      The fancy.xsl stylesheet uses DOM and JavaScript for navigation and CSS for visual presentation.

      The fancy-hist.xsl an evolution of fancy.xsl stylesheet. It makes extensive use of DOM and JavaScript for dynamically filtering the lists of bugs.

      If you want to specify your own XSLT stylesheet to perform the transformation to HTML, specify the option as myStylesheet.xsl, the filename of the stylesheet you want to use.

      Parameters:
      filePath - the output file
      stylesheet - the stylesheet to use
      Returns:
      this operation
      See Also:
    • html

      public SpotBugsOperation html(File file, String stylesheet)
      Generate HTML output.

      By default, SpotBugs will use the default.xsl XSLT stylesheet to generate the HTML: you can find this file in spotbugs.jar, or in the SpotBugs source or binary distributions. Variants of this option include:

      • plain.xsl
      • fancy.xsl
      • fancy-hist.xsl

      The plain.xsl stylesheet does not use JavaScript or DOM, and may work better with older web browsers, or for printing.

      The fancy.xsl stylesheet uses DOM and JavaScript for navigation and CSS for visual presentation.

      The fancy-hist.xsl an evolution of fancy.xsl stylesheet. It makes extensive use of DOM and JavaScript for dynamically filtering the lists of bugs.

      If you want to specify your own XSLT stylesheet to perform the transformation to HTML, specify the option as myStylesheet.xsl, the filename of the stylesheet you want to use.

      Parameters:
      file - the output file
      stylesheet - the stylesheet to use
      Returns:
      this operation
      See Also:
    • ignoreFailure

      public SpotBugsOperation ignoreFailure(boolean ignoreFailures)
      Sets the flag to indicate whether failures should be ignored.

      The default is enabled.

      Parameters:
      ignoreFailures - true to enable, false to disable.
      Returns:
      this operation
    • ignoreFailures

      public boolean ignoreFailures()
      Return the ignore failures flag.
      Returns:
      true if enabled, false otherwise
    • include

      public SpotBugsOperation include(String includeFilter)
    • include

      public SpotBugsOperation include(File includeFilter)
      Only report bug instances that match the filter specified by filter file.
      Parameters:
      includeFilter - the filter file
      Returns:
      this operation
      See Also:
    • include

      public SpotBugsOperation include(Path includeFilter)
      Only report bug instances that match the filter specified by filter file.
      Parameters:
      includeFilter - the filter file
      Returns:
      this operation
      See Also:
    • include

      public File include()
      Returns the include filter file.
      Returns:
      the include filter File, or null if none configured
    • includeLineNumber

      public SpotBugsOperation includeLineNumber(boolean includeLineNumber)
      Enable or disable line number in source file URIs.

      While clicking on the URI works in IntelliJ IDEA, Visual Studio Code, etc.; it might not in terminal emulators.

      < Enabled by default.

      Parameters:
      includeLineNumber - true to enable, false otherwise
      Returns:
      this operation
    • includeLineNumber

      public boolean includeLineNumber()
      Returns whether the line number should be included in source file URIs.
      Returns:
      true if the line number should be included, false otherwise
    • jvmArgs

      public SpotBugsOperation jvmArgs(String... args)
      Specifies arguments to pass to the JVM.
      Parameters:
      args - the args to pass to JVM
      Returns:
      this operation
      See Also:
    • jvmArgs

      public SpotBugsOperation jvmArgs(Collection<String> args)
      Specifies arguments to pass to the JVM.
      Parameters:
      args - the args to pass to JVM
      Returns:
      this operation
      See Also:
    • jvmArgs

      public Collection<String> jvmArgs()
      Returns the collection of JVM arguments configured for the SpotBugs run.
      Returns:
      a collection containing JVM arguments
    • longBugCodes

      public SpotBugsOperation longBugCodes(boolean longBugCodes)
      Report long bug codes.
      Parameters:
      longBugCodes - set to true to enable, false otherwise
      Returns:
      this operation
    • longBugCodes

      public boolean longBugCodes()
      Returns whether long bug codes are enabled.
      Returns:
      true if long bug codes will be reported, false otherwise
    • low

      public SpotBugsOperation low(boolean low)
      Report all bugs.
      Parameters:
      low - set to true to enable, false otherwise
      Returns:
      this operation
    • low

      public boolean low()
    • maxHeap

      public SpotBugsOperation maxHeap(int size)
      Specifies the maximum Java heap size in megabytes.

      The default is 256. More memory may be required to analyze very large programs or libraries.

      Parameters:
      size - the maximum heap size in megabytes
      Returns:
      this operation
    • maxHeap

      public int maxHeap()
      Returns the configured maximum Java heap size in megabytes.
      Returns:
      the maximum heap size in megabytes
    • maxRank

      public SpotBugsOperation maxRank(int maxRank)
      Only report issues with a bug rank at least as scary as that provided.
      Parameters:
      maxRank - the maximum rank
      Returns:
      this operation
    • maxRank

      public int maxRank()
      Returns the configured maximum bug rank threshold.
      Returns:
      the maximum rank value
    • medium

      public SpotBugsOperation medium(boolean medium)
      Report medium and high-priority bugs.

      This is the default setting.

      Parameters:
      medium - set to true to enable, false otherwise
      Returns:
      this operation
    • medium

      public boolean medium()
      Returns whether medium-priority bugs are reported.
      Returns:
      true if medium (and higher) priority bugs are reported, false otherwise
    • nested

      public SpotBugsOperation nested(boolean nested)
      This option enables or disables scanning of nested jar and zip files found in the list of files and directories to be analyzed.

      By default, scanning of nested jar/zip files is enabled.

      Parameters:
      nested - set to true to enable, false otherwise
      Returns:
      this operation
    • nested

      public boolean nested()
      Returns whether nested jar/zip scanning is enabled.
      Returns:
      true if nested scanning is enabled, false otherwise
    • noClassOk

      public SpotBugsOperation noClassOk(boolean noClassOk)
      Output an empty warning file if no classes are specified.
      Parameters:
      noClassOk - set to true to enable, false otherwise
      Returns:
      this operation
    • noClassOk

      public boolean noClassOk()
      Returns whether an empty warning file is allowed when no classes are specified.
      Returns:
      true if an empty warning file is allowed, false otherwise
    • omitVisitors

      public SpotBugsOperation omitVisitors(String... visitors)
      Omit named visitors.
      Parameters:
      visitors - the visitors to omit
      Returns:
      this operation
      See Also:
    • omitVisitors

      public SpotBugsOperation omitVisitors(Collection<String> visitors)
      Omit named visitors.
      Parameters:
      visitors - the visitors to omit
      Returns:
      this operation
      See Also:
    • omitVisitors

      public Collection<String> omitVisitors()
      Returns the collection of visitors configured to be omitted.
      Returns:
      a collection containing the visitors to omit
    • onlyAnalyze

      public SpotBugsOperation onlyAnalyze(String... patterns)
      Restrict analysis to find bugs to ist of classes and packages.

      Unlike filtering, this option avoids running analysis on classes and packages that are not explicitly matched: for large projects, this may greatly reduce the amount of time needed to run the analysis. (However, some detectors may produce inaccurate results if they aren’t run on the entire application.)

      Classes should be specified using their full classnames (including package).

      Packages should be specified in the same way they would in a Java import statement to import all classes in the package (i.e., add .* to the full name of the package). Replace .* with .- to also analyze all subpackages.

      Items starting with ! are treated as exclusions, removing otherwise-included classes from analysis.

      Parameters:
      patterns - the patterns to analyze
      Returns:
      this operation
      See Also:
    • onlyAnalyze

      public SpotBugsOperation onlyAnalyze(Collection<String> patterns)
      Restrict analysis to find bugs to ist of classes and packages.

      Unlike filtering, this option avoids running analysis on classes and packages that are not explicitly matched: for large projects, this may greatly reduce the amount of time needed to run the analysis. (However, some detectors may produce inaccurate results if they aren’t run on the entire application.)

      Classes should be specified using their full classnames (including package).

      Packages should be specified in the same way they would in a Java import statement to import all classes in the package (i.e., add .* to the full name of the package). Replace .* with .- to also analyze all subpackages.

      Items starting with ! are treated as exclusions, removing otherwise-included classes from analysis.

      Parameters:
      patterns - the patterns to analyze
      Returns:
      this operation
      See Also:
    • onlyAnalyze

      public Collection<String> onlyAnalyze()
      Returns the collection of analyze-only patterns configured.
      Returns:
      a collection of analyze-only patterns
    • output

      public SpotBugsOperation output(String file)
      Sets the XML bug report file path.

      The default is: spotbugs.xml

      Parameters:
      file - the file path
      Returns:
      this operation
      See Also:
    • output

      public SpotBugsOperation output(File file)
      Sets the XML bug report file path.

      The default is: spotbugs.xml

      Parameters:
      file - the file path
      Returns:
      this operation
      See Also:
    • output

      public SpotBugsOperation output(Path filePath)
      Sets the XML bug report file path.

      The default is: spotbugs.xml

      Parameters:
      filePath - the file path
      Returns:
      this operation
      See Also:
    • output

      public File output()
      Returns the configured XML bug report output file.
      Returns:
      the output File
    • pluginList

      public SpotBugsOperation pluginList(String... plugins)
      Specify a list of plugin Jar files to load.
      Parameters:
      plugins - the plugin list
      Returns:
      this operation
      See Also:
    • pluginList

      public SpotBugsOperation pluginList(Collection<String> plugins)
      Specify a list of plugin Jar files to load.
      Parameters:
      plugins - the plugin list
      Returns:
      this operation
      See Also:
    • pluginList

      public Collection<String> pluginList()
      Returns the collection of plugin jar files to load.
      Returns:
      a collection containing the plugin jar files
    • progress

      public SpotBugsOperation progress(boolean progress)
      Display progress in the terminal window.
      Parameters:
      progress - set to true to enable, false otherwise
      Returns:
      this operation
    • progress

      public boolean progress()
      Retrieves the current progress setting.
      Returns:
      true if progress display is enabled, false otherwise
    • projectName

      public SpotBugsOperation projectName(String name)
      Descriptive name of the project.
      Parameters:
      name - the project name
      Returns:
      this operation
    • projectName

      public String projectName()
      Returns the configured descriptive project name.
      Returns:
      the project name, or null if not configured
    • relaxed

      public SpotBugsOperation relaxed(boolean relaxed)
      Relaxed reporting mode.

      For many detectors, this option suppresses the heuristics used to avoid reporting false positives.

      Parameters:
      relaxed - set to true to enable, false otherwise
      Returns:
      this operation
    • relaxed

      public boolean relaxed()
      Returns whether relaxed reporting mode is enabled.
      Returns:
      true if relaxed mode is enabled, false otherwise
    • release

      public SpotBugsOperation release(String release)
      Set the release name of the analyzed application.
      Parameters:
      release - the release name
      Returns:
      this operation
    • release

      public String release()
      Returns the configured release name for the analyzed application.
      Returns:
      the release name, or null if not set
    • sarif

      public SpotBugsOperation sarif(File file)
      Produce the bug reports in SARIF 2.1.0.
      Parameters:
      file - the output file
      Returns:
      this operation
      See Also:
    • sarif

      public SpotBugsOperation sarif(String file)
      Produce the bug reports in SARIF 2.1.0.
      Parameters:
      file - the output file
      Returns:
      this operation
      See Also:
    • sarif

      public SpotBugsOperation sarif(Path filePath)
      Produce the bug reports in SARIF 2.1.0.
      Parameters:
      filePath - the output file
      Returns:
      this operation
      See Also:
    • sarif

      public File sarif()
      Returns the SARIF bug reports file.
      Returns:
      the bug reports file
    • sortByClass

      public boolean sortByClass()
      Returns whether bug instances will be sorted by class name.
      Returns:
      true if enabled, false otherwise
    • sortByClass

      public SpotBugsOperation sortByClass(boolean sortByClass)
      Sort reported bug instances by class name.
      Parameters:
      sortByClass - set to true to enable, false otherwise
      Returns:
      this operation
    • sourceInfo

      public SpotBugsOperation sourceInfo(String sourceInfo)
      Specify the source info file (line numbers for fields/classes)
      Parameters:
      sourceInfo - the source info file
      Returns:
      this operation
      See Also:
    • sourceInfo

      public SpotBugsOperation sourceInfo(File sourceInfo)
      Specify the source info file (line numbers for fields/classes)
      Parameters:
      sourceInfo - the source info file
      Returns:
      this operation
      See Also:
    • sourceInfo

      public SpotBugsOperation sourceInfo(Path sourceInfo)
      Specify the source info file (line numbers for fields/classes)
      Parameters:
      sourceInfo - the source info file
      Returns:
      this operation
      See Also:
    • sourceInfo

      public File sourceInfo()
      Returns the source info file containing line numbers for fields/classes.
      Returns:
      the source info file
    • sourcePath

      public SpotBugsOperation sourcePath(String... path)
      Set the source path for analyzed classes.
      Parameters:
      path - the source path
      Returns:
      this operation
      See Also:
    • sourcePath

      public SpotBugsOperation sourcePath(Path... path)
      Set the source path for analyzed classes. * @see #sourcePathPaths(Collection)
      Parameters:
      path - the source path
      Returns:
      this operation
      See Also:
    • sourcePath

      public SpotBugsOperation sourcePath(File... path)
      Set the source path for analyzed classes.
      Parameters:
      path - the source path
      Returns:
      this operation
      See Also:
    • sourcePath

      public Collection<String> sourcePath()
      Returns the source path for analyzed classes.
      Returns:
      a collection containing the source paths
    • sourcePath

      public SpotBugsOperation sourcePath(Collection<?> path)
      Set the source path for analyzed classes.
      Parameters:
      path - the source path
      Returns:
      this operation
      See Also:
    • spotBugsJar

      public File spotBugsJar()
      Returns the SpotBugs jar file.
      Returns:
      the SpotBugs jar file
    • spotBugsJar

      public SpotBugsOperation spotBugsJar(String jar)
      Sets the SpotBugs jar file.
      Parameters:
      jar - the SpotBugs jar file
      Returns:
      this operation
      See Also:
    • spotBugsJar

      public SpotBugsOperation spotBugsJar(Path jarPath)
      Sets the SpotBugs jar file.
      Parameters:
      jarPath - the SpotBugs jar file
      Returns:
      this operation
      See Also:
    • spotBugsJar

      public SpotBugsOperation spotBugsJar(File jar)
      Sets the SpotBugs jar file.
      Parameters:
      jar - the SpotBugs jar file
      Returns:
      this operation
      See Also:
    • timestampNow

      public SpotBugsOperation timestampNow(boolean timeStampNow)
      Set the timestamp of results to be the current time.
      Parameters:
      timeStampNow - set to true to enable, false otherwise
      Returns:
      this operation
    • timestampNow

      public boolean timestampNow()
      Returns whether the timestamp of results will be set to the current time.
      Returns:
      true if timestampNow is enabled, false otherwise
    • visitors

      public SpotBugsOperation visitors(String... visitors)
      Run only named visitors.
      Parameters:
      visitors - the visitors to run
      Returns:
      this operation
      See Also:
    • visitors

      public SpotBugsOperation visitors(Collection<String> visitors)
      Run only named visitors.
      Parameters:
      visitors - the visitors to run
      Returns:
      this operation
      See Also:
    • visitors

      public Collection<String> visitors()
      Returns the collection of named visitors to run.
      Returns:
      a collection containing the visitors
    • workHard

      public SpotBugsOperation workHard(boolean workHard)
      Ensure analysis effort is at least Effort.DEFAULT.
      Parameters:
      workHard - set to true to enable, false otherwise
      Returns:
      this operation
    • workHard

      public boolean workHard()
      Returns whether analysis effort should be at least Effort.DEFAULT.
      Returns:
      true if enabled, false otherwise