Structural cleanup based on thermo-nuclear code quality review: - Extract shared color-picker.css and color-popover.css from badges.css (611→85 lines) - Extract shared lib/presets.js for preset CRUD used by popup and popover - Unify dark mode to single applyDarkModeClass on <html>, removing 4 scattered functions - Fix stale closure in startPostObserver, data-driven reload key check - Remove dead exports, getHelpers wrapper, duplicated colorToHex - Replace DOM expando properties with state array in popup.js Net: -318 lines of duplication, no file over 401 lines. Co-authored-by: Cursor <cursoragent@cursor.com>
2.8 KiB
Thermo-Nuclear Code Quality Review — Reddit Tweaks Extension
Date: 2026-08-28 01:08 Task: Deep code quality audit of the full codebase using thermo-nuclear review criteria
Verdict
Not approved — several structural regressions and missed simplification opportunities identified.
Key Findings
Critical
-
~200 lines of CSS duplicated between
content/styles/badges.css(lines 409–611) andpopup/popup.css(lines 287–489). Color picker widget and preset badge styles are copy-pasted verbatim. Fix: extract sharedcolor-picker.css. -
badges.css(611 lines) conflates three concerns — badge styling (~85 lines), color popover chrome (~230 lines), and color picker widget (~150 lines). Should be decomposed into separate files.
High
-
Preset management logic duplicated across
popup.js(renderPopupPresets,addPopupPreset,deletePopupPreset) andcolor-popover.js(renderPresets,saveAsPreset,removePreset). Nearly identical CRUD pattern. Fix: extract sharedpresets.jsmodule. -
colorToHexidentity function duplicated in bothpopup.jsandcolor-popover.js.
Medium
-
Dark mode class management scattered across 4 files with inconsistent scoping —
cards.jstargets<html>,badges.jstargets each container,color-popover.jstargets itself. Code-judo: applyrt-darkonce on<html>and let CSS cascade handle the rest. -
DOM expando properties (
entry._colorState,entry._nameInput, etc.) used as state management inpopup.js. Should use plain objects. -
Stale closure in
startPostObserver— line 47 uses capturedsettingsinstead of freshly-loadedupdated.
Low
- Dead exports (
isDarkMode,getColorPrefix) onbadgeTweakobject. - Verbose storage change listener — four repetitive conditions should be data-driven.
getHelpers()wrapper incolor-popover.jsadds pointless indirection.
Recommended Priority Order
- Extract shared
color-picker.css(~200 lines deleted) - Split
badges.cssinto badges, popover, picker - Extract shared preset module
- Unify dark mode to single
html.rt-darkclass - Fix stale closure bug
- Clean up dead exports, verbose conditions, and unnecessary wrappers
Lessons Learned
- The thermo-nuclear review skill is useful for catching CSS duplication that would otherwise grow silently — CSS files don't get the same refactoring attention as JS.
- Browser extension architecture (content scripts vs popup) makes code sharing harder since there's no module system, but shared files loaded via both manifest.json and popup.html
<script>/<link>tags work fine. - IIFE-scoped modules on a global namespace are a reasonable pattern for small extensions but make duplication easy to miss since there's no import graph to inspect.