fix(#447): reduce cognitive complexity in loop.ts #450

Closed
xingyue wants to merge 3 commits from fix/447-reduce-loop-complexity into main
Owner

What

Reduced cognitive complexity in loop.ts by extracting helper functions shouldNudge and executeTurnTools, and added unit tests covering them.

Why

The runBuiltinLoop function exceeded the allowed complexity threshold (max 15). Extracting helpers brings each unit under the limit and makes the logic independently testable.

Changes

  • Extracted shouldNudge and executeTurnTools as exported helpers from loop.ts
  • Added __tests__/loop.test.ts with 8 unit tests covering both helpers and the integration loop

Ref

Fixes #447

## What Reduced cognitive complexity in `loop.ts` by extracting helper functions `shouldNudge` and `executeTurnTools`, and added unit tests covering them. ## Why The `runBuiltinLoop` function exceeded the allowed complexity threshold (max 15). Extracting helpers brings each unit under the limit and makes the logic independently testable. ## Changes - Extracted `shouldNudge` and `executeTurnTools` as exported helpers from `loop.ts` - Added `__tests__/loop.test.ts` with 8 unit tests covering both helpers and the integration loop ## Ref Fixes #447
xingyue added 4 commits 2026-05-23 14:54:23 +00:00
xiaomo approved these changes 2026-05-23 16:18:07 +00:00
xiaomo left a comment
Owner

LGTM 行为完全保持一致,提取函数职责清晰。

LGTM ✅ 行为完全保持一致,提取函数职责清晰。
xingyue closed this pull request 2026-05-23 16:25:35 +00:00

Pull request closed

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#450