refactor(audit): split add_ado_proxy_findings into per-condition helpers - #2119
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
Reduces cognitive complexity / too-many-lines by extracting seven independent check_proxy_* helpers (lifecycle, credential-unavailable, upstream-failed, out-of-scope-response, prompt-conflicts, prohibited requests, malformed-records) out of add_ado_proxy_findings, each with an early-return guard clause. No behaviour change; all 154 audit unit tests continue to pass.
|
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
add_ado_proxy_findingsinsrc/audit/findings.rswas flagged by Clippy'stoo_many_lineslint at 219/100 lines (measured over the whole findings.rs before this run; the function itself spanned ~230 lines). It handled seven independent proxy-diagnostic conditions (lifecycle health, credential-unavailable, upstream-failed, out-of-scope-response, prompt conflicts, prohibited requests, malformed records) inline as a sequence ofifblocks each constructing aFinding+Recommendation, making the function long and hard to scan or test in isolation.What changed
Extracted each condition into its own single-purpose helper function, each taking
&AdoProxyAnalysisplus the sharedfindings/recommendationsaccumulators and using an early-return guard clause instead of a large wrappingif:check_proxy_lifecyclecheck_proxy_credential_unavailablecheck_proxy_upstream_failedcheck_proxy_out_of_scope_responsecheck_proxy_prompt_conflictscheck_proxy_prohibited_requestscheck_proxy_malformed_recordsadd_ado_proxy_findingsnow just early-returns when there's no proxy analysis and calls each helper in the original order — so the aggregation order (and thus emitted finding order) is unchanged.No public API changed, no behaviour changed, no comments removed.
Before / after
too_many_linesreportedadd_ado_proxy_findingswell over the 100-line threshold.cargo clippy --all-targets --all-features -- -W clippy::cognitive_complexityreports no warnings forsrc/audit/findings.rs.Verification
cargo check --all-targets— cleancargo clippy --all-targets --all-features— cleancargo test --bin ado-aw audit::— 154 passed, 0 failed (including allaudit::findings::tests::*cases covering each proxy condition)