|
Replace two magic numbers with self-documenting constants:
1. Cache cleanup percentage (line 395):
- Before: (dotimes (_ (/ (length entries) 5))
- After: (dotimes (_ (floor (* (length entries) wttrin--cache-cleanup-percentage)))
- Added: wttrin--cache-cleanup-percentage constant (0.20 = 20%)
- Explains WHY 20%: provides buffer before next cleanup cycle
2. Mode-line startup delay (line 508):
- Before: (run-at-time 3 nil #'wttrin--mode-line-fetch-weather)
- After: (run-at-time wttrin-mode-line-startup-delay nil ...)
- Added: wttrin-mode-line-startup-delay defcustom (default 3 seconds)
- Now user-customizable, range 1-5 seconds recommended
Added comprehensive tests (8 tests, all passing):
- 5 tests verify cache cleanup behavior (removes ~20% of oldest entries)
- 3 tests verify startup delay defcustom exists and has reasonable value
Benefits:
- Self-documenting code (explains WHY these values exist)
- Startup delay is now user-customizable
- Easier for future maintainers to understand rationale
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|