Fork me on GitHub
#clj-kondo
<
2023-01-23
>
pmooser08:01:59

I'm assuming I must have some kind of syntax error, but I had turned off certain warnings in comment blocks, but one of them seems to be back. I have the following (excerpt):

:config-in-comment {:linters {:clojure-lsp/unused-public-var {:level :off}}}
But it does not seem to be working. A separate question is, when using clojure-lsp, and we make a config edit for clj-kondo, do we have to do anything to ensure that the config change has been picked up?

pmooser08:01:17

So interestingly, if I run clj-kondo from the command line on the whole project, I don't get those errors emitted ... which suggests that maybe however clojure-lsp is running isn't finding my project's clj-kondo config? Hmmm.

borkdude08:01:08

This linter is implemented by clojure-lsp and doesn't work with :config-in-comment at the moment

pmooser08:01:11

Oh, ok. I must have been wrong that it was previously working ... thank you!

zakkor11:01:50

When I define a malli schema for a function and return an incorrect type in the function, clj-kondo does not complain as it would if I passed in an incorrect param for example. Is this expected?

zakkor11:01:31

@U04V15CAJ here is an example (I might be doing something wrong)

zakkor11:01:00

but returning an int when the function spec says it is supposed to return string seems to cause no issues

zakkor11:01:42

(defn welcome-string
  {:malli/schema [:=> [:cat :int] :string]}
  [name]
  12)

(welcome-string "asd")

borkdude11:01:34

I think it will emit an error when you call welcome-string and use its result as a non-string. The checking between the implementation and the actual spec might currently not be implemented yet

zakkor12:01:18

Yup, there is an error if you try to pass the result of the function (string) to inc (which wants a number) for example

zakkor12:01:41

Would be huge if the return expression in the function was also typed according to its spec though!

zakkor12:01:20

I imagine that would prevent lots of usual errors, like accidentally returning a higher-order function instead of a number, etc

zakkor12:01:39

Instead of at the call site

borkdude12:01:29

sure, feel free to post an issue

zakkor12:01:17

@U04V15CAJ posted one here: https://github.com/clj-kondo/clj-kondo/issues/1973 (Sorry if I messed that up 😄)

borkdude12:01:23

Can you also please post some code in there to fully repro the situation? Preferably a github repo someone can clone. This will save the person who is going to implement this time.

zakkor12:01:59

Yeah I can, adding now

🙏 2
borkdude13:01:57

This certainly helps, thanks!

Sam Ritchie21:01:51

is there a tool out there that can auto-sort all of my project’s namespaces?

Sam Ritchie21:01:58

I am doing a big rename and 63 namespaces are now unsorted 🙂

dpsutton21:01:13

❯ clojure-lsp clean-ns
[100%] Project analyzed
Checking namespaces...
Cleaned clojure.java.jdbc-test
Cleaned clojure.java.jdbc.spec
Cleaned clojure.java.jdbc.utilities-test
Cleaned clojure.java.jdbc
Cleaned clojure.java.jdbc.datafy
Cleared 5 namespaces

java.jdbc on  master [!?] via ☕ v17.0.1 on ☁️  metabase-query took 5s
❯ pwd
/Users/dan/projects/clojure/java.jdbc

dpsutton21:01:26

i had a copy of java.jdbc and ran clojure-lsp clean-ns on it

Sam Ritchie21:01:45

that is great

borkdude21:01:01

@U017QJZ9M7W You're not using clojure-lsp yet?

Sam Ritchie22:01:10

Not yet! Stuck in my old cider and kondo setup

Sam Ritchie22:01:30

Sounds like I need to make an upgrade

ericdallo00:01:12

clojure-lsp has tasks to clean-ns, format code using cljfmt and get diagnostics using kondo, all in a single tool :)

dpsutton21:01:04

clojure-lsp --help lists: > clean-ns Organize ns form, removing unused requires/refers/imports and sorting alphabetically.

Sam Ritchie21:01:22

amazing… docs for clojure-lsp also reminded me of cljfmt

clojure -Sdeps '{:deps {cljfmt/cljfmt {:mvn/version "0.9.2"}}}'   -m cljfmt.main fix test

👍 2
Sam Ritchie21:01:24

that got it done!