refactor(ado-proxy): reduce complexity of operations() in catalog.rs - #2081
Draft
github-actions[bot] wants to merge 1 commit into
Draft
refactor(ado-proxy): reduce complexity of operations() in catalog.rs#2081github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was complex
src/ado_proxy/catalog.rs::operations()was a single 406-line functionbuilding one flat
vec![...]of 36Operationentries spanning fivedistinct 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, eachreturning its own
Vec<Operation>, concatenated by the public function:discovery_operations()— organization/area/resource-area bootstrap probescore_operations()— project metadata lookupsrepos_operations()— git repository/ref/item/commit/pull-request readspipelines_operations()— build definition/build/timeline/pipeline-run readsboards_operations()— work-item/comment/update/revision readsoperations()itself is now a straightforward 8-line composition:No
Operationentries were reordered, added, removed, or modified — this isa pure structural split. The catalog's public shape, IDs, routes, and policy
data are byte-for-byte the same.
Before / after complexity
operations()repos_operations()(largest new helper)pipelines_operations()discovery_operations()/core_operations()/boards_operations()Verification
cargo build --bin ado-aw— cleancargo test— full suite passes (no failures), including theado_proxy::catalog::testsmodule (6 tests: uniqueness/route-normalization,version-marker consistency, denied-family coverage, protected-host checks)
cargo clippy --all-targets --all-features— cleansrc/ado_proxy/catalog.rsto confirm no function in the file exceeds148/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.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.