Skip to content
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

CLIPPY_FLAGS to pass options to clippy/ enable disable lints via env vars #5214

Closed
matthiaskrgr opened this issue Feb 21, 2020 · 5 comments · Fixed by #6441
Closed

CLIPPY_FLAGS to pass options to clippy/ enable disable lints via env vars #5214

matthiaskrgr opened this issue Feb 21, 2020 · 5 comments · Fixed by #6441
Labels
S-needs-discussion Status: Needs further discussion before merging or work can be started

Comments

@matthiaskrgr
Copy link
Member

Right now, there is no way to globally enable/disable clippy lints on a system.
If we want to disable certain lint, we have to either modify the code and add #[allow(clippy::foo)] which is tedious, or we have to add -- -Aclippy::foo to EVERY clippy invocation which is also tedious and not always easily done, especially if clippy is invoked by another tool.

IMO the biggest problem is that we cannot use RUSTFLAGS for some reason:
RUSTFLAGS="-Aclippy::needless_return" cargo clippy will just throw errors:

error[E0602]: unknown lint: `clippy::needless_return`
  |
  = note: requested on the command line with `-A clippy::needless_return`

I would love to have something like
export CLIPPY_FLAGS="-A collapsible_if that I just throw into my zshrc and stop worrying about that lint forever.

@matthiaskrgr matthiaskrgr added the S-needs-discussion Status: Needs further discussion before merging or work can be started label Feb 21, 2020
@Manishearth
Copy link
Member

I'd say we should wait for rust-lang/cargo#7533 first

@ebroto
Copy link
Member

ebroto commented Oct 15, 2020

I can't reproduce the RUSTFLAGS problem anymore. Could you test it @matthiaskrgr?

This would be great news as it could help to solve the problem when Clippy does not re-run if flags passed after -- change.

@matthiaskrgr
Copy link
Member Author

Yeah, looks like RUSTFLAGS="-Aclippy::needless_return" cargo clippy no longer throws errors! 🎉

@flip1995
Copy link
Member

Can we close this issue now that RUSTFLAGS works? Or should we document this somewhere first?

@ebroto
Copy link
Member

ebroto commented Oct 17, 2020

I'm preparing a PR for the "no re-run" problem and I hit that error in the dogfood. I still have to debug it, could be a misuse on my side, but in the meantime I would keep this open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-discussion Status: Needs further discussion before merging or work can be started
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants