PhyberApex/kuroshiro
refactor(api): ScreensService.add complexity and duplicated screen lookup
Open
#852 opened on Aug 22, 2026
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) andupdateExternalScreen(180-185) both do "find screen with device relation, warn +NotFoundException('Screen not found')".
Solution
- Extract
private async findScreenWithDevice(id): Promise<Screen>that throws theNotFoundException, and use it fromdelete,updateExternalScreenand any other method doing the same lookup. - Split
addinto 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 testpass- Run
pnpm fallow:baselinein the same PR so the finding disappears from.fallow-baselines/, then confirmpnpm fallow:cipasses. Never add new findings to a baseline; seedocs/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.