refactor: reduce complexity of render_ado_proxy_analysis_section in console.rs - #2060
Draft
github-actions[bot] wants to merge 1 commit into
Conversation
…onsole.rs 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
render_ado_proxy_analysis_sectioninsrc/audit/render/console.rswas flagged by Clippy'stoo_many_lineslint at 267/100 lines. The function built a single flatVec<String>of report lines by sequentially handling five independent, unrelated concerns: schema/lifecycle summary, request/latency/byte/malformed/credential-stripping stats, per-operation breakdown, per-reason breakdown, and recent denied/error request listing.What changed
Extracted five well-named private helper functions, each owning one section of the report:
push_ado_proxy_lifecycle_lines— lifecycle health/state/listening summary + diagnostics + docker errorpush_ado_proxy_stats_lines— request counts, latency, response bytes, malformed records, upstream status classes, stripped credential headerspush_ado_proxy_operations_lines— per-operation request/allow/deny/error breakdownpush_ado_proxy_reasons_lines— per-decision/reason breakdownpush_ado_proxy_recent_problem_events_lines— recent denied/error request listingrender_ado_proxy_analysis_sectionnow just orchestrates these helpers and appends to the samelines: Vec<String>, keeping the original ordering and output byte-for-byte identical.No public API signatures changed and no observable behavior changed — this is a pure structural refactor.
Before / after
Verification
cargo test --bin ado-aw— all 3229 tests pass (0 failed), including theaudit::render::consoletests that assert on the exact rendered output (ado_proxy_analysis_renders_lifecycle_rollups_and_recent_events,full_audit_data_renders_inline_snapshot,headings_follow_documented_order).cargo clippy --all-targets --all-features— clean except for one pre-existing, unrelated warning increate_work_item.rs.too_many_linesclippy check scoped toconsole.rs: the only remaining hit is the unrelated test helperpopulated_audit_data(test-only code), not the refactored function.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.