This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-11
Channels
- # aleph (7)
- # announcements (5)
- # beginners (58)
- # calva (20)
- # cider (10)
- # clj-kondo (4)
- # cljfx (5)
- # cljsrn (7)
- # clojure (29)
- # clojure-europe (11)
- # clojure-mexico (1)
- # clojure-norway (26)
- # clojure-uk (9)
- # clojurescript (1)
- # cursive (31)
- # datahike (22)
- # datomic (12)
- # duct (3)
- # fulcro (28)
- # helix (35)
- # hyperfiddle (28)
- # lsp (4)
- # malli (8)
- # midje (3)
- # music (2)
- # nbb (9)
- # nrepl (20)
- # off-topic (36)
- # polylith (3)
- # shadow-cljs (47)
- # sql (2)
- # testing (7)
- # vim (17)
- # xtdb (7)
hi, thanks for rcf ! . Some feedback: more documentation, for noobs as well. I got lucky and found https://github.com/hyperfiddle/rcf/issues/53 quite fast
saw that, ty
will add lein instructions to the readme. hope to publish a new build soon as well, master is stable
is this the right way to do multiple tests on a value?
(let [m (->month-names RO)]
(count m) := 12
(first m) := "Ianuarie")
clj-kondo complains about :=
with "redundant expression"it's correct, maybe someone can contribute a kondo rule
you can also use def or *1
if it's not too much to ask, I think that the above (multiple tests on a value) can also make it to the docs.
you can send a PR that adds an example to the readme if you want
I have added a PR to remove the warning around :=
here: https://github.com/hyperfiddle/rcf/pull/77
thank you!
@U051S5XR3 can you post here a concrete example you are using to test?
I.e. this seems a bit nuanced, in (tests (def a 1) a := 1)
is 1
also considered unused by kondo? is a
?
I have to go AFK at the moment, but I will test this against a repl and update here later in the night. Yea, this PR removes the warnings for all unused values, but I thought it was a decent compromise. Linting it using other means seems much more complicated.
I'll ping borkdude to validate but i want to make sure I understand the exact pain point you're solving first
so it is not just :=
but also a
The definition of :unused-value
in the documentation is: _Description:_ warn on unused value: constants, unrealized lazy values, pure functions and transient ops (assoc!, conj! etc).
without any clj-kondo
config, if I have the following code:
(rcf/tests
"Ensure connection"
(start-pool! *test-data-source*) := nil
*test-data-source* := nil
(start-pool! *test-data-source*) *test-data-source* := nil
"Drop existing test table, if any"
(-> *test-data-source*
(jdbc/execute-one! ["drop table if exists invoice"])
keys)
:= '(:next.jdbc/update-count))
^ no linting error or warning is thrown here. nothing is considered unused
but if I put this in a let binding:
(ns temp
(:require
[hyperfiddle.rcf :as rcf]
[next.jdbc :as jdbc]))
(defn start-pool!
[data-source]
(with-open [conn (jdbc/get-connection data-source)]
(.close conn)))
(rcf/tests
(let [*test-data-source* {:dbtype "sqlite"
:dbname "development/db/testing.sqlite"
:dataSourceProperties {:socketTimeout 30}}]
"Ensure connection"
(start-pool! *test-data-source*) := nil
*test-data-source* := nil
(start-pool! *test-data-source*) *test-data-source* := nil
"Drop existing test table, if any"
(-> *test-data-source*
(jdbc/execute-one! ["drop table if exists invoice"])
keys)
:= '(:next.jdbc/update-count)))
every constant is an unused value:
15 4 warning Unused value: "Ensure connection" (clj-kondo-clj)
16 37 warning Unused value: := (clj-kondo-clj)
16 40 warning Unused value: nil (clj-kondo-clj)
17 4 warning Unused value: *test-data-source* (clj-kondo-clj)
17 23 warning Unused value: := (clj-kondo-clj)
17 26 warning Unused value: nil (clj-kondo-clj)
18 37 warning Unused value: *test-data-source* (clj-kondo-clj)
18 56 warning Unused value: := (clj-kondo-clj)
18 59 warning Unused value: nil (clj-kondo-clj)
20 4 warning Unused value: "Drop existing test table, if any" (clj-kondo-clj)
24 4 warning Unused value: := (clj-kondo-clj)
(probably because it is not used in the let form, from the point of view of standard Clojure code)