refactor: reduce complexity of populate_custom_safe_output_jobs in custom_jobs.rs - #1815
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
…stom_jobs.rs 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.
What was complex
populate_custom_safe_output_jobsinsrc/audit/analyzers/custom_jobs.rswas flagged byclippy::too_many_lines(147/100). The per-tool loop body inlined three separate concerns:aw_infometadata against the typed pipeline graph (job identity, approval path, and component provenance), pushing High-severity findings on mismatch.What changed
Extracted two focused helpers with no behavioural change:
correlate_tool_with_graph(audit, tool, entry, findings) -> ToolGraphCorrelation— owns all three graph/metadata mismatch checks and returns a small struct (expected_job_id,graph_display_name,approval_path,graph_is_authoritative).build_report_for_tool(audit, tool, entry, correlation, proposal_counts, previous_entry) -> CustomSafeOutputJobAudit— owns timeline matching and the previous-run fallback merge, returning the final report.populate_custom_safe_output_jobsnow just loops calling these two helpers and building the report list.Before/after
too_many_lines (147/100)clippy warning.add_report_findings, still reports 131/100 but was out of scope for this change.)Verification
cargo build— cleancargo clippy --all-targets --all-features— no warningscargo test— full suite passes, including the 10 existingcustom_jobs::testscases (unchanged, no test modifications needed)Warning
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.