Open ikappaki opened 2 years ago
We would need to make clj-kondo return analysis for bb.edn
, then clojure-lsp would find that those functions are really being used as bb tasks, what you think @borkdude?
Yeah, there is a clj-kondo issue to provide linting for bb.edn as well. If we implement that, then this would work as well. But for now you could maybe just treat the task .clj code as a library (so it will ignore unused public vars)?
@borkdude what do you mean to treat the task .clj as a library? How can we know that a specific user ns is supposed to be a library?
@ericdallo "as a library" I mean: a namespace in which all vars should not be linted as unused public vars. This is a general problem with that linter right?
Yes, I think that would be a new feature for clojure-lsp where user specifies those ns, right? not sure how common is that since most cases I saw are related to functions that are being used on edn files
If you write a library, isn't it common that many functions in the public API are not used anywhere else? Except in tests.
Yes, but we already have the config to allow that, right?
.clj-kondo/config.edn
{:linters {:clojure-lsp/unused-public-var {:exclude #{my-ns}}}}
Indeed, that's what I intended to say :)
So, @ericdallo, it sounds like it would have been better if I had done {:linters {:clojure-lsp/unused-public-var {:exclude #{make}}}}
rather than ignoring each of the make tasks individually. Would you like a PR that corrects that?
I'm fine with both
Yeah, there is a clj-kondo issue to provide linting for bb.edn as well. If we implement that, then this would work as well. But for now you could maybe just treat the task .clj code as a library (so it will ignore unused public vars)?
HI @borkdude, is this the one you are referring to please? https://github.com/clj-kondo/clj-kondo/issues/1576
Yup!
Describe the bug clojure-lsp diagnostics misreports as
unused public var
fns that are referenced bybb.edn
tasks.To Reproduce
create a test directory with the following files (say in
~/clsp-diags-miss-bb
) :bb.edn
:scripts/make.clj
Expected behavior no diagnostics message should be produced about Unused public var, since
make/hi
is referenced bybb.edn
.User details (please complete the following information):