-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Metadata collection monster searching for Clippy's configuration options #7214
Metadata collection monster searching for Clippy's configuration options #7214
Conversation
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.
Just some ignorable comments.
8948ed9
to
f810c11
Compare
I've addressed @camsteffen's suggestions which were excellent! I'm happy with this version, but I was sadly unable to fully test it with my current setup. I'll be able to do so on Thursday. However, I strongly believe that this works and can therefor at least be reviewed if not merged :) |
…r=flip1995 Add `cargo collect-metadata` as an cargo alias for the metadata collection lint This PR adds a new alias to run the metadata collection monster on `clippy_lints`. I'm currently using it to create the `metadata_collection.json` file and I plan to use it in the `deply.sh` script. Having it as a new alias enables us to simply use: ```sh cargo collect-metadata ``` It sometimes requires running `cargo clean` before collecting the metadata due to caching. I'm still debating if I should include a cargo clean as part of the `run_metadata_collection_lint` test or not. Input on this would be greatly appreciated 🙃 That's it, just a small change that can be reviewed and merged in parallel to #7214. --- See: #7172 for the full metadata collection to-do list or to suggest a new feature in connection to it. --- changelog: none r? `@flip1995` btw. feel free to pass these PRs one to other team members as well if you want.
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.
The new parsing will also allow us to have a documentation that spans over multiple lines in the future. For example, this will be valid when the old script has been removed:
That would be really neat, but I think the macro definition would have to be changed to allow multi-lint doc comments:
error: no rules expected the token `doc`
--> clippy_lints/src/utils/conf.rs:126:5
|
27 | macro_rules! define_Conf {
| ------------------------ when calling this macro
...
126 | /// FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no rules expected this token in macro call
LGTM. Works great for me locally. Just a NIT.
} | ||
|
||
impl MetadataCollector { | ||
pub fn new() -> Self { |
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.
Doesn't this trigger our new_without_default
lint?
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.
It's the first time that I've heard of that lint... so, I guess not 🤔. Unless it got merged after this branch was crated from master. I would also expect it not to trigger as new()
does more than just assign default values but that might be just my opinion 🙃 .
It didn't trigger during testing. We'll see if bors complains about it 🙃
✌️ @xFrednet can now approve this pull request |
That's true and done on purpose for now. The change is pretty simple but it would not be supported by our current python script. I therefore decided to leave the macro definition to be restrictive until we fully switched over. The parsing itself is already setup for it :) I'm happy with merging this, and it also brings us one step closer to switching over. Thank you for the fast reviews on these PRs! @flip1995 @bors r=flip1995,camsteffen The bors syntax should be correct this time to add you as a reviewer, I've also added @camsteffen as he reviewed it as well 🙃 |
📌 Commit f810c11 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This PR teaches our lovely metadata collection monster which configurations are available inside Clippy. It then adds a new Configuration section to the lint documentation.
The implementation uses the
define_Conf!
macro to create a vector of metadata during compilation. This enables easy collection and parsing without the need of searching for the struct during a lint-pass (and it's quite elegant IMO). The information is then parsed into an intermediate struct calledClippyConfiguration
which will be saved inside theMetadataCollector
struct itself. It is currently only used to generate the Configuration section in the lint documentation, but I'm thinking about adding an overview of available configurations to the website. Saving them in this intermediate state without formatting them right away enables this in the future.The new parsing will also allow us to have a documentation that spans over multiple lines in the future. For example, this will be valid when the old script has been removed:
The deprecation reason is also currently being collected but not used any further and that's basically it.
See: #7172 for the full metadata collection to-do list or to suggest a new feature in connection to it 🙃
changelog: none
r? @flip1995
cc @camsteffen It would be great if you could also review this PR as you have recently worked on Clippy's
define_Conf!
macro.