Skip to content

fix(enrichment): enumerate generic-typed and generic-default params in doc-comment drift - #1875

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
nickmopen:fix/enrichment-doc-drift-generic-default-params
Jun 30, 2026
Merged

fix(enrichment): enumerate generic-typed and generic-default params in doc-comment drift#1875
JSONbored merged 1 commit into
JSONbored:mainfrom
nickmopen:fix/enrichment-doc-drift-generic-default-params

Conversation

@nickmopen

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1794, addressing the false negative called out on its review:

The most important remaining risk is a real false negative around optional JSDoc parameter syntax with defaults, where stale docs can be silently missed.

Root cause (signature side, not the doc side). parseFunctionParams split a parameter list on every top-level comma without tracking generic <…>. So a comma inside a generic type or default value split the list mid-generic:

export function f(cache = new Map<string, number>()) {}
//                                       ^ this comma split the param list

That produced an unparseable fragment, parseFunctionParams returned null, and the whole function was skipped — so a documented-but-removed sibling parameter was silently missed (no drift reported).

Fix

Make splitParams generic-aware: on <, look ahead for a balanced matching >. If found, the <…> is treated as one opaque generic argument list (its commas don't split — Map<K, V> stays one segment). If there's no match, the </> is a comparison/arrow operator and is ignored. This:

  • fixes the false negative (generic-typed and generic-default params now enumerate),
  • keeps comparison defaults (max > 0 ? …) and callback/arrow defaults enumerable, and
  • removes the previous need to drop type-argument fragments (no fabricated names).

Validation

From review-enrichment/ (Node 24):

npm test   # build + node --test: 290 pass / 0 fail

New coverage: parseFunctionParams on Map<K, V>, Map<K, readonly V[]>, new Map<string, number>() defaults, and nested generics; plus an end-to-end scanDocCommentDrift regression where a removed-and-documented param sits beside a sibling with a new Map<string, number>() default and is now correctly reported.

@nickmopen
nickmopen requested a review from JSONbored as a code owner June 30, 2026 13:00
@dosubot dosubot Bot added the size:M label Jun 30, 2026
@loopover-orb

loopover-orb Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-06-30 19:10:19 UTC

2 files · 1 AI reviewer · no blockers · readiness 66/100 · CI green · unknown

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This change makes the parameter splitter aware of balanced generic angle-bracket regions and adds focused regression coverage for generic type annotations, generic defaults, and comparison defaults. The visible implementation is coherent with the analyzer’s conservative contract: valid generic comma cases now enumerate, while malformed or ambiguous signatures either continue splitting normally or fail closed. The notable detail is that `matchAngle` deliberately uses the token after the matching `>` to avoid treating normal comparison operators as generic closes, and the new tests exercise the high-risk no-space comparison paths.

Nits — 5 non-blocking
  • nit: `review-enrichment/src/analyzers/doc-comment-drift.ts:122` uses a Unicode minus sign in the doc comment (`−1`) while the file otherwise sticks to ASCII punctuation, so I would change it to `-1` for consistency.
  • nit: `review-enrichment/src/analyzers/doc-comment-drift.ts:140` only treats one preceding backslash as an escape in string literals, so escaped-backslash-then-quote cases inside a generic type string are not modeled precisely; this is unlikely for parameter signatures but worth keeping in mind if this parser grows.
  • `review-enrichment/test/doc-comment-drift.test.ts:142` already covers object and function type arguments; add one explicit escaped-string-literal case only if you intend `matchAngle` to be robust beyond normal TypeScript type syntax.
  • `review-enrichment/src/analyzers/doc-comment-drift.ts:153` would be easier to audit if the accepted terminator character set from the comment lived in a named helper or constant rather than an inline regex.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (size label size:M; no linked issue context).
Validation posture ❌ 5/25 Preflight is holding this PR; address the blocker before review.
Contributor workload ✅ 10/10 Author activity: 90 registered-repo PR(s), 61 merged, 1 issue(s).
Contributor context ✅ Confirmed Gittensor contributor nickmopen; Gittensor profile; 90 PR(s), 1 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: nickmopen
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: TypeScript
  • Official Gittensor activity: 90 PR(s), 1 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Explain no-issue PR.
  • Fix the blocker.
  • Triage stale or unlinked PRs.
  • Refresh registry data or choose a registered active repo.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jun 30, 2026
@nickmopen
nickmopen force-pushed the fix/enrichment-doc-drift-generic-default-params branch 7 times, most recently from 4a61f5c to 0a98bf0 Compare June 30, 2026 16:06
…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.
@dosubot dosubot Bot added the lgtm label Jun 30, 2026
@JSONbored
JSONbored merged commit bef3c28 into JSONbored:main Jun 30, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants