refactor: reduce complexity of execute_impl in update_work_item.rs#368
Merged
jamesadevine merged 1 commit intoApr 30, 2026
Merged
Conversation
Extract four focused helpers from the monolithic execute_impl: - check_target_config: validates the configured target constraint - check_field_permissions: data-driven table check replacing 7 sequential if-guards - check_prefix_guards: fetches the work item and verifies title-/tag-prefix rules - build_patch_document: assembles the JSON Patch operations execute_impl is now ~100 lines of linear, easy-to-follow orchestration; each extracted function has a single responsibility and is independently testable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jamesadevine
approved these changes
Apr 30, 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_implinsrc/safeoutputs/update_work_item.rswas a 245-line function with ~25 control-flow points. It mixed five distinct concerns inline:targetconstraintifguards)title-prefix/tag-prefixguardsWhat changed
Four focused helpers were extracted:
check_target_config(id, config)None(allowed) orSome(failure)based on the configured target pattern/IDcheck_field_permissions(params, config)(message, field_set, field_enabled)tuples — replaces 7 sequentialifguardscheck_prefix_guards(client, ..., config)build_patch_document(params, config)Vec<serde_json::Value>JSON Patch operationsexecute_implis now ~100 lines of linear orchestration that reads top-to-bottom without deep nesting.Before / after complexity
execute_impl+ 4 single-responsibility helpers, max 2 levels of nestingVerification
cargo build✅cargo test✅ (all tests pass)cargo clippy --all-targets --all-features✅ (no new warnings in the changed file)