fix(lint): preserve underscores and honor mixed_case_exceptions in pascal-case-struct - #16578
Open
gomesalexandre wants to merge 1 commit into
Conversation
…scal-case-struct check_pascal_case never called preserve_underscores unlike its two siblings (check_screaming_snake_case, check_mixed_case), so a struct named _PascalCase would be flagged with a MachineApplicable suggestion to rename to PascalCase - colliding with an already-existing struct of that name in the same file. The existing StructPascalCase.sol fixture was pinning exactly this broken suggestion. pascal_case.rs also never consulted LintSpecificConfig.mixed_case_exceptions (the acronym allowlist mixed-case-function/mixed-case-variable already use), so struct names like ERC20Data were flagged and suggested as Erc20Data. Fixed check_pascal_case to preserve underscores like its siblings, and wired PascalCaseStructPass through the same Arc<LintSpecificConfig> pattern mixed_case.rs already uses, including its pre/post acronym- exception matching. Updated the fixture (regenerated stderr via --bless) to cover both fixes and removed the collision.
gomesalexandre
marked this pull request as ready for review
September 2, 2026 20:16
gomesalexandre
requested review from
0xrusowsky,
DaniPopes,
figtracer,
grandizzy,
mablr,
mattsse and
stevencartavia
as code owners
September 2, 2026 20:16
Contributor
✅ Changelog foundThe deterministic check will validate the changed entry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
pascal-case-structhad two bugs, both incrates/lint/src/sol/naming.rs/crates/lint/src/sol/info/pascal_case.rs:Underscores weren't preserved.
check_pascal_casewas the only one of the three naming helpers (check_pascal_case,check_screaming_snake_case,check_mixed_case) that didn't call the sharedpreserve_underscoreshelper. A struct named_PascalCasegot flagged with aMachineApplicablesuggestion to rename toPascalCase— colliding with an already-existing struct of that exact name in the same contract. The existingStructPascalCase.solfixture was pinning exactly this broken suggestion (struct PascalCaseat one line,struct _PascalCaseflagged suggestingPascalCaseat another).mixed_case_exceptionswas never consulted.mixed-case-function/mixed-case-variableboth respect the configurable acronym allowlist (ERC,URI, etc. by default) viaLintSpecificConfig, butpascal-case-structnever received the config at all — sostruct ERC20Datagets flagged and suggested asErc20Data.Fix
check_pascal_casenow callspreserve_underscores, matching its two siblings.pascal_case.rsgained aPascalCaseStructPasswrappingArc<LintSpecificConfig>, wired throughregister_lints!'s constructor mechanism exactly the waymixed_case.rs's two passes already do — including the same pre/postAsUpperCamelCasepattern-exception matching (adjusted for full PascalCase rather than lowerCamelCase).StructPascalCase.sol/.stderr(stderr regenerated viacargo test -p forge --test ui -- --bless) to cover both fixes: an_pascalCasecase (proves the underscore is preserved in a real suggestion, not just a no-op passthrough) and anERC20Datacase (proves the exception now applies). The previously-colliding_PascalCasecase is no longer flagged at all, since it already satisfies PascalCase-with-preserved-underscore.Testing
cargo test -p forge-lint --lib— 11/11 passing, including newpascal_case_preserves_underscoresunit tests.cargo test -p forge --test ui) — 97/97 passing after the bless regeneration; confirmed the blessed diff only touches the one line that changed (the other already-flagged invalid cases —pascalCase,pascalcase,pascal_case,PASCAL_CASE,PASCALCASE— are unaffected).s.find(pattern)on an empty pre/post, a pattern at the very start/end of the string, and a pattern longer than the input all resolve safely (no panic, no false match) — same as the pre-existingmixed_case.rsimplementation this mirrors.Note on review
Ran a synchronous Codex adversarial pass on this diff. It got partway through independently cross-referencing the exact
mixed_case.rspattern this PR mirrors before hitting a transient "model at capacity" error and never returned a final verdict. Did a manual self-review of the edge cases it was mid-way through checking (pattern-boundary matching, empty pre/post) rather than re-run it — noting this honestly rather than claiming a completed automated review.closes nothing — filed independently, dupe-checked clean (no existing issue/PR on this).