Skip to content

Add a summary of lints caught in cargo clippy #11532

@ericwu17

Description

@ericwu17

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.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions