Skip to content

refactor: reduce complexity of render_ado_proxy_analysis_section in console.rs - #2060

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-render-ado-proxy-analysis-section-0071af2942230d4c
Draft

refactor: reduce complexity of render_ado_proxy_analysis_section in console.rs#2060
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-render-ado-proxy-analysis-section-0071af2942230d4c

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What was complex

render_ado_proxy_analysis_section in src/audit/render/console.rs was flagged by Clippy's too_many_lines lint at 267/100 lines. The function built a single flat Vec<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 error
  • push_ado_proxy_stats_lines — request counts, latency, response bytes, malformed records, upstream status classes, stripped credential headers
  • push_ado_proxy_operations_lines — per-operation request/allow/deny/error breakdown
  • push_ado_proxy_reasons_lines — per-decision/reason breakdown
  • push_ado_proxy_recent_problem_events_lines — recent denied/error request listing

render_ado_proxy_analysis_section now just orchestrates these helpers and appends to the same lines: 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

  • Before: 267/100 lines (too_many_lines)
  • After: below the Clippy threshold (function is no longer flagged)

Verification

  • cargo test --bin ado-aw — all 3229 tests pass (0 failed), including the audit::render::console tests 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 in create_work_item.rs.
  • Re-ran the too_many_lines clippy check scoped to console.rs: the only remaining hit is the unrelated test helper populated_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.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 · 51.1 AIC · ⌖ 15.2 AIC · ⊞ 11.4K ·

…onsole.rs

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