-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add configuration options to --explain
#10751
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
Conversation
I've only skimmed over the code, but we might be able, to only move Btw, thank you for giving this a shot, the idea already looks good ❤️ |
dddb664
to
2a4571d
Compare
Ok, the new commit minimizes changes and build times (53.15s from 58s). Keeping the same dependencies.
|
I also really like the idea! Thanks for keeping those deps optional and measuring the compile time and sizes. I'll now leave this PR to you and the friendly penguin to review :) |
/// | ||
/// Would yield: | ||
/// ```rust, ignore | ||
/// Some(["lint_name_1", "lint_name_2"], "Papa penguin, papa penguin") |
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'm happy that you kept the doc comments ❤️
clippy_lints/src/lib.rs
Outdated
println!("### Configuration for {}:", info.lint.name_lower()); | ||
for position in config_vec_positions { | ||
let conf = &mdconf[position]; | ||
println!(" - {}: {} (default: {})", conf.name, conf.doc, conf.default); |
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 moving this into format into a method on the configuration struct, to have it more uniform with the other formatting code. However, that is just a style question, and I can see reasons for having it here, so this is an optional suggestion :)
I feel like the formatting is a bit hard to read, for lints with multiple configs, like in this example:
> cargo run --bin cargo-clippy --manifest-path ../rust-clippy/Cargo.toml -- --explain manual_let_else
### Configuration for clippy::manual_let_else:
- msrv: The minimum rust version that the project supports (default: None)
- matches-for-let-else: Whether the matches should be considered by the lint, and whether there should
be filtering for common types. (default: WellKnownTypes)
But I also don't know how to improve it much. It should be fine, since we have very few lints with multiple config values :)
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.
About the first issue: I'll fix it.
About the second: I have 0 ideas about how to fix this. Maybe adding a newline between ### Configuration for ...
and the options?
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.
After taking a look at the code again, I don't think I can even fix the first problem.
Each configuration option depends on mdconf
and config_vec_positions
. While mdconf
is independent (taken from get_configuration_metadata()
), config_vec_positions
depends on info
.
I think extrapolating the whole fragment (from line 480 to 491) would abstract so much the process of getting the configuration, that it would difficult future contributors and would make the function more readable, but less understandable overall.
I'll still fix the formatting.
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.
Alright, then just keep it as is. Fixing the indention was a nice catch! Thank you, I'll leave you then honer of ordering @bors
to merge it :D
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.
omg thx ❤️
Looks good to me, I have one small optional NIT, and then it's ready to be merged. You can @bors delegate+ |
@bors delegate+ |
✌️ @blyxyas can now approve this pull request |
@bors r=xFrednet |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This PR rearranges some modules, taking
metadata_collector
out ofinternal_lints
and making public just the necessary functions forexplain()
to use.The output looks something like this:
Fixes #9990
r? @xFrednet
changelog: Docs:
cargo clippy --explain LINT
now shows possible configuration options for the explained lint#10751