Skip to content

feat(enrichment): floating-promise / unhandled-rejection analyzer #2023

Description

@JSONbored

New REES local analyzer (named in the #1499 epic 'Uncaught-rejection / floating-promise' idea) that flags newly-added async calls whose returned promise is neither awaited, returned, nor .catch()-chained on the same statement — a common silent-failure bug. Structural heuristic over added TS/JS lines, precision-first, no network. Scoped narrowly (single-statement expression call to a known-async/await-adjacent identifier) to keep false positives low.

Deliverables

  • Add FloatingPromiseFinding ({ file, line, call: string }) + floatingPromise? key to review-enrichment/src/types.ts (call name truncated, no full expression)
  • Create review-enrichment/src/analyzers/floating-promise.ts: match added statement lines that call a function returning a promise (e.g. bare foo.thenable() / somePromiseFn()) with no leading await/return and no trailing .catch/.then; conservative allowlist of promise-shaped call sites; cap with maxFindings
  • Register a local descriptor (category 'quality', cost 'local', requires ['files']) with inline render() in review-enrichment/src/analyzers/registry.ts
  • Add review-enrichment/test/floating-promise.test.ts covering a floating call flagged, awaited/returned/caught calls NOT flagged, non-JS/TS skip, and the cap

References

  • review-enrichment/src/analyzers/redos.ts (precision-first structural local analyzer)
  • review-enrichment/src/analyzers/registry.ts:158-175
  • gh issue 1499 lists 'Uncaught-rejection / floating-promise + error-swallow analyzer' as a speculative idea

Part of #1499.


size: S · gittensor:feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions