Skip to content

Commit

Permalink
Add fn* to checks, to include short-form fn syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed Nov 7, 2023
1 parent 2ac748e commit e41531c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/clj_kondo/impl/analyzer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@
;; explicit do
(= 'do core-sym)
;; implicit do
(one-of core-sym [fn defn defn-
(one-of core-sym [fn fn* defn defn-
let when-let loop binding with-open
doseq try when when-not when-first
when-some future])))))]
Expand Down
4 changes: 2 additions & 2 deletions src/clj_kondo/impl/analyzer/usages.clj
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
(and (not generated?)
core?
(not (:clj-kondo.impl/generated (meta parent-call)))
(one-of core-sym [do fn defn defn-
(one-of core-sym [do fn fn* defn defn-
let when-let loop binding with-open
doseq try when when-not when-first
when-some future]))]
Expand All @@ -293,7 +293,7 @@
(or core? test?)
(not (:clj-kondo.impl/generated (meta parent-call)))
(if core?
(one-of core-sym [do fn defn defn-
(one-of core-sym [do fn fn* defn defn-
let when-let loop binding with-open
doseq try when when-not when-first
when-some future])
Expand Down
2 changes: 1 addition & 1 deletion src/clj_kondo/impl/linters.clj
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@
;; doseq always return nil
(utils/one-of core-sym [doseq])
(< idx (dec (:len call))))
(utils/one-of core-sym [do fn defn defn-
(utils/one-of core-sym [do fn fn* defn defn-
let when-let loop binding with-open
doseq try when when-not when-first
when-some 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 @@ -67,7 +67,13 @@
(testing "unused pure function call"
(assert-submaps
'({:file "<stdin>", :row 1, :col 14, :level :warning, :message "Unused value"})
(lint! "(defn foo [] (update {} :dude 1) 1)" {:linters {:unused-value {:level :warning}}})))
(lint! "(defn foo [] (update {} :dude 1) 1)" {:linters {:unused-value {:level :warning}}}))
(assert-submaps
'({:file "<stdin>", :row 1, :col 12, :level :warning, :message "Unused value"})
(lint! "(fn foo [] (update {} :dude 1) 1)" {:linters {:unused-value {:level :warning}}}))
(assert-submaps
'({:file "<stdin>", :row 1, :col 9, :level :warning, :message "Unused value"})
(lint! "(->> 1 #(update {} :dude 1))" {:linters {:unused-value {:level :warning}}})))
(testing "unused lazy seq"
(assert-submaps
'({:file "<stdin>", :row 1, :col 14, :level :warning, :message "Unused value"})
Expand Down

0 comments on commit e41531c

Please sign in to comment.