Skip to content

refactor(execute): split execute_safe_output dispatch into category helpers#388

Merged
jamesadevine merged 1 commit intomainfrom
refactor/execute-safe-output-complexity-54feab2c1438a8bb
May 3, 2026
Merged

refactor(execute): split execute_safe_output dispatch into category helpers#388
jamesadevine merged 1 commit intomainfrom
refactor/execute-safe-output-complexity-54feab2c1438a8bb

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 2, 2026

What was complex

execute_safe_output in src/execute.rs contained a single dispatch_executor_tools! macro invocation with 22 match arms covering every registered safe-output tool. Clippy's cognitive complexity lint measured this at 26/25 — just over the threshold — because macro expansions to match statements cause each arm to contribute to the score.

What changed

The flat 22-arm dispatch table is split into four focused async helpers grouped by tool category:

Helper Tools
dispatch_meta_tools noop, missing-tool, missing-data, report-incomplete
dispatch_work_item_tools create-work-item, comment-on-work-item, update-work-item, link-work-items, upload-workitem-attachment
dispatch_pr_tools create-pull-request, add-pr-comment, update-pr, submit-pr-review, reply-to-pr-review-comment, resolve-pr-thread
dispatch_resource_tools update-wiki-page, create-wiki-page, queue-build, create-git-tag, add-build-tag, create-branch, upload-build-artifact

A new find_tool_executor function chains them with early-return semantics. execute_safe_output itself now calls find_tool_executor and uses .ok_or_else(...) to handle the unknown-tool case cleanly without an if/else branch.

Before / After

  • Before: complexity 26/25 (Clippy warning), single 22-arm match in execute_safe_output
  • After: no Clippy cognitive complexity warnings anywhere in the codebase

Testing

  • cargo build
  • cargo test — all 8 tests pass ✓
  • cargo clippy --all-targets --all-features -W clippy::cognitive_complexity — zero warnings ✓

No behaviour changes.

Generated by Cyclomatic Complexity Reducer · ● 872.5K ·

…elpers

The 22-arm dispatch_executor_tools! call in execute_safe_output produced
a cognitive complexity score of 26/25 according to Clippy. Extract the
flat match table into four focused async helpers grouped by tool category:

- dispatch_meta_tools     (noop, missing-*, report-incomplete)
- dispatch_work_item_tools (create/comment/update/link work items, attachment)
- dispatch_pr_tools        (create/add/update PR, review, reply, resolve-thread)
- dispatch_resource_tools  (wiki, queue-build, git tag, branch, build artifact)

A new find_tool_executor helper chains them with early-return semantics so
execute_safe_output itself stays minimal. No behaviour changes; all tests pass
and Clippy reports zero cognitive complexity warnings after the change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jamesadevine jamesadevine marked this pull request as ready for review May 3, 2026 07:28
@jamesadevine jamesadevine merged commit 989449b into main May 3, 2026
@jamesadevine jamesadevine deleted the refactor/execute-safe-output-complexity-54feab2c1438a8bb branch May 3, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant