-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Diagnostic summary #11542
Diagnostic summary #11542
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. |
After looking at the example output, I feel like the summary is less important than the actual messages and the summary could easily push the messages off screen. imo the only value I feel I'd get out of it is the diagnostic name as it only gets reported in the first instance which makes it hard to find to copy/paste it for suppressing it. Even then, without a clear association with a message, I'd likely be guessing which I need. |
@epage Thanks for your feedback! I don't quite understand your concern about the summary pushing messages off the screen: the summary here comes from an example where clippy emitted 65 warnings and errors (full output is here) so even without the summary, the user will only see the last few messages on the screen. The value you'd get from the summary is an aggregate picture of how many times each lint was triggered when linting the project. (the number to the right of the colon after the diagnostic name is the count of occurrences) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with epage but from a slightly different angle. The summary shouldn't be generated by default for cargo build
and cargo run
. My points are:
- Cargo is already a bit too verbose.
- Seeing a summary of clippy error is not the purpose of those commands.
clippy
might be missing if a toolchain is installed with a minimal rustup profile
Instead, I'll suggest only cargo clippy
outputs the summary, as running cargo clippy
generally means a user is looking into clippy errors. And maybe putting it behind nightly is a better way to rollout .
src/bin/cargo/cli.rs
Outdated
let summary_override = if subcommand_args.flag("summary") { | ||
Some(true) | ||
} else if subcommand_args.flag("no-summary") { | ||
Some(false) | ||
} else { | ||
None | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest avoiding adding a new flag at first place. This is a one way door decision and cannot be reverted once stabilized. We could figure it out in follow-up PRs and discussions.
I tend to resolve the last warnings first, re-running after each iteration rather than scrolling to see what is still relevant.
To clarify, that is the value you would be getting. I was speaking of the value for my own personal workflow which this would negatively affect. Also, I feel like there is an unspoken value you are getting. An aggregate picture isn't a change in action or behavior, so it'd help in making the case for this to dig deeper and answer what value you get out of an aggregate picture. |
@epage Thanks for providing the perspective on why this change would be detrimental to your workflow. What do you think about only @weihanglo's suggestion of only showing the summary when running
To answer this, the value would be for fairly medium or large projects which migrate to using clippy. When running clippy for the first time, there might be an intimidatingly large amount of errors. If clippy emits some 300 errors, then walking through the output and fixing each error would take hours, not minutes. If I'm about to begin the task of fixing clippy's errors, then I'd like to know about the nature of the work I'm about to start. Since some lint types are much easier/quicker to fix than others, I hope that a summary like the one above would help with estimating the amount of work required to address all the warnings emitted by clippy. |
This reverts commit d689608.
the commands "cargo run" and "cargo build" should never show a summary because only users running "cargo clippy" would be most interested in seeing a summary
I see some people talk about replacing I'm unsure if there is a good heuristic for when to display this. It isn't unheard of in my projects to see a hundred warnings or so in a go, depending on what is happening.
I guess for me, I could only estimate the difference in lints if I had already been dealing a lot with the same lints in a short period of time. I rarely pay attention to or remember their names. Again, what I would like do with this information is see "oh, this lint appears 200 times, maybe I should In general. these are occasional workflows, so an "always on" feature (with or without a heuristic) feels odd to me. Also, a lot of these lints can be fixed in an automated fashion; I feel like it'd be a higher priority to improve the |
@weihanglo @epage What would you guys think about outputting this diagnostic summary only when the user passes in a flag like I do believe this feature would add value to some users' workflows (some users do care about which lints are being caught and how many times). I understand that implementing the feature as an "always on" thing would be detrimental to some other users' workflows which would not find the summary valuable, but only a nuisance getting in the way of clippy's already verbose output. How should we move this PR forward from here? |
I seldom use clippy and has a similar workflow as epage's. My editor displays a list of error, and then I just tackle them one by one. Not devalue the idea, but I completely have no idea how useful it is as I did less with clippy. I would suggest looking into other linter tools outside Rust community. Make a summary of what they've done. Those could be good references to Cargo. Apart from that, a new flag usually comes out behind |
☔ The latest upstream changes (presumably #11758) made this pull request unmergeable. Please resolve the merge conflicts. |
Closes #11532
This draft PR implements the suggestion of writing a diagnostic summary when clippy emits at least 10 diagnostics. Right now, the diagnostic summary looks like this:
And the same diagnostic summary is generated for
cargo build
andcargo run
. Using the flag--summary
will make cargo output a summary even when < 10 diagnostics are emitted, and using--no-summary
will suppress the summary.I have marked this PR as a draft to request feedback on any major problems with the code, and also about stylistic/formatting suggestions.