Skip to content

Commit 5e89709

Browse files
author
Bruce Hauman
committed
Fix clj-kondo warnings: remove unused imports and bindings
- Remove unused imports from core namespaces - Fix unused bindings by replacing with underscore prefix - Move type hints to arg vectors - Replace (not (empty? x)) with (seq x) - Fix inline def in tests - Simplify redundant str calls Reduces warnings from 226 to 169 (25% reduction) All tests passing: 295 tests, 2085 assertions
1 parent db57358 commit 5e89709

File tree

20 files changed

+44
-68
lines changed

20 files changed

+44
-68
lines changed

src/clojure_mcp/agent/general_agent.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Please use it to inform you as to which files should be investigated.\n=========
167167
:system-message - The system prompt
168168
:stateless? - Whether memory clears on each chat
169169
:memory-size - The configured memory size (for reset logic)"
170-
[{:keys [system-prompt context tools memory model memory-size]}]
170+
[{:keys [system-prompt context tools model memory-size]}]
171171
(try
172172
(when-not model
173173
(throw (ex-info "Model is required" {:missing :model})))
@@ -176,7 +176,7 @@ Please use it to inform you as to which files should be investigated.\n=========
176176
(throw (ex-info "System prompt is required" {:missing :system-prompt})))
177177

178178
(let [;; Use new memory-size logic
179-
{:keys [memory stateless?] :as memory-config} (create-memory-for-config memory-size)
179+
{:keys [memory stateless?]} (create-memory-for-config memory-size)
180180
;; Get the actual memory size for reset logic
181181
actual-memory-size (if stateless?
182182
DEFAULT-STATELESS-BUFFER

src/clojure_mcp/agent/langchain.clj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
[dev.langchain4j.agent.tool ToolSpecification #_ToolParameter]
1212
[dev.langchain4j.service.tool ToolExecutor]
1313
[dev.langchain4j.data.message SystemMessage UserMessage]
14-
[dev.langchain4j.agent.tool ToolExecutionRequest]
1514
[dev.langchain4j.memory.chat MessageWindowChatMemory]
1615
[dev.langchain4j.model.chat.request ChatRequest]
1716

@@ -137,7 +136,7 @@
137136

138137
(defn registration-map->tool-executor [{:keys [tool-fn]}]
139138
(reify ToolExecutor
140-
(execute [_this request memory-id]
139+
(execute [_this request _memory-id]
141140
(let [tool-name (.name request)
142141
arg-str (.arguments request)]
143142
(if-let [arg-result (is-well-formed-json? arg-str)]
@@ -178,7 +177,7 @@
178177
registration-map->tool-executor)
179178
registration-maps)))
180179

181-
(defn chat-request [message & {:keys [system-message tools require-tool-choice]}]
180+
(defn chat-request [message & {:keys [system-message tools]}]
182181
;; ChatResponse response = model.chat(request);
183182
;;AiMessage aiMessage = response.aiMessage();
184183
(cond-> (ChatRequest/builder)
@@ -199,7 +198,7 @@
199198
(.chatModel model)
200199
(.systemMessageProvider
201200
(reify Function
202-
(apply [this mem-id]
201+
(apply [_this _mem-id]
203202
system-message)))
204203
(cond->
205204
tools (.tools (convert-tools tools)))

src/clojure_mcp/core.clj

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,24 @@
1010
[clojure-mcp.nrepl-launcher :as nrepl-launcher])
1111
(:import [io.modelcontextprotocol.server.transport
1212
StdioServerTransportProvider]
13-
[io.modelcontextprotocol.server McpServer McpServerFeatures
13+
[io.modelcontextprotocol.server McpServer
1414
McpServerFeatures$AsyncToolSpecification
15-
McpServerFeatures$AsyncResourceSpecification]
15+
McpServerFeatures$AsyncResourceSpecification
16+
McpServerFeatures$AsyncPromptSpecification]
1617
[io.modelcontextprotocol.spec
1718
McpSchema$ServerCapabilities
1819
McpSchema$Tool
1920
McpSchema$CallToolResult
2021
McpSchema$TextContent
21-
McpSchema$ImageContent
2222
McpSchema$Prompt
2323
McpSchema$PromptArgument
2424
McpSchema$GetPromptRequest
2525
McpSchema$GetPromptResult
2626
McpSchema$PromptMessage
2727
McpSchema$Role
28-
McpSchema$LoggingLevel
2928
McpSchema$Resource
30-
McpSchema$ReadResourceResult
3129
McpSchema$TextResourceContents
32-
McpSchema$ResourceContents]
33-
[io.modelcontextprotocol.server McpServer McpServerFeatures
34-
McpServerFeatures$AsyncToolSpecification
35-
McpServerFeatures$AsyncPromptSpecification]
30+
McpSchema$ReadResourceResult]
3631
[reactor.core.publisher Mono]
3732
[io.modelcontextprotocol.json McpJsonMapper]))
3833

@@ -47,7 +42,7 @@
4742
(fn [exchange arguments]
4843
(Mono/create
4944
(reify java.util.function.Consumer
50-
(accept [this sink]
45+
(accept [_this sink]
5146
(callback-fn
5247
exchange
5348
arguments
@@ -61,7 +56,7 @@
6156
(file-content/file-response->file-content result)
6257
:else (McpSchema$TextContent. " ")))
6358

64-
(defn ^McpSchema$CallToolResult adapt-results [list-str error?]
59+
(defn adapt-results ^McpSchema$CallToolResult [list-str error?]
6560
(McpSchema$CallToolResult. (vec (keep adapt-result list-str)) error?))
6661

6762
(defn create-async-tool
@@ -95,13 +90,14 @@
9590
(McpServerFeatures$AsyncToolSpecification.
9691
mcp-tool
9792
(reify java.util.function.BiFunction
98-
(apply [this exchange arguments]
93+
(apply [_this exchange arguments]
9994
(log/debug (str "Args from MCP: " (pr-str arguments)))
10095
(mono-fn exchange arguments))))))
10196

102-
(defn ^McpSchema$GetPromptResult adapt-prompt-result
97+
(defn adapt-prompt-result
10398
"Adapts a Clojure prompt result map into an McpSchema$GetPromptResult.
10499
Expects a map like {:description \"...\" :messages [{:role :user :content \"...\"}]}"
100+
^McpSchema$GetPromptResult
105101
[{:keys [description messages]}]
106102
(let [mcp-messages (mapv (fn [{:keys [role content]}]
107103
(McpSchema$PromptMessage.
@@ -144,7 +140,7 @@
144140
(McpServerFeatures$AsyncPromptSpecification.
145141
mcp-prompt
146142
(reify java.util.function.BiFunction
147-
(apply [this exchange request]
143+
(apply [_this exchange request]
148144
(mono-fn exchange request))))))
149145

150146
(defn add-tool
@@ -184,7 +180,7 @@
184180
(McpServerFeatures$AsyncResourceSpecification.
185181
resource
186182
(reify java.util.function.BiFunction
187-
(apply [this exchange request]
183+
(apply [_this exchange request]
188184
(mono-fn exchange request))))))
189185

190186
(defn add-resource
@@ -245,7 +241,7 @@
245241
(if (= ::config/schema-error (-> e ex-data :type))
246242
(let [{:keys [errors file-path]} (ex-data e)]
247243
(binding [*out* *err*]
248-
(println (str "\n❌ Configuration validation failed!\n"))
244+
(println "\n❌ Configuration validation failed!\n")
249245
(when file-path
250246
(println (str "File: " file-path "\n")))
251247
(println "Errors found:")

src/clojure_mcp/nrepl.clj

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
[nrepl.misc :as nrepl.misc]
66
[nrepl.transport]
77
[clojure.tools.logging :as log]
8-
[clojure.edn])
9-
(:import
10-
[java.util.concurrent LinkedBlockingQueue TimeUnit]))
8+
[clojure.edn]))
119

1210
;; callback system
1311
(defn add-callback! [{:keys [::state]} id f]
@@ -22,7 +20,7 @@
2220
(defn remove-current-eval-id! [{:keys [::state]}]
2321
(swap! state dissoc :current-eval-id))
2422

25-
(defn dispatch-response! [{:keys [::state] :as service} msg]
23+
(defn dispatch-response! [{:keys [::state]} msg]
2624
(doseq [f (vals (get @state :id-callbacks))]
2725
(f msg)))
2826

@@ -95,12 +93,12 @@
9593
(get @state :ns-session))
9694

9795
(defn current-ns
98-
([{:keys [::state] :as service} session]
96+
([{:keys [::state]} session]
9997
(get-in @state [:current-ns session]))
100-
([{:keys [::state] :as service} session new-ns]
98+
([{:keys [::state]} session new-ns]
10199
(swap! state assoc-in [:current-ns session] new-ns)))
102100

103-
(defn new-message [{:keys [::state] :as service} msg]
101+
(defn new-message [service msg]
104102
(merge
105103
{:session (eval-session service)
106104
:id (new-id)}
@@ -115,7 +113,7 @@
115113
(def truncation-length 10000) ;; 20000 roughly 250 lines
116114

117115
(defn eval-code-msg
118-
[{:keys [::state] :as service} code-str msg' k]
116+
[service code-str msg' k]
119117
(let [msg (merge
120118
msg'
121119
{:op "eval"
@@ -154,7 +152,7 @@
154152
(new-message service {:op "interrupt" :interrupt-id current-eval-id})
155153
identity))))
156154

157-
(defn lookup [{:keys [::state] :as service} symbol]
155+
(defn lookup [service symbol]
158156
(let [prom (promise)]
159157
(send-msg! service
160158
(new-tool-message service {:op "lookup" :sym symbol})
@@ -166,7 +164,7 @@
166164
(update :arglists clojure.edn/read-string))))))
167165
(deref prom 400 nil)))
168166

169-
(defn completions [{:keys [::state] :as service} prefix]
167+
(defn completions [service prefix]
170168
(let [prom (promise)]
171169
(send-msg! service
172170
(new-tool-message service {:op "completions" :prefix prefix})
@@ -182,7 +180,7 @@
182180
(value #(deliver prom %))))
183181
(deref prom 400 nil)))
184182

185-
(defn ls-middleware [{:keys [::state] :as service}]
183+
(defn ls-middleware [service]
186184
(let [prom (promise)]
187185
(send-msg! service
188186
(new-tool-message service {:op "ls-middleware"})
@@ -207,7 +205,7 @@
207205
(done #(deliver prom (get % :new-session)))))
208206
(deref prom 600 nil)))
209207

210-
(defn send-input [{:keys [::state] :as service} input]
208+
(defn send-input [service input]
211209
(send-msg! service
212210
(new-message service {:op "stdin" :stdin (when input
213211
(str input "\n"))})
@@ -221,14 +219,13 @@
221219

222220
(declare create)
223221

224-
(defn poll-for-responses [{:keys [::state] :as options} conn]
222+
(defn poll-for-responses [{:keys [::state] :as options} _conn]
225223
(let [retries (atom 60)]
226224
(loop []
227225
(when (polling? options)
228226
(let [continue
229227
(try
230-
(when-let [{:keys [id out err value ns session] :as resp}
231-
(nrepl.transport/recv (:conn @state) 100)]
228+
(when-let [resp (nrepl.transport/recv (:conn @state) 100)]
232229
(reset! retries 60)
233230
#_(tap> resp)
234231
(dispatch-response! options resp))

src/clojure_mcp/prompts.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
{:root-directory
4545
working-dir})}]})
4646
(clj-result-k
47-
{:description (str "Root directory not found.")
47+
{:description "Root directory not found."
4848
:messages [{:role :user
4949
:content
5050
(str "Root directory not provided So this will not be a prompt." "::" working-dir "::")}]})))})

src/clojure_mcp/resources.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
[clojure-mcp.config :as config]
55
[clojure-mcp.file-content :as file-content]
66
[clojure-mcp.tools.project.core :as project]
7-
[clojure-mcp.utils.file :as file-utils])
8-
(:import [io.modelcontextprotocol.spec McpSchema$Resource McpSchema$ReadResourceResult]))
7+
[clojure-mcp.utils.file :as file-utils]))
98

109
(defn read-file [full-path]
1110
(let [file (io/file full-path)]

src/clojure_mcp/sexp/match.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns clojure-mcp.sexp.match
2-
(:require [rewrite-clj.zip :as z]
3-
[rewrite-clj.parser :as p]))
2+
(:require [rewrite-clj.zip :as z]))
43

54
(defn match-sexpr
65
"Return true if `pattern` matches `data`.

src/clojure_mcp/sse_core.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns clojure-mcp.sse-core
22
(:require
3-
[clojure-mcp.main :as main]
43
[clojure-mcp.core :as core]
54
[clojure-mcp.config :as config]
65
[clojure-mcp.nrepl-launcher :as nrepl-launcher]

src/clojure_mcp/tool_system.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
(:require
66
[clojure.string :as string]
77
[clojure.walk :as walk]
8-
[clojure.tools.logging :as log]
9-
[clojure.data.json :as json]))
8+
[clojure.tools.logging :as log]))
109

1110
;; Core multimethods for tool behavior
1211

test/clojure_mcp/tools/directory_tree/tool_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
(testing "tool-description returns a non-empty description"
1616
(let [description (tool-system/tool-description {:tool-type :directory-tree})]
1717
(is (string? description))
18-
(is (not (empty? description))))))
18+
(is (seq description)))))
1919

2020
(deftest tool-schema-test
2121
(testing "tool-schema returns a valid schema with required path parameter"

0 commit comments

Comments
 (0)