Skip to content

feat: point out hotspots among the files a PR changes - #91

Merged
navasvarela merged 1 commit into
mainfrom
feat/hotspots
Nov 20, 2026
Merged

navasvarela merged 1 commit into
mainfrom
feat/hotspots

Conversation

@navasvarela

Copy link
Copy Markdown
Owner

Item 7 on the roadmap: hotspots. A new Hotspots check with a context dimension of its own. It's not a security finding and not a checklist question, but a hotspot file ranks higher on the review path and gives the reason.

Rules

For each changed code file that existed before the PR (up to 60, leaving out tests, vendored and generated files), Walkdiff reads its commits in the 365 days before the merge base, so the PR's own commits never count.

Rule When Title
hotspot.recently-reverted A commit starting "Revert" touched it in the 90 days before the PR Had a change reverted recently
hotspot.fix-prone At least 5 fixes, making up a quarter or more of its changes Often fixed: 13 of 27 changes in the past year
hotspot.churn 30 or more commits Changes often: 41 commits in the past year

What counts as a fix: "fix", "bug", "hotfix", "regression", "crash" or "broken" in the subject (conventional fix: and fix(scope): included). Subjects about typos, lint, formatting, docs, tests, CI, builds or dependencies don't count, and neither do reverts.

The limits are judgement calls, commented as such, chosen so a file has to stand out.

Where history comes from

Engine checks get a FileHistoryReader (defined in review-model, so providers can implement it without depending on the engine):

  • Local reviews, and any checkout with history: gitHistoryReader runs one git log --name-only per 200 paths. A shallow repository raises HistoryUnavailableError.
  • Hosted PRs: the depth-1 fetch has no history, so the CLI passes the host's reader. Offline, it passes one that reports offline mode instead.
    • GitHub: one GraphQL query per 20 files, history(path:, since:, first: 100) on the merge-base commit, with paths passed as variables. It needs a token.
    • GitLab: repository/commits?ref_name=&path=&since= per file, 6 at a time.
    • Host errors, unreachable hosts and unexpected answers become HistoryUnavailableError.

Whenever history can't be read, the Risks tab lists Hotspots under "Not checked" with why. The review itself never fails over it.

Settings: a new CheckId.Hotspots lets people turn it off. Its catalog entry says it sends "paths of the files a PR changes" to the PR's host, so the privacy list in Settings shows it.

Tried on real PRs

PR Source Flagged
Walkdiff's last 15 merged PRs local git Nothing. The busiest files had 17–22 commits and ≤3 fixes
navasvarela/walkdiff#82 GitHub API Nothing, matching git
vitejs/vite#24135, a fix to HTML entries GitHub API plugins/html.ts: often fixed, 14 of 27
vitejs/vite#24126, an optimizer fix GitHub API optimizer/index.ts: 13 of 27, by 18 people
vitejs/vite#24119, an optimizer fix GitHub API optimizer/index.ts (14 of 28) and optimizer/scan.ts (8 of 16)

Tests

  • New tests (20):
    • fix classification
    • each rule, and the "at least" wording when a host returns a page
    • an old revert that doesn't count
    • the git reader over a dated temporary repository
    • the whole check through analyzeChangedFiles
    • a shallow clone
    • both host readers against fake APIs: one query with paths as variables, the token requirement, and errors becoming missing history
  • Locally, the full suite had timeouts while this machine slept mid-run, about 15 minutes per test, in a different test each time. The affected files pass when re-run, apart from breakingChanges.test.ts, which also times out on main on this machine. CI is the full check.
  • Lint, typecheck and the UI build pass.

README and the site manual describe the check and its sources.

A new Hotspots check, with a context dimension of its own. It reads each
changed code file's commits in the year before the merge base and notes
files that had a change reverted in the last 90 days, keep needing
fixes, or change far more often than most. A hotspot ranks higher on the
review path and says why.

History comes from wherever it is: the repository for local reviews,
and the host for hosted ones, whose depth-1 fetch has none. GitHub
answers for up to 20 files in one GraphQL query, and GitLab lists each
file's commits. Offline, without a GitHub token, or in a shallow clone,
the check is listed as not run. It can be turned off in Settings, which
now also lists the file paths it sends to the host.
@github-actions

Copy link
Copy Markdown

Walkdiff

Note

No security findings from Built-in rules, Semgrep, gitleaks and Supply chain. These checks look for known patterns and secrets on the lines this PR adds, so this isn't a security audit.

At a glance
Changes 87 code units to review
Used elsewhere 100 places this PR did not touch use code it changed
Checks 11 ran: 1 with issues, 10 clean
Severity Finding Where
🟠 Medium Large change: 595 lines This PR

Open the full report. It's a single HTML file; if it downloads, open it in a browser.

Was this useful? React with 👍 or 👎.

@navasvarela
navasvarela merged commit 3cd7529 into main Nov 20, 2026
5 checks passed
@navasvarela
navasvarela deleted the feat/hotspots branch November 20, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant