clippy
clippy documentation
- Version in MegaLinter: 0.1.69
- Visit Official Web Site
- See How to configure clippy rules
- See How to disable clippy rules in files
- See Index of problems detected by clippy
Configuration in MegaLinter
- Enable clippy by adding
RUST_CLIPPY
in ENABLE_LINTERS variable - Disable clippy by adding
RUST_CLIPPY
in DISABLE_LINTERS variable
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 filesEx: [".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 |
RUST_CLIPPY_CLI_EXECUTABLE | Override CLI executable | ['cargo-clippy'] |
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 | 113 | ||
cupcake | MegaLinter for the most commonly used languages | 81 | ||
rust | Optimized for RUST based projects | 47 |
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
doesn't 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, e.g.:
#[allow(clippy::needless_lifetimes)]