Permalink
Browse files

debugging

  • Loading branch information...
1 parent 8c6472e commit e25aa215087be417d6459d455c53860bbf1cdf4d @jonase committed Jan 20, 2012
Showing with 14 additions and 16 deletions.
  1. +2 −2 src/eastwood/core.clj
  2. +1 −3 src/eastwood/linters/reflection.clj
  3. +11 −11 src/eastwood/util.clj
@@ -23,7 +23,7 @@
;; :non-dynamic-earmuffs misc/non-dynamic-earmuffs ; checked by compiler
:reflection reflection/reflection
:deprecations deprecated/deprecations
- :unused-locals unused/unused-locals ; Currently too slow to be practical
+ :unused-locals unused/unused-locals ; buggy with loops
:unused-private-vars unused/unused-private-vars})
(def ^:private all-linters (set (keys linters)))
@@ -40,5 +40,5 @@
(doseq [linter linters]
(lint exprs linter))))
-;(lint-ns 'brittle.core)
+;(lint-ns 'clojure.core.logic :only [:unused-locals])
@@ -27,7 +27,5 @@
(defn reflection [exprs]
(doseq [expr (mapcat expr-seq exprs)
- :when (and (reflective-call? expr)
- (not (= "__methodImplCache"
- (:field-name expr))))]
+ :when (reflective-call? expr)]
(report expr)))
View
@@ -6,9 +6,9 @@
(defmulti bound-locals :op)
(defmulti free-locals :op)
-(defmethod bound-locals :fn-method [expr]
- (let [required (set (map :sym (:required-params expr)))]
- (if-let [rest (:sym (:rest-param expr))]
+(defn fn-method-bound-locals [fnm]
+ (let [required (set (map :sym (:required-params fnm)))]
+ (if-let [rest (:sym (:rest-param fnm))]
(conj required rest)
required)))
@@ -25,7 +25,6 @@
(take-while (complement empty?)
(iterate rest seq)))
-(declare free-locals*)
;; Tricky because the second 'a in (let [a a] a) is free.
(defmethod free-locals :let [expr]
(let [free-in-bindings
@@ -41,16 +40,17 @@
(bound-locals expr))
free-in-bindings)))
-(defn free-locals* [expr]
- (set/difference (apply set/union (map free-locals
- (:children expr)))
- (bound-locals expr)))
+(defn fn-method-free-locals [fnm]
+ (set/difference (free-locals (:body fnm))
+ (fn-method-bound-locals fnm)))
-(defmethod free-locals :fn-method [expr]
- (free-locals* expr))
+(defmethod free-locals :fn-expr [expr]
+ (apply set/union (map fn-method-free-locals (:methods expr))))
(defmethod free-locals :letfn [expr]
- (free-locals* expr))
+ (set/difference (apply set/union (map free-locals
+ (:children expr)))
+ (bound-locals expr)))
(defmethod free-locals :default [expr]
(apply set/union (map free-locals (:children expr))))

0 comments on commit e25aa21

Please sign in to comment.