refactor: reduce complexity of test_compiled_yaml_structure in compiler_tests.rs#325
Merged
jamesadevine merged 1 commit intoApr 27, 2026
Conversation
…er_tests.rs
Extract four focused helper functions from the monolithic assertion body:
- assert_required_markers: data-driven loop over all {{ marker }} placeholders
- assert_pool_config: pool marker count and no-hardcode checks
- assert_compiler_download: ado-aw GitHub Releases fetch + checksum assertions
- assert_awf_download: AWF GitHub Releases fetch + no legacy artifact tasks
- assert_mcpg_integration: MCPG flags + no legacy mcp-firewall artefacts
Moving firewall_version, mcpg_config, and mcpg_version into the markers loop
in assert_required_markers also removes three duplicated assert! calls.
Complexity: 29 → below 25 (no longer flagged by clippy::cognitive_complexity).
All tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Open
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
test_compiled_yaml_structureintests/compiler_tests.rswas flagged byclippy::cognitive_complexityat 29/25.The function was a single monolithic block of ~30 individual
assert!calls grouped only by comments. Clippy counts each macro invocation (which expands to anif !(condition) { panic! }branch) as a complexity increment, so the score grew linearly with the number of assertions.What changed
Five focused helper functions were extracted from the assertion body:
assert_required_markers\{\{ marker }}placeholders — a singleforloop replaces 13 identicalassert!(content.contains(...))calls. Also consolidatesfirewall_version,mcpg_config, andmcpg_versionmarkers that were previously checked in separate sections.assert_pool_configassert_compiler_downloadassert_awf_downloadassert_mcpg_integrationmcp-firewallartefactsThe main test now reads as a clear five-step checklist:
No assertions were removed — the data-driven loop in
assert_required_markersactually adds coverage forfirewall_version,mcpg_config, andmcpg_versionto the unified marker list.Results
tests/compiler_tests.rstest_compiled_yaml_structureVerification
cargo test)clippy::cognitive_complexityno longer flagstests/compiler_tests.rssrc/engine.rs::copilot_argsandsrc/configure.rs::run, both 27/25) are already addressed in open PR refactor: reduce complexity ofcopilot_argsandconfigure::run#324Warning
The following domain was blocked by the firewall during workflow execution:
dev.azure.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.