PhyberApex/kuroshiro

refactor(api): ScreensService.add complexity and duplicated screen lookup

Aperta

#852 aperta il 22 ago 2026

 (0 commenti) (0 reazioni) (0 assegnatari)TypeScript (0 fork)auto 404
fallowgood first issueready-for-agent

Metriche repository

Star
 (10 stelle)
Metriche merge PR
 (Merge medio 3g 2h) (92 PR mergiate in 30 g)

Descrizione

Problem Statement

packages/api/src/screens/screens.service.ts:

  • add (line 34): cyclomatic 16, cognitive 18, 71 lines — high (fallow health)
  • Clone group: delete (116-121) and updateExternalScreen (180-185) both do "find screen with device relation, warn + NotFoundException('Screen not found')".

Solution

  • Extract private async findScreenWithDevice(id): Promise<Screen> that throws the NotFoundException, and use it from delete, updateExternalScreen and any other method doing the same lookup.
  • Split add into the branches it handles (upload vs external link vs plugin/mashup source) as private methods so the public method is a dispatcher.
  • screens/__test__ specs stay green.

Verification

  • pnpm lint && pnpm type-check && pnpm test pass
  • Run pnpm fallow:baseline in the same PR so the finding disappears from .fallow-baselines/, then confirm pnpm fallow:ci passes. Never add new findings to a baseline; see docs/agents/fallow.md.

Found by the initial fallow scan (pnpm fallow) on 2026-08-22 and baselined so CI stays green until this is fixed.

Guida contributor