Skip to content

clippy GitHub last commit

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 name
Use 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 101 Docker Image Size (tag) Docker Pulls
rust Optimized for RUST based projects 43 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

  • 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

Rust's package manager

USAGE:
    cargo [+toolchain] [OPTIONS] [SUBCOMMAND]

OPTIONS:
    -V, --version               Print version info and exit
        --list                  List installed commands
        --explain <CODE>        Run `rustc --explain CODE`
    -v, --verbose               Use verbose output (-vv very verbose/build.rs output)
    -q, --quiet                 Do not print cargo log messages
        --color <WHEN>          Coloring: auto, always, never
        --frozen                Require Cargo.lock and cache are up to date
        --locked                Require Cargo.lock is up to date
        --offline               Run without accessing the network
        --config <KEY=VALUE>    Override a configuration value (unstable)
    -Z <FLAG>                   Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for
                                details
    -h, --help                  Print help information

Some common cargo commands are (see all commands with --list):
    build, b    Compile the current package
    check, c    Analyze the current package and report errors, but don't build object files
    clean       Remove the target directory
    doc, d      Build this package's and its dependencies' documentation
    new         Create a new cargo package
    init        Create a new cargo package in an existing directory
    add         Add dependencies to a manifest file
    run, r      Run a binary or example of the local package
    test, t     Run the tests
    bench       Run the benchmarks
    update      Update dependencies listed in Cargo.lock
    search      Search registry for crates
    publish     Package and upload this package to the registry
    install     Install a Rust binary. Default location is $HOME/.cargo/bin
    uninstall   Uninstall a Rust binary

See 'cargo help <command>' for more information on a specific command.

Installation on mega-linter Docker image

  • Dockerfile commands :
# Parent descriptor install
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Linter install
RUN rustup component add clippy