Skip to content

refactor: reduce cognitive complexity of dispatch and compile_pipeline_inner#831

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-dispatch-compile-fe1be6b8148f602b
Draft

refactor: reduce cognitive complexity of dispatch and compile_pipeline_inner#831
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-dispatch-compile-fe1be6b8148f602b

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 2, 2026

Summary

Two functions exceeded Clippy's cognitive_complexity threshold (25) and are refactored here by extracting well-named helper functions. No behaviour is changed.


src/audit/cli.rsdispatch (51 → below 25)

The dispatch function was doing five distinct jobs in one 275-line body. Four helpers are extracted:

Helper Responsibility
fetch_and_record_artifacts Lists and downloads all selected build artifacts; tracks auth-error state; records non-fatal failures as warnings
run_analyzers Runs all analysis passes (firewall, policy, MCP, OTel, safe-outputs, detection, missing-tools, jobs) over the downloaded artifacts
run_agent_output_analyzers Scoped to the agent_outputs artifact directory — firewall, policy, MCP, OTel passes
populate_performance_metrics Backfills perf metric fields from the already-populated firewall and MCP analysis results

After the refactor dispatch is a clean ~65-line orchestration function.


src/compile/mod.rscompile_pipeline_inner (26 → below 25)

Two small extractions:

Helper Responsibility
resolve_output_path Output path resolution: directory → default filename, explicit path → as-is, None<stem>.lock.yml
print_compile_success Prints the "Generated ... pipeline/template: ..." success line

Verification

  • All tests pass (cargo test)
  • Zero clippy::cognitive_complexity warnings remain (cargo clippy --all-targets --all-features -W clippy::cognitive_complexity)

Warning

Firewall blocked 2 domains

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

  • spsprodeus21.vssps.visualstudio.com
  • spsprodweu4.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"
    - "spsprodweu4.vssps.visualstudio.com"

See Network Configuration for more information.

Generated by Cyclomatic Complexity Reducer · sonnet46 3.5M ·

…e_inner

Extract helper functions to bring both functions below Clippy's
cognitive_complexity threshold (25):

audit/cli.rs dispatch (51 → below 25):
- fetch_and_record_artifacts: artifact listing/download loop with
  auth-error tracking
- run_analyzers: all analyzer passes over downloaded artifacts
- run_agent_output_analyzers: analyzers scoped to agent_outputs dir
- populate_performance_metrics: backfill perf fields from analysis results

compile/mod.rs compile_pipeline_inner (26 → below 25):
- resolve_output_path: output path resolution (dir vs file vs default)
- print_compile_success: success log line with pipeline/template label

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

0 participants