From 519038ceed01c5a245fd4d8166eeaaaf49dbafec Mon Sep 17 00:00:00 2001 From: "Robert C. Martin" Date: Sun, 20 Feb 2022 13:21:44 -0600 Subject: [PATCH] Eliminate 'unused local variable' warnings by prefixing those variables with an underscore. --- spec/more_speech/text_spec.clj | 3 +- spec/more_speech/ui/button_spec.clj | 4 +-- spec/more_speech/ui/header_frame_spec.clj | 2 +- spec/more_speech/ui/widget_spec.clj | 7 ++--- src/more_speech/nostr/events.clj | 8 ++--- src/more_speech/ui/application.clj | 4 +-- src/more_speech/ui/article_window.clj | 4 +-- src/more_speech/ui/author_window.clj | 4 +-- src/more_speech/ui/button.clj | 2 +- src/more_speech/ui/cursor.clj | 12 ++++---- src/more_speech/ui/graphics.clj | 36 +++++++++++------------ 11 files changed, 42 insertions(+), 44 deletions(-) diff --git a/spec/more_speech/text_spec.clj b/spec/more_speech/text_spec.clj index 5e71eb4..4a0b2cf 100644 --- a/spec/more_speech/text_spec.clj +++ b/spec/more_speech/text_spec.clj @@ -1,7 +1,6 @@ (ns more-speech.text-spec (:require [speclj.core :refer :all] - [more-speech.ui.cursor :refer :all] - [quil.core :as q])) + [more-speech.ui.cursor :refer :all])) (describe "Text Utilities" (context "nil->blank" diff --git a/spec/more_speech/ui/button_spec.clj b/spec/more_speech/ui/button_spec.clj index 87ae7e7..37c3a7f 100644 --- a/spec/more_speech/ui/button_spec.clj +++ b/spec/more_speech/ui/button_spec.clj @@ -6,8 +6,8 @@ (defrecord mock-graphic [x y which time] g/graphics - (get-mouse [graphics] [x y which]) - (get-time [graphics] time)) + (get-mouse [_graphics] [x y which]) + (get-time [_graphics] time)) (defn- left-up [button state] (assoc-in state (concat (:path button) [:left-came-up]) true)) diff --git a/spec/more_speech/ui/header_frame_spec.clj b/spec/more_speech/ui/header_frame_spec.clj index 27fc558..79af448 100644 --- a/spec/more_speech/ui/header_frame_spec.clj +++ b/spec/more_speech/ui/header_frame_spec.clj @@ -7,7 +7,7 @@ (defrecord mock-graphics [] g/graphics - (line-height [graphics] + (line-height [_graphics] 20) ) diff --git a/spec/more_speech/ui/widget_spec.clj b/spec/more_speech/ui/widget_spec.clj index acbe79c..508d695 100644 --- a/spec/more_speech/ui/widget_spec.clj +++ b/spec/more_speech/ui/widget_spec.clj @@ -1,17 +1,16 @@ (ns more-speech.ui.widget-spec (:require [speclj.core :refer :all] [more-speech.ui.application :refer [map->application]] - [more-speech.ui.graphics :as g] [more-speech.ui.widget :refer :all])) (defrecord child [] widget - (setup-widget [widget state] + (setup-widget [widget _state] (assoc widget :setup true))) (defrecord child-with-child [] widget - (setup-widget [widget state] + (setup-widget [widget _state] (assoc widget :child (->child)))) (defn- f [widget state] (assoc-in state (concat (:path widget) [:did-f]) true)) @@ -101,7 +100,7 @@ (defrecord mock-widget [x y w h] widget - (setup-widget [widget state] + (setup-widget [widget _state] widget)) (describe "mouse operations" diff --git a/src/more_speech/nostr/events.clj b/src/more_speech/nostr/events.clj index ed46685..394d532 100644 --- a/src/more_speech/nostr/events.clj +++ b/src/more_speech/nostr/events.clj @@ -22,10 +22,10 @@ (declare process-text-event) (defn process-event [{:keys [application] :as state} event] - (let [{:keys [articles nicknames]} application + (let [{:keys [_articles nicknames]} application name-of (fn [pubkey] (get nicknames pubkey pubkey)) - [name subscription-id inner-event :as decoded-msg] event - {:strs [id pubkey created_at kind tags content sig]} inner-event] + [_name _subscription-id inner-event :as _decoded-msg] event + {:strs [_id pubkey created_at kind _tags content _sig]} inner-event] (condp = kind 0 (let [pubkey (hex-string->num pubkey) name (get (json/read-str content) "name" "tilt")] @@ -47,7 +47,7 @@ (defn process-tags [tags] (map process-tag tags)) -(defn process-references [state {:keys [id tags] :as event}] +(defn process-references [state {:keys [id tags] :as _event}] (let [e-tags (filter #(= :e (first %)) tags) refs (map second e-tags)] (loop [refs refs diff --git a/src/more_speech/ui/application.clj b/src/more_speech/ui/application.clj index b32649a..c84e41a 100644 --- a/src/more_speech/ui/application.clj +++ b/src/more_speech/ui/application.clj @@ -50,13 +50,13 @@ widget (setup-widget [widget state] (setup-application widget path state)) - (update-widget [widget state] + (update-widget [_widget state] state) (draw-widget [application state] (draw-child-widgets application state)) ) -(defn- setup-application [application path state] +(defn- setup-application [application _path _state] (let [graphics (:graphics application) bold (get-in graphics [:fonts :bold])] (g/text-font graphics bold) diff --git a/src/more_speech/ui/article_window.clj b/src/more_speech/ui/article_window.clj index 07a4d15..b954ff9 100644 --- a/src/more_speech/ui/article_window.clj +++ b/src/more_speech/ui/article_window.clj @@ -31,7 +31,7 @@ (draw-widget [widget state] (draw-article-window state widget))) -(defn setup-article-window [widget state] +(defn setup-article-window [widget _state] (let [{:keys [x y w h]} widget dim config/header-frame-dimensions frame-path (concat (:path widget) [:header-frame]) @@ -135,5 +135,5 @@ (defn- lock-thumb [widget state] (app/lock-mouse state widget)) -(defn- unlock-thumb [widget state] +(defn- unlock-thumb [_widget state] (app/unlock-mouse state)) diff --git a/src/more_speech/ui/author_window.clj b/src/more_speech/ui/author_window.clj index 32acd0d..97c1701 100644 --- a/src/more_speech/ui/author_window.clj +++ b/src/more_speech/ui/author_window.clj @@ -10,9 +10,9 @@ (defrecord author-window [x y w h fonts] widget - (setup-widget [widget state] + (setup-widget [widget _state] widget) - (update-widget [widget state] + (update-widget [_widget state] state) (draw-widget [widget state] (draw-author-window (:application state) widget)) diff --git a/src/more_speech/ui/button.clj b/src/more_speech/ui/button.clj index fc5f846..906cd11 100644 --- a/src/more_speech/ui/button.clj +++ b/src/more_speech/ui/button.clj @@ -9,7 +9,7 @@ (defrecord button [x y h w button-state left-up] w/widget - (setup-widget [widget state] + (setup-widget [widget _state] widget) (update-widget [widget state] (update-button widget state)) diff --git a/src/more_speech/ui/cursor.clj b/src/more_speech/ui/cursor.clj index 4038e3b..a275462 100644 --- a/src/more_speech/ui/cursor.clj +++ b/src/more_speech/ui/cursor.clj @@ -19,14 +19,14 @@ (defrecord cursor [graphics x y l-margin] Cursor - (set-x [c x] - (assoc c :x x)) + (set-x [c new-x] + (assoc c :x new-x)) - (set-y [c y] - (assoc c :y y)) + (set-y [c new-y] + (assoc c :y new-y)) - (set-xy [c x y] - (assoc c :x x :y y)) + (set-xy [c new-x new-y] + (assoc c :x new-x :y new-y)) (set-pos [c pos] (set-x c (g/pos-width graphics pos))) diff --git a/src/more_speech/ui/graphics.clj b/src/more_speech/ui/graphics.clj index 78374af..34c5ac6 100644 --- a/src/more_speech/ui/graphics.clj +++ b/src/more_speech/ui/graphics.clj @@ -32,47 +32,47 @@ (defrecord quil-graphics [fonts] graphics - (screen-height [graphics] + (screen-height [_graphics] (q/screen-height)) - (screen-width [graphics] + (screen-width [_graphics] (q/screen-width)) - (text-align [graphics alignment] + (text-align [_graphics alignment] (apply q/text-align alignment)) - (text-color [graphics color] + (text-color [_graphics color] (apply q/fill color)) - (stroke [graphics color] + (stroke [_graphics color] (apply q/stroke color)) - (stroke-weight [graphics weight] + (stroke-weight [_graphics weight] (q/stroke-weight weight)) - (fill [graphics color] + (fill [_graphics color] (apply q/fill color)) - (no-fill [graphics] + (no-fill [_graphics] (q/no-fill)) - (rect [graphics rect] + (rect [_graphics rect] (apply q/rect rect)) - (line [graphics line] + (line [_graphics line] (apply q/line line)) - (polygon [graphics points] + (polygon [_graphics points] (draw-polygon points)) (with-translation [graphics translation f] (q/with-translation translation (f graphics))) - (text-font [graphics font] + (text-font [_graphics font] (q/text-font font)) - (line-height [graphics] + (line-height [_graphics] (+ (q/text-ascent) (q/text-descent))) - (pos-width [graphics pos] + (pos-width [_graphics pos] (let [s (apply str (repeat pos "X"))] (q/text-width s))) - (text-width [graphics s] + (text-width [_graphics s] (q/text-width s)) - (text [graphics text-spec] + (text [_graphics text-spec] (apply q/text text-spec)) - (get-mouse [graphics] + (get-mouse [_graphics] (let [x (q/mouse-x) y (q/mouse-y) which (if (q/mouse-pressed?) (q/mouse-button) nil)] [x y which])) - (get-time [graphics] + (get-time [_graphics] (System/currentTimeMillis)) )