I'm having a problem with clj-kondo integration in emacs, where it sometimes does not lint functions defined in the project but only those defined in required libs. I'm not really certain about how to start debugging that - anybody got a hint maybe?
(it's about number of required args)
how are you using clj-kondo, via which plugins
Getting odd false warnings from clj-kondo
(ns witan.small-test
(:require [tablecloth.api :as tc]))
(defn add-series-name [ds series-name]
(if (contains? (set (tc/column-names ds)) :series-name)
ds
(tc/add-column ds :series-name series-name)))
spacemacs clojure layer
all the tc/* things are getting squigglies with the warning Unresolved var:...
should be using flycheck/lsp afaik
not sure if it is something odd about tablecloth or something in kondo
I'm on the latest kondo release
Doth tablecloth define these vars using some custom macro?
If so, then you should either add a config for this custom macro, or add the tc namespace to :exclude in the unresolved-var linter
(defn add-column
"Add or update (modify) column under `column-name`.
`column` can be sequence of values or generator function (which gets `ds` as input)."
([ds column-name column] (add-column ds column-name column nil))
([ds column-name column size-strategy]
(let [process-fn (prepare-add-column-fn column-name column (or size-strategy :cycle))]
(if (grouped? ds)
(process-group-data ds process-fn)
(process-fn ds)))))
weird thing is, it works fine with fns defined in the same namespace, but not in those defined in other namespaces in the same project
and defn = clojure.core/defn? this is not always the case, but I assume it is?
I believe so, but I'm looking
yeah, looks like normal defn (I know potemkin is used in other places, but it doesn't look like in this place)
@otfrom Maybe re-lint your tablecloth dependency?
If you have some same-named namespace somewhere else it could be that the definitions are overwritten
never done that before
@otfrom rm -rf .clj-kondo/.cache should then solve it, but I assume clojure-lsp is linting your deps
it was, but I removed it as that was showing even more weirdness
repro welcome, need more details
Workaround is {:linters {:unresolved-var {:exclude [<http://your.tc|your.tc>.namespace]}}}
if you can make a repro using a minimal project + command line examples, I can take a look. Hard to say anything without more details
seems good now. Not sure how the cache got messed up
Could be an issue with lsp + clj-kondo
ok
possibly
the cache getting messed up over a number of updates sounds like a reasonable culprit until it happens again
I just had no idea about the cache
(caches have been the bane of my life recently)
thx for pointing me in the right direction
clojure-lsp tries to lint all of your deps automatically. clj-kondo doesn't do this, unless you tell it to
also clojure-lsp using an incremental diff when you edit files, which might go wrong - there were some discussions about this in the lsp channel
is tablecloth your dep, or your project?
as in did I create tablecloth? I'm just using it
you can try clj-kondo --lint $(clojure -Spath)
(assuming deps.edn) and see if you get the issue again
I've run that and I am getting the same issue
(ns witan.small-test
(:require [tablecloth.api :as tc]))
(defn col-wrapper [ds]
(tc/column-names ds))
Unresolved var: tc/column-names
ok, that's what I suspected. taking a look at that api ns: https://github.com/scicloj/tablecloth/blob/master/src/tablecloth/api.clj so these vars are all defined using some custom machinery. you must either configure clj-kondo to make it understand this machinery, or to ignore this
it looks an awful lot like potemkin/import-vars but not quite, so you cannot simply use :lint-as
for this
you can either write a hook, or use the workaround I suggested. this is expected behavior
thx. sorry for snitch tagging you on zulip, but I was wondering if someone else had already solved it
fwiw @lee has a nice way to generate the potemkin-like-code using a couple of functions instead of using a macro, this makes all the tooling understand it
but writing a hook for this isn't too hard
any examples of other hooks I could crib from?
more docs are here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md
Referenced in hooks.md, but https://github.com/lread/rewrite-cljc-playground/commit/09882e1244a8c12879ef8c1e6872724748e7914b when I needed it (I no longer do because I abandoned import-vars - too many headaches!).