Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any arg starting with "_" is ignored when looking for unused #6

Merged
merged 1 commit into from
Apr 22, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/eastwood/linters/unused.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down