Skip to content

feat: GOP party → GOP / Grand Old Party#3232

Open
hippietrail wants to merge 3 commits into
Automattic:masterfrom
hippietrail:redundant-acronym
Open

feat: GOP party → GOP / Grand Old Party#3232
hippietrail wants to merge 3 commits into
Automattic:masterfrom
hippietrail:redundant-acronym

Conversation

@hippietrail
Copy link
Copy Markdown
Collaborator

Issues

N/A

Description

I noticed "GOP party" in a YouTube comment and thought "we have a linter that can fix that"!

It turned out to be a little complicated by the fact that it's the first one that's a proper noun so when fully-spelled-out each word should begin with a capital.

Since this involved computationally creating the right-side of a string test that requires the right side to be all-lowercase, I've also included debug-time-only asserts to ensure right sides of such tests are always all-lowercase. And a pair of unit tests to make sure that they work as intended.

How Has This Been Tested?

A unit test for the redundancy and two unit tests for the lowercase-right-side invariant.
Thence just test-rust

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have considered splitting this into smaller pull requests.

Since this involved computationally creating the right-side of a string test that requires the right side to be all-lowerse, I've also included debug-time-only asserts to ensure right sides of such tests are always all-lowercase, and a pair of unit tests to make sure that they work as intended.

fn eq_str(&self, other: &str) -> bool {
// Assert that the right-hand side is all-lowercase as required
debug_assert!(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm a little confused here. The name of the function (and the way I would use it) does not imply that the right side is lowercase. Why is that necessary?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's always been documented. It was an optimization because in practice the right side was always a literal:

harper-core/src/char_string.rs

image

Should I add a to-lowercase into the loop on the right-hand side and remove this requirement?


fn eq_ch(&self, other: &[char]) -> bool {
// Assert that the right-hand side is all-lowercase as required
debug_assert!(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as my other comment.

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