refactor: reduce complexity of add_report_findings in custom_jobs.rs - #2167
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
Extract each independent finding check in add_report_findings into its own well-named helper function returning Option<Finding>, appended via Vec::extend. This flattens the previously monolithic loop body (six inline if/push blocks, 131 lines, exceeding clippy::too_many_lines' 100-line threshold) into small, individually testable predicates: - incomplete_provenance_finding - job_identity_mismatch_finding - ran_without_proposals_finding - ran_after_unsafe_detection_finding - ran_without_approval_finding - expected_job_missing_finding No behavioural change: same findings are produced in the same order for the same inputs. All existing unit tests in this module continue to pass, and the clippy::too_many_lines warning for this function no longer appears. 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
|
Closed as partially superseded by aggregate PR #2189, which retains the add_report_findings helper extraction. Unrelated or overlapping cumulative changes were intentionally omitted. |
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_report_findingsinsrc/audit/analyzers/custom_jobs.rsexceeded Clippy'stoo_many_linesthreshold (131/100), driven by a single loop body containing six independent, inlineif/Finding-push blocks.Change
Extracted each independent check into its own well-named helper function returning
Option<Finding>, appended to the findings vec viaVec::extend:incomplete_provenance_findingjob_identity_mismatch_findingran_without_proposals_findingran_after_unsafe_detection_findingran_without_approval_findingexpected_job_missing_findingThe loop body in
add_report_findingsis now a short, readable sequence of calls. No public API changed, and behaviour is identical (same findings, same order, for the same inputs).Before / after
clippy::too_many_lineswarning (131/100) onadd_report_findings.too_many_lineswarning for this function.Verification
cargo build— passescargo test(full suite) — all tests pass, including all 9 existing unit tests inaudit::analyzers::custom_jobscargo clippy --all-targets --all-features— clean, no warningsWarning
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.