refactor: reduce complexity of add_ado_proxy_findings in src/audit/findings.rs - #2163
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…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: 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.
Summary
add_ado_proxy_findingsinsrc/audit/findings.rswas flagged byclippy::too_many_linesat 219/100 lines. It contained seven independentif-guarded blocks, each constructing and pushing oneFinding+ oneRecommendationpair 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_findingadd_ado_proxy_credential_unavailable_findingadd_ado_proxy_upstream_failed_findingadd_ado_proxy_out_of_scope_response_findingadd_ado_proxy_prompt_conflict_findingadd_ado_proxy_prohibited_request_findingadd_ado_proxy_malformed_record_findingadd_ado_proxy_findingsnow short-circuits on a missingado_proxy_analysisand calls each helper in sequence — no behavior change.Verification
cargo build— cleancargo test --bin ado-aw— all 3358 tests pass (0 failed), including all 18 existingaudit::findingstests unmodifiedcargo clippy --all-targets --all-features— cleanclippy::too_many_linesno longer fires for this file (previously reported as 219/100)Before / after complexity
clippy::too_many_linesWarning
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.