refactor(review-enrichment): dedupe githubHeaders() across 17 analyzers - #4675
Merged
Conversation
17 of 63 review-enrichment analyzer files hand-copied a private githubHeaders()
helper that had drifted into 4 shapes: 11 sent no User-Agent, 3 added a
User-Agent plus a local GITHUB_API_VERSION constant, 1 hardcoded Accept to
raw-only (unable to ever request JSON), and 2 reinvented a raw-toggle param a
4th way.
Add one exported githubHeaders(token, opts?: { raw?: boolean }) in a new
review-enrichment/src/github-headers.ts, using the most complete existing
shape (Accept toggle + GITHUB_API_VERSION + User-Agent) as the target, and
replace all 17 call sites with an import. Positional-boolean callers
(caller-impact.ts, unused-export.ts) move to the opts-object form; the
raw-only exhaustiveness-drift.ts call now explicitly passes { raw: true },
preserving its existing behavior while making the file capable of requesting
JSON like every other analyzer.
Entirely self-contained within review-enrichment (own tsconfig, own build,
own Railway deploy) -- no cross-service-boundary risk. Validated with
npm run rees:test (build, sourcemap check, analyzer-metadata drift check,
and the full node:test suite -- 1223 passing, 0 failing) plus a dedicated
test/github-headers.test.ts covering the new shared helper's default,
raw, and empty-opts branches.
Fixes #4609.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
This was referenced Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
review-enrichment/src/analyzers/*.tsfiles hand-copied a privategithubHeaders()helper that had drifted into 4 shapes: 11 files sent noUser-Agent, 3 added aUser-Agentplus a localGITHUB_API_VERSIONconstant, 1 (exhaustiveness-drift.ts) hardcodedAcceptto raw-only (unable to ever request JSON), and 2 reinvented a raw-toggle param a 4th way.githubHeaders(token: string, opts?: { raw?: boolean }): Record<string, string>in a newreview-enrichment/src/github-headers.ts, using the most complete existing shape (Accept toggle +GITHUB_API_VERSION+User-Agent) as the target shape.GITHUB_API_VERSIONconst in the 5 files that had one).truefor raw content (caller-impact.ts,unused-export.ts) now pass{ raw: true }.exhaustiveness-drift.ts's one call site now explicitly passes{ raw: true }too, preserving its existing runtime behavior (it fetches raw file content) while closing the structural gap called out in the issue — it can now request JSON like every other analyzer, it just doesn't need to today.approval-integrity.ts,blame-link.ts,churn-hotspot.ts,commit-hygiene.ts,commit-lint.ts,commit-signature.ts,coverage-delta.ts,flaky-test.ts,pending-review-requests.ts,revert-recurrence.ts,stale-branch.ts,asset-weight.ts,duplication-scan.ts,history.ts,exhaustiveness-drift.ts,caller-impact.ts,unused-export.ts.review-enrichment/(owntsconfig.json, own build, own Railway deploy) — no cross-service-boundary risk, no version-bump ceremony.Fixes #4609.
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragenpm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
review-enrichment/**, which has its owntsconfig.json(not included by the roottsconfig.json) and its ownnode --testsuite (not matched by the root vitesttest/**/*.test.tsinclude), so the rootactionlint/typecheck/test:coverage/test:workers/build:mcp/test:mcp-pack/ui:*checks are structurally unaffected by this diff and were not re-run. The actual CI check for this change isrees:test, which I ran directly:npm run rees:test(build +validate:sourcemaps+generate-analyzer-metadata.mjs --check+ the fullnode:testsuite) — 1223 passing, 0 failing, including a newtest/github-headers.test.tscovering the shared helper's default/raw/empty-opts branches. Ran once before the final rebase and again immediately after rebasing onto latestorigin/main, both green.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.The four unchecked Safety boxes are not applicable: this PR touches no auth/cookie/CORS/GitHub App/Cloudflare/session code, no API/OpenAPI/MCP surface, no UI, and no docs/changelog — it is a pure internal header-builder consolidation inside
review-enrichment/src/analyzers/.UI Evidence
Not applicable — no UI/frontend/docs changes.
Notes
refactor(review-enrichment): dedupe REES analyzer limit constants), which consolidated another cross-analyzer constant duplication the same way.