Skip to content

refactor(ir): reduce complexity of add_edges_from_job in graph.rs - #1683

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-add-edges-from-job-a6a7c40dfef88a13
Draft

refactor(ir): reduce complexity of add_edges_from_job in graph.rs#1683
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-add-edges-from-job-a6a7c40dfef88a13

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

add_edges_from_job in src/compile/ir/graph.rs repeated the same
collect→for→add_edge_for_ref pattern inline inside every match arm,
creating 4 levels of nesting and making the intent hard to read.

What changed

Extracted two focused private helpers:

  • add_edges_for_condition — takes an Option<&Condition> and adds
    graph edges for all OutputRefs found inside it.
  • add_edges_for_env — takes an iterator of &EnvValue and adds
    graph edges for all StepOutput references.

add_edges_from_job now delegates to these helpers; each match arm is
≤ 2 lines.

Before / After

Before After
Lines in add_edges_from_job 52 30
Max nesting depth 4 2
Repeated for-loop bodies 4 0

Verification

  • cargo test — all tests pass
  • cargo clippy --all-targets --all-features — clean

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 · 60.8 AIC · ⌖ 12.3 AIC · ⊞ 7.2K ·

Extract add_edges_for_condition and add_edges_for_env helpers to
eliminate the repeated for-ref-loop pattern inside every Step arm.

Before: 52 lines, 4 nested levels, each of 4 step variants repeated
        the same collect→loop→add_edge_for_ref pattern inline.
After:  30-line match delegating to two focused helpers; each match
        arm is ≤2 lines.

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.

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