oakmac / standard-clojure-style-js

Standard Clojure Style in JavaScript
ISC License
84 stars 1 forks source link

odd indentation cases #132

Open oakmac opened 1 month ago

oakmac commented 1 month ago

Test case from metabase/analyze/fingerprint/fingerprinters.clj:

(deffingerprinter :type/Text
  ((map str) ; we cast to str to support `field-literal` type overwriting:
             ; `[:field-literal "A_NUMBER" :type/Text]` (which still
             ; returns numbers in the result set)
   (robust-fuse {:percent-json   (stats/share valid-serialized-json?)
                 :percent-url    (stats/share u/url?)
                 :percent-email  (stats/share u/email?)
                 :percent-state  (stats/share u/state?)
                 :average-length ((map count) stats/mean)})))

This is currently formatted to:


(deffingerprinter :type/Text
  ((map str) ; we cast to str to support `field-literal` type overwriting:
             ; `[:field-literal "A_NUMBER" :type/Text]` (which still
             ; returns numbers in the result set)
             (robust-fuse {:percent-json   (stats/share valid-serialized-json?)
                           :percent-url    (stats/share u/url?)
                           :percent-email  (stats/share u/email?)
                           :percent-state  (stats/share u/state?)
                           :average-length ((map count) stats/mean)})))

This seems wrong to me?

oakmac commented 1 month ago

Another one from src/metabase/api/automagic_dashboards.clj:

(api/defendpoint GET "/model_index/:model-index-id/primary_key/:pk-id"
  "Return an automagic dashboard for an entity detail specified by `entity`
  with id `id` and a primary key of `indexed-value`."
  [model-index-id pk-id]
  {model-index-id :int
   pk-id          :int}
  (api/let-404 [model-index (t2/select-one ModelIndex model-index-id)
                model (t2/select-one Card (:model_id model-index))
                model-index-value (t2/select-one ModelIndexValue
                                                 :model_index_id model-index-id
                                                 :model_pk pk-id)]
               ;; `->entity` does a read check on the model but this is here as well to be extra sure.
    (api/read-check Card (:model_id model-index))
    (let [linked (linked-entities {:model             model
                                   :model-index       model-index
                                   :model-index-value model-index-value})]
      (create-linked-dashboard {:model             model
                                :linked-tables     linked
                                :model-index       model-index
                                :model-index-value model-index-value}))))

This is currently formatted to:

(api/defendpoint GET "/model_index/:model-index-id/primary_key/:pk-id"
  "Return an automagic dashboard for an entity detail specified by `entity`
  with id `id` and a primary key of `indexed-value`."
  [model-index-id pk-id]
  {model-index-id :int
   pk-id          :int}
  (api/let-404 [model-index (t2/select-one ModelIndex model-index-id)
                model (t2/select-one Card (:model_id model-index))
                model-index-value (t2/select-one ModelIndexValue
                                                 :model_index_id model-index-id
                                                 :model_pk pk-id)]
               ;; `->entity` does a read check on the model but this is here as well to be extra sure.
               (api/read-check Card (:model_id model-index))
               (let [linked (linked-entities {:model             model
                                              :model-index       model-index
                                              :model-index-value model-index-value})]
                 (create-linked-dashboard {:model             model
                                           :linked-tables     linked
                                           :model-index       model-index
                                           :model-index-value model-index-value}))))
oakmac commented 1 month ago

In both cases, the ;; comment is causing the odd alignment.

In the first case, not sure how to automatically detect / fix this.

In the second case, arguably the comment should be de-dented.