feat(enrichment): add static analysis + complexity analyzer (#1477) - #1806
feat(enrichment): add static analysis + complexity analyzer (#1477)#1806Daedalus-Icarus wants to merge 1 commit into
Conversation
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review result - reject/close recommendedReview updated: 2026-06-30 03:45:13 UTC
🛑 Suggested Action - Reject/Close
Review summary Blockers
Nits — 6 non-blocking
Why this is blocked
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.
|
ba1045d to
6f971db
Compare
6f971db to
7ee4524
Compare
Summary
Adds two REES analyzers that perform static-defect detection and cyclomatic-complexity estimation directly on the changed lines of each source file in the diff (#1477).
staticLintscans added lines for common static-defect patterns, gated by language detection:no-eval,no-debugger,no-console,no-empty-catch,eqeqeq(==vs===),no-unawaited-call,no-varno-bare-exceptEach rule is a flat linear-time regex tested against a single added line — no nested quantifiers, no backtracking risk. Capped at 25 findings (configurable via
maxFindings); one finding per line (first matching rule wins). Language detection gates which rules apply so non-source files are skipped.complexityestimates cyclomatic complexity per changed function by counting decision keywords (if,else if,for,while,case,catch,&&,||,?). Functions with cyclomatic >= 10 are flagged (matches ESLint default threshold). Detects function declarations from BOTH added lines AND context lines — so adding decision logic inside an existing unchanged function is correctly counted. Includeschurn(added-line count in the function).Both analyzers are pure and deterministic — no external tools, no repo checkout, no network. They degrade independently (a timeout/abort marks only that analyzer
degraded).Updated from the prior review — the blocker (complexity scanner only detected functions on added lines, missing the most common case) and all 5 nits are addressed:
braceDepthtracks per-functionbaseDepthinstead of a global zero, so function-end detection works inside nested blocks.no-floating-promiserenamed tono-unawaited-callwith a softer, best-effort message.else ifdecision count locked with explicit tests (= 1 decision).> 10to>= 10(matches ESLint default).Closes #1477.
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocallynpm 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/(a standalone package with its owntsconfig.json,node:testrunner, andpackage.json). It is outside the workersrc/**/*.tsCodecov scope and vitest scope. The worker-side checks do not exercise or regress from this change.npm test-> 231/232 pass (15 new; 1 pre-existingsentry-uploadenv failure),tsc-> exit 0.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.UI Evidence
Not applicable — backend REES analyzers, no visible UI/frontend/docs/extension surface.
Notes
if/for/&&logic inside an existing function whosefunction foo() {declaration is just diff context. The scanner tracksbaseDepth(the brace depth at the function opening) so function-end detection works correctly even inside nested blocks/classes.no-unawaited-calluses a conservative heuristic — it may produce false positives on synchronous calls, but the softer message ("if this returns a Promise") reflects the best-effort nature.{ file, line, rule, severity, message }and{ file, function, cyclomatic, churn }carry no source content or variable values. Render blocks route file paths throughsafeCodeSpanand messages throughpromptText.MAX_LINT_FINDINGS=25,MAX_COMPLEXITY_FINDINGS=10,COMPLEXITY_THRESHOLD=10) are committed as named constants.