Any reason why clj-kondo warns about only the first unresolved-symbol/namespace of the same symbol?
if I have the same unresolved symbol/ns multiple times on the file, clj-kondo only warn the first occurrence
To not annoy you with more info than you probably need
I see, clojure-lsp uses the findings to know if should try to suggest a add-require ns
but without the finding it doesn't know that it should seek for a code action
That will also be sufficient on only the first probably?
I don't think so, we get the findings of the current line, we don't iterate over all the findings of the buffer
so on a big buffer, I need to search the first occurrence of the unresolved var to apply the code action
As a user, why would I apply the action on the second unresolved ns instead of the first?
Imagine a big buffer, where I has the foo/bar
on the start of the buffer and on the end, IMO I want to be able to apply the code action on both places, otherwise I need to find the first occurrence
that's how cursive handles that too.
but the code action only applies something to the ns form. why would you need all places?
what do you mean with "apply the code action"
let me show you a minimal repro
love it
minimal repros I mean
With a code of:
(ns my-ns)
(def some-func []
(string/split "some-func" #"-"))
;; lots of code
(def other-func []
(string/split "other-func" #"-"))
I only get a unresolved ns on the first string/split
, I'd like to have the same warn on the second split, otherwise that looks a correct code.
Also without that finding, there is no way clojure-lsp knows that there is a unresolved ns without that findingso if I try to lsp-execute-code-action
on the last string/split
, clojure-lsp will suggest no Add missing clojure.string require
It just seems odd to me, clj-kondo don't report about all the occurrences of a lint, I know this can be sometimes to much info, but is actually a code that is missing something indeed, just like other IDEs and languages do AFAIK
But why would I apply the code action on the second one, if I already see that the first one isn't right, at the moment of typing it?
It's the same for displaying an unresolved var: just once
that's the issue, If I copy a lot of code for another buffer/ns I'll need to check from top to bottom
in my case, I copied a schema declaration from a clojrue service to another
Why do you need a finding to infer the alias -> namespace?
Can't you add this code action to any alias/foo symbol?
to know that we should search for a unresolved ns
it' could result in some performance issues
check of require code actions on each alias/foo
We could make this an option in clj-kondo, but I would prefer that the user keeps seeing it as it is now
The reason is that clj-kondo might be wrong and it's really annoying if your buffer is littered with false positives
And ignoring only the first will ignore all of them
Else you would have to ignore all 60 of them
And lsp already indicates there is an error in the buffer using the top-level thing
a clj-kondo flag looks good to me as we could have users migrating from other IDEs and having this behavior. I agree that would be a lot of warnings, but all of them correct, right?
> all of them correct Not always, that's the false positives I referred to
Even in LSP I would prefer if the display was the same, although you could have all of them as data
I'll have to think about this
I think we can have a hammock time for that, but that is something I always missed from clj-kondo before clojure-lsp 😛 Could be just me, but I prefer a warning if my code is not right and not need to check the whole buffer for the same symbol or something
I think if you have a false positive, you need to fix that somehow first, otherwise you will already have some warning somewhere about that
The issue is, like I already explained: if clj-kondo is wrong, which it can be, then it's irritating to have 60 errors instead of just 1.
And right now, you can get rid of those, by only ignoring 1 warning with #_:clj-kondo/ignore
. This won't work if we emit all of them. Please put that in an issue.
I see, it's a tradeoff indeed, other languages follow this way though, like dart, you can suppress a single warning in a buffer just like #_:clj-kondo/ignore
, but still other lines will warn about that.
Sure, I'll open a issue later about that, thanks 🙂
I think this should be a user preference and not a clojure-lsp opinion. We can make toggles for this per linter config
Actually, I'm the same. I always wondered why it only showed the first but not the others. I wouldn't mind it being a toggle. False positives I can deal with 🙂
I basically did the same what joker did when I implemented this ;)
and personally I like that
I'm linting a file that has some xml namespaces created via clojure.data.xml/alias-uri. How do I best fix/suppress the unresolved namespace errors for ::<alias>/<keyword>
?
@danieleneal I just fixed this in the latest version, released Sunday
wow! That's great - how does it work, do I need to do anything special in config?
@danieleneal No, should work out of the box
I'll try now
Perfect 🙂
Hi there, is there a way to tell clj-kondo
not to warn me in case of defmulti
"unused" bindings?
I basically like to leave them there as part of the documentation of the defmulti
Can you use _arg
?
I could, if that was the only way
but it feels like a hack
I think it's the usual convention. Not sure if there is a config specific for defmulti.
I see, thanks, it might be worth an issue but I am going to wait to see if borkdude is around
This question has come up more than a couple of times and I think it's good to make an option for this
e.g. this question was asked today here: https://clojureverse.org/t/clj-kondo-and-defmulti/7290/3
There are already a couple of options for unused-binding
We can add another one
issue welcome
kk thanks @borkdude will open one