refactor(review-enrichment): dedupe REES analyzer limit constants - #4164
Merged
Conversation
Factor the 25/2000 default findings-cap and line-length limits, repeated verbatim across 28 and 18 analyzer files respectively plus their registry.ts descriptors, into a shared review-enrichment/src/analyzers/limits.ts module. Analyzer-specific overrides (asset-weight's 50, heavy-dependency's 15, etc.) are left untouched. Also import complexity.ts's and deep-nesting.ts's own already-exported maxComplexity/maxDepth constants into registry.ts instead of repeating those two literals too. Extract complexity.ts's and error-swallow.ts's innermost pending/flush conditional into named helper functions -- both files' own diffs tripped the repo's own deep-nesting analyzer at depth 5 vs. the policed threshold of 4, confirmed via scanPatchForDeepNesting before and after this change. Regenerated analyzer-metadata.json / rees-analyzers.ts / .env.example via npm run rees:metadata (byte-identical -- only the source's use of named constants changed, not the underlying values). Closes #4163.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Contributor
|
Important 🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪 🔍 Gittensory is reviewing…AI analysis is in progress. This comment will update when the review is complete. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing |
24 tasks
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
const MAX_FINDINGS = 25;verbatim and 18 repeatconst MAX_LINE_CHARS = 2000;, plusregistry.ts's descriptors repeat the same two literals 28 and 18 times respectively.review-enrichment/src/analyzers/limits.tsexportingDEFAULT_MAX_FINDINGS = 25/DEFAULT_MAX_LINE_CHARS = 2000. Every file with the plain default now doesconst MAX_FINDINGS = DEFAULT_MAX_FINDINGS;(imported) instead of redeclaring the literal — zero usage-site churn, since the local identifier name is unchanged. Analyzer-specific overrides (asset-weight's 50, heavy-dependency's 15, migration-safety/loose-range's 20, undocumented-export/provenance's 30) are deliberately untouched — those are real per-analyzer tuning, not a duplicate worth centralizing.registry.ts's 50 descriptorlimits: {...}objects: replaced the exactmaxFindings: 25(28×) andmaxLineChars: 2000(18×) occurrences with the imported constants, via precise word-boundary matching that never touched a genuinely different value (15/20/30/50).maxDepth: 4andmaxComplexity: 10inregistry.tswere also duplicating a literal that each analyzer already exports as its own named constant (DEFAULT_MAX_DEPTHindeep-nesting.ts,DEFAULT_MAX_COMPLEXITYincomplexity.ts) — imported those instead of repeating the numbers a second time.review-enrichment/analyzer-metadata.json+apps/gittensory-ui/src/lib/rees-analyzers.ts+ the.env.examplegenerated block vianpm run rees:metadata— confirmed byte-identical (only the source's use of named constants changed, not the underlying values, so nothing downstream drifted).Separately, the same review noted
complexity.tsanderror-swallow.ts"themselves trip the repo's own deep-nesting threshold (depth 5 vs. 4)." Fixed both:complexity.ts: extracted the innermostif (pending) {...} else {...}block (continue-tracking vs. start-tracking a function) into a new top-leveladvancePendingFunctionhelper, called from a single flatifin the scan loop instead of a nested if/else.error-swallow.ts: same shape, split into two helpers (advancePendingCatchfor the continue-tracking branch,tryStartPendingCatchfor the immediate-finding-or-start-tracking branch), both returning a uniform{ pending, finding, findingLine }result so the scan loop's own body collapses to a ternary + one flatif.deep-nesting.tsanalyzer's own exportedscanPatchForDeepNestingfunction. The original diff (from merged PR feat(review): add REES complexity and Go/Python error-defect analyzers #4155) reports{"depth":5,"threshold":4}for both files — reproducing the exact finding the review described. The refactored diff reports zero findings for both.complexity.test.ts/error-swallow.test.ts/deep-nesting.test.tspass identically.Closes #4163.
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 #4163).Validation
git diff --checknpm run rees:test(the exact root-level command CI runs:npm ci --prefix review-enrichment+npm --prefix review-enrichment test, which itself chains build + sourcemap validation +generate-analyzer-metadata.mjs --check+ the full node test suite) — 1216/1216 tests passing, metadata check clean (no drift after regeneration).npm --prefix review-enrichment run build(tsc -p tsconfig.json) — clean, both before and after the rebase onto latestmain.scanPatchForDeepNesting.review-enrichment/**is outsidesrc/**/packages/**, so nocodecov/patchobligation — confirmed via.claude/skills/contributing-to-gittensory/reference.md.npm audit --audit-level=moderate— 0 vulnerabilities (review-enrichment's ownnpm cireported none; no new dependency was added anywhere in this PR).Safety
review-enrichmentis a standalone service with its own test suite; nosrc/apior MCP surface touched.)apps/gittensory-ui/src/lib/rees-analyzers.tsis a generated data file, regenerated byte-identical, not hand-edited.)UI Evidencesection below with screenshots. (N/A — no visible UI surface changed.)UI Evidence
Not applicable — this PR only touches
review-enrichment/src/analyzers/**plus the three files its own metadata generator regenerates (confirmed byte-identical).