refactor(safe-outputs): reduce complexity of execute_impl in link_github_sub_issue.rs - #2116
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
…ecute_impl Split the 190-line execute_impl into focused helpers: - resolve_targets: resolve and validate parent/sub-issue targets - fetch_and_validate_metadata: fetch issue metadata and validate capability/mutation filters - check_existing_parent: preflight check for already-linked sub-issues - link_sub_issue: perform the addSubIssue mutation and validate the response No behaviour change; all 9 existing unit tests for this module pass unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
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
LinkGithubSubIssueResult::execute_implinsrc/safe_outputs/link_github_sub_issue.rswas flagged by Clippy'stoo_many_lineslint at 190/100 lines — the single highest non-test candidate after the two functions already at the top of the list (create_pull_request.rsandado_proxy/catalog.rs) had already been processed in prior runs.The function mixed together several distinct concerns in one long block: config/token validation, resolving and cross-checking the parent/sub-issue targets, fetching and validating GitHub issue metadata, a GraphQL preflight check for an existing parent, and finally performing the
addSubIssuemutation and validating its response.What changed
Extracted four well-named helper functions/methods, each owning one concern:
LinkGithubSubIssueResult::resolve_targets— resolves the parent/sub-issue targets viaresolve_github_issue_targetand validates they're in the same repository and are distinct issues.fetch_and_validate_metadata— fetches parent/sub-issue metadata and validates target capability + mutation filters.check_existing_parent— runs the GraphQL preflight query and returns an early success (already linked to the same parent) or failure (linked to a different parent), orNoneto proceed.link_sub_issue— performs theaddSubIssueGraphQL mutation and validates the response identifies the requested parent/sub-issue.execute_implitself is now a short, linear sequence of these calls with early returns, matching the original control flow and error messages exactly. No public API signatures changed and no behaviour changed.Verification
cargo build— succeeds.cargo test --bin ado-aw— all 3322 tests pass (0 failed), including all 9 existing tests for this module (link_github_sub_issue::tests::*), unchanged.cargo clippy --all-targets --all-features— clean, no warnings.clippy::too_many_linescheck scoped to this file — no warning remains (previously 190/100).Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.