6.2.11.12. ImportSpotBugs

Run SpotBugs and import its results

Runs SpotBugs and imports its bug instances as analysis violations.

SpotBugs is invoked with -textui -sarif; each result of its SARIF report becomes a violation with the provider option's value, spotbugs by default, and the bug type as its error number. Use additional_args for the analyzed class files and set cwd for your project.

Set source_directories so that bugs are reported at their source files, which the analysis's include and exclude patterns then apply to.

Possible Messages

This rule has no predefined messages.

Options

additional_args

additional_args : list[str] = []

Additional arguments for the tool. They are passed on unquoted and unfiltered.
 

check_returncode

check_returncode : bool = True

Whether a non-zero exit status of the tool fails the rule. Turn it off for tools that report findings through their exit status, as many linters do.

Independent of this option, a run that imports no violations while the tool exits non-zero fails: its results are indistinguishable from a run in which the tool found nothing.

 

cwd

cwd : bauhaus.analysis.config.LayerRelativePath | None = None

Optional execution directory for the command.
 

encoding

encoding : str = 'utf-8'

The encoding of the output of the executed command. See also encoding_error_handler.
 

encoding_error_handler

encoding_error_handler

Type: EncodingErrorHandler

Default: 'IGNORE'

The strategy to handle encoding errors during processing of the output of the executed command.

  • STRICT: abort with on error on encoding errors,
  • IGNORE: ignore encoding errors (accepting data loss),
  • REPLACE: replace problematic code points with a question mark (?).
 

environment

environment : dict[str, str] = {}

Additional environment variables for the command. These entries are added to the inherited environment; existing entries are overwritten.
 

exclude_filter

exclude_filter : bauhaus.analysis.config.PlainPath | None = None

SpotBugs filter file, relative to cwd, selecting the bugs not to report. It is passed as -exclude.
 

executable

executable : bauhaus.analysis.config.PlainPath | None = None

Path to the tool's executable. Unset, the tool is looked up on PATH.
 

include_filter

include_filter : bauhaus.analysis.config.PlainPath | None = None

SpotBugs filter file, relative to cwd, selecting the bugs to report. It is passed as -include.
 

source_directories

source_directories : list[bauhaus.analysis.config.PlainPath] = []

Source directories of the analyzed classes, relative to cwd. The current working directory is always implicitly included in the list. They are passed as -sourcepath and used to map the reported bugs to source files.
 

Option Types

These types are used by options listed above:

EncodingErrorHandler

  • STRICT

  • IGNORE

  • REPLACE