fix: reduce cyclomatic complexity in resolve_config functions#27
Open
fix: reduce cyclomatic complexity in resolve_config functions#27
Conversation
- 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)
|
Test Report missing or unfilled. This PR touches This is a soft gate - your CI checks are unaffected - but reviewers will not approve until the report is filled in. |
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.
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.