6.2.11.2. ImportClippy

Run Clippy and import its results

Runs Clippy on a cargo-based Rust project and imports its lints as analysis violations.

Each violation uses the provider option's value, clippy by default (forwarded rustc diagnostics always use rustc). Secondary spans become secondary locations, and clippy lints get their documentation URL attached as extra info. By default, this documentation is fetched for each clippy lint via cargo clippy --explain <lint>; turn this off by setting explain to false. Set config_file (and, if needed, cwd) to run Clippy against a crate in a sub-directory.

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 = False

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.

 

config_file

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

Path to the crate's Cargo.toml, relative to cwd. When set it is passed to clippy as --manifest-path, and -- because clippy reports file names relative to the manifest directory -- imported violations are relocated to be relative to cwd (the project directory). Leave unset when clippy is run from the crate root and its paths are already project-relative.
 

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.
 

executable

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

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

explain

explain : bool = True

Whether to fetch and import Clippy lint documentation using ``cargo clippy --explain``.
 

Option Types

These types are used by options listed above:

EncodingErrorHandler

  • STRICT

  • IGNORE

  • REPLACE