Conversation
🦋 Changeset detectedLatest commit: 6e4ae14 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughRefactors the Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/suspicious/no_empty_block_statements.rs (1)
89-93: Micro-optimisation: swap the last two guards for cheaper short-circuiting.On Line 89, descendant comment scanning can still happen before the constructor exemption on Line 92. Flipping those checks keeps behaviour identical and avoids an unnecessary tree walk for exempt constructors.
Suggested tweak
- if query.syntax().has_comments_descendants() { - return None; - } if is_constructor_with_ts_param_props_or_private(query) { return None; } + if query.syntax().has_comments_descendants() { + return None; + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_js_analyze/src/lint/suspicious/no_empty_block_statements.rs` around lines 89 - 93, Swap the two early-return guards so the cheaper constructor exemption runs before the expensive comment-descendant scan: check is_constructor_with_ts_param_props_or_private(query) first and return None if true, then call query.syntax().has_comments_descendants() and return None if that is true; update the order where those two checks appear (the calls to is_constructor_with_ts_param_props_or_private and has_comments_descendants) to short-circuit the tree walk for exempt constructors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/biome_js_analyze/src/lint/suspicious/no_empty_block_statements.rs`:
- Around line 89-93: Swap the two early-return guards so the cheaper constructor
exemption runs before the expensive comment-descendant scan: check
is_constructor_with_ts_param_props_or_private(query) first and return None if
true, then call query.syntax().has_comments_descendants() and return None if
that is true; update the order where those two checks appear (the calls to
is_constructor_with_ts_param_props_or_private and has_comments_descendants) to
short-circuit the tree walk for exempt constructors.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2c144eba-c769-415e-ad9b-67babec5ed5d
📒 Files selected for processing (2)
.changeset/nine-sides-wish.mdcrates/biome_js_analyze/src/lint/suspicious/no_empty_block_statements.rs
Merging this PR will not alter performance
Comparing Footnotes
|
6793136 to
3adec68
Compare
…ndants for comments
3adec68 to
6e4ae14
Compare
Summary
It turns out the compiler wasn't optimizing this rule so that it would short circuit automatically. This manually short circuits the logic to avoid scanning of descendants for comments if the block is already known to be not empty.
Found this when stress testing on https://github.com/elastic/kibana Originally, the rule was taking 6s total to execute, but now it takes 124ms.
Test Plan
CI should remain green
Docs