chore: fix biome noExcessiveCognitiveComplexity warnings #458

Merged
xiaomo merged 1 commits from fix/444-biome-complexity-warnings into main 2026-05-24 07:30:42 +00:00
Owner

What

Refactored runBuiltinLoop function in packages/workflow-agent-builtin/src/loop.ts to reduce cognitive complexity from 30 to below 15.

Why

The function exceeded Biome's cognitive complexity threshold (noExcessiveCognitiveComplexity warning), making the code harder to understand and maintain.

Changes

Extracted helper functions from runBuiltinLoop:

  • shouldInjectDeadlineWarning: checks if deadline warning should be shown
  • shouldProcessToolCalls: determines if tool calls should be processed
  • extractFinalText: extracts last assistant message content
  • injectDeadlineWarning: injects deadline warning message
  • handleTextOnlyTurn: handles text-only turn logic
  • handleToolCallTurn: handles tool call turn logic
  • processLoopIteration: processes a single loop iteration

Added 24 new unit tests for the extracted helper functions, bringing total test count to 41 (all passing). All existing behavior is preserved.

Ref

Fixes #444

## What Refactored runBuiltinLoop function in packages/workflow-agent-builtin/src/loop.ts to reduce cognitive complexity from 30 to below 15. ## Why The function exceeded Biome's cognitive complexity threshold (noExcessiveCognitiveComplexity warning), making the code harder to understand and maintain. ## Changes Extracted helper functions from runBuiltinLoop: - shouldInjectDeadlineWarning: checks if deadline warning should be shown - shouldProcessToolCalls: determines if tool calls should be processed - extractFinalText: extracts last assistant message content - injectDeadlineWarning: injects deadline warning message - handleTextOnlyTurn: handles text-only turn logic - handleToolCallTurn: handles tool call turn logic - processLoopIteration: processes a single loop iteration Added 24 new unit tests for the extracted helper functions, bringing total test count to 41 (all passing). All existing behavior is preserved. ## Ref Fixes #444
xiaoju added 1 commit 2026-05-24 06:01:13 +00:00
Refactored runBuiltinLoop function to reduce cognitive complexity from 30 to below 15 by extracting helper functions:

- shouldInjectDeadlineWarning: checks if deadline warning should be shown
- shouldProcessToolCalls: determines if tool calls should be processed
- extractFinalText: extracts last assistant message content
- injectDeadlineWarning: injects deadline warning message
- handleTextOnlyTurn: handles text-only turn logic
- handleToolCallTurn: handles tool call turn logic
- processLoopIteration: processes a single loop iteration

Added 24 new unit tests for the extracted helper functions, bringing total test count to 41 (all passing). All existing behavior is preserved.

Fixes #444

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
xiaomo approved these changes 2026-05-24 07:30:41 +00:00
xiaomo left a comment
Owner

LGTM 👍 干净的重构,测试覆盖充分。turnsRemaining > 0 的新增检查是个好的 bugfix。

LGTM 👍 干净的重构,测试覆盖充分。`turnsRemaining > 0` 的新增检查是个好的 bugfix。
xiaomo merged commit 9440b9af82 into main 2026-05-24 07:30:42 +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#458