Skip to content

validate lint name in clippy_dev #10817

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

Merged
merged 3 commits into from
May 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,14 @@ fn get_clap_config() -> ArgMatches {
.short('n')
.long("name")
.help("Name of the new lint in snake case, ex: fn_too_long")
.required(true),
.required(true)
.value_parser(|name: &str| {
if name.contains('-') {
Err("Lint name cannot contain `-`, use `_` instead.")
Copy link
Member

@flip1995 flip1995 May 24, 2023

Choose a reason for hiding this comment

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

Instead of error, would it make sense to just replace - with _? I don't think there ever is a use case where you want -.

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense to me (assuming that was directed at me). I think it's safe to assume that the user probably didn't want the literal character - but just meant to have it as a delimiter and replacing it with _ is fine

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that question was for you :)

} else {
Ok(name.to_owned())
}
}),
Arg::new("category")
.short('c')
.long("category")
Expand Down