Skip to content

refactor(safe-outputs): reduce complexity of execute_impl in create_github_issue.rs - #2181

Closed
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-create-github-issue-fecf71beabc1e10e
Closed

github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-create-github-issue-fecf71beabc1e10e

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What

CreateGithubIssueResult::execute_impl in src/safe_outputs/create_github_issue.rs was flagged by Clippy's too_many_lines lint at 168/100 lines. This PR extracts three logically distinct blocks into dedicated helper functions, with no behavioural change:

  • validate_agent_labels(labels, config) -> Result<(), String> — the allowed-labels allowlist check (default-deny semantics, wildcard support, disallowed-label error formatting).
  • build_final_title(title, config) -> Result<String, String> — applies title-prefix and enforces MAX_FINAL_TITLE_LEN.
  • CreateGithubIssueResult::handle_issue_response(ctx, target_repo, response) -> anyhow::Result<ExecutionResult> — interprets the GitHub API response (success/failure, issue number/URL extraction, temporary_id registration).

execute_impl itself is now a straight-line sequence of guard checks followed by delegation to these helpers, which are independently readable and (in principle) independently testable.

Before / after

  • Before: clippy::too_many_lines warning, 168/100 lines, on execute_impl.
  • After: no too_many_lines (or any other) Clippy warning for this file.

Verification

  • cargo check --all-targets — clean.
  • cargo clippy --all-targets --all-features — clean, no warnings anywhere in the crate.
  • cargo test --bin ado-aw — full suite: 3360 passed, 0 failed, 1 ignored.
  • cargo test --bin ado-aw create_github_issue — all 46 module tests pass unchanged.
  • rustfmt applied to the touched file only; no unrelated formatting changes.

No public API signatures changed; no observable behaviour changed.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • spsprodeus21.vssps.visualstudio.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "spsprodeus21.vssps.visualstudio.com"

See Network Configuration for more information.

Generated by Cyclomatic Complexity Reducer · auto · 93.1 AIC · ⌖ 11.7 AIC · ⊞ 10.2K ·

…ithub_issue.rs

Extract label validation, title-prefix/length enforcement, and API
response handling into dedicated helper functions:
- validate_agent_labels(): allowed-labels allowlist check
- build_final_title(): applies title-prefix and enforces MAX_FINAL_TITLE_LEN
- CreateGithubIssueResult::handle_issue_response(): interprets the GitHub
  API response and registers temporary_id on success

No behavioural changes; all 46 module tests and the full 3360-test suite
pass, and clippy is clean. The clippy::too_many_lines warning (168/100)
on execute_impl no longer fires.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
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.

@jamesadevine

Copy link
Copy Markdown
Collaborator

Closed as partially superseded by aggregate PR #2189, which retains the isolated create_github_issue complexity refactor. Unrelated or overlapping cumulative changes were intentionally omitted.

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