refactor(compile): reduce complexity of build_pipeline_context in agentic_pipeline.rs - #1874
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
Extracts four cohesive blocks from the 258-line build_pipeline_context into named helper functions to reduce clippy::too_many_lines from 258/100 to 192/100: - validate_pipeline_front_matter: the sequence of shared front-matter validators. - collect_extension_declarations: the per-extension Declarations collection loop (with warning surfacing). - fanout_extension_declarations: fan-out of Declarations into Agent setup steps, prepare steps, and conditions. - build_engine_setup: engine invocation, install-steps, composed env, and BYOM/BYOK exclusion-key computation for both Agent and Detection engines (returns a small EngineSetup struct). No public API or observable behavior changes. Verified with the full test suite (2948 tests, all passing) and a clean cargo clippy run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 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
build_pipeline_contextinsrc/compile/agentic_pipeline.rswas flagged bycargo clippy -W clippy::too_many_linesat 258/100 lines — the highest of any function in the crate. It mixed several independent concerns inline: front-matter validation, extension declaration collection, engine invocation/env/install-steps computation, and extension declaration fan-out into Agent job steps/conditions.What changed
Extracted four cohesive blocks into named helper functions, each with a doc comment noting it exists purely to reduce cognitive complexity:
validate_pipeline_front_matter— the sequence of shared front-matter validators (identity, permissions, timeout, variable groups, safe-outputs keys, threat detection, require-approval, staged, GitHub issue outputs, comment target, work-item target, PR review events/votes, PR thread statuses, ado-aw-debug config, supply-chain).collect_extension_declarations— the per-extensionDeclarationscollection loop, including warning surfacing.fanout_extension_declarations— fan-out of collectedDeclarationsinto Agent setup steps, prepare steps, and conditions (plus prompt-supplement raw-YAML steps).build_engine_setup— engine invocation, install-steps, composed env block, and Copilot BYOM/BYOK exclusion-key computation for both the Agent and Detection engines (returns a smallEngineSetupstruct).Before / after
too_many_lines (258/100)too_many_lines (192/100)build_pipeline_contextis still above the lint's threshold; the remaining body (network/MCPG config generation and paths/tokens/prompt content assembly) is a natural next target for a follow-up refactor.Verification
cargo test— 2948 passed, 0 failed.cargo clippy --all-targets --all-features— clean, no warnings.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.