Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #5] - any arg starting with "_" is ignored when looking for unused

  • Loading branch information...
commit 99a7e0dd902577dc6556355210cd9548fc190b98 1 parent 4e2024e
@AlexBaranosky AlexBaranosky authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/eastwood/linters/unused.clj
View
10 src/eastwood/linters/unused.clj
@@ -30,7 +30,9 @@
;; Unused fn args
-(def ^:private ignore-args '#{_ &env &form})
+(defn- ignore-arg? [arg]
+ (or (contains? #{'&env '&form} arg)
+ (.startsWith (name arg) "_")))
(defn- params [fn-method]
(let [required (:required-params fn-method)
@@ -55,8 +57,10 @@
(let [fn-exprs (->> (mapcat expr-seq exprs)
(filter (util/op= :fn-expr)))]
(for [expr fn-exprs
- :let [unused (set/difference (set (map :sym (unused-fn-args* expr)))
- ignore-args)]
+ :let [unused (->> (unused-fn-args* expr)
+ (map :sym)
+ (remove ignore-arg?)
+ set)]
:when (not-empty unused)]
{:linter :unused-fn-args
:msg (format "Function args %s are never used" unused)
Please sign in to comment.
Something went wrong with that request. Please try again.