rust-lang / rust-lang/rust-clippy
Add modes of operation to customize all enabled lints at once
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Problem Description
Most Clippy users think of linting in two ways: check for the common issues (default), and check for the less agreed on or controversial issues (pedantic/perf/...). Clippy represents those usage patterns as multiple sets of lints, where each lint belongs to just one category, i.e. style and pedantic.
The problem is that some lints are not so clear-cut. They have additional configuration to make them more or less strict. Yet we must still decide which category they belong to -- either style with just a few checks, or pedantic with a lot of checks, but not commonly used by the majority of users.
Moreover, adding lint configuration requires that each Clippy user has to switch to a different mental model - instead of the "default" vs "pedantic", they must start reading documentation on each lint and configuring those lints, plus monitor for any changes between Clippy versions. Obviously most users ignore this to use the default configuration, which significantly impacts discoverability of additional functionality.
Proposal
I would like to propose a new "intention" (or mode) Clippy concept, e.g. a mutually exclusive command line argument (--default | --pedantic | ...). Using the --pedantic argument would automatically set -W clippy::pedantic, but it would also allow the other enabled lints to use the pedantic configuration. The users will be able to easily switch between the two modes, will help with discoverability, and also allow Clippy to have a more flexible lint categorization.
Examples
For example, --pedantic could enable the following lints to act differently:
clippy::uninlined_format_args- inline simple cases likeformat!("{}", foo) → format!("{foo}")by default, but will only inline mixed casesformat!("{}:{}", foo, bar.baz()) → format!("{foo}:{}", bar.bas())in the pedantic mode.- ... TBD
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing Clippy's existing lint categories, per-lint configuration, and command-line behavior against the proposed mutually exclusive modes. Identify how the default and pedantic modes should affect both enabled lint groups and configurable checks. Done means the mode behavior and its interaction with existing lint configuration are specified clearly enough to implement and validate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100