Skip to content

Start a new word at "Is" or "As" after an acronym [patch] - #157

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/104-is-as-after-acronym
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/104-is-as-after-acronym

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #104

What changed

The plural-acronym rule from #99 (#102) treated the s of Is/As as a plural suffix whenever a capital followed it, so UserIDIsValid read as the plural of IDI and fused into user_idis_valid.

  • IsWordBoundary: an I or A that ends an acronym run, followed directly by s and then a capital, now starts its own word (IsIsOrAsBeforeNextWord). An s that ends the word (APIs, getIDs, GUIDs_2) or precedes a non-letter is still a plural, and other plurals before a capital (PDFsAndDOCs, URLsList) are unchanged.
  • LowercaseOneLetterWordsAfterOneLetterWords: PascalCase/camelCase output used to lower Is/As after a capital one-letter word so XIs wouldn't read back as a plural. That's still done at the end of the identifier (check_x_is → CheckXis, unchanged), but not when a capitalised word follows, since that now reads back correctly. So IfXIsNull stays unchanged, and check_x_is_null → CheckXIsNull → check_x_is_null.

Trade-off to confirm

The triage asked for the APIsList case to be settled before merging. With this rule, a plural acronym ending in I/A followed by another word can't be told apart from Is, so APIsList now gives ap_is_list (it gave apis_list before). The new test APluralAcronymEndingInIOrAFollowedByAWordShouldSplitAsIs pins this so it's a deliberate, reviewable choice. If you'd rather keep APIsList whole, the alternative is to revert #102's capital-follows case, which brings back the #99 behaviour for PDFsAndDOCs.

Tests

  • New IsOrAsAfterAnAcronymShouldStartItsOwnWord covers every converter for the rows in the issue table (UserIDIsValid, URLIsSet, ConvertIDAsString, getAPIAsJson, DOMIsReady, PlayerAIsDead). Also new: IsAfterASingleCapitalShouldKeepAPascalCaseIdentifierUnchanged and the APIsList pin.
  • With the source change reverted, 8 of the new cases fail. With it applied, the full suite passes (218/218).

Generated by Claude Code

The plural-acronym rule from #99 read the "s" of "Is" or "As" as a
plural suffix whenever a capital followed it, so "UserIDIsValid" fused
into "user_idis_valid". An "I" or "A" plus "s" followed by a capital
now starts its own word; an "s" that ends the word ("APIs", "getIDs")
is still a plural. PascalCase output no longer lowers "Is"/"As" after a
one-letter word when a capitalised word follows, so "IfXIsNull" stays
unchanged.

Fixes #104

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW6ap2X1hPcsPueGLQX
@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants