rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.31k stars 1.62k forks source link

FR: Option that automatically applies clippy fix's #10216

Open Milo123459 opened 3 years ago

Milo123459 commented 3 years ago

Hello! Rust-analyzer is great, and just thought that maybe if there was a clippy fix available, a little pop-up could show up in the bottom right, just asking if you want to apply the clippy fixes. This'll run clippy --all-targets --all-features --fix as well as cargo fix. If there are staged files, what should happen is a backup should be created temporarily, then once changes are applied, it'll ask if you want to go back to using the old version. The backup could be stored in the target directory.

lnicola commented 3 years ago

If there are staged files, what should happen is a backup should be created temporarily, then once changes are applied, it'll ask if you want to go back to using the old version. The backup could be stored in the target directory.

This is out of scope. git isn't the only VCS out there.

Milo123459 commented 3 years ago

If there are staged files, what should happen is a backup should be created temporarily, then once changes are applied, it'll ask if you want to go back to using the old version. The backup could be stored in the target directory.

This is out of scope. git isn't the only VCS out there.

I'm not sure how I forgot about git 😆

But yea, that'd work better. Open to feedback.

lnicola commented 3 years ago

And generally I'd advise against applying all clippy fixes at once. It still has a lot of false positives. My workflow has generally been to enable and fix one category of lints at a time.

Milo123459 commented 3 years ago

And generally I'd advise against applying all clippy fixes at once. It still has a lot of false positives. My workflow has generally been to enable and fix one category of lints at a time.

With the addition of clippy fix, I had a bunch of warnings, (was nightly, --fix didn't work) and I had to apply everything by default. I just think it might be a nice option to have. Yes, I do understand doing it one at a time, but clippy is only getting better / smarter so it might be good to implement something. Or, wait until the false positives on clippy has a tiny percentage of happening, not as much as it does now.