Skip to content

refactor(configure): reduce complexity of run in src/configure.rs#349

Merged
jamesadevine merged 1 commit into
mainfrom
refactor/configure-run-complexity-f856ca3fc924428f
Apr 29, 2026
Merged

refactor(configure): reduce complexity of run in src/configure.rs#349
jamesadevine merged 1 commit into
mainfrom
refactor/configure-run-complexity-f856ca3fc924428f

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

The run function in src/configure.rs was flagged by Clippy's cognitive_complexity lint at 27/25. It was a single ~230-line async function doing five distinct jobs inline.

What changed

Five focused helper functions were extracted from run:

Helper Responsibility
resolve_token CLI flag → interactive password prompt
resolve_auth PAT flag → Azure CLI token → interactive PAT prompt
resolve_ado_context Git remote (best-effort) → apply --org/--project overrides
resolve_definitions Explicit --definition-ids or auto-detect + ADO match
apply_token_updates Update loop with per-definition ✓/✗ reporting

run is now a thin coordinator (~50 lines) that calls each helper in order and handles the two early-exit paths (no pipelines found, dry-run).

Behaviour

No observable behaviour changes. All existing tests pass. Each helper is individually readable and testable.

Complexity

Before After
run 27 (flagged) below threshold — no longer flagged
New helpers all well below 25
cargo clippy --all-targets --all-features --message-format=json -- \
  -W clippy::cognitive_complexity \
  | jq '... select(.file == "src/configure.rs")'
# → no output

Generated by Cyclomatic Complexity Reducer · ● 841.4K ·

Extract five focused helpers from the monolithic run() function:
- resolve_token: CLI flag → interactive prompt
- resolve_auth: PAT flag → Azure CLI → interactive prompt
- resolve_ado_context: git remote → override with --org/--project flags
- resolve_definitions: explicit IDs or auto-detect + match
- apply_token_updates: update loop with per-definition reporting

run() becomes a thin coordinator that delegates to each helper and
handles the two early-exit paths (no pipelines found, dry-run).

Cognitive complexity: 27 → below threshold (25)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jamesadevine jamesadevine marked this pull request as ready for review April 29, 2026 15:19
@jamesadevine jamesadevine merged commit 06c9480 into main Apr 29, 2026
@jamesadevine jamesadevine deleted the refactor/configure-run-complexity-f856ca3fc924428f branch April 29, 2026 15:19
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.

1 participant