Fork me on GitHub
#lsp
<
2021-10-13
>
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)

borkdude09:10:27

perhaps you can make a repro?

ericdallo12:10:36

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?

ericdallo12:10:54

A repro would help indeed

borkdude12:10:55

I actually fixed another possible issue just on master.

borkdude12:10:13

which was also bothering Carve

ericdallo12:10:03

good! I'll bump on clojure-lsp

borkdude12:10:49

it's still deploying

borkdude12:10:03

we also have to merge the dedupe branch first I think

👍 1
borkdude12:10:40

@UKFSJSM38 if you can PR your test

borkdude12:10:48

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

ericdallo12:10:59

I'll do that, sorry for the delay

borkdude12:10:18

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

ericdallo13:10:42

no, it is not priority

borkdude13:10:02

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

borkdude13:10:07

with lots of new improvements!

borkdude13:10:30

=== duplicate-files

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

borkdude13:10:12

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

ericdallo13:10:17

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.

borkdude15:10:57

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

borkdude15:10:03

it's a custom linter

r16:10:48

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
ericdallo16:10:24

thanks for the tip!

ericdallo16:10:44

Is having symlinks called checkouts something common?

ericdallo16:10:24

if so, we should consider adding that to lsp-mode repo: https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L343

ericdallo16:10:38

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

r16:10:38

great. i’ll open up a pull request

👍 1
ericdallo16:10:07

Merged, thanks!

❤️ 1