Skip to content

clippy

GitHub stars GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

clippy documentation

rust-clippy - GitHub

Configuration in MegaLinter

Variable Description Default value
RUST_CLIPPY_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
RUST_CLIPPY_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".rs"]
RUST_CLIPPY_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
RUST_CLIPPY_PRE_COMMANDS List of bash commands to run before the linter None
RUST_CLIPPY_POST_COMMANDS List of bash commands to run after the linter None
RUST_CLIPPY_CONFIG_FILE clippy configuration file nameUse LINTER_DEFAULT to let the linter find it .clippy.toml
RUST_CLIPPY_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
RUST_CLIPPY_DISABLE_ERRORS Run linter but consider errors as warnings false
RUST_CLIPPY_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0

IDE Integration

Use clippy in your favorite IDE to catch errors before MegaLinter !

IDE Extension Name Install
Atom Atom IDE Rest Visit Web Site

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 114 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 82 Docker Image Size (tag) Docker Pulls
rust Optimized for RUST based projects 48 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .rs

How the linting is performed

clippy is called once on the whole project directory (project CLI lint mode)

  • filtering can not be done using MegaLinter configuration variables,it must be done using clippy configuration or ignore file (if existing)
  • VALIDATE_ALL_CODEBASE: false does not make clippy analyze only updated files

Example calls

cargo-clippy

Help content

Checks a package to catch common mistakes and improve your Rust code.

Usage:
    cargo clippy [options] [--] [<opts>...]

Common options:
    --no-deps                Run Clippy only on the given crate, without linting the dependencies
    --fix                    Automatically apply lint suggestions. This flag implies `--no-deps`
    -h, --help               Print this message
    -V, --version            Print version info and exit
    --explain LINT           Print the documentation for a given lint

Other options are the same as `cargo check`.

To allow or deny a lint from the command line you can use `cargo clippy --`
with:

    -W --warn OPT       Set lint warnings
    -A --allow OPT      Set lint allowed
    -D --deny OPT       Set lint denied
    -F --forbid OPT     Set lint forbidden

You can use tool lints to allow or deny lints from your code, eg.:

    #[allow(clippy::needless_lifetimes)]

Installation on mega-linter Docker image