Permalink
Browse files

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

  • Loading branch information...
1 parent 4e2024e commit 99a7e0dd902577dc6556355210cd9548fc190b98 @AlexBaranosky AlexBaranosky committed Apr 22, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 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)

0 comments on commit 99a7e0d

Please sign in to comment.