Permalink
Browse files

Fixed field reflection & and some def-in-def cleanup

  • Loading branch information...
1 parent 440e756 commit 8e41f810e7da267f370db95b0773c9099474ca7d @jonase committed Feb 25, 2012
Showing with 10 additions and 7 deletions.
  1. +7 −1 src/brittle/core.clj
  2. +1 −2 src/eastwood/linters/misc.clj
  3. +2 −4 src/eastwood/linters/reflection.clj
@@ -27,4 +27,10 @@
(defn defndef [x]
- (def a 3))
+ (def a 3))
+
+;; This is often ok.
+(defmacro ^:private defindefmacro []
+ (def b nil))
+
+(defrecord SomeRecord [])
@@ -58,12 +58,11 @@
;; Def-in-def
-
(defn def-in-def [exprs]
(doseq [expr (mapcat expr-seq exprs)
:when (and (= (:op expr) :def)
(-> expr :var meta :macro not))]
- (if (some #(= (:op %) :def) (rest (expr-seq expr)))
+ (when (some #(= (:op %) :def) (rest (expr-seq expr)))
(println "There is a def inside" (:var expr)))))
@@ -7,7 +7,7 @@
(not (:method expr)))
(defmethod reflective-call? :instance-field [expr]
- (not (:method expr)))
+ (not (:field expr)))
(defmethod reflective-call? :default [_] false)
@@ -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)))

0 comments on commit 8e41f81

Please sign in to comment.