Skip to content

refactor: reduce complexity of build_conclusion_job in agentic_pipeline.rs#1646

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

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

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What was complex

build_conclusion_job in src/compile/agentic_pipeline.rs contained a 65-line loop body that applied per-tool conclusion env vars for noop, missing-tool, and missing-data. The body had 5–6 levels of nesting:

for tool_key          ← level 1
  if let Some(cfg)    ← level 2
    if cfg.is_bool()  ← level 3
      if == Some(false) ← level 4
    if let Some(obj)  ← level 3
      if let Some(v)  ← level 4
        if let Some(s) ← level 5  (report-as-work-item)

The string-field fan-out (title-prefix, work-item-type, area-path, iteration-path) was repeated verbatim five times.

What changed

Two private helpers extracted:

apply_tool_config_envs(step, env_prefix, obj) -> BashStep

Handles the object-form config for one tool. String fields are driven by a data-table slice so adding a new config key requires one entry, not a new if let block.

apply_conclusion_tool_config(step, tool_key, tool_config) -> BashStep

Handles the bool/object dispatch for one tool: derives env_prefix, handles the false-bool early-return, then delegates to apply_tool_config_envs.

The per-tool loop in build_conclusion_job becomes:

for tool_key in &["noop", "missing-tool", "missing-data"] {
    if let Some(tool_config) = front_matter.safe_outputs.get(*tool_key) {
        conclusion_step = apply_conclusion_tool_config(conclusion_step, tool_key, tool_config);
    }
}

Verification

  • All tests pass (cargo test)
  • Clippy is clean (cargo clippy --all-targets --all-features)
  • No behaviour change: the same env vars are set with the same values in the same order

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 · 90.1 AIC · ⌖ 12.7 AIC · ⊞ 7.2K ·

…ne.rs

Extract apply_tool_config_envs and apply_conclusion_tool_config helpers to
flatten the 5-6 level deep per-tool config loop inside build_conclusion_job.

Before: a single 65-line loop body with nested if/if-let/if-let/if-let/if-let
chains for each of noop/missing-tool/missing-data.

After: the loop body is a 3-line call to apply_conclusion_tool_config, which
delegates to apply_tool_config_envs for the object-form config. The string-
field fan-out is further condensed into a data-driven slice iteration so new
config keys only require one entry.

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