refactor(execute): split execute_safe_output dispatch into category helpers#388
Merged
jamesadevine merged 1 commit intomainfrom May 3, 2026
Conversation
…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
approved these changes
May 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was complex
execute_safe_outputinsrc/execute.rscontained a singledispatch_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 tomatchstatements 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:
dispatch_meta_toolsnoop,missing-tool,missing-data,report-incompletedispatch_work_item_toolscreate-work-item,comment-on-work-item,update-work-item,link-work-items,upload-workitem-attachmentdispatch_pr_toolscreate-pull-request,add-pr-comment,update-pr,submit-pr-review,reply-to-pr-review-comment,resolve-pr-threaddispatch_resource_toolsupdate-wiki-page,create-wiki-page,queue-build,create-git-tag,add-build-tag,create-branch,upload-build-artifactA new
find_tool_executorfunction chains them with early-return semantics.execute_safe_outputitself now callsfind_tool_executorand uses.ok_or_else(...)to handle the unknown-tool case cleanly without anif/elsebranch.Before / After
execute_safe_outputTesting
cargo build✓cargo test— all 8 tests pass ✓cargo clippy --all-targets --all-features -W clippy::cognitive_complexity— zero warnings ✓No behaviour changes.