Fork me on GitHub
#clj-kondo
<
2022-06-16
>
mpenet13:06:20

I saw some weird error today: Can't parse blablabla.clj, No implementation of method: :tag of protocol: #'clj-kondo.impl.rewrite-clj.node.protocols/Node found for class: nil - clj-kondo

mpenet13:06:29

does that ring a bell?

mpenet13:06:35

it flags a ns declaration

mpenet13:06:13

a very simple one: (ns something.something), no require/refer-clojure & co

mpenet13:06:49

tried to nuke the .lsp cache & the clj-kondo one, still here

borkdude13:06:47

please try with the most recent version of clj-kondo on the command line, to avoid any downstream involvement

borkdude13:06:17

can't repro using this example alone:

(ns something.something)

mpenet13:06:49

this is not the real namespace I have, but I think the ns name is irrelevant in that case

borkdude13:06:44

is it possible to make a minimal repro though and do it with clj-kondo on the command line and send that repro here?

mpenet13:06:49

❯ clojure-lsp --version clojure-lsp 2022.05.31-17.35.50 clj-kondo 2022.05.31

mpenet13:06:52

still here

mpenet13:06:00

I ll check on the command-line

mpenet13:06:53

same error on the cli

borkdude13:06:41

can you show me your CLI invocation?

mpenet13:06:22

❯ clj-kondo --lint . ./some-random-file.clj:0:0: error: Can't parse ../some-random-file.clj, No implementation of method: :tag of protocol: #'clj-kondo.impl.rewrite-clj.node.protocols/Node found for class: nil

mpenet13:06:31

same result with ❯ clj-kondo --cache false --lint .

borkdude13:06:47

what is in some-random-file.clj?

mpenet13:06:39

protocols & implems of these etc etc, but the problem lies here. If I remove half of the code the issue goes away, I ll try to bisect the thing until I find the culprit

mpenet13:06:08

ah found it

mpenet13:06:13

there was a buggy defmulti

mpenet13:06:33

it had no dispatch fn defined, something like (defmulti foo)

mpenet13:06:08

odd that I got pos 0:0 flagged tho

mpenet13:06:42

try with a file with that:

mpenet13:06:46

(ns foo)

(defmulti foo)

mpenet13:06:51

you'll get the same issue

borkdude13:06:23

yes, when something unexpected happens, then clj-kondo doesn't know where to put the issue and it just puts it at 0:0

borkdude13:06:33

but we should make this more robust. feel free to post an issue

delaguardo15:06:20

Is it possible to discourage usage of whole namespace? I know there is https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#discouraged-var but would be great to place the warning directly on ns declaration because requiring namespace is a mutation and might cause some problems even if vars are not used

borkdude15:06:53

Currently not but feel free to post an issue

borkdude15:06:00

I think there were also some requests recently to lint access from namespace X to namespace Y etc

borkdude15:06:06

which might also be nice to incorporate

Alex Miller (Clojure team)15:06:08

you can deprecate in the namespace metadata

Alex Miller (Clojure team)15:06:02

I guess that's not actually metadata, but it could be

Alex Miller (Clojure team)15:06:00

that's proposed in https://clojure.atlassian.net/browse/CLJ-706 (not sure if that will ever get looked at, Rich was noncommittal the last time he did)

delaguardo15:06:47

@U064X3EF3 those namespaces out of my control. They are coming from a library and to alter metadata I have to load it first which is exactly what I'm trying to avoid.

borkdude15:06:12

Thanks! There's also already an issue for warning on deprecated ns metadata

delaguardo10:06:10

FWI - https://github.com/clj-kondo/clj-kondo/pull/1724 @U04V15CAJ adding new linter was surprisingly easy, kudos for the architecture of kondo

borkdude10:06:19

Nice. Maybe we should add some example of using an ns group + the in option? Maybe :from is a better name than :in ?

delaguardo10:06:18

In my head in emerged from the sentence: "In namespaces #{X Y Z} discourage usage of namespace A" can't make such sentence with from but probably it is a problem of my english 🙂

borkdude10:06:03

We already use the word :from in the analysis here: https://github.com/clj-kondo/clj-kondo/blob/master/analysis/README.md so imo that would be more consistent

borkdude10:06:55

The namespace A is used from namespaces X Y Z. Valid English I think?

delaguardo10:06:00

sounds right to me, I'll change it

borkdude09:06:57

@U04V4KLKC I invited you to #clj-kondo-dev for some PR feedback