Skip to content

[Clippy command line] Add ignore flag (e.g., for directories or crate names). #10957

@JoshLind

Description

@JoshLind

Description

Hi 😄

I may be missing how to do this already (so please correct me if there's a way!), but I'd love it if the cargo clippy command provided support for an ignore or exclude flag that would allow clippy to ignore directories and/or crates when running.

The use case is that we currently use clippy at Aptos (https://github.com/aptos-labs/aptos-core/blob/main/.cargo/config.toml#L2), but due to security reasons, we directly import third party rust code into our repository from upstream, e.g., see here: https://github.com/aptos-labs/aptos-core/tree/main/third_party. Now, generally we don't modify this code, but occasionally we do, hence the need to import it directly (as opposed to just using regular rust deps). Because this code is part of our workspace, cargo clippy --workspace ... will run clippy on these files, which is less than ideal because we only really want to change this code if we absolutely have to. Likewise, ensuring that the upstream is up-to-date with the same clippy/rust version is also not a great option (because it blocks our development).

In the ideal case, we'd be able to do something like cargo clippy --workspace --ignore third_party/*, which would run clippy on all workspace packages except those identified by the ignore flag. Is this possible to do?*

Thanks so much for your help! 😃

*I know it's probably possible to do this by removing the --workspace flag and instead listing all packages that we want clippy to operate on, but we have such a large number of packages that things would become messy quickly. Ideally, we could avoid this.

Version

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: aarch64-apple-darwin
release: 1.70.0
LLVM version: 16.0.2

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-uiArea: Clippy interface, usage and configurationC-feature-requestCategory: Feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions