From 43e364c9ea25d2877b6aa33ba5bec256ab4a834f Mon Sep 17 00:00:00 2001 From: Tom Dalziel Date: Sun, 10 Nov 2024 23:39:19 +0100 Subject: [PATCH] Fix tests, fix lint errors from self-lint --- src/clj_kondo/hooks_api.clj | 2 +- src/clj_kondo/impl/analyzer.clj | 2 +- src/clj_kondo/impl/analyzer/namespace.clj | 2 +- src/clj_kondo/impl/analyzer/usages.clj | 6 ++---- src/clj_kondo/impl/cache.clj | 2 +- src/clj_kondo/impl/linters.clj | 6 +++--- src/clj_kondo/impl/namespace.clj | 4 ++-- test/clj_kondo/redundant_call_test.clj | 3 ++- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/clj_kondo/hooks_api.clj b/src/clj_kondo/hooks_api.clj index e49eb60c47..b2dcfc2cf5 100644 --- a/src/clj_kondo/hooks_api.clj +++ b/src/clj_kondo/hooks_api.clj @@ -55,7 +55,7 @@ (when *debug* (when-let [node (some #(when-not (node? %) %) children)] - (throw (new IllegalArgumentException (str "Not a node: " (str node))))))) + (throw (new IllegalArgumentException (str "Not a node: " node)))))) (defn vector-node [children] (assert-children-nodes children) diff --git a/src/clj_kondo/impl/analyzer.clj b/src/clj_kondo/impl/analyzer.clj index 995be3e0f6..ebcffbb847 100644 --- a/src/clj_kondo/impl/analyzer.clj +++ b/src/clj_kondo/impl/analyzer.clj @@ -375,7 +375,7 @@ (defn lint-fn-name! [ctx name-node] (when-not (simple-symbol? (:value name-node)) (findings/reg-finding! ctx (assoc (meta name-node) - :message (str "Function name must be simple symbol but got: " (str name-node)) + :message (str "Function name must be simple symbol but got: " name-node) :type :syntax :filename (:filename ctx))))) diff --git a/src/clj_kondo/impl/analyzer/namespace.clj b/src/clj_kondo/impl/analyzer/namespace.clj index 69e88a28b6..25491cd18b 100644 --- a/src/clj_kondo/impl/analyzer/namespace.clj +++ b/src/clj_kondo/impl/analyzer/namespace.clj @@ -180,7 +180,7 @@ (node->line (:filename ctx) child-expr :refer - (str "require with " (str child-k)))))) + (str "require with " child-k))))) (recur (nnext children) (cond (and (not cljs-macros-self-require?) (sequential? opt)) diff --git a/src/clj_kondo/impl/analyzer/usages.clj b/src/clj_kondo/impl/analyzer/usages.clj index f9a2339eae..1a67a85463 100644 --- a/src/clj_kondo/impl/analyzer/usages.clj +++ b/src/clj_kondo/impl/analyzer/usages.clj @@ -284,8 +284,7 @@ (when redundant? (findings/reg-finding! ctx (assoc (meta expr) :type :unused-value - :message (str "Unused value: " - (str expr)) + :message (str "Unused value: " expr) :filename (:filename ctx))))))))) (do ;; this everything but a symbol token, including keywords @@ -313,8 +312,7 @@ (when redundant? (findings/reg-finding! ctx (assoc (meta expr) :type :unused-value - :message (str "Unused value: " - (str expr)) + :message (str "Unused value: " expr) :filename (:filename ctx)))))))) (when (:k expr) (analyze-keyword ctx expr opts)))) diff --git a/src/clj_kondo/impl/cache.clj b/src/clj_kondo/impl/cache.clj index b62f61089d..6ab9d187e3 100644 --- a/src/clj_kondo/impl/cache.clj +++ b/src/clj_kondo/impl/cache.clj @@ -12,7 +12,7 @@ (defn built-in-cache-resource [lang ns-sym] (io/resource (str "clj_kondo/impl/cache/built_in/" - (name lang) "/" (str ns-sym ".transit.json")))) + (name lang) "/" ns-sym ".transit.json"))) (defn cache-file ^java.io.File [cache-dir lang ns-sym] (io/file cache-dir (name lang) (str ns-sym ".transit.json"))) diff --git a/src/clj_kondo/impl/linters.clj b/src/clj_kondo/impl/linters.clj index b211760511..afae76c0f0 100644 --- a/src/clj_kondo/impl/linters.clj +++ b/src/clj_kondo/impl/linters.clj @@ -311,9 +311,9 @@ (when called-fn (or different-file? (not row-called-fn) - (or (> row-call row-called-fn) - (and (= row-call row-called-fn) - (> (:col call) (:col called-fn))))))) + (> row-call row-called-fn) + (and (= row-call row-called-fn) + (> (:col call) (:col called-fn)))))) _ (when-let [t (:type called-fn)] (when (and call? (utils/one-of t [:string])) (findings/reg-finding! diff --git a/src/clj_kondo/impl/namespace.clj b/src/clj_kondo/impl/namespace.clj index e11c3cf440..d4c0b8f674 100644 --- a/src/clj_kondo/impl/namespace.clj +++ b/src/clj_kondo/impl/namespace.clj @@ -155,8 +155,8 @@ (when (and var-sym (or (str/starts-with? var-sym ".") (str/ends-with? var-sym ".")) - (and (not= '.. var-sym) - (not (one-of ns-sym [cljs.core clojure.core])))) + (not= '.. var-sym) + (not (one-of ns-sym [cljs.core clojure.core]))) (findings/reg-finding! ctx (node->line filename (let [thing (if (meta var-sym) var-sym expr)] thing) diff --git a/test/clj_kondo/redundant_call_test.clj b/test/clj_kondo/redundant_call_test.clj index 951bab6607..aeeb1454a9 100644 --- a/test/clj_kondo/redundant_call_test.clj +++ b/test/clj_kondo/redundant_call_test.clj @@ -12,7 +12,8 @@ (doseq [sym `[-> ->> cond-> cond->> some-> some->> partial comp merge]] (assert-submaps [{:level :warning :message (format "Single arg use of %s always returns the arg itself" sym)}] - (lint! (format "(%s 1)" sym) config)) + (lint! (format "(%s 1)" sym) config))) + (doseq [sym `[-> ->> cond-> cond->> some-> some->> partial]] (assert-submaps [{:level :warning :message (format "Single arg use of %s always returns the arg itself" sym)} {:level :warning :message (format "Single arg use of %s always returns the arg itself" sym)}]