PhyberApex/kuroshiro

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

Open

#852 opened on Aug 22, 2026

 (0 comments) (0 reactions) (0 assignees)TypeScript (0 forks)auto 404
fallowgood first issueready-for-agent

Repository metrics

Stars
 (10 stars)
PR merge metrics
 (Avg merge 3d 2h) (92 merged PRs in 30d)

Description

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.

Contributor guide