Skip to content

fix: reduce cyclomatic complexity and clean up Python scripts for production readiness#30

Open
57388sp wants to merge 3 commits into
mainfrom
fix/cyclomatic-complexity-all
Open

fix: reduce cyclomatic complexity and clean up Python scripts for production readiness#30
57388sp wants to merge 3 commits into
mainfrom
fix/cyclomatic-complexity-all

Conversation

@57388sp
Copy link
Copy Markdown
Collaborator

@57388sp 57388sp commented May 12, 2026

This PR refactors Python scripts that had high cyclomatic complexity grades (C or D) as measured by radon. Functions with too many branches are hard to read, test, and maintain, so each large function was broken into smaller, focused helper functions.

The key improvements are in the NFS provision, SnapMirror cleanup, and SnapMirror destination-managed scripts, where the most complex functions dropped from grades C/D down to grade A or B. All functions across the codebase now grade A or B.

No behaviour was changed — the extracted helpers perform exactly the same logic as before. All scripts pass ruff check and ruff format --check with no issues.

@github-actions
Copy link
Copy Markdown

Test Report missing or unfilled.

This PR touches python/, ansible/, or terraform/, so a populated Test Report section is required in the PR body. See TESTING.md for what to capture (environment, platform version, first-run output, idempotency check, teardown).

This is a soft gate - your CI checks are unaffected - but reviewers will not approve until the report is filled in.

57388sp added 2 commits May 12, 2026 16:55
- Remove phase narration comment blocks above logger.info phase headers
- Remove redundant _env() inline doc comment across all scripts
- Remove stale section decorators (#--- banners for Steps/Main)
- Remove garbled mojibake chars from ENV dict inline comments (nfs_provision)
- Fix bug in snapmirror_test_failover.py: logger.info() calls for phases
  A/B/C were embedded inside comment text and never executed
- Preserve USER INPUTS banners, Steps banners, and version-specific
  field-set comments that carry non-obvious semantic meaning

All scripts pass ruff check + ruff format --check.
@57388sp 57388sp force-pushed the fix/cyclomatic-complexity-all branch from 5fd75e0 to 6676a3c Compare May 12, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant