Skip to content

feat(checker): add complexity-hints, a checker scoped to the change - #57

Merged
afterimaginary merged 2 commits into
mainfrom
feat/scoped-checker
Oct 26, 2026
Merged

afterimaginary merged 2 commits into
mainfrom
feat/scoped-checker

Conversation

@afterimaginary

Copy link
Copy Markdown
Owner

Closes #44

Summary

Adds a complexity-hints bin that runs the project's own Oxlint on a change and reports only what the change is responsible for, so an agent (or a pre-commit/CI gate) isn't asked to fix complexity it didn't touch. ADR-0006 records why; the behavior is in docs/specs/scoped-checker.md and the implementation in docs/designs/scoped-checker.md.

  • The change is every line that differs between the merge base with the default branch (origin/HEAD, else local main/master, or --base <ref>) and the working tree, plus untracked files whole. With no base it exits 2 rather than checking less.
  • cognitive-complexity: blocks when the change touches the function's own lines and the fix's target; a note when it touches only the function; nothing when it touches neither. --strict blocks on any touched function. The fallback fix targets the whole function.
  • max-params blocks when the parameter list changed. Other rules are left to the project's own lint.
  • Exit 0 (nothing blocks), 1 (something blocks), 2 (the check couldn't run). A setup failure is never read as a finding.

Changes

  • Node built-ins only; the package keeps no runtime dependencies.
  • The diff format is pinned against user git config (prefixes, relative paths, quoting, renames, external diff, color), and hunk content is skipped by count, so an added line reading +++ x isn't taken for a header.
  • vp is preferred over a plain oxlint and runs as vp lint, since only it reads vite.config.ts. A plain oxlint runs without VP_VERSION, which otherwise makes it skip .oxlintrc.json and lint with no rules.
  • The bin is built by vp pack (exports.bin), and the package checks cover dist/checker/cli.* and run --help on the built bin.

Verification

  • vp run ready: format, lint, typecheck and 100 tests pass.
  • tests/checker.test.ts (35 tests) runs the CLI against throwaway git repositories: block/note/--strict, untracked files, commits and --base, origin/HEAD, deletions, renames, nested functions, max-params across lines with non-ASCII text, warn severity, .vue positions, path and directory arguments, deleted/ignored/unlinted files, hostile git config, a header-like added line, a quoted path, and each setup error.
  • The tests for renames, header-like lines and quoted paths fail against the code before the review fixes.
  • Two /refine rounds on the plan and one on the implementation; findings applied.
  • Not run locally: Node 20 (the floor), which CI covers.

Plan deviations

None. The Claude Code hook and the README guidance follow in the next PR (#45).

afterimaginary and others added 2 commits October 26, 2026 08:38
Runs the project's Oxlint on the files changed since the merge base with
the default branch, and reports only the cognitive-complexity and
max-params diagnostics the change is responsible for: a function blocks
when the change touches both it and its fix's target, and is a note when
it touches only the function. --strict blocks on both.

Closes #44

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@afterimaginary
afterimaginary marked this pull request as ready for review October 26, 2026 15:47
@afterimaginary
afterimaginary merged commit 15233dc into main Oct 26, 2026
1 check passed
@afterimaginary
afterimaginary deleted the feat/scoped-checker branch October 26, 2026 15:47
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.

Scoped checker: report only what the change is responsible for

1 participant