Skip to content

Commit

Permalink
Fix #2309: report unused for expression
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Apr 5, 2024
1 parent 0728512 commit 9cd2114
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion extract/clj_kondo/impl/extract_var_info.clj
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
#_(:pure-fn-if-fn-args-pure info))
(conj acc sym)
acc))
#{} var-info))
'#{clojure.core/for}
var-info))

(defn print-set-sorted [s]
(format "#{%s}"
Expand Down
1 change: 1 addition & 0 deletions src/clj_kondo/impl/var_info_gen.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,7 @@ clojure.core/float-array
clojure.core/float?
clojure.core/fn?
clojure.core/fnext
clojure.core/for
clojure.core/format
clojure.core/frequencies
clojure.core/future?
Expand Down
8 changes: 7 additions & 1 deletion test/clj_kondo/unused_value_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,10 @@
'({:file "<stdin>", :row 1, :col 20, :level :warning, :message "Unused value: \"hello\""}
{:file "<stdin>", :row 1, :col 28, :level :warning, :message "Unused value"})
(lint! "(defn foo [bar] {} \"hello\" (+ 2 2) bar)"
{:linters {:unused-value {:level :warning}}})))
{:linters {:unused-value {:level :warning}}})))

(deftest issue-2309-test
(assert-submaps
'({:file "<stdin>", :row 1, :col 14, :level :warning, :message "Unused value"})
(lint! "(defn foo [] (for [x [1 2 3]] x) nil)"
{:linters {:unused-value {:level :warning}}})))

0 comments on commit 9cd2114

Please sign in to comment.