Skip to content

refactor(ado-proxy): reduce complexity of operations() in catalog.rs - #2081

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-catalog-operations-3-8f7d017c72915173
Draft

refactor(ado-proxy): reduce complexity of operations() in catalog.rs#2081
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-catalog-operations-3-8f7d017c72915173

Conversation

@github-actions

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

Copy link
Copy Markdown
Contributor

What was complex

src/ado_proxy/catalog.rs::operations() was a single 406-line function
building one flat vec![...] of 36 Operation entries spanning five
distinct capability domains (Discovery, Core, Repos, Pipelines, Boards).
Clippy flagged it at 391/100 lines (clippy::too_many_lines).

What changed

Split operations() into five capability-scoped helper functions, each
returning its own Vec<Operation>, concatenated by the public function:

  • discovery_operations() — organization/area/resource-area bootstrap probes
  • core_operations() — project metadata lookups
  • repos_operations() — git repository/ref/item/commit/pull-request reads
  • pipelines_operations() — build definition/build/timeline/pipeline-run reads
  • boards_operations() — work-item/comment/update/revision reads

operations() itself is now a straightforward 8-line composition:

pub fn operations() -> Vec<Operation> {
    let mut ops = discovery_operations();
    ops.extend(core_operations());
    ops.extend(repos_operations());
    ops.extend(pipelines_operations());
    ops.extend(boards_operations());
    ops
}

No Operation entries were reordered, added, removed, or modified — this is
a pure structural split. The catalog's public shape, IDs, routes, and policy
data are byte-for-byte the same.

Before / after complexity

Function Before After
operations() 391/100 lines 8 lines (below threshold)
repos_operations() (largest new helper) 148/100 lines
pipelines_operations() 105/100 lines
discovery_operations() / core_operations() / boards_operations() below threshold

Verification

  • cargo build --bin ado-aw — clean
  • cargo test — full suite passes (no failures), including the
    ado_proxy::catalog::tests module (6 tests: uniqueness/route-normalization,
    version-marker consistency, denied-family coverage, protected-host checks)
  • cargo clippy --all-targets --all-features — clean
  • Re-ran the cognitive-complexity/too-many-lines clippy scan on
    src/ado_proxy/catalog.rs to confirm no function in the file exceeds
    148/100 lines (down from 391/100).

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 · 108.7 AIC · ⌖ 10.5 AIC · ⊞ 11.4K ·

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