Skip to content

Provide a way to enable auto-fixing of lints with MaybeIncorrect applicability #11158

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
Veetaha opened this issue Jul 14, 2023 · 1 comment

Comments

@Veetaha
Copy link

Veetaha commented Jul 14, 2023

I have an enormous codebase, where I would like to apply the unnecessary-wraps lint, which has MaybeIncorrect applicability. The problem is that there are so many errors reported with this lint that it will take me several hours of work to just manually go over each one and apply them manually.

What is most disappointing is that clippy already knows how to fix that code, because it shows me the correct fixes in its output, and my human task becomes to mechanically copy-paste the suggestions from clippy. I'd prefer much more to have an option to include MaybeIncorrect lint into cargo clippy --fix for example something like:

cargo clippy --fix --allow-maybe-incorrect

I agree, that MaybeIncorrect may break code, but what if 99% of the fixes they do are, in fact, correct? It will be much more productive if I let cargo clippy apply MaybeIncorrect lints, then check for compile errors, fix them manually, and review the git diff manually as the last step to cover all changes that were made as the double-check. This switches the work for the human from manually applying each-and-every lint to basically reviewing the work of clippy (as if clippy was my own clever-but-sometimes-dumb junior developer).

In simple words, it's faster to fix all the wrong changes that MaybeIncorrect lint did than manually fix everything that it reports.

@Alexendoo
Copy link
Member

See also rust-lang/cargo#13028

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants