Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nyurik opened this issue Nov 4, 2022 · 0 comments
Open

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

nyurik opened this issue Nov 4, 2022 · 0 comments
Labels
C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise.

Comments

@nyurik
Copy link
Contributor

nyurik commented Nov 4, 2022

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
@flip1995 flip1995 added the C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise. label Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise.
Projects
None yet
Development

No branches or pull requests

2 participants