refactor(engine): split oversized plugin modules (card_plugin 4.1k lines, hud/settings 3.5k+) #118

Closed
opened 2026-07-06 19:19:09 +00:00 by funman300 · 2 comments
Owner

Severity: Low (maintainability / refactor)

Problem

Several solitaire_engine plugin modules have grown past the point of comfortable navigation and review (line counts include their in-file test modules):

File Lines
solitaire_engine/src/card_plugin.rs 4,129
solitaire_engine/src/hud_plugin.rs 3,598
solitaire_engine/src/settings_plugin.rs 3,512
solitaire_engine/src/game_plugin.rs 2,562
solitaire_engine/src/input_plugin.rs 2,540

The card_animation/ directory already demonstrates the target shape: a module directory with focused submodules (interaction.rs, tuning.rs, mod.rs) and a separate tests.rs (as replay_overlay/ does).

Suggested approach

Incrementally, one file per PR, no behaviour change:

  1. Move each file's #[cfg(test)] mod tests block into a sibling tests.rs (biggest single win — e.g. much of card_plugin.rs is tests).
  2. Split the remaining runtime code along existing system boundaries (spawn/layout/interaction for card_plugin, band/buttons/toasts for hud_plugin, sections for settings_plugin).

Keep the single-responsibility system rule from CLAUDE.md §3.1 as the seam guide.

Found during scripted repo review (rsoutline/wc pass), 2026-07-06.

**Severity: Low (maintainability / refactor)** ## Problem Several `solitaire_engine` plugin modules have grown past the point of comfortable navigation and review (line counts include their in-file test modules): | File | Lines | |---|---| | `solitaire_engine/src/card_plugin.rs` | 4,129 | | `solitaire_engine/src/hud_plugin.rs` | 3,598 | | `solitaire_engine/src/settings_plugin.rs` | 3,512 | | `solitaire_engine/src/game_plugin.rs` | 2,562 | | `solitaire_engine/src/input_plugin.rs` | 2,540 | The `card_animation/` directory already demonstrates the target shape: a module directory with focused submodules (`interaction.rs`, `tuning.rs`, `mod.rs`) and a separate `tests.rs` (as `replay_overlay/` does). ## Suggested approach Incrementally, one file per PR, no behaviour change: 1. Move each file's `#[cfg(test)] mod tests` block into a sibling `tests.rs` (biggest single win — e.g. much of `card_plugin.rs` is tests). 2. Split the remaining runtime code along existing system boundaries (spawn/layout/interaction for `card_plugin`, band/buttons/toasts for `hud_plugin`, sections for `settings_plugin`). Keep the single-responsibility system rule from CLAUDE.md §3.1 as the seam guide. Found during scripted repo review (`rsoutline`/`wc` pass), 2026-07-06.
Author
Owner

Tests-extraction phase complete (PRs #124, #125): all five oversized files are now module directories with tests in sibling tests.rs files. Runtime line counts after extraction: card_plugin 2,536 / settings_plugin 2,857 / hud_plugin 2,725 / input_plugin 1,832 / game_plugin 1,310. Remaining work on this issue: split the runtime code along system boundaries (spawn/layout/interaction for card_plugin; band/buttons/toasts for hud_plugin; sections for settings_plugin).

Tests-extraction phase complete (PRs #124, #125): all five oversized files are now module directories with tests in sibling tests.rs files. Runtime line counts after extraction: card_plugin 2,536 / settings_plugin 2,857 / hud_plugin 2,725 / input_plugin 1,832 / game_plugin 1,310. Remaining work on this issue: split the runtime code along system boundaries (spawn/layout/interaction for card_plugin; band/buttons/toasts for hud_plugin; sections for settings_plugin).
Author
Owner

settings_plugin runtime split merged (PR #127): mod.rs 561 / input.rs 632 / updates.rs 495 / ui.rs 1,231. Remaining: hud_plugin (2,725) and card_plugin (2,536) runtime splits; game_plugin (1,310) and input_plugin (1,832) are now within reasonable size and may not need further splitting.

settings_plugin runtime split merged (PR #127): mod.rs 561 / input.rs 632 / updates.rs 495 / ui.rs 1,231. Remaining: hud_plugin (2,725) and card_plugin (2,536) runtime splits; game_plugin (1,310) and input_plugin (1,832) are now within reasonable size and may not need further splitting.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: funman300/Ferrous-Solitaire#118