This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-22
Channels
- # aleph (6)
- # announcements (1)
- # babashka (2)
- # beginners (51)
- # calva (14)
- # cider (1)
- # clj-kondo (15)
- # cljs-dev (2)
- # cljsrn (1)
- # clojure (9)
- # clojure-czech (2)
- # clojure-spec (5)
- # clojure-uk (45)
- # clojuredesign-podcast (2)
- # clojurescript (4)
- # clojutre (3)
- # cursive (4)
- # datomic (8)
- # duct (8)
- # jackdaw (1)
- # joker (1)
- # keechma (1)
- # off-topic (127)
- # om (1)
- # reagent (1)
- # reitit (6)
- # shadow-cljs (22)
- # testing (3)
i was thinking it would help to get people to try the feature out -- not too keen on having to write the annotations from scratch, but may be the barrier-to-entry might be sufficiently low if all i needed to do was edit some generated things 🙂 he he -- just being lazy
Yeah, spec provider might be used to generate an initial config. This can be a third party tool outside of clj-kondo
i wonder if it's practical to generate the annotations for clj-kondo from at least some types of existing specs
may be there's a way to automate getting part-way there -- and fill the rest in with core.logic? i can dream, can't i 🙂
👋 Just wanted to expand on the success story @marc-omorain mentioned: This is an extracted code sample that represents what i actually had
(defn- make-api-call
"Separate the logic from the call mechanism, even though there's only one call"
[{:keys [api path body tags]}]
(let [metric-result (promise)
metric-status (promise)]
(try
(let [{:keys [status]}
(clj-http.client/post ""
{:form-params body})]
(deliver metric-status status)
(deliver metric-result :ok))
(catch clojure.lang.ExceptionInfo ex
(let [data (ex-data ex)]
(when-let [status (:status data)]
(deliver metric-status status)
(deliver metric-result :http-error)
(throw (ex-info "request failed"
(merge data {:api api
:type :http})
ex)))
(deliver metric-result)
(throw ex)))
(catch java.io.IOException ex
(deliver metric-result :io-error)
(throw (ex-info "connection failed"
{:api api
:type :transport}
ex)))
(catch Throwable ex
(deliver metric-result :error)
(throw ex)))))
and this is the error clj-kondo found that i’d overlooked
error: wrong number of args (1) passed to clojure.core/deliver
My tests didn’t exercise that path, because it probably shouldn’t ever happen in practice.This is the slide I've made out of it. Have to keep it brief, because I have only 20 minutes, so I'm going to mention it in passing. https://www.dropbox.com/s/mcptwz75u6bqcgz/Screenshot%202019-09-22%2013.57.24.png?dl=0
on a different note, is this scenario something that kondo could/should catch?
(deftest does-some-stuff
(testing "it does-some-stuff"
(let [path "resources/test/some/stuff"]
(= (keywordize-keys (yaml/parse-string (slurp (str path "/config.yml"))))
(do-stuff path {:parameters {:option false}})))))
yeah, it could. right now it only catches that if you use the predicate directly under deftest, but it could be made more intelligent
clj-kondo v2019.09.22-alpha ✨ Type checking and more. https://github.com/borkdude/clj-kondo/releases/tag/v2019.09.22-alpha