This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-14
Channels
- # announcements (40)
- # aws (9)
- # babashka (21)
- # beginners (75)
- # calva (56)
- # chlorine-clover (1)
- # cider (12)
- # circleci (1)
- # clj-kondo (7)
- # cljsrn (13)
- # clojars (3)
- # clojure (171)
- # clojure-dev (11)
- # clojure-europe (64)
- # clojure-nl (11)
- # clojure-spec (6)
- # clojure-uk (9)
- # clojurescript (31)
- # conjure (1)
- # cursive (7)
- # datascript (7)
- # datomic (9)
- # emacs (4)
- # fulcro (65)
- # introduce-yourself (1)
- # jobs-discuss (7)
- # kaocha (7)
- # lsp (39)
- # missionary (5)
- # off-topic (54)
- # pathom (10)
- # re-frame (6)
- # shadow-cljs (110)
- # tools-deps (41)
It seems that sometimes declarations to ignore unused public vars are behaving strangely. Example code:
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn foo []
42)
If I open a new instance of Emacs and navigate to this code, then, after the workspace has started, the code can sometimes be highlighted as having an unused public var.
If I then edit the file (eg enter a space and then undo the change), the error report goes away.
If I restart the lsp workspace (with `lsp-worspace-restart`), the error report re-appears (or can re-appear),
If I move the declaration to the project’s `config.edn` like this…
:clojure-lsp/unused-public-var {:exclude #{my-ns/foo}}
…then all is OK.
I said “sometimes” and “can re-appear” above. It seems to work like this: In small projects, there’s never a problem; in large projects, the problem always happens; in projects of a certain middle size the problem sometimes happens and sometimes doesn’t.
Any thoughts on what might be happening or what I can do to find out more?
I’m now using clojure-lsp 2021.09.13-22.25.35, but I first noticed this some time ago.yeah, I saw this behaviour recently, but couldn't understand exactly what is going on, I suspect it's related with the first clj-kondo analysis we do when starting the project which doesn't understand the ignore for some reason in the custom-lint-fn but the next analysis scan, did when you open a file or edit something works
Does your suggestion account for it happening only sometimes? (I mean with the same code — ie it’s non-deterministic).
no, for me it's deterministic, if I start clojure-lsp, and call lsp-treemacs-errors-list
, I will see unused public var diagnostics that only go away if I enter the file (which will trigger a clj-kondo single-file analysis)
Ah. For me, lsp-treemacs-errors-list
deterministically gives me the erroneous reports, but the flycheck
reports are non-deterministic.
Still working on a repro repo.
that's why if we fix it we can confirm it won't happen if lsp-treemacs-errors-list show no warnings
There’s a repo at https://github.com/simon-katz/clojure-lsp-unused-public-var-misreports
If you want more than 1000 namespaces, the code in the create-ns-s
namespace creates them.
I think only 2 namespace are enough to repro the issue, but there is no problem keeping the 1000, I tested and confirmed the issue
BTW, I need many namespaces in order to get the non-deterministic behaviour with flycheck
. (But I understand your point.)
I’m possibly hitting this though in my project all my declarations are in .lsp/config.edn. I’ve upgraded to the new brew version (clojure-lsp/brew/clojure-lsp-native) and I’ve updated to the latest clj-kondo. I’ve also updated to the new key (:clojure-lsp/unused-public-var)… anything else I’m possilby not thinking of?
@U0VP19K6K It turns out that what I said about putting things in config.edn
was only sometimes true. I edited the bug report to say so a little while ago.
I think it’s a matter of waiting for a new release of clj-kondo (which has a fix merged), and then a new release of lsp-clojure that includes the new clj-kondo.
Thanks, was just about to ask if it’s just a matter of waiting, thanks @U06A9U5RP!
Yeah, clj-kondo just merged the improvement, I will add a unit test and then make the changes on clojure-lsp, then it should fix this issue :)
Fixed on master, you can try building clojure-lsp local with make
or waiting for the next release :)
I’m still having issues with this (I think!). Is there anything here that stands out to anyone?
I have
• clojure-lsp/brew/clojure-lsp-native 2021.09.13-22.25.35
• borkdude/brew/clj-kondo 2021.09.15
• I’ve cleared out both cache directories
• I’m using the new config.edn format:
{:linters
{:clojure-lsp/unused-public-var
{:exclude #{FULLY_QUALIFIED_VARS}}}}
https://github.com/dcostaras/lsp-unused-vars-repro There is a screenshot in the root showing the warning
your configuration content is correct, but it's on the wrong file 😅
The correct location for this lint config is on .clj-kondo/config.edn
there is more info explaning why here: https://clojure-lsp.io/settings/#custom-clj-kondo-hooks
Oh right! Haha, yeah this is hold over from before (I think this used to the correct dir?) I changed the format but didn’t read that paragraph properly. Thanks again 🙌
yeah, some months ago this was on clojure-lsp but this was causing a lot of other issues, since we started using as a custom clj-kondo lint-fn, this now needs to be configured there
You can think: when this is related to lint, should be configured on clj-kondo otherwise probably lsp
Yeah, I did actually think it was a bit less ergonomic having two config files for linting. All good 🙂
I’m still having issues with this (I think!). Is there anything here that stands out to anyone?
I have
• clojure-lsp/brew/clojure-lsp-native 2021.09.13-22.25.35
• borkdude/brew/clj-kondo 2021.09.15
• I’ve cleared out both cache directories
• I’m using the new config.edn format:
{:linters
{:clojure-lsp/unused-public-var
{:exclude #{FULLY_QUALIFIED_VARS}}}}