Skip to content

refactor(compile): reduce complexity of validate_github_issue_outputs_config - #2236

Closed
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-validate-github-issue-outputs-config-da980d3036c626ba
Closed

github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-validate-github-issue-outputs-config-da980d3036c626ba

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What

Refactors validate_github_issue_outputs_config in src/compile/common.rs, which Clippy flagged at cognitive complexity 25 (threshold 15), the highest in the codebase.

Why

The function mixed four unrelated concerns in one 135-line body: approval-lane checks, a per-tool loop with shared repo/mutation-filter policy validation, an 11-arm match dispatching to tool-specific validators, and two blocks of pipeline-injection checks. This made it hard to read, test in isolation, or extend with a new safe-output tool.

Changes

Extracted six focused helper functions, each with a single responsibility:

  • validate_create_github_issue_approval_lanes — approval-lane parity checks for temporary-ID consumers.
  • validate_github_issue_shared_policy — shared repository-policy and mutation-filter validation for one tool.
  • validate_github_issue_tool_specific_config — the per-tool match dispatch.
  • validate_github_issue_tools — loops over configured tools, calling the two helpers above.
  • validate_create_github_issue_injection — pipeline-injection checks for create-github-issue fields.
  • validate_set_github_issue_type_injection — pipeline-injection checks for set-github-issue-type.allowed.

validate_github_issue_outputs_config now just orchestrates these calls plus the final auth/permission lookups.

Behaviour

No behavior change — this is a pure decomposition. Every branch, error message, and validation order is preserved exactly.

Verification

  • cargo test --bin ado-aw — all 3359 tests pass (0 failures), including all pre-existing validate_github_issue_outputs_config-related tests unmodified.
  • cargo clippy --all-targets --all-features — clean, no warnings.
  • Cognitive complexity re-check: the orchestrator function is no longer flagged even at a cognitive-complexity-threshold of 10 (previously 25 at threshold 15). The highest-complexity extracted helper (validate_github_issue_tool_specific_config, an 11-arm dispatch match) is 13.

Before/after

Before After
validate_github_issue_outputs_config 25 not flagged (< 10)
Highest extracted helper n/a 13 (validate_github_issue_tool_specific_config)

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 · 102.5 AIC · ⌖ 11.8 AIC · ⊞ 11K · ◷

…_config

Splits the 135-line, cognitive-complexity-25 function into six focused
helpers:
- validate_create_github_issue_approval_lanes
- validate_github_issue_shared_policy
- validate_github_issue_tool_specific_config
- validate_github_issue_tools
- validate_create_github_issue_injection
- validate_set_github_issue_type_injection

validate_github_issue_outputs_config now just orchestrates these calls.
No behaviour change; all existing tests pass unmodified. Highest
remaining complexity among the extracted helpers is 13 (down from 25),
and the orchestrator itself is no longer flagged even at a
cognitive-complexity-threshold of 10.

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

Copy link
Copy Markdown
Azure Pipelines:
2 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

Integrated into #2238 as the canonical GitHub issue validation refactor and validated there. Closing this source PR as superseded by the aggregate.

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