Skip to content

refactor(compile): reduce complexity of build_conclusion_job in agentic_pipeline.rs - #2037

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-build-conclusion-job-d7eab08c2bf11996
Draft

refactor(compile): reduce complexity of build_conclusion_job in agentic_pipeline.rs#2037
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-build-conclusion-job-d7eab08c2bf11996

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What was complex

build_conclusion_job in src/compile/agentic_pipeline.rs was flagged by Clippy's too_many_lines lint at 195/100 lines. It mixed several distinct concerns in one function body: building the Conclusion job's steps, applying per-tool (noop/missing-tool/missing-data) config as flat env vars, and hoisting upstream job results (Agent/Detection/SafeOutputs[/_Reviewed]/custom jobs) into job-level variables + step env wiring.

What changed

Extracted two well-named helper functions, keeping build_conclusion_job's public signature and behavior unchanged:

  • apply_conclusion_tool_config_env — applies a single per-tool config (noop / missing-tool / missing-data) onto the Conclusion step as flat AW_<TOOL>_* env vars, using early returns (let-else) instead of nested if let chains.
  • hoist_conclusion_job_results — hoists upstream job $[dependencies...] results into job-level JobVariables and wires the corresponding $(name) macro env vars onto the Conclusion step, returning (Vec<JobVariable>, BashStep).

build_conclusion_job now calls these helpers in a loop / single call instead of inlining ~150 lines of logic.

Before / after

  • Before: build_conclusion_job flagged at 195/100 lines by clippy::too_many_lines.
  • After: the function no longer appears in the too_many_lines clippy report for this file at all.

Verification

  • cargo test --bin ado-aw — all 3229 tests pass (1 ignored, unrelated to this change).
  • cargo clippy --all-targets --all-features — clean except one pre-existing, unrelated warning in create_work_item.rs.
  • No public API/behavior change; only internal decomposition.

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 · 91 AIC · ⌖ 11.8 AIC · ⊞ 11.4K ·

…ic_pipeline.rs

Extracted two helper functions from build_conclusion_job:
- apply_conclusion_tool_config_env: applies a single per-tool (noop/
  missing-tool/missing-data) config as flat AW_<TOOL>_* env vars
- hoist_conclusion_job_results: hoists upstream job results (Agent/
  Detection/SafeOutputs[/_Reviewed]/custom jobs) into job-level
  variables and wires them onto the Conclusion step

No behavior change. Reduces the too_many_lines lint from 195/100 for
build_conclusion_job. Full test suite (3229 tests) and clippy pass.

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.

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