dakrone / lein-bikeshed

A Leiningen plugin designed to tell you your code is bad, and that you should feel bad
176 stars 23 forks source link

clojure.core/key is not detected #35

Open wontheone1 opened 6 years ago

wontheone1 commented 6 years ago

I had code looking like this. Even though key is clojure core function it did not give error when checking arguments colliding with clojure.core functions. I don't know if it's missing because it does not detect key (in reduce) or it could be that lein-bikeshed does not detect the arguments in anonymous functions. If the case is the latter, I don't know if it's a bug or intentional decision.

(defn- a-func-name [config config-keys]
  (reduce
    (fn [config key]
      (if-let [[optional-key value] (find config (s/optional-key key))]
        (-> config
            (dissoc optional-key)
            (assoc key value))
        config))
    config
    config-keys))
dakrone commented 6 years ago

I believe this has to do with read-namespace not returning lambdas and other anonymous functions.

Basically we require the namespace and then look at the ns-interns to see what the methods are, since ns-interns doesn't return lambdas, they're ignored for shadowing.