← Back to Pull requests

perf(linter/eslint/max-depth): derive node types #23896

Closed
unknown closed this pull request without merging on Jun 28, 2026 14:23 UTC
View on GitHub
unknown unknown commented on Jun 28, 2026 14:05 UTC
Author

Run on VS Code before and after to compare call #s and also to ensure that the number of violations were identical (which they are). Generated with Claude Code, tested and reviewed by me.

This rule is the last rule (after the other open PR is also merged) in the Rust set that runs on every node in a given codebase. All other rules had less than 15.2M calls when run on the vscode codebase. --debug=timings doesn't include type-aware rules, so I haven't looked at those at all, and I'm not sure we can limit AST Nodes like this for those rules anyway.

What

eslint/max-depth matched on AST kinds inside its should_count helper rather than inline in run, so the linter codegen couldn't derive a NODE_TYPES bitset and emitted None. That placed the rule in the any_type bucket, dispatching run on every AST node.

This restructures run to lead with a narrowing match node.kind() that the codegen's EarlyDivergeDetector recognizes, so codegen now emits a bitset of the 9 statement kinds the rule actually acts on. should_count/should_stop are unchanged, so the IfStatement parent-guard and ancestor-counting logic — and thus the rule's behavior — are identical.

Results

Measured on 11,674 files with only this rule enabled:

| | Calls | Rule time |
|---|---|---|
| Before | 15,251,059 | 223.1 ms |
| After | 157,335 | 5.5 ms |

~97× fewer run calls, ~40× faster.

Test plan

  • cargo test -p oxc_linter max_depth passes (behavior unchanged)

  • cargo lintgen regenerates the bitset; generated impl now carries the 9 node types
  • 🤖 Generated with Claude Code

    Diff: 207 lines (+155 / -52) across 2 files Reviewer: connorshea Review duration: 18m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.41) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.41 · 207 lines diff across 2 files
    0.41
    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%
    60%
    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.319
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #23896"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 41.4% (MEDIUM) · Higher = larger blast radius
    41.4%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 16.4% · Safe to merge
    16.4%