Fork me on GitHub
Tomas Brejla08:10:07

is there any simple way of tracking down why I sometimes get false-positive unused-public-var problems on functions, which are actually being called in my codebase?

Tomas Brejla08:10:26

or perhaps some "force reindexing" command or something?

Tomas Brejla08:10:55

(using vscode + calva, so I hope it's actually lsp-related)


perhaps you can make a repro?


We have a issue on cljc files that was ready fixed on kondo and it will be available on next clojure-lsp release, any chance your issue is related to cljc files?


A repro would help indeed


I actually fixed another possible issue just on master.


which was also bothering Carve


good! I'll bump on clojure-lsp


it's still deploying


we also have to merge the dedupe branch first I think

👍 1

@UKFSJSM38 if you can PR your test


then I can merge that into the dedupe branch and then merge that


I'll do that, sorry for the delay


also, the ns-config, is this something that is blocking something?


no, it is not priority


ok, then after the dedupe stuff I think you can bump clj-kondo


with lots of new improvements!


=== duplicate-files

[clj-kondo] Already seen the file /home/circleci/repo/corpus/simple_test/a_test.clj before, skipping


ok, merged to master. I will add a few more features to clj-kondo before announcing a new release (later this week or next week) but those are probably not so interesting for LSP


awesome! will test later today, thank you!

Tomas Brejla14:10:11

sorry, I wasn't around much today. that issue I'm facing happens on regular clj files. I'm affraid I don't have an easy way to reproduce it easily. In fact I believe that there's a chance that the mentioned unused-public-var false positive warning might even fix after I restart my running calva instance. That's why I wanted to check first whether I can try to analyse something on that running calva instance where the problem still shows.

Tomas Brejla14:10:10

For example I have

(ns someproject.util
  (:import [java.util UUID]))

(defn uuid []
  (str (UUID/randomUUID)))
and then
(ns someproject.db.someitem
  (:require [xtdb.api :as xt]
            [someproject.util :refer [uuid]]))


(defn somefn! [xtdb-node some-id]
  (let [new-id (uuid)]
I can ctrl+click the (uuid) and it navigates me correctly to defn uuid function.. Everything works on runtime, but the editor shows unsused var warning on that "function definition side". When I run
clj-kondo --lint src/clj
then the output is clear.. no issues.

Tomas Brejla14:10:49

Btw... > In fact I believe that there's a chance that the mentioned `unused-public-var` false positive warning might even fix after I restart my running calva instance. I can now confirm that. I simply made a copy of the whole folder of my app, opened it in yet another vscode/calva instance and the uuid function is no longer shown as "unused". So I'm affraid makins repro doesn't seem to be an easy task. I have no idea how it happened, that I ended up in that strange situation where the fn is shown as unused - and restarting my editor (and calva/lsp) seems to fix the problem.


@U01LFP3LA6P clj-kondo itself doesn't have the unused-public-var linter, you have to use clojure-lsp for linting


it's a custom linter


just a small tip for those of us using lsp-mode in emacs in a Clojure monorepo with a lot of checkouts directories—i kept running out of file handles on my system because lsp-mode was following symlinks to projects many times. adding (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\checkouts\\'") to my emacs configuration remediated the issue

👍 1

thanks for the tip!


Is having symlinks called checkouts something common?


if so, we should consider adding that to lsp-mode repo:


@U013GG71CHL LGTM, would you mind opening a PR on lsp-mode adding that to the link I sent?


great. i’ll open up a pull request

👍 1

Merged, thanks!

❤️ 1