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

Added lint public_module_level_constant_now_doc_hidden #690

Merged
merged 15 commits into from
Mar 11, 2024

Conversation

arpity22
Copy link
Contributor

@arpity22 arpity22 commented Mar 9, 2024

Lint for when a public module level constant is marked as #[doc(hidden)]

Issue mention in #576

Caught a lint in test crate for the lint function_now_doc_hidden, which is mentioned in the test output for this lint

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint query looks good! Some of the surrounding metadata could use another polishing pass, and I made a few specific suggestions for that. Looking forward to merging this soon!

As a small tangent: I highly recommend reading your PR in the GitHub PR review interface before making the PR ready for review. A lot of the suggestions I made here are much easier to see in the PR review interface than in your own editor, so I bet you would have spotted them yourself if you did a self-review like that. In turn, that would have saved us both some time because it's always faster to merge a PR than to have a back-and-forth around it.

Anyway — excited to merge this soon and include it in the new release!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure the name of the file matches the value of the id field in the lint's metadata.

Comment on lines 3 to 4
human_readable_name: "a public module level constant is marked #[doc(hidden)]",
description: "a public module level constant is now marked #[doc(hidden)] and is thus not a part of public API",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to match the style of the other lints for these metadata fields.

For example, compare the contents of the pub_module_level_const_missing lint for these fields:

human_readable_name: "pub module-level const is missing",
description: "A pub const is missing, renamed, or changed to static.",

Comment on lines 46 to 47
error_message: "A public module level constant is now marked #[doc(hidden)], removing it from the crate's public API.",
per_result_error_template: Some("constant {{constant_name}} in file {{span_filename}}:{{span_begin_line}}"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, to match the output and style of pub_module_level_const_missing lint:

Suggested change
error_message: "A public module level constant is now marked #[doc(hidden)], removing it from the crate's public API.",
per_result_error_template: Some("constant {{constant_name}} in file {{span_filename}}:{{span_begin_line}}"),
error_message: "A public const is now marked #[doc(hidden)], removing it from the crate's public API.",
per_result_error_template: Some("{{constant_name}} in file {{span_filename}}:{{span_begin_line}}"),

@@ -0,0 +1,7 @@
[package]
publish = false
name = "public_module_level_constant_now_doc_hidden"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to rename all the test crates directories and names to match the lint's id and filename. This seems like you might have accidentally created the lint with the name public_module_level_constant_now_doc_hidden and then only partially renamed it and its metadata.

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I'm going to merge this.

It seems that this lint name is inconsistent with the other lints that target pub constants / pub statics (pub_module_level_const_missing / pub_static_missing), and this consistency is important since it'll aid users when they need to refer to lints by name. For example, when opting into or out of lints via package.metadata configuration like in #58.

I'll open a PR to rename the lint and its test outputs to pub_module_level_const_now_doc_hidden.

@obi1kenobi obi1kenobi merged commit 281bdcb into obi1kenobi:main Mar 11, 2024
32 checks passed
@obi1kenobi
Copy link
Owner

Renamed in #703.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants