Skip to content

refactor: reduce complexity of add_ado_proxy_findings in src/audit/findings.rs - #2163

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-findings-ado-proxy-2-9ac9d696196efda9
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-findings-ado-proxy-2-9ac9d696196efda9

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

add_ado_proxy_findings in src/audit/findings.rs was flagged by clippy::too_many_lines at 219/100 lines. It contained seven independent if-guarded blocks, each constructing and pushing one Finding + one Recommendation pair based on a distinct ado-proxy analysis condition (unhealthy lifecycle, credential unavailable, upstream failed, out-of-scope response, prompt conflicts, prohibited requests, malformed records).

Change

Extracted each block into its own small, descriptively-named helper function using an early-return guard clause (matching the style already used by sibling add_* rule functions in this module):

  • add_ado_proxy_unhealthy_lifecycle_finding
  • add_ado_proxy_credential_unavailable_finding
  • add_ado_proxy_upstream_failed_finding
  • add_ado_proxy_out_of_scope_response_finding
  • add_ado_proxy_prompt_conflict_finding
  • add_ado_proxy_prohibited_request_finding
  • add_ado_proxy_malformed_record_finding

add_ado_proxy_findings now short-circuits on a missing ado_proxy_analysis and calls each helper in sequence — no behavior change.

Verification

  • cargo build — clean
  • cargo test --bin ado-aw — all 3358 tests pass (0 failed), including all 18 existing audit::findings tests unmodified
  • cargo clippy --all-targets --all-features — clean
  • clippy::too_many_lines no longer fires for this file (previously reported as 219/100)

Before / after complexity

Lines Lint
Before 219/100 clippy::too_many_lines
After split across 8 functions, largest ~55 lines none

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 · 82.9 AIC · ⌖ 13.6 AIC · ⊞ 10.2K ·

…ndings.rs

Split the 219-line add_ado_proxy_findings function (clippy::too_many_lines)
into seven small, independently-testable helper functions, one per
finding/recommendation rule:

- add_ado_proxy_unhealthy_lifecycle_finding
- add_ado_proxy_credential_unavailable_finding
- add_ado_proxy_upstream_failed_finding
- add_ado_proxy_out_of_scope_response_finding
- add_ado_proxy_prompt_conflict_finding
- add_ado_proxy_prohibited_request_finding
- add_ado_proxy_malformed_record_finding

Each helper uses an early return guard clause instead of a large if-block,
matching the existing add_* rule functions elsewhere in this module. No
behavior change: all 18 existing audit::findings tests continue to pass
unmodified, and the full suite (3358 tests) passes.

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