refactor(audit): reduce complexity of add_ado_proxy_findings in src/audit/findings.rs - #2216
Closed
github-actions[bot] wants to merge 1 commit into
Closed
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Split the 219-line add_ado_proxy_findings function (clippy::too_many_lines) into seven single-purpose helpers, one per proxy failure/policy signal: lifecycle health, credential unavailability, upstream failures, out-of-scope responses, prompt/policy conflicts, prohibited requests, and malformed decision records. Each helper takes the shared AdoProxyAnalysis plus the findings/ recommendations vectors and early-returns when its condition doesn't apply, replacing the previous single function's long sequence of if-blocks. No behavioral change: same findings/recommendations are produced in the same order for the same inputs. Before: this function has too many lines (219/100) After: no too_many_lines warning remains for add_ado_proxy_findings 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. |
Collaborator
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
Clippy's
too_many_lineslint flaggedadd_ado_proxy_findingsinsrc/audit/findings.rsat 219/100 lines. The function was a single long sequence of seven independent if-blocks, each checking a differentado-proxyfailure/policy signal (unhealthy lifecycle, unavailable credential, upstream failures, out-of-scope responses, prompt/policy conflicts, prohibited requests, malformed decision records) and pushing a matchingFinding+Recommendation.Change
Extracted each of the seven blocks into its own single-purpose helper function (e.g.
add_ado_proxy_unhealthy_lifecycle_finding,add_ado_proxy_credential_unavailable_finding, ...), each taking&AdoProxyAnalysisplus the sharedfindings/recommendationsvectors and early-returning when its condition does not apply.add_ado_proxy_findingsnow just calls each helper in the original order.No behavioral change — the same findings and recommendations are produced in the same order for the same inputs, and the public API (
derive_findings) is unchanged.Verification
cargo build— passescargo test --bin ado-aw audit::— 154 tests pass, including allaudit::findings::tests::*cargo clippy --all-targets --all-features— cleancargo clippy -- -W clippy::too_many_linesscoped to this file — no more warning foradd_ado_proxy_findingsBefore:
this function has too many lines (219/100)After: no
too_many_lineswarning remains foradd_ado_proxy_findings