-
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
Better testing of clippy lints before enabling them by default #6429
Comments
I see it the way that there is no better way to test a lint than releasing it into the wild :) |
Those lints made it to stable. Don't know why they weren't caught earlier, but to me having a codebase light up with false positives is a problem. |
Like @matthiaskrgr comments, interaction from the community has worked acceptably for Clippy. Getting lints right is hard and we need people to try them and report the problems. That being said, I think this workflow has a negative impact on Clippy.
Ideally, if Clippy had the correct amount of people and resources, I think warn/deny-by-default lints would benefit from a stabilization process similar to the feature gates for lang/lib features.
I'm not sure if we want/can implement that process or something similar currently due to the aforementioned lack of resources, but I personally agree that this is something we should think about. |
It may accumulate to a lot of effort if the lint gets recursively disabled in ci's, because for example a library uses |
Yeah, we definitely need to improve the process somehow. This is something I have in mind for Clippy for 2021. On the one hand usability and on the other getting more people for maintaining/triaging. A process like the one @ebroto suggested above might actually make sense. I think one problem is, that fewer people use nightly every year. Which speaks for the Rust language and ecosystem, but makes the process of "just putting a lint out there with 2-4 weeks in nightly and hoping enough people complain" harder and harder. Spoiler: general governance, recruiting and allocating resources across the Rust ecosystem is also on the radar of the core team and the Rust foundation. So I'm positive we'll improve the situation of Clippy during 2021. Trying to start with this process now with Covid still raging in most countries and the holidays coming won't make much sense though. |
At cppcheck (static analysis for c/c++) we had something called "daca" which was essentially a big loop of downloading a package source from the debian archives, running cppcheck on it and saving the results in one big file (a bit like rusts crater). I made a script that would download these cppcheck-logs so I could diff them and see if there were suddenly lint warnings appearing/disappearing. Later Daniel wrote daca2 where anyone could launch a "checking" client which would pull cppcheck from source, build it, fetch a source package from the queue and send back the results to a central server, so multiple people could "donate" cpu power to the project Some time ago I spent a bit of time trying to make something like a run-clippy-on-crates-and-diff-the-stdout program but I don't remember what its state is. It seems to extract one line for each clippy warning
and print a summary at the end
If I put the logs into a git repo and run it every day (I assume this could be run on github actions) this could already provide a bit of an insight in what kind of warnings are occurring in common crates. |
I really like the idea of having new lints to be nightly only by default, we could then observe the amount of false positives we get and then explicitly "release" lints on beta which then ride up to stable. To spot false positives early, we could also consider having something like our current integration tests on gha inside the our repo. |
Rust already has |
It might be possible to have a clippy-specific "nightly" process: completely independently of rustc nightlies, advanced users could enable "unstable = true` in some clippy.toml and that would enable beleeding-edge lints. That way even people who use rustc stable can provide feedback on new lints, with a longer testing period if we want. |
This sounds a bit like the current |
Yes, that would be a What I want to achieve here would be a system where you don't have to change any configuration between This might be harder to implement in Clippy, but makes it easier to run |
I'm not sure if this has come up before, but would it be possible to have lint warnings collected but not shown except as summary? Instead of new lints generating noise, there could be a phase where you run clippy and get a line like I'm just wondering if something like this could work as a middle ground for the wider community that is both transparent and non-disruptive. |
add "cargo dev crater" to run clippy on a fixed set of crates and diff the lint warnings `cargo dev crater` now does the following: build clippy in debug mode for a fixed set of crates: download and extract the crate run compiled clippy on the crate dump the warnings into a file that is inside the repo We can then do a "git diff" and see what effects our clippy changes had on a tiny fraction of the rust ecosystem and can see when an change unexpectedly added or silenced a lot of warnings. Checking all the crates took less than 5 minutes on my system. Should help with #6429 --- *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: extend cargo dev to run clippy against a fixed set of crates and compare warnings
An idea: what if lints that are less than one stable release old had a specific note that said “lintnamehere is a new Clippy lint and may have bugs; if this warning seems dubious, please let us know: ...”? Of course, not very many people will read all the details. But some will, and that might be enough to get feedback from more nightly users. |
This suggestion sounds in line with our idea to have lints be only on nightly for one or two releases #6623 |
A small clarification: I don't mean just testing longer in nightly, but also that lints that are newly in stable should also have this note (for one stable release), so that the audience of only-stable users gets the information too. |
Ahh okay, I'm not sure if that wouldn't create too much noise in the lint output. It could be something, which is only printed on the first lint trigger or something similar to reduce the text per lint emission. |
needless-collect
andmutable-key-type
are two recent examples or buggy lints. (By buggy I mean a large number of false positives)The text was updated successfully, but these errors were encountered: