Fork me on GitHub
#clj-kondo
<
2021-04-24
>
Duck Nebuchadnezzar13:04:11

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

borkdude13:04:07

@duck Is this for #babashka? :)

mike_ananev16:04:42

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}

borkdude16:04:42

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

borkdude16:04:49

the empty filename always matches any file probably

borkdude16:04:38

it's a regex

mike_ananev16:04:45

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

dgr19:04:12

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.

borkdude19:04:46

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

dgr19:04:16

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.

dgr19:04:32

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

borkdude19:04:54

@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

borkdude19:04:41

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?

borkdude19:04:17

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

dgr20:04:07

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

dgr20:04:27

Yep, that worked

dgr20:04:57

Thanks!

👍 3