Skip to content

refactor(compile): reduce complexity of validate_github_issue_outputs_config in common.rs - #2229

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

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

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Clippy's cognitive_complexity lint (threshold 15) flagged validate_github_issue_outputs_config in src/compile/common.rs at 25/15 — the highest-complexity non-test function currently in the codebase.

The function mixed four distinct concerns in one body:

  1. Cross-tool require-approval lane consistency for temporary-issue-ID consumers.
  2. Per-tool repository-policy + mutation-filter validation, shared across all GitHub issue tools.
  3. A 12-arm match dispatching to each tool's dedicated config validator.
  4. Pipeline-injection checks scattered across create-github-issue and set-github-issue-type free-text fields.

Changes

Extracted five well-named helpers, each owning one concern:

  • validate_temporary_id_consumers_approval_lane — the create-github-issue / consumer approval-lane check.
  • validate_github_issue_tool_config — shared repo-policy + mutation-filter validation per tool.
  • dispatch_github_issue_tool_config_validation — the tool-name match dispatch (unchanged arms, just isolated).
  • validate_create_github_issue_injection — injection checks for create-github-issue's title prefix, labels, allowed-labels, assignees.
  • validate_set_github_issue_type_injection — injection checks for set-github-issue-type.allowed.

validate_github_issue_outputs_config now simply orchestrates these helpers in the same original order, preserving all early-return/?-propagation semantics.

Verification

  • cargo build — clean.
  • cargo test — full suite passes (all binaries/integration tests), no regressions.
  • cargo clippy --all-targets --all-features — clean, no new warnings.
  • Re-ran clippy::cognitive_complexity with threshold 15: validate_github_issue_outputs_config is no longer flagged (down from 25/15).

No public API, behavior, or error-message changes.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • releaseassets.githubusercontent.com
  • spsprodeus21.vssps.visualstudio.com

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

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

See Network Configuration for more information.

Generated by Cyclomatic Complexity Reducer · auto · 93.6 AIC · ⌖ 5.76 AIC · ⊞ 11K · ◷

…_config

Split the 25/15 cognitive-complexity function into five focused helpers:
- validate_temporary_id_consumers_approval_lane
- validate_github_issue_tool_config
- dispatch_github_issue_tool_config_validation
- validate_create_github_issue_injection
- validate_set_github_issue_type_injection

No behavior change; validate_github_issue_outputs_config now orchestrates
these helpers and is no longer flagged by clippy::cognitive_complexity.

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

Superseded by the stronger validation decomposition from #2236, now integrated and validated in #2238. Closing as superseded.

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