#cargo #clippy

app cargo-cranky

Easy to configure wrapper for clippy

4 releases (2 breaking)

0.3.0 Jul 8, 2022
0.2.0 Jul 7, 2022
0.1.1 Jul 6, 2022
0.1.0 Jul 6, 2022

#198 in Cargo plugins

Download history 67/week @ 2022-12-01 71/week @ 2022-12-08 54/week @ 2022-12-15 22/week @ 2022-12-22 45/week @ 2022-12-29 73/week @ 2023-01-05 118/week @ 2023-01-12 163/week @ 2023-01-19 102/week @ 2023-01-26 59/week @ 2023-02-02 110/week @ 2023-02-09 92/week @ 2023-02-16 121/week @ 2023-02-23 85/week @ 2023-03-02 93/week @ 2023-03-09 104/week @ 2023-03-16

414 downloads per month


181 lines


I wish that I could check in a file that would specify Rust lints for my entire Cargo workspace, and have that be applied to all the crates, libraries, binaries, and examples.

Doing this with just Rust/Cargo/Clippy can be a bit of a pain. cargo-cranky makes it a little easier!

cargo-cranky is just a wrapper around cargo clippy; it examines your Cranky.toml config file, and constructs the necessary cargo clippy command line. Most arguments are passed through to clippy, so it should work from every context where clippy works (IDEs, CI scripts, etc).

For example, if Cranky.toml contains this:

warn = [

and I run cargo cranky, I get those extra lints:

warning: found empty brackets on struct declaration
  --> src/main.rs:11:12
11 | struct Unit {}
   |            ^^^
warning: casting `u64` to `u8` may truncate the value
  --> src/main.rs:23:9
23 |         x as u8

This is exactly the same as manually running cargo clippy with the extra parameters --warn clippy::empty_structs_with_brackets and --warn clippy::cast_possible_truncation.

You may find some useful clippy lints for your project in the clippy documentation. I recommend browsing the "pedantic" and "restriction" groups.


cargo install cargo-cranky


Create a file called Cranky.toml at the top of your project tree. The file can contain keys allow, warn, or deny that contain an array of clippy lint names.


deny = [
  # My crate should never need unsafe code.

warn = [

allow = [

Note: in the case of overlap, allow will always override warn, which in turn will always override deny. The order of these fields in Cranky.toml has no effect.


Can I specify non-clippy lints?

Yes! Try for example unsafe_code or missing_docs.

Note: Clippy lints should be specified using the long syntax, e.g. clippy::some_lint_name. Clippy will issue a warning if the prefix is missing.

Does it work with vscode?

Yes! Just type cranky into the "Check On Save: Command" setting, or drop this into settings.json:

    "rust-analyzer.checkOnSave.command": "cranky"

Set it back to "check" (or "clippy") to return to the previous behavior.

Is this reckless or non-idiomatic?

That depends on how you use it. If your goal is to enforce a non-idiomatic coding style, that's probably not a great idea.

If you want to suppress lints that are enabled by default, it's probably better to do that using the #[allow(clippy::some_lint)] syntax in the source file, since that gives you a chance to add a comment explaining your reasoning.

The main goal of this tool is to make it easier to enable additional clippy lints, that improve code maintainability or safety (i.e. clippy::cast_possible_truncation).

I have complaints suggestions!

Please file a GitHub issue if you have ideas that could make this tool better.


~37K SLoC