refactor: reduce cyclomatic complexity of RAID plugin msg_curse (#3460)#3575
Open
santoshguru-11 wants to merge 1 commit into
Open
Conversation
Extract _msg_curse_array, _msg_curse_raid0_active, _msg_curse_active, _msg_curse_inactive, and _msg_curse_degraded helpers from msg_curse to bring its cyclomatic complexity from 15 down to ~4. Fixes part of nicolargo#3460. No behaviour change — output is identical to the original.
21 tasks
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.
Summary
Fixes part of #3460 — reduces cyclomatic complexity of
msg_curseinglances/plugins/raid/__init__.pyfrom 15 down to ~4 by extracting focused helper methods.What changed
The monolithic
msg_cursemethod is refactored into five helpers:_msg_curse_array_msg_curse_raid0_active_msg_curse_active_msg_curse_inactive_msg_curse_degradedmsg_curseitself now only handles the guard clauses, the header, and the loop — keeping each method single-purpose and easy to test independently.No behaviour change
The output produced is identical to the original; only the internal structure changed.
Test plan
python -m pytest(unit tests pass)/proc/mdstatand confirm RAID section renders correctly