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

add "cargo dev crater" to run clippy on a fixed set of crates and diff the lint warnings #6469

Merged
merged 29 commits into from
Jan 26, 2021

Conversation

matthiaskrgr
Copy link
Member

@matthiaskrgr matthiaskrgr commented Dec 18, 2020

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

@rust-highfive
Copy link

r? @Manishearth

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 18, 2020
@matthiaskrgr matthiaskrgr added the S-needs-discussion Status: Needs further discussion before merging or work can be started label Dec 18, 2020
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some ideas how to expand this.

clippy_dev/src/crater.rs Outdated Show resolved Hide resolved
clippy_dev/src/crater.rs Outdated Show resolved Hide resolved
"--message-format=short",
"--",
"--cap-lints=warn",
"-Wclippy::pedantic",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be nice if we can specify the lint groups with a flag. I think this default is fine though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why not just lint everything?
That way we have greater coverage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, by default that is good, but for future testing, we might want to only run exactly one lint, to make it easier to check the output.

clippy_dev/src/main.rs Outdated Show resolved Hide resolved
clippy_dev/src/crater.rs Outdated Show resolved Hide resolved
clippy_dev/Cargo.toml Outdated Show resolved Hide resolved
clippy_dev/src/crater.rs Outdated Show resolved Hide resolved
clippy_dev/src/crater.rs Outdated Show resolved Hide resolved
Copy link
Member

@camelid camelid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, sorry I left several 'single comments' – it always bothers me when people do that :)

clippy_dev/src/crater.rs Outdated Show resolved Hide resolved
clippy_dev/src/crater.rs Outdated Show resolved Hide resolved
@matthiaskrgr matthiaskrgr force-pushed the clippy_dev_crater branch 2 times, most recently from fe8f897 to 202c46c Compare December 23, 2020 12:12
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of my enhancement suggestions should block this PR. I you feel like you don't want to add this (yet), we can merge this as is and revisit possible enhancements later when we need them.

clippy_dev/Cargo.toml Outdated Show resolved Hide resolved
clippy_dev/Cargo.toml Outdated Show resolved Hide resolved
clippy_dev/src/crater.rs Outdated Show resolved Hide resolved
@matthiaskrgr matthiaskrgr force-pushed the clippy_dev_crater branch 2 times, most recently from 590e046 to 00e36d2 Compare December 29, 2020 16:04
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM now! Please squash some of the commits.

Two more ideas I got from this:

  1. maybe it would make sense to dump the lint statistics in the log file for a quick overview of the changes.
  2. Something for the future: We could implement an disabled by default lint that looks for allow(clippy::_) attributes and then use this tool to find out how often (and which) Clippy lints are allowed in crates that use Clippy.

This can be done in future PRs, so r=me once squashed.

@phansch
Copy link
Member

phansch commented Jan 4, 2021

Potential bikeshed: Would it maybe make sense to rename this to something else than crater? I could see someone getting confused with rust-lang/crater which also has Clippy related features.

@bors
Copy link
Collaborator

bors commented Jan 5, 2021

☔ The latest upstream changes (presumably #6547) made this pull request unmergeable. Please resolve the merge conflicts.

@flip1995
Copy link
Member

@matthiaskrgr The only thing to address for this to get merged is the request for renaming this to $something else.

@flip1995 flip1995 mentioned this pull request Jan 22, 2021
5 tasks
@flip1995 flip1995 added this to False positive rate in Roadmap 2021/2022 Jan 22, 2021
@matthiaskrgr
Copy link
Member Author

Yes, sorry, i'll try to wrap this over the course of the weekend.

@matthiaskrgr
Copy link
Member Author

I've renamed to "lintcheck" now, hope that's better.

@matthiaskrgr matthiaskrgr force-pushed the clippy_dev_crater branch 2 times, most recently from 7499cc8 to 253740a Compare January 23, 2021 01:17
Also sort lint results alphabetically.
make serde a feature-dep
save clippy version in the crater log
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phansch r=me if you're also ok with the new name.

@phansch
Copy link
Member

phansch commented Jan 26, 2021

@bors r=flip1995

@bors
Copy link
Collaborator

bors commented Jan 26, 2021

📌 Commit 5b6a183 has been approved by flip1995

@bors
Copy link
Collaborator

bors commented Jan 26, 2021

⌛ Testing commit 5b6a183 with merge be0125b...

@bors
Copy link
Collaborator

bors commented Jan 26, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing be0125b to master...

@bors bors merged commit be0125b into rust-lang:master Jan 26, 2021
Roadmap 2021/2022 automation moved this from False positive rate to Done Jan 26, 2021
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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants