Skip to content

fix: reduce cyclomatic complexity in resolve_config functions#27

Open
57388sp wants to merge 4 commits intomainfrom
fix/reduce-cyclomatic-complexity
Open

fix: reduce cyclomatic complexity in resolve_config functions#27
57388sp wants to merge 4 commits intomainfrom
fix/reduce-cyclomatic-complexity

Conversation

@57388sp
Copy link
Copy Markdown
Collaborator

@57388sp 57388sp commented May 8, 2026

The cyclomatic complexity tool flagged [_resolve_config] in the CIFS and NFS scripts as high risk — rated E (36) and D (21) respectively. Both had the same root cause: a long chain of or expressions to resolve each config value from CLI args, environment variables, a defaults dict, and a hardcoded fallback. Each or counts as a separate decision branch, inflating the score.

Fixed by extracting a [_pick()] helper that encapsulates that priority logic once. [_resolve_config] now reads as a clean flat mapping — no nested chains.

Results: CIFS E(36) → B(6), NFS D(21) → B(6), overall average A(3.2). no logic changes.

57388sp added 3 commits May 7, 2026 19:43
- Extract _pick() helper in cifs_provision.py and nfs_provision.py to
  eliminate repeated cli-arg / env-var / ENV-dict / default or-chains
- cifs_provision::_resolve_config: CC E(36) -> B(6)
- nfs_provision::_resolve_config: CC D(21) -> B(6)
- Strip UTF-8 BOM from cluster_info.py and nfs_provision.py so radon
  and other tooling can parse them cleanly
- Overall average CC across all scripts: A (3.2)
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

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, ONTAP 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.

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