refactor: reduce complexity of execute_impl in create_work_item.rs#1509
Merged
jamesadevine merged 1 commit intoJul 15, 2026
Merged
Conversation
Extract maybe_build_artifact_link_op helper to eliminate deep nesting in the artifact-link resolution block. The nested if-enabled → if-repo_name → match repo_id → match resolve chain (4 levels of nesting) is now a single call that returns Ok(None), Ok(Some((op,msg))), or Err(failure) — reducing the nesting depth of execute_impl from 7 to 4 and making the main execution path linear and easy to follow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jamesadevine
marked this pull request as ready for review
July 15, 2026 09:47
jamesadevine
deleted the
refactor/reduce-complexity-create-work-item-9282d502e72e3878
branch
July 15, 2026 09:54
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/safe_outputs/create_work_item.rshad a nesting depth of 7 — driven by the artifact-link resolution block, which stacked four layers of control flow:This made the artifact-link path hard to read and test in isolation.
What changed
Extracted a new async helper
maybe_build_artifact_link_opthat encapsulates the full artifact-link resolution logic and returns a tri-state:Ok(None)— linking disabledOk(Some((op, message)))— op built successfullyErr(ExecutionResult)— caller should short-circuit with a failureThe main
execute_implbody now calls it with a singlematchon three arms, reducing the nesting depth from 7 → 4 and making the execution path linear and easy to follow.Verification
cargo test)cargo clippy --all-targets --all-features)Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comSee Network Configuration for more information.