Fork me on GitHub
#clj-kondo
<
2019-11-19
>
jaihindhreddy07:11:31

Does clj-kondo warn when some know lazy construct is being created but not forced to be realized in the lexical scope of with-redefs?

jaihindhreddy07:11:57

After more thinking, doing so would require analysis through dynamic scopes, because things outside of core can both create lazy stuff and force it to be realized (without telling us so). So maybe it is out of scope for clj-kondo. Maybe a job for a more involved static analysis tool.

borkdude08:11:46

@jaihindhreddy Same trouble with try, with-open and binding

borkdude08:11:40

Clj-kondo could in theory warn about (try (map ...)) because it can know about a set of functions that are lazy like map. Maybe eastwood already has this? I'll ask in their channel.

borkdude08:11:14

@jaihindhreddy Feel free to post more examples here: https://github.com/borkdude/clj-kondo/issues/614

roger42911:11:17

@borkdude Sorry, I had to fix another error I made (def i.s.o. defn) first... From the Clojure for the Brave and True book, chapter 6:

(ns the-divine-cheese-code.core
  (:gen-class))
(require 'the-divine-cheese-code.visualization.svg)
(refer 'the-divine-cheese-code.visualization.svg)

(def heists [{:location "Cologne, Germany"
              :cheese-name "Archbishop Hildebold's Cheese Pretzel"
              :lat 50.95
              :lng 6.97}
             {:location "Zurich, Switzerland"
              :cheese-name "The Standard Emmental"
              :lat 47.37
              :lng 8.55}
             {:location "Marseille, France"
              :cheese-name "Le Fromage de Cosquer"
              :lat 43.30
              :lng 5.37}
             {:location "Zurich, Switzerland"
              :cheese-name "The Lesser Emmental"
              :lat 47.37
              :lng 8.55}
             {:location "Vatican City"
              :cheese-name "The Cheese of Turin"
              :lat 41.90
              :lng 12.45}])

(defn -main
  [& args]
  (println (points heists)))
clj-kondo complains about 'points' in the prinln form. lein run gives expected output, though.

roger42911:11:04

and the corresponding namespace:

(ns the-divine-cheese-code.visualization.svg)

(defn latlng->point
  "Convert lat/lng map to comma-separated string"
  [latlng]
  (str (:lat latlng) "," (:lng latlng)))

(defn points
  [locations]
  (clojure.string/join " " (map latlng->point locations)))

borkdude11:11:47

@roger429 clj-kondo doesn't support (refer ...). To be honest I've never used this myself in 10 years of Clojure. Just use (require '[the-divine... :refer [points]])

borkdude11:11:33

So maybe I should add support for it, I'll make a ticket for it

roger42911:11:43

(require ['the-divine-cheese-code.visualization.svg :refer [points]])
still has squiggles under points.

borkdude12:11:13

you need to put the quote in front of the vector

roger42912:11:53

Thank you! I'm not the eagle-eyed reader at the moment that Daniel Higginbotham assumes his readers to be:blush:

borkdude12:11:21

no problem šŸ™‚

pez18:11:05

I almost recruited a Calva user the other day. He liked the help I got with unused and misused stuff. Iā€™m pretty sure he was ready to install VS Code. Then I told him it was clj-kondo doing the magic and that he could use it in Emacs as well. šŸ˜ƒ

sogaiu19:11:29

very much enjoying the ability to use clj-kondo in various editors šŸ‘ am a big fan of tooling that can be shared in a variety of environments.