refactor(cli): reduce cognitive complexity in setup.ts #453

Merged
xiaomo merged 1 commits from fix/445-reduce-setup-complexity into main 2026-05-23 16:18:10 +00:00
Owner

What

Refactored setup.ts in cli-workflow to reduce cognitive complexity by extracting inline logic into focused helper functions.

Why

The setup command contained deeply nested conditional logic that exceeded the maximum allowed cognitive complexity of 15, making it hard to read, test, and maintain.

Changes

  • Extracted provider prompt/validation logic into dedicated helper functions
  • Extracted agent alias configuration into a standalone function
  • Added setup-complexity.test.ts to verify the refactored helpers

Ref

Fixes #445

## What Refactored `setup.ts` in `cli-workflow` to reduce cognitive complexity by extracting inline logic into focused helper functions. ## Why The setup command contained deeply nested conditional logic that exceeded the maximum allowed cognitive complexity of 15, making it hard to read, test, and maintain. ## Changes - Extracted provider prompt/validation logic into dedicated helper functions - Extracted agent alias configuration into a standalone function - Added `setup-complexity.test.ts` to verify the refactored helpers ## Ref Fixes #445
xingyue added 1 commit 2026-05-23 16:14:56 +00:00
Extracts inline logic into focused helper functions to bring
each function under the complexity threshold.

Fixes #445
xiaomo approved these changes 2026-05-23 16:18:09 +00:00
xiaomo left a comment
Owner

LGTM 重构质量好,测试覆盖全面。

⚠️ Minor

ValidationResult 类型中 error 建议改为 error?: string | null 以匹配原始类型。不阻塞。

LGTM ✅ 重构质量好,测试覆盖全面。 ### ⚠️ Minor `ValidationResult` 类型中 `error` 建议改为 `error?: string | null` 以匹配原始类型。不阻塞。
xiaomo merged commit 335b8a4ae6 into main 2026-05-23 16:18:10 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#453