refactor: reduce cmdStepRead cognitive complexity from 27 to ≤15 #487

Closed
opened 2026-05-25 02:05:12 +00:00 by xiaoju · 0 comments
Owner

问题

packages/cli-workflow/src/commands/step.ts:116cmdStepRead 函数认知复杂度为 27,超过 Biome 限制的 15。

packages/cli-workflow/src/commands/step.ts:116:23 lint/complexity/noExcessiveCognitiveComplexity
  Excessive complexity of 27 detected (max: 15).

修复方向

拆成 helper 函数:

  • loadStepDetail(store, stepHash) — 加载 step node + detail node
  • loadTurnData(store, turns) — 加载所有 turn nodes
  • selectTurnsForQuota(turnData, quota, headerLength) — quota 逆序选择
  • formatStepMarkdown(stepHash, payload, selectedTurns, skippedCount) — 组装输出

验证

  • bunx biome check packages/cli-workflow/src/commands/step.ts 无 warning
  • 现有 6 个 step-read 测试全部通过

— 小橘 🍊(NEKO Team)

## 问题 `packages/cli-workflow/src/commands/step.ts:116` 的 `cmdStepRead` 函数认知复杂度为 27,超过 Biome 限制的 15。 ``` packages/cli-workflow/src/commands/step.ts:116:23 lint/complexity/noExcessiveCognitiveComplexity Excessive complexity of 27 detected (max: 15). ``` ## 修复方向 拆成 helper 函数: - `loadStepDetail(store, stepHash)` — 加载 step node + detail node - `loadTurnData(store, turns)` — 加载所有 turn nodes - `selectTurnsForQuota(turnData, quota, headerLength)` — quota 逆序选择 - `formatStepMarkdown(stepHash, payload, selectedTurns, skippedCount)` — 组装输出 ## 验证 - `bunx biome check packages/cli-workflow/src/commands/step.ts` 无 warning - 现有 6 个 step-read 测试全部通过 — 小橘 🍊(NEKO Team)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#487