refactor(rees): migrate three analyzers off hand-rolled bounded-fetch onto boundedFetchText - #4821
Conversation
… onto boundedFetchText (#4759) doc-comment-drift.ts, exhaustiveness-drift.ts, and complexity-delta.ts each carried their own private "fetch a file at headSha, bounded/streamed read capped at 1MB" helper -- near-byte-identical copies of the same logic, none with a timeout or circuit breaker. duplication-delta.ts (#4741/#4760) already migrated onto the more mature boundedFetchText (external-fetch.ts): a typed ok/failure result, a per-endpoint-category circuit breaker, a configurable timeout, and byte-size capping. Mirror that same fetchFileAtHead call pattern -- including the options.analysis.fetchText fallback for when an AnalysisContext is available -- in all three instead of leaving three more hand-rolled copies to drift further. doc-comment-drift.ts also switches to the shared githubHeaders() helper in place of its own inline auth headers, closing the one pre-existing inconsistency among the three (the other two already used it). Pure fetch-mechanism migration -- verified byte-faithful via each analyzer's existing test suite passing unchanged, plus one new test per file exercising the added options.analysis branch (mirroring duplication-delta.test.ts's own coverage of that path).
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-11 01:32:32 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 6 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
…fetch onto boundedFetchText (#4947) undocumented-export.ts, unused-export.ts, and caller-impact.ts each still hand-rolled their own private readBoundedText + fetchFileAtHead wrapper for fetching a changed file's content at headSha, the same pattern doc-comment-drift.ts, exhaustiveness-drift.ts, and complexity-delta.ts had before #4759/PR #4821 migrated them onto the shared boundedFetchText helper. undocumented-export.ts also hand-built its own GitHub auth headers inline instead of the shared githubHeaders() helper, the same inconsistency doc-comment-drift.ts had before that PR. Deletes each file's private readBoundedText outright (never relocated), replaces the fetch path with boundedFetchText / options.analysis.fetchText (mirroring duplication-delta.ts's own fetchFileAtHead), and switches undocumented-export.ts onto githubHeaders(). unused-export.ts and caller-impact.ts already used githubHeaders() and only needed the boundedFetchText migration. No new shared module. Closes #4824
Summary
doc-comment-drift.ts,exhaustiveness-drift.ts, andcomplexity-delta.tseach hand-rolled their own private "fetch a repo file's content at a ref, bounded/streamed read capped at 1MB" helper.duplication-delta.ts(Real duplication-delta analyzer (before/after comparison) #4741/feat(rees): detect resolved duplication via before/after comparison #4760) already migrated onto the more matureboundedFetchText(external-fetch.ts— typed ok/failure result, per-endpoint-category circuit breaker, configurable timeout, byte-size capping), so this migrates all three onto that existing utility instead, deleting each file's ownreadBoundedText/bounded-fetch logic entirely. No new shared module is introduced.doc-comment-drift.tsalso switches to the sharedgithubHeaders()helper instead of hand-building its own auth headers inline (the other two analyzers already used it).fetchFileAtHead/fetchFileAtHeadShahelper mirrorsduplication-delta.ts's own reference implementation exactly, including theoptions.analysis?.fetchText(...)vs. directboundedFetchText(...)fallback and theendpointCategory/phase/subcallfield conventions.Verification
doc-comment-drift.test.ts,exhaustiveness-drift.test.ts,complexity-delta.test.ts) pass unchanged with zero logic edits — confirmed byte-faithful, including the oversized-response, streamed-cancel, and abort-timing edge cases already covered there.options.analysisbranch (mirroringduplication-delta.test.ts's own equivalent test), so that branch has real coverage rather than shipping untested.complexity-delta.test.tsthat named the now-deletedreadBoundedText's internal abort-polling as the mechanism under test were reworded to describe the actual post-migration mechanism (the analyzer's own outer post-fetch abort check) — no assertions changed.analyzer-metadata.jsondrift (pure fetch-mechanism refactor, no descriptor-shape change).npm run rees:testand the completenpm run test:ci(all steps, including the engine-parity/coverage steps called out as a specific risk for this change) both pass.Closes #4759