PhyberApex/kuroshiro

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

开放

#852 创建于 2026年8月22日

 (0 条评论) (0 个反应) (0 位负责人)TypeScript (0 个派生)auto 404
fallowgood first issueready-for-agent

仓库指标

星标
 (10 个星标)
PR 合并指标
 (平均合并 3天 2小时) (30 天内合并 92 个 PR)

描述

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.

贡献者指南