clj-kondo

https://github.com/clj-kondo/clj-kondo
2021-04-24T13:21:11.339900Z

Is there a good way to get a repl with all of the namespaces in my :requires key processed? (also the default commands)

borkdude 2021-04-24T13:39:07.340200Z

@duck Is this for #babashka? :)

2021-04-24T14:23:17.340500Z

oops, it was

mike_ananev 2021-04-24T16:13:42.343200Z

Why, If I have .clj-kondo/config.edn all warnings and errors disappears in IDE (Emacs, Cursive)? If I delete .clj-kondo/config.edn then all warnings returns in IDE. contents of .clj-kondo/config.edn

{:output        {:exclude-files [""]}

 :linters       {:consistent-alias
                 {:aliases {clojure.string   string}}

                 :unresolved-namespace
                 {:exclude [user criterium.core]}

                 :unresolved-symbol
                 {:exclude [(cljs.test/are [thrown? thrown-with-msg?])
                            (cljs.test/is [thrown? thrown-with-msg?])
                            (clojure.test/are [thrown? thrown-with-msg?])
                            (clojure.test/is [thrown? thrown-with-msg?])]}

                 :unsorted-required-namespaces
                 {:level :warning}

                 :unused-referred-var
                 {:exclude {clojure.test [is deftest testing use-fixtures]}}}

 :skip-comments true}

borkdude 2021-04-24T16:14:42.343400Z

I suspect this is the culprit: :output {:exclude-files [""]}

borkdude 2021-04-24T16:14:49.343700Z

the empty filename always matches any file probably

borkdude 2021-04-24T16:16:38.343900Z

it's a regex

mike_ananev 2021-04-24T16:18:45.345500Z

thanks! if I put {:exclude-files ["target"]} all warnings became visible!

dgr 2021-04-24T19:53:12.350100Z

I’ve got a clojure.test file that is using (:require [foo.core :refer :all]) in the namespace declaration. All the symbols that should be referred by that are being flagged later on as error: Unresolved symbol: bar. Is that expected or a bug? If I use :refer [bar], it is not flagged. This is with the latest version of clj-kondo installed on latest MacOS Big Sur via Homebrew.

borkdude 2021-04-24T19:53:46.350400Z

@droberts3 Did you not have that with the previous version of clj-kondo?

dgr 2021-04-24T19:55:16.352Z

I don’t know. I haven’t gone back and installed a previous version to figure it out. I wanted to ask here before I tried to debug it too much further. I was thinking that maybe clj-kondo didn’t pull in required namespaces on purpose (performance?) and was just using the static symbols in a :refer form in the file itself.

dgr 2021-04-24T19:56:32.353700Z

It’s pretty common in unit tests to use :refer :all to pull in everything in the namespace under test.

borkdude 2021-04-24T19:56:54.354100Z

@droberts3 It's a bit of a gray area. Since clj-kondo is a static analyzer and pretty much just lints what you throw at it, without inspecting other stuff on your filesystem, this can be hard. But chances are that when you also have linted foo.core while also having a .clj-kondo dir so it can save information there, that this will work correctly

borkdude 2021-04-24T19:58:41.355700Z

I think that should work even. So can you maybe do:

mkdir -p .clj-kondo
clj-kondo --lint src:test --dependencies
and then check again in your editor after making an edit?

borkdude 2021-04-24T19:59:17.356300Z

(the --dependencies flag is telling clj-kondo to not emit any output because you are linting only for populating the cache)

dgr 2021-04-24T20:00:07.356500Z

Ah. Let me try this. I don’t have a .clj-kondo directory as I have just been using straight defaults.

dgr 2021-04-24T20:00:27.356800Z

Yep, that worked

dgr 2021-04-24T20:00:57.357400Z

Thanks!

👍 1