Skip to content

refactor: code smell remediation across core modules#50

Merged
flexiondotorg merged 5 commits intomainfrom
polish
Mar 25, 2026
Merged

refactor: code smell remediation across core modules#50
flexiondotorg merged 5 commits intomainfrom
polish

Conversation

@flexiondotorg
Copy link
Copy Markdown
Member

Summary

This PR consolidates three phases of targeted code smell remediation that eliminate duplication, improve maintainability, and reduce cyclomatic complexity across core modules. All changes are refactoring with no functional impact; the full test suite (218 tests) passes.

Changes

  • Phase 1: Eliminate duplicate i18n logic in getLocalizedString, consolidate did-fail-load patterns, simplify config helpers
  • Phase 2: Extract playback snapshot to Player class; migrate Discord presence and wedge detector to use shared state
  • Phase 3: Extract tray context menu builder into logical helper functions, reducing main tray function from 216 to 100 lines

Testing

All 218 tests passing. No functional changes; refactoring only.

- i18n: delegate getLocalizedString to getLocalizedEntry
- config: introduce getConfigValue helpers and consolidate 9 getters
- main: merge dual did-fail-load handlers with first-fire semantics

Improves maintainability and reduces duplication across core modules.

Signed-off-by: Martin Wimpress <code@wimpress.io>
…dString

Delegate to getLocalizedEntry() to remove duplicated lang-matching
logic, reducing maintenance burden and ensuring consistent behaviour
across both functions.

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Replace redundant once() listener with guard flag on on() listener
- Ensure markCssReady() executes exactly once despite repeated failures
- Add clarifying comments on handler purpose and timing

Signed-off-by: Martin Wimpress <code@wimpress.io>
Replace local state tracking in discord-presence and wedgeDetector with
a shared Player snapshot method. Introduces PlaybackSnapshot interface
and maintains isPlaying, positionUs, and state in Player class.

This centralises playback data, removing duplicate state variables from
multiple integrations.

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Extract buildStartPageSubmenu to handle start page radio group
- Extract buildNotificationsSubmenu for notification toggle
- Extract buildDiscordSubmenu for Discord RPC toggle
- Extract buildStyleSubmenu for theme selection
- Extract buildZoomSubmenu for zoom factor options
- Introduce SubmenuContext interface for shared parameters
- Reduce buildContextMenu from 216 to 64 lines

Improves testability and readability by separating concerns.

Signed-off-by: Martin Wimpress <code@wimpress.io>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Requires human review: Significant refactoring across core modules (player state, tray menus, window events) exceeds the scope of auto-approval and requires human architectural review.

@flexiondotorg flexiondotorg merged commit 8bea1ef into main Mar 25, 2026
12 checks passed
@flexiondotorg flexiondotorg deleted the polish branch March 25, 2026 23:00
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