Skip to content

Grasp doesn't seem to descend into macro forms #28

@dpsutton

Description

@dpsutton

I'm looking for all strings in our codebase at Metabase that need translations. To this end i'm doing

(s/def ::translate (s/and
                     (complement vector?)
                     (s/cat :translate-symbol (fn [x]
                                               (and (symbol? x)
                                                    (#{"trs" "deferred-trs"
                                                       "tru" "deferred-tru"}
                                                      (name x))))
                            :args (s/+ any?))))

(I only just now realized I can resolve symbols for smarter matching but not relevant here). This spec works great and finds almost all usages. However I've found one that it does not find:

(defmacro ^:private deffingerprinter
  [field-type transducer]
  {:pre [(keyword? field-type)]}
  (let [field-type [field-type :Semantic/* :Relation/*]]
    `(defmethod fingerprinter ~field-type
       [field#]
       (with-error-handling
         (with-global-fingerprinter
           (redux/post-complete
            ~transducer
            (fn [fingerprint#]
              {:type {~(first field-type) fingerprint#}})))
         (trs "Error generating fingerprint for {0}" (sync-util/name-for-logging field#))))))

I'm going to try to come up with a minimal reproduction because there's a lot going on.

  (g/grasp "/Users/dan/projects/work/metabase/src/metabase/sync/analyze/fingerprint/fingerprinters.clj"
           ::translate)
;; misses the example above
[(deferred-trs "Error reducing {0}" (name k))]

Note I'm not expecting to find the usage at macro invocations and call sites, just in the literal form here which I would expect it to be able to descend into and match on the trs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions