-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add an easy way to run clippy with high FPR / trivial lints disabled #5537
Comments
Implementation wise, this would be really easy to do: Add a lint group The hard/tedious thing would be to build this group. Someone would have to handpick the lints for this group. I would suggest some heuristic for this like auto-applicability, number of open issues with FPs, ... |
I feel like the need of a I think ideally, all the changes suggested by default should make sense in ~95% of the case, warnings that can be argued about should be moved to |
After sleeping about this, I'm also against introducing a TL;DR: This would involve too much bikeshedding, and personal opinion which lints should be included.
For this dtolnay opened #5418, where he already moved multiple lints.
After reading @matklad comment on the rust-analyzer/rowan PR, it is not about that the suggestion doesn't make sense, but that the suggested code doesn't improve something directly, so the change is in his opinion a bigger downside than having stylistic slightly worse code. (That's how I understood his comment, expressed in a very condensed way). As I commented in rust-analyzer/rowan#57 (comment), I think that for lints that doesn't directly improve code, the lint groups Now disabling And now we're at the bikeshedding point. Why should This is where I think the existing groups give a really good classification. You want Clippy to get you to write more correct code, but don't want to change code style? Allow What I could see as an improvement would be to subdivide the pedantic group more. So we have a |
I feel they both should be in the conservative set of lints, as they both strictly improve the code along more dimensions. I don't mind |
I would rather move lints to allow-by-default, if they are too noisy, than introducing a new subgroup of The philosophy of Clippy is (from the |
Yup, this a totally fine philosophy, and I think a good default. However for me personally, explicitly allowing lints and/or explicitely configuring linter is a big red flag, in the context of Rust, where compiler already handles most important lints. So clippy's philosophy and my philosophy are directly in conflict. At the moment, I solve this by not using clippy. I see |
This reminds me of a comment I made.
The lint categories are an effective solution for allowing the user to configure what they want to be linted. What we are missing is a way to configure how confident clippy must be when it lints. To solve this, each lint would need to be assigned a confidence level in addition to its category. Probably just a boolean that means "I might be a false positive". For example, this flag would make sense for
@matklad I assume you are talking about line-level configuration. You would be okay with configuring clippy at the project level, perhaps disabling a handful of lints, right? I suspect there will be some cases where the lint is confident, but you just don't care for the stylistic preference being asserted. |
I’d be semi fine. I probably wouldn’t add a clippy config (even if it is small) to every project, but I can imagine this working for Rust-analyzer, if that’s easy to do, and if only a handful of lints needs to be disabled. We actually have something like this in ra already: https://github.com/rust-analyzer/rust-analyzer/blob/20a911f3cc2beb0409ab71cc1560648374745f7f/xtask/src/lib.rs#L73 we don’t run this code on CI though, as it never was tweaked to silence all false positives. |
10440: Fix Clippy warnings and replace some `if let`s with `match` r=Veykril a=arzg I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both [rust-lang/clippy#5537](rust-lang/rust-clippy#5537) and [rust-analyzer/rowan#57 (comment)](rust-analyzer/rowan#57 (comment))), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and `if let` vs `match` commits provide comparatively little benefit when compared to the ensuing churn. I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely. Sidenote: I should really have asked about this on Zulip before going through all 1,555 `if let`s in the codebase to decide which ones definitely look better as `match` :P Co-authored-by: Aramis Razzaghipour <[email protected]>
isn't this just applicability? |
Not quite. Applicability is for the suggestion, not the lint triggering. But we could also use it as a heuristic for a confidence level. But the issue here is mostly that applicability is not fine grained enough. There's a rustc issue about improving this. I.e.
If we could separate this with applicability we could just filter out the 1. variant. |
Hi!
It often happens that users submit a "make clippy happier" PR to one of my projects. These PRs often contain quite a bunch of changes, of which a couple are undeniably great, but majority just shuffle code around. An example of good change would be a removal of (now useless)
.into()
or.clone()
. A typical example of not really good change is.unwrap_or(xs.len()) -> .unwrap_or_else(|| xs.len())
.I've written at some length about this here: rust-analyzer/rowan#57 (comment).
I would really love the ability to run
cargo clippy --conservative
, and only get lints about the code which can be unambiguously improved across all dimensions. (that is, those lints that we probably want to lift eventually into the compiler).I know that lint categories exists, but:
The text was updated successfully, but these errors were encountered: