Repository navigation
fix(cli): make create-sg-rule's Quirks workarounds hold for real code - #491
Merged
Merged
Conversation
A post-merge review of #488 found the recipe's own workarounds reintroduced the silent failures the section warns about. All measured on ast-grep 0.45.3. - The `readonly` workaround (`^readonly\b` on `required_parameter`) matched 1 of 4 real shapes. It missed `private readonly x` and a decorated parameter, whose text starts before the keyword, and `readonly x?`, which is an `optional_parameter`. The new regex covers all four and keeps out a `readonly` type and a parameter named `readonly`. - The awaited-call workaround and the repro both used a `regex` with no sibling `kind`, which `verify` refuses (`sg-regex-needs-kind`). Both now carry `kind: identifier`. The recipe also shows the method form: under `await`, `client.rpc<Foo>()` wraps a `member_expression`, and the identifier branch found 0 of 2. - Step 5 claimed every quirk "verifies clean", but `verify` does report the `language:` spelling and a TypeScript rule whose `files:` names `.tsx`. The table gains a column saying which quirks `verify` reports. The vendor contract now pins the claims it previously took on trust: Tsx parses awaited generics the same way, `!`/`void`/`typeof` wrap the callee in `unary_expression` and `yield` does not, and both workarounds match exactly what the recipe says. The header reads "measured at" rather than "added at", since a bump did not introduce these. `typescriptMatches` and `arityMatches` were the third copy of the same parse chain; both now go through `grammarMatches`. The topic moves to v7, because v6 already shipped in the nightly, and the pending changeset says so.
Member
Author
|
@claude /review |
Contributor
|
Claude finished @theCodeDrift's task in 3m 57s —— View job Review mode: incremental — read 0 prior review thread(s) before reviewing. Todo
SummaryI found nothing NEW to flag. This is a tight, well-verified fix — every claim it makes is cross-checked against either the test file or the actual
No correctness, security, or test-adequacy issues found in this diff. |
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.
Follow-up to #488, which merged without review. A local review afterwards found that the recipe's own workarounds reintroduced the silent failures the Quirks section warns about. Everything below was measured on ast-grep 0.45.3.
Recipe fixes (
create-sg-rule.md, topic v6 → v7; v6 already shipped in the nightly)readonlyworkaround matched 1 of 4 real shapes.^readonly\bonrequired_parametermissedprivate readonly x, a decorated parameter, andreadonly x?(anoptional_parameter). The new regex matches all four and excludesx: readonly string[], a parameter namedreadonly, andpublic x.verify. Each had aregexwith no siblingkind(sg-regex-needs-kind). Both now carrykind: identifier.await,client.rpc<Foo>()wraps amember_expression; the identifier-only workaround found 0 of 2. The recipe now shows the member form.verifyreports thelanguage:spelling and a TypeScript rule whosefiles:names.tsx. The Quirks table gains a column saying which quirksverifyreports.Every YAML example in the recipe passes
taskless verifyandtaskless test, checked in a scratch project.Tests
!,voidandtypeofhide the callee behindunary_expression;yielddoes not; and both workarounds match exactly what the recipe says.grammarMatches.agent-extensionsassertsexitCodein both new tests.Changeset: the pending
sg-rule-quirks.mdis extended, not duplicated, and now names topic v7.Refs #485