feat(enrichment): doc-comment-vs-signature drift analyzer - #1794
Conversation
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-06-30 06:45:31 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 6 non-blocking
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.
|
a019120 to
21bacd8
Compare
abf9d13 to
a9ab1e9
Compare
632c2d0 to
088ad59
Compare
Add a REES analyzer that flags a verifiable doc-vs-code mismatch the PR introduced: a JSDoc/TSDoc `@param` tag that names a parameter the adjacent function no longer declares (a signature changed but the doc was left stale). The hunk often splits the doc block from the signature, so it fetches the full changed file at headSha (one authed contents fetch) and parses it. Deliberately conservative for precision: only NAMED `function` declarations whose parameters are confidently enumerable (any destructuring or arrow-default param → the function is skipped), only functions whose signature the PR actually changed (added lines), and only top-level `@param` names (nested `opts.x` tags reference an existing param and are ignored). Non-source and test files are skipped; missing token/headSha and any fetch error fail safe. Registered in the brief orchestrator and rendered as a public-safe block (file:line + symbol + the stale param names). Tests in their own file. Closes JSONbored#1519
088ad59 to
d971655
Compare
JSONbored
left a comment
There was a problem hiding this comment.
The most important remaining risk is a real false negative around optional JSDoc parameter syntax with defaults, where stale docs can be silently missed.
Please create a followup PR to resolve this as well. Approving.
…n doc-comment drift Follow-up to JSONbored#1794. `parseFunctionParams` split parameter lists on every top-level comma without tracking generic `<…>`, so a comma inside a generic type or default value (e.g. `cache = new Map<string, number>()` or `a: Map<K, V>`) split mid-generic, produced an unparseable fragment, and made the whole function skip — silently MISSING a documented-but-removed parameter (the false negative noted on the JSONbored#1794 review). Make `splitParams` generic-aware: a `<` with a balanced matching `>` is treated as one opaque generic argument list (its commas don't split), while a `<`/`>` with no match stays a comparison operator. This fixes the false negative, keeps comparison/arrow defaults enumerable, and removes the prior need to drop type-argument fragments. Adds unit + end-to-end regressions.
…n doc-comment drift Follow-up to JSONbored#1794. `parseFunctionParams` split parameter lists on every top-level comma without tracking generic `<…>`, so a comma inside a generic type or default value (e.g. `cache = new Map<string, number>()` or `a: Map<K, V>`) split mid-generic, produced an unparseable fragment, and made the whole function skip — silently MISSING a documented-but-removed parameter (the false negative noted on the JSONbored#1794 review). Make `splitParams` generic-aware: a `<` with a balanced matching `>` is treated as one opaque generic argument list (its commas don't split), while a `<`/`>` with no match stays a comparison operator. This fixes the false negative, keeps comparison/arrow defaults enumerable, and removes the prior need to drop type-argument fragments. Adds unit + end-to-end regressions.
…n doc-comment drift Follow-up to JSONbored#1794. `parseFunctionParams` split parameter lists on every top-level comma without tracking generic `<…>`, so a comma inside a generic type or default value (e.g. `cache = new Map<string, number>()` or `a: Map<K, V>`) split mid-generic, produced an unparseable fragment, and made the whole function skip — silently MISSING a documented-but-removed parameter (the false negative noted on the JSONbored#1794 review). Make `splitParams` generic-aware: a `<` with a balanced matching `>` is treated as one opaque generic argument list (its commas don't split), while a `<`/`>` with no match stays a comparison operator. This fixes the false negative, keeps comparison/arrow defaults enumerable, and removes the prior need to drop type-argument fragments. Adds unit + end-to-end regressions.
…n doc-comment drift Follow-up to JSONbored#1794. `parseFunctionParams` split parameter lists on every top-level comma without tracking generic `<…>`, so a comma inside a generic type or default value (e.g. `cache = new Map<string, number>()` or `a: Map<K, V>`) split mid-generic, produced an unparseable fragment, and made the whole function skip — silently MISSING a documented-but-removed parameter (the false negative noted on the JSONbored#1794 review). Make `splitParams` generic-aware: a `<` with a balanced matching `>` is treated as one opaque generic argument list (its commas don't split), while a `<`/`>` with no match stays a comparison operator. This fixes the false negative, keeps comparison/arrow defaults enumerable, and removes the prior need to drop type-argument fragments. Adds unit + end-to-end regressions.
…n doc-comment drift Follow-up to JSONbored#1794. `parseFunctionParams` split parameter lists on every top-level comma without tracking generic `<…>`, so a comma inside a generic type or default value (e.g. `cache = new Map<string, number>()` or `a: Map<K, V>`) split mid-generic, produced an unparseable fragment, and made the whole function skip — silently MISSING a documented-but-removed parameter (the false negative noted on the JSONbored#1794 review). Make `splitParams` generic-aware: a `<` with a balanced matching `>` is treated as one opaque generic argument list (its commas don't split), while a `<`/`>` with no match stays a comparison operator. This fixes the false negative, keeps comparison/arrow defaults enumerable, and removes the prior need to drop type-argument fragments. Adds unit + end-to-end regressions.
…n doc-comment drift Follow-up to JSONbored#1794. `parseFunctionParams` split parameter lists on every top-level comma without tracking generic `<…>`, so a comma inside a generic type or default value (e.g. `cache = new Map<string, number>()` or `a: Map<K, V>`) split mid-generic, produced an unparseable fragment, and made the whole function skip — silently MISSING a documented-but-removed parameter (the false negative noted on the JSONbored#1794 review). Make `splitParams` generic-aware: a `<` with a balanced matching `>` is treated as one opaque generic argument list (its commas don't split), while a `<`/`>` with no match stays a comparison operator. This fixes the false negative, keeps comparison/arrow defaults enumerable, and removes the prior need to drop type-argument fragments. Adds unit + end-to-end regressions.
…n doc-comment drift Follow-up to JSONbored#1794. `parseFunctionParams` split parameter lists on every top-level comma without tracking generic `<…>`, so a comma inside a generic type or default value (e.g. `cache = new Map<string, number>()` or `a: Map<K, V>`) split mid-generic, produced an unparseable fragment, and made the whole function skip — silently MISSING a documented-but-removed parameter (the false negative noted on the JSONbored#1794 review). Make `splitParams` generic-aware: a `<` with a balanced matching `>` is treated as one opaque generic argument list (its commas don't split), while a `<`/`>` with no match stays a comparison operator. This fixes the false negative, keeps comparison/arrow defaults enumerable, and removes the prior need to drop type-argument fragments. Adds unit + end-to-end regressions.
…n doc-comment drift Follow-up to JSONbored#1794. `parseFunctionParams` split parameter lists on every top-level comma without tracking generic `<…>`, so a comma inside a generic type or default value (e.g. `cache = new Map<string, number>()` or `a: Map<K, V>`) split mid-generic, produced an unparseable fragment, and made the whole function skip — silently MISSING a documented-but-removed parameter (the false negative noted on the JSONbored#1794 review). Make `splitParams` generic-aware: a `<` with a balanced matching `>` is treated as one opaque generic argument list (its commas don't split), while a `<`/`>` with no match stays a comparison operator. This fixes the false negative, keeps comparison/arrow defaults enumerable, and removes the prior need to drop type-argument fragments. Adds unit + end-to-end regressions.
…n doc-comment drift (#1875) Follow-up to #1794. `parseFunctionParams` split parameter lists on every top-level comma without tracking generic `<…>`, so a comma inside a generic type or default value (e.g. `cache = new Map<string, number>()` or `a: Map<K, V>`) split mid-generic, produced an unparseable fragment, and made the whole function skip — silently MISSING a documented-but-removed parameter (the false negative noted on the #1794 review). Make `splitParams` generic-aware: a `<` with a balanced matching `>` is treated as one opaque generic argument list (its commas don't split), while a `<`/`>` with no match stays a comparison operator. This fixes the false negative, keeps comparison/arrow defaults enumerable, and removes the prior need to drop type-argument fragments. Adds unit + end-to-end regressions. Co-authored-by: Nick M <274344962+nickmopen@users.noreply.github.com>
Summary
Adds a REES analyzer (#1519) that flags a verifiable doc-vs-code mismatch the PR introduced: a JSDoc/TSDoc
@paramtag naming a parameter the adjacent function no longer declares (the signature changed but the doc was left stale). The hunk often splits the doc block from the signature, so it fetches the full changed file atheadSha(one authed contents fetch) and parses it. Additive + fail-safe — fills its owndocCommentDriftfindings key.Deliberately conservative for precision (no fuzzy guessing):
functiondeclarations whose parameters are confidently enumerable — any destructuring ({ }/[ ]) or arrow-default param makes the set ambiguous, so the whole function is skipped.@paramnames; nested@param opts.xtags reference an existing param and are ignored.headShaor any fetch error fails safe (no finding).Implementation (established
review-enrichment/pattern)DocCommentDriftFindingtype +docCommentDrift?key insrc/types.tssrc/analyzers/doc-comment-drift.ts— pure helpers (addedLineNumbers,parseDocParams,parseFunctionParams,findDocCommentDrift) +scanDocCommentDrift(req, fetch, opts); reuses the codeowners-stylecontentsfetchsrc/brief.tsANALYZERS registrysrc/render.ts(file:line + symbol + stale param names only)node:testunits in a separatetest/doc-comment-drift.test.tsValidation
From
review-enrichment/(Node 24):Covers added-line parsing, doc/param extraction (typed/optional/nested/rest/
this/generics-with-comma), destructuring→skip, multi-line signatures, untouched-function exclusion, fail-safe fetch (missing token/headSha, non-ok, throw, abort), non-source skip, and the rendered block.Closes #1519