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

Stricter check_option_description for single-letter words #171

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

omertuc
Copy link
Contributor

@omertuc omertuc commented Sep 8, 2023

/// A parameter

Would be accepted as a parameter description even though it starts with
an uppercase letter, because argh would consider the word "A" to be an
initialism, which it's not

@google-cla
Copy link

google-cla bot commented Sep 8, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@@ -467,7 +467,7 @@ fn check_option_description(errors: &Errors, desc: &str, span: Span) {
(Some(x), _) if x.is_lowercase() => {}
// If both the first and second letter are not lowercase,
// this is likely an initialism which should be allowed.
(Some(x), Some(y)) if !x.is_lowercase() && !y.is_lowercase() => {}
(Some(x), Some(y)) if !x.is_lowercase() && (y.is_alphanumeric() && !y.is_lowercase()) => {}
Copy link
Contributor Author

@omertuc omertuc Sep 8, 2023

Choose a reason for hiding this comment

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

is_alphanumeric and not is_alphabetic to still support initialisms like I2C

Copy link

Choose a reason for hiding this comment

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

Seems to me that initialisms like I2C are already accepted:

!'2'.is_lowercase() = true
'2'.is_alphanumeric() && !'2'.is_lowercase() = true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, they are (even edited my message to say "still"). I'm just justifying my use of is_alphanumeric over is_alphabetic, which would prevent initialisms like I2C

@omertuc
Copy link
Contributor Author

omertuc commented Sep 8, 2023

Worth noting that this is technically a "breaking change" for any code that happens to already have such descriptions in its structs

Copy link
Collaborator

@sadmac7000 sadmac7000 left a comment

Choose a reason for hiding this comment

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

This probably needs unit tests.

@omertuc omertuc force-pushed the initialism branch 2 times, most recently from 79011ca to 964e798 Compare October 20, 2023 10:25
```
/// A parameter
```

Would be accepted as a parameter description even though it starts with
an uppercase letter, because argh would consider the word "A" to be an
initialism, which it's not
@sadmac7000 sadmac7000 merged commit c2b8549 into google:master Oct 20, 2023
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.

3 participants