This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-27
Channels
- # announcements (2)
- # aws (31)
- # babashka (81)
- # beginners (82)
- # calva (38)
- # clj-kondo (41)
- # cljdoc (4)
- # cljs-dev (6)
- # clojure (101)
- # clojure-belgium (1)
- # clojure-europe (30)
- # clojure-germany (1)
- # clojure-italy (7)
- # clojure-nl (4)
- # clojure-norway (1)
- # clojure-spec (1)
- # clojure-uk (19)
- # clojurescript (16)
- # clojutre (1)
- # community-development (26)
- # core-logic (2)
- # data-science (26)
- # datomic (71)
- # events (3)
- # fulcro (55)
- # graalvm (2)
- # graphql (3)
- # joker (2)
- # kaocha (19)
- # luminus (2)
- # malli (6)
- # meander (3)
- # off-topic (6)
- # pathom (34)
- # random (1)
- # re-frame (2)
- # robots (1)
- # shadow-cljs (37)
- # sql (30)
- # tools-deps (21)
- # xtdb (4)
- # yada (25)
Both clojure.java.jdbc
and next.jdbc
have a "with transaction" style macro that has the form (with-transaction [sym expr opts] & body)
-- sym
is introduced by the macro, for the body (like binding
or several other core macros) but if I tell kondo to :lint-as
any of those macros, it then complains about opts
since a binding form should be an even number of forms. Can anyone think of a core macro that has an optional extra expression in a binding like that?
(I know I can turn off :unresolved-symbol
inside the macro but that's a bit brutal)
Also
(+ (byte 32) 1)
what is the justification for error: Expected: number, received: byte
? A byte
is a number.@seancorfield The type warning is a bug in clj-kondo. You can override it with:
$ clj-kondo --lint - --config '{:linters {:type-mismatch {:namespaces {clojure.core {byte {:arities {1 {:ret #{:byte :number}}}}}}}}}' <<< '(+ (byte 32) 1)'
linting took 15ms, errors: 0, warnings: 0
@mitchell_clojure The strange issue you had was related to populating the m2 cache for the tests. It should now be fixed when you run script/test with master.
thanks for the followup. confirmed fixed. was it just the version mismatch?
cool makes sense to me. interesting that lein/clojure didn't populate .m2 when run with the clojure-1.10.2-alpha1 profile/alias. thanks again
@seancorfield The type warning got fixed on master (https://github.com/borkdude/clj-kondo/issues/819)
the relevant bit: https://github.com/borkdude/clj-kondo/commit/c5b8b7850420f054bcacfe56b3bfcbc3dafe8da1#diff-6d8aa5ed918d9c02addd52e5c039fc29
For now I worked around this in my code, but once that drops in a release, I'll change it back.
cool. you can also use this config in the meanwhile:
{:linters {:type-mismatch {:namespaces {clojure.core {byte {:arities {1 {:ret #{:byte :number}}}}}}}}}
I already changed the code 🙂
note that you can also introduce type checking for arbitrary other functions you're interested in, this way. it's not used a lot yet, because it's not "for free" I guess
Good to know. I will say that I am already super-impressed with clj-kondo
-- it's an amazing piece of work!
As for a lint-as config for clojura.java.jdbc with-transaction: clojure.core/let doesn't work unfortunately because of the opts, but I think this would be good to support out of the box in clj-kondo. Made an issue for it: https://github.com/borkdude/clj-kondo/issues/821
https://github.com/borkdude/clj-kondo/pull/823 adds support for three with-db-*
macros in clojure.java.jdbc
and also next.jdbc/with-transaction
The way I usually test "findings" is to first call (prn (lint! "..."))
and then paste that output back into the test file and test it with (assert-submaps the-output (lint! "..."))
Merged. Thanks a lot. Do you need a new binary with this included or did you figure out how to build it yourself?
I will just wait until you make a new release.
(and, thank you again, for an excellent project and also for taking the time to provide feedback in the PR)
It can take a while since there are plenty other enhancements to make. Until then you can use the :unresolved-symbol config. If you want to speed up things, you could even try to contribute 🙂
I'm off work today (I often take Fridays off, so I can have a 3 day weekend) so maybe I'll take a look as part of my "OSS Friday" routine 🙂
Any particular guidance for how you like PRs packaged up? Code style? Tests?
Here's a document that should give some guidance: https://github.com/borkdude/clj-kondo/blob/master/doc/dev.md
Yup. Already reading it and I've forked the repo 🙂
@borkdude thank you for the swift responses!
@seancorfield no problem. fwiw I have this in the config of the app I'm now working on:
:lint-as {clojure.java.jdbc/with-db-transaction clojure.core/let
schema.core/defschema clojure.core/def
reagent.core/with-let clojure.core/let}
but we're not using any opts in with-db-transaction
I guess I can remove the config for schema.core/defschema
, that's already supported for a while
Yeah, both clojure.java.jdbc/with-db-transaction
and next.jdbc/with-transaction
are like when-let
when you don't provide options (only one binding allowed, so not really like let
). I've never been happy with the syntax tho', because of this not-quite-let
style.
Good to know. I will say that I am already super-impressed with clj-kondo
-- it's an amazing piece of work!
https://github.com/borkdude/clj-kondo/pull/823 adds support for three with-db-*
macros in clojure.java.jdbc
and also next.jdbc/with-transaction