Skip to content

refactor(compile): reduce complexity of check_pipeline in src/compile/mod.rs - #2243

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-check-pipeline-7dc7ccb036c7d2cd
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/reduce-complexity-check-pipeline-7dc7ccb036c7d2cd

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

clippy::cognitive_complexity produced no diagnostics under this toolchain (clippy 0.1.98) — it is documented as restriction-only and effectively inert, suggesting too_many_lines / excessive_nesting as replacements. Running those surfaced check_pipeline in src/compile/mod.rs at 105/100 lines (clippy::too_many_lines), the largest untouched, non-test production function not already covered by prior refactor runs.

What changed

Split check_pipeline into four focused pieces, preserving all logic and comments verbatim:

  • warn_on_version_mismatch — stderr warning when the pipeline's header compiler version differs from the current one.
  • resolve_header_source_path — resolves the header's relative source path against the repo root found by walking up from the pipeline file.
  • compile_fresh_from_header_source — reads the source markdown, applies the pending-codemod guard, resolves/merges imports, sanitizes config, resolves repos, and compiles fresh YAML (returns (pipeline_yaml, pipeline_name)).
  • check_pipeline — orchestrates the steps above and reports the integrity diff.

No public API changed and no observable behavior changed — only structure.

Verification

  • cargo build --all-features — clean.
  • cargo clippy --all-targets --all-features — no warnings.
  • cargo clippy -- -W clippy::too_many_lines — check_pipeline no longer flagged.
  • cargo test — full suite passes (3406+ tests, including tests/codemod_tests.rs, which directly exercises the check CLI command / check_pipeline).

Before / after

Lines Lint
Before 105 (limit 100) clippy::too_many_lines
After 4 functions, none exceeding threshold (helper compile_fresh_from_header_source ~70 lines) not flagged

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • releaseassets.githubusercontent.com
  • spsprodeus21.vssps.visualstudio.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "releaseassets.githubusercontent.com"
    - "spsprodeus21.vssps.visualstudio.com"

See Network Configuration for more information.

Generated by Cyclomatic Complexity Reducer · auto · 93.6 AIC · ⌖ 11.1 AIC · ⊞ 9.7K · ◷

…/mod.rs

Split the 105-line check_pipeline function (clippy::too_many_lines) into
four focused pieces:
- warn_on_version_mismatch: version-drift warning
- resolve_header_source_path: repo-root + header source path resolution
- compile_fresh_from_header_source: read source, run codemods/import
  merge/repo resolution, and compile fresh YAML
- check_pipeline: orchestrates the steps above and reports the diff

No behavior change; clippy::too_many_lines no longer flags this file and
all check_pipeline-exercising tests (tests/codemod_tests.rs) plus the full
test suite pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
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 branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants