From b6761ed66012fcf3e98aa252582aaf03b2b85c12 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 8 Nov 2025 13:16:42 -0600 Subject: refactor: Improve cache cleanup clarity and add input validation Cache Refactorings: - Extract wttrin--get-cache-entries-by-age helper function - Refactor wttrin--cleanup-cache-if-needed to use helper - Improves code clarity with descriptive variable names - Makes cache logic independently testable - Add 15 new tests (8 for helper, 7 for refactored cleanup) Input Validation: - Add range validation to wttrin-mode-line-startup-delay (1-10 seconds) - Prevents invalid values (0, negative, or excessive delays) - Uses restricted-sexp type for enforcement Test Fixes: - Fix debug function naming (use public wttrin-debug-clear-log) - Ensure wttrin-debug module loads in test setup - Make mocks synchronous for batch mode compatibility - Update test expectations to match actual debug messages - Fix startup delay test to check defcustom default value Linter/Compiler Fixes: - Add declare-function for wttrin--debug-log - Add defvar/declare-function in wttrin-debug.el - Fix docstring line lengths (wrap at 80 chars) - Fix checkdoc warnings (imperative mood, escaping) - Disambiguate temporary-file-directory reference All 165 tests passing. Clean byte-compile, package-lint, checkdoc. --- wttrin-debug.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'wttrin-debug.el') diff --git a/wttrin-debug.el b/wttrin-debug.el index 810f875..dd08a5a 100644 --- a/wttrin-debug.el +++ b/wttrin-debug.el @@ -32,6 +32,10 @@ ;; wttrin-debug.el is loaded by wttrin.el, so wttrin is already loaded ;; No need for (require 'wttrin) here +;; Declare variables and functions from wttrin.el +(defvar wttrin-debug) +(declare-function wttrin--get-cached-or-fetch "wttrin") + ;;;###autoload (defun debug-wttrin-show-raw (location) "Fetch and display raw wttr.in data for LOCATION with line numbers. -- cgit v1.2.3