perf(transform): skip parsing files without await#135
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds an shouldTransform await guard
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/transform.ts`:
- Line 38: The `AWAIT_RE` fast path in `shouldTransform()` is too broad because
it matches member accesses like `obj.await()` and `$await()` even when no
`AwaitExpression` exists. Tighten the regex or guard logic in `shouldTransform`
to only detect real async/await syntax, and add test coverage for member-access
and `$`-prefixed identifiers to ensure those cases do not trigger parsing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0c0818a1-3201-42e7-a1bf-9761959b36f3
📒 Files selected for processing (2)
src/transform.tstest/transform.test.ts
fe2bf77 to
901160d
Compare
| function shouldTransform(code: string): boolean { | ||
| return typeof code === "string" && matchRE.test(code); | ||
| return ( | ||
| typeof code === "string" && matchRE.test(code) && AWAIT_RE.test(code) |
There was a problem hiding this comment.
I think we can reorder await check before matchRe as it is more predictable/restrictive.
There was a problem hiding this comment.
I don't think that'll be more efficient.
At the moment, we check less files for both the functions + await
If we put the await regex first we have more files in the first selection (more files have await than one of the functions checked matchRE), and then reject a lot of files after.
|
CI is failing due to setup issues that I resolved via #134 already |
Thightens
shouldTransformgiven thatawaitis needed as keyword.Summary by CodeRabbit
awaitkeyword.shouldTransformtest coverage with additional negative and edge-case inputs (e.g., target call withoutawait,awaitwithout the target call, and non-keyword “await” usage).