← Back to Pull requests

fix(linter/no-magic-array-flat-depth): scan for `(` by byte offset instead of character count #25130

Closed
unknown closed this pull request without merging on Aug 01, 2026 18:37 UTC
View on GitHub
unknown unknown commented on Jul 31, 2026 02:17 UTC
Author

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_pos located the argument list's opening paren with source_text().char_indices().skip(callee_span.end). That had two problems:

  • callee_span.end is a byte offset but skip counts 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:
  • const s = "⚓️💥";
    array.flat(2);
    

    See the Playground

  • skip on CharIndices decodes 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 None rather 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 array in array[key(/ c /)].flat(2), found the ( of key(, and counted the computed key's comment as the depth explanation.

    Diff: 405 lines (+303 / -102) across 5 files Reviewer: connorshea Review duration: 2419m
    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
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.8% (MEDIUM) · Higher = larger blast radius
    49.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.5% · Safe to merge
    21.5%