fix(linter/no-magic-array-flat-depth): scan for `(` by byte offset instead of character count #25130
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 405 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.359
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #25130"
general
weight: 0.35
connorshea
AI Disclosure: Generated with Claude Code, Opus 5. This was reviewed and tested by me. It fixes a crash when parsing specific inputs and also improves the performance of the rule in edge cases.
---
get_call_expression_parentheses_poslocated the argument list's opening paren withsource_text().char_indices().skip(callee_span.end). That had two problems:callee_span.endis a byte offset butskipcounts chars, so any multi-byte character earlier in the file shifted the scan. A small skew landed on a later(and produced a false positive on a correctly commented call; a large one exhausted the iterator and hit the.expect(), aborting the process. Two lines of valid JavaScript were enough to crash oxlint:See the Playground
skiponCharIndicesdecodes and discards from byte 0, making each call O(offset in file). With 200.flat(2)calls the rule's own cost grew 4x for every 4x of file size: 19.6ms at 250KB, 75.0ms at 1MB, 301.8ms at 4MB.Search the source slice by byte offset instead, and return
Nonerather than panicking when no(is found — the caller already handles it. Rule-only cost at 4MB drops from 301.8ms to 0.4ms and no longer scales with file size.Anchor the scan on the callee's end rather than the member object's end. The old anchor scanned from the end of
arrayinarray[key(/ c /)].flat(2), found the(ofkey(, and counted the computed key's comment as the depth explanation.