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 a summary of lints caught in cargo clippy #11532

Open
ericwu17 opened this issue Jan 3, 2023 · 2 comments
Open

Add a summary of lints caught in cargo clippy #11532

ericwu17 opened this issue Jan 3, 2023 · 2 comments
Assignees
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-clippy

Comments

@ericwu17
Copy link

ericwu17 commented Jan 3, 2023

Problem

When a relatively medium/large project migrates to clippy, there might be a large number of lint diagnostics. It can be difficult to get a clear picture of the category with the most problems.

@dclong raised an issue here describing this feature request in the clippy github repo.

Proposed Solution

It would help if running cargo clippy automatically shows counts of lints whenever a large number of diagnostics (> 10) are generated. For example, cargo clippy should show something like

`my_project` (bin "my_project") generated 28 warnings

Summary of diagnostics:
clippy::collapsible_if: 16
clippy::collapsible_else_if: 4
clippy::approx_constant: 3
dead_code: 3
clippy::single_match: 1
clippy::new_without_default: 1

Although the default behavior is to show this summary whenever the total amount of diagnostics is greater than 10, we should also allow users to override whether the summary is shown by running cargo clippy --summary or cargo clippy --no-summary.

Notes

Note that the summary includes both warnings generated from clippy and rustc.

@ericwu17 ericwu17 added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 3, 2023
@weihanglo
Copy link
Member

Thank you for proposing this.

cargo-clippy is an external subcommand provided by clippy's main.rs. Cargo usually just hands over argument parsing to subcommands, so --summary/--no-summary might not be feasible at this moment.

Apart from that, the idea of a summary report sounds good to me.. Cargo already has experiments on auto-fix suggestions (#10989, #11399) on nightly. This I guess could be a part of that. And we could tweak the style to fit with the current output style of cargo clippy. @Muscraft has previously worked on those experiments. We might hear great feedback from there :)

@weihanglo weihanglo added A-diagnostics Area: Error and warning messages generated by Cargo itself. Command-clippy labels Jan 4, 2023
@ericwu17
Copy link
Author

ericwu17 commented Jan 4, 2023

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants