Skip to content

feat(enrichment): empty-catch / error-swallow analyzer#3541

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bohdansolovie:feat/enrichment-error-swallow-2014-v5
Jul 5, 2026
Merged

feat(enrichment): empty-catch / error-swallow analyzer#3541
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bohdansolovie:feat/enrichment-error-swallow-2014-v5

Conversation

@bohdansolovie

Copy link
Copy Markdown
Contributor

Summary

Fixes #2014

  • Add ErrorSwallowFinding and a local errorSwallow analyzer that flags newly-added catch/except blocks that swallow errors: empty body, unused binding, or bare return null
  • Brace-balanced catch-body extraction for single-line and multi-line added hunks; JS/TS optional-binding catch {} and Python except: pass supported
  • Binding references use identifier-boundary lookarounds (including $ in valid JS identifiers), not \b word boundaries
  • Register the analyzer in the REES registry with render/docs/metadata; sync src/review/enrichment-analyzer-names.ts and generated .env.example / UI metadata
  • Add review-enrichment/test/error-swallow.test.ts covering empty/return-null/unused-binding cases, log/rethrow/$-binding/nested-brace non-flags, multiline catches, cap, and public-safe brief rendering

Test plan

  • cd review-enrichment && npm run build && npm run metadata && node --test test/error-swallow.test.ts test/analyzer-registry.test.ts
  • CI validate-code

Made with Cursor

Fixes JSONbored#2014

Co-authored-by: Cursor <cursoragent@cursor.com>
@bohdansolovie bohdansolovie requested a review from JSONbored as a code owner July 5, 2026 16:28
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-05 16:34:03 UTC

10 files · 1 AI reviewer · no blockers · readiness 80/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
Adds the `errorSwallow` enrichment analyzer end-to-end: a new `error-swallow.ts` pure-compute module, `ErrorSwallowFinding` type, registry/render/metadata/UI/names/env-example wiring, and a solid test file. The core logic is correct: `parseCompleteCatchLine` brace-balances single-line catches, `scanPatchForErrorSwallow` accumulates multi-line pending blocks with the same balance approach, `referencesBinding` uses identifier-boundary lookarounds (`[A-Za-z0-9_$]`) instead of `\b` so `$`-prefixed bindings work, and the known limitation (string-literal braces are not stripped) is explicitly documented. All registration touchpoints are synchronized. No correctness or data-integrity defects are visible.

Nits — 5 non-blocking
  • registry.ts:1117 and apps/gittensory-ui/src/lib/rees-analyzers.ts:1039-1040 hardcode `25` and `2000` as inline literals; `error-swallow.ts` keeps them as unexported module constants (`MAX_FINDINGS`, `MAX_LINE_CHARS`), so the registration sites can't import them — either export the constants or at minimum add a comment tying the values back to the source file so they don't drift.
  • referencesBinding (error-swallow.ts) calls `new RegExp(...)` on every invocation; since this runs inside a per-line loop over patch content, compile the regex once per unique binding name rather than re-creating it each call.
  • The innermost pending-tracking branch of `scanPatchForErrorSwallow` reaches depth 5 (flagged by the analyzer's own deep-nesting rule at error-swallow.ts:84) — extracting the `maybeStartPending` logic into a small helper would both flatten this and make the function easier to follow.
  • test/error-swallow.test.ts has no test for a catch that uses a `$`-prefixed binding (e.g., `catch ($err) { handle($err); }`) to confirm the custom lookaround fires correctly; a single assert in the existing 'does not flag' test would close the gap.
  • Python `except ValueError: pass` (no `as` binding) is classified as `empty-catch` rather than something like `pass-body`; this is defensible but slightly misleading since the body isn't empty — add a brief comment to `bodySwallowsError` explaining the intentional classification.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2014
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 (1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 318 registered-repo PR(s), 186 merged, 9 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bohdansolovie; Gittensor profile; 318 PR(s), 9 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: bohdansolovie
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: Python, C++, JavaScript
  • Official Gittensor activity: 318 PR(s), 9 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Await review-lane availability.
  • Refresh registry data or choose a registered active repo.
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

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@1fbe48a). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3541   +/-   ##
=======================================
  Coverage        ?   93.10%           
=======================================
  Files           ?      302           
  Lines           ?    31504           
  Branches        ?    11504           
=======================================
  Hits            ?    29333           
  Misses          ?     1517           
  Partials        ?      654           
Files with missing lines Coverage Δ
src/review/enrichment-analyzer-names.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb loopover-orb Bot merged commit 4aa3f64 into JSONbored:main Jul 5, 2026
9 checks passed
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

None yet

Development

Successfully merging this pull request may close these issues.

feat(enrichment): empty-catch / error-swallow analyzer

1 participant