Skip to content

refactor: reduce cyclomatic complexity of RAID plugin msg_curse (#3460)#3575

Open
santoshguru-11 wants to merge 1 commit into
nicolargo:developfrom
santoshguru-11:refactor/reduce-complexity-raid-msg-curse
Open

refactor: reduce cyclomatic complexity of RAID plugin msg_curse (#3460)#3575
santoshguru-11 wants to merge 1 commit into
nicolargo:developfrom
santoshguru-11:refactor/reduce-complexity-raid-msg-curse

Conversation

@santoshguru-11

Copy link
Copy Markdown

Summary

Fixes part of #3460 — reduces cyclomatic complexity of msg_curse in glances/plugins/raid/__init__.py from 15 down to ~4 by extracting focused helper methods.

What changed

The monolithic msg_curse method is refactored into five helpers:

Helper Responsibility
_msg_curse_array Renders a single RAID array entry (new line + name + delegates to status helpers)
_msg_curse_raid0_active Lines for an active RAID-0 array
_msg_curse_active Lines for a non-RAID-0 active array
_msg_curse_inactive Lines for an inactive array with component tree
_msg_curse_degraded Lines for degraded-mode arrays

msg_curse itself 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

  • Run python -m pytest (unit tests pass)
  • Manual smoke-test: start glances on a machine with /proc/mdstat and confirm RAID section renders correctly

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