Skip to content

Add modes of operation to customize all enabled lints at once #9787

Open
@nyurik

Description

@nyurik

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 like format!("{}", foo) → format!("{foo}") by default, but will only inline mixed cases format!("{}:{}", foo, bar.baz()) → format!("{foo}:{}", bar.bas()) in the pedantic mode.
  • ... TBD

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-an-interesting-projectCategory: Interesting projects, that usually are more involved design/code wise.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions