Skip to content

refactor: apply §5 high-ROI cleanups from CODE_REVIEW.md#65

Merged
StudentWeis merged 5 commits into
mainfrom
refactor/64-code-review-section-5-cleanups
Apr 27, 2026
Merged

refactor: apply §5 high-ROI cleanups from CODE_REVIEW.md#65
StudentWeis merged 5 commits into
mainfrom
refactor/64-code-review-section-5-cleanups

Conversation

@StudentWeis
Copy link
Copy Markdown
Owner

@StudentWeis StudentWeis commented Apr 27, 2026

Summary

Apply the four small, high-ROI cleanups called out in doc/CODE_REVIEW.md §5. All changes are mechanical refactors with no user-visible behavior change — the existing 411-test suite is the safety net.

Linked Issue

Closes #64

Changes

  • 5.1 refactor(config): split src/config/settings.rs (726 lines) into settings/mod.rs + settings/validate.rs. mod.rs now owns type definitions and file I/O; validate.rs owns the three private validate_* helpers invoked by Settings::load.
  • 5.2 refactor(gui): split src/gui/board/settings_handler.rs (950 lines) into settings_handler/{mod.rs, hotkey.rs, layout.rs, storage.rs, theme.rs, update.rs}. Each themed submodule owns its save_* methods; mod.rs keeps the shared notification/persistence helpers plus the autostart / confirm-mode / hover-preview handlers that don't fit the five themes.
  • 5.3 refactor(gui): collapse the five truncate_* wrappers in records_list.rs into a single truncate(content, char_limit, options) paired with a TruncateOptions { max_lines: Option<usize> } struct. Promote the previously inline 3 and 10 magic numbers into named LIST_CONTENT_PREVIEW_MAX_LINES / TOOLTIP_CONTENT_PREVIEW_MAX_LINES constants.
  • 5.4 ci: add a dedicated cargo-machete step to the Precheck job in .github/workflows/ci.yml (via taiki-e/install-action for a cached binary install) so unused crate dependencies fail CI before they reach main. scripts/precheck.sh stays focused on the fmt/check/clippy/test gate; contributors can install cargo-machete locally through scripts/init.sh, which now includes it in its cargo binstall list.

Testing

  • scripts/precheck.sh passes locally (411 tests, 0 clippy warnings)
  • cargo machete passes locally (0 unused dependencies)
  • No new tests needed — refactors are covered by existing behavior tests, and the truncate_* unit tests were updated in-place to call the new API

Move `settings.rs` into `settings/mod.rs` and extract the three
private `validate_*` helpers into a dedicated `validate.rs` so that
`mod.rs` stays focused on type definitions and file I/O.

Refs #64
…dule

The 950-line `settings_handler.rs` bundled 20+ `save_*` methods for
hotkey, layout, storage, theme, and update concerns in one file. Group
them into themed submodules so each concern lives next to its peers:

- `hotkey.rs`  — activation-key recording and `save_hotkey`
- `layout.rs`  — `save_selected_layout`
- `storage.rs` — `save_max_history` / `save_max_storage` and the
  `has_pending_max_*` helpers
- `theme.rs`   — theme, language, and window-opacity persistence
- `update.rs`  — `save_auto_check_enabled` /
  `save_include_prerelease_enabled`

`mod.rs` keeps shared helpers (notifications, `persist_settings_update`,
selection sync, validation helpers) plus autostart / confirm-mode /
hover-preview handlers that don't fit the five themes.

Refs #64
…tions)

`records_list.rs` previously defined five near-duplicate helpers
(`truncate_content`, `truncate_content_with_lines`,
`truncate_content_for_list`, `truncate_content_for_grid`,
`truncate_content_for_preview`) that all routed to the same core
routine with different hard-coded line limits.

Consolidate them into a single `truncate(content, char_limit, options)`
paired with a `TruncateOptions { max_lines: Option<usize> }` struct:
`None` means character-limit only, `Some(n)` applies a line cap.
Promote the previously inline `3` (list) and `10` (tooltip preview)
magic numbers into named `LIST_CONTENT_PREVIEW_MAX_LINES` /
`TOOLTIP_CONTENT_PREVIEW_MAX_LINES` constants so each call site
documents its intent.

Refs #64
Add a dedicated `cargo-machete` step to the Precheck job in
`.github/workflows/ci.yml` so unused crate dependencies fail CI before
they reach main. `taiki-e/install-action` provides a cached binary
install, keeping the extra CI time minimal.

Keep `scripts/precheck.sh` focused on the fmt/check/clippy/test gate —
contributors can opt into local machete checks via `scripts/init.sh`,
which now includes `cargo-machete` in its `cargo binstall` list.

Refs #64
@StudentWeis StudentWeis force-pushed the refactor/64-code-review-section-5-cleanups branch from d622674 to d82211d Compare April 27, 2026 05:30
@StudentWeis StudentWeis merged commit 59ed87c into main Apr 27, 2026
8 checks passed
@StudentWeis StudentWeis deleted the refactor/64-code-review-section-5-cleanups branch April 27, 2026 05:38
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.

refactor: apply §5 high-ROI cleanups from CODE_REVIEW.md

1 participant