Fork me on GitHub
#clj-kondo
<
2023-04-13
>
ericdallo02:04:54

There is a kondo analysis missing issue that happens a lot in Nubank projects that if fixed would help a lot developing, especially completion lsp feature 🧵

ericdallo02:04:32

After some debugging I found it's related with the usage of schema.core/defn , when you have a map with odd pairs all analysis of that function are lost: This works, returning all keywods, var-usages and other analysis as expected, even with invalid map (common when you are writing code and completing):

(defn foo []
  (str {:a 1 :b}))
This doesn't return any analysis inside foo:
(schema.core/defn foo []
  (str {:a 1 :b}))

ericdallo02:04:23

Is quite easy to spot the issue in editor where lens, semantic tokens and other features are missing for s/defn:

ericdallo02:04:24

I think this kondo only repro proves it:

clj -Sdeps '{:deps {clj-kondo {:mvn/version "2023.03.17"}}}' -m clj-kondo.main --config '{:config-paths ^:replace [] :output {:format :json :analysis {:keywords 
true}}}' --lint - <<< '(ns foo (:require [schema.core :as s])) (s/defn foo [] (str {:a 1 :b}))' |jq .

borkdude07:04:25

ok issue welcome

tobias09:04:05

Any chance that in the future clj-kondo could add static analysis support for the for-by macro used in Electric Clojure? • e/for-by: a reactive map operator, stabilized to bind each child branch state (e.g. DOM element) to an entity in the collection by id (provided by userland fn - similar to React.js key). See example https://electric-examples-app.fly.dev/user.demo-system-properties!SystemProperties

borkdude09:04:05

@UA9399DFZ This is something that library authors or users can do themselves in the form of hooks

borkdude09:04:31

If you want I can guide you through that process. Then you can either contribute that back to the project or keep it as a separate dependency

tobias09:04:46

Oh nice, I didn't know about hooks for extending clj-kondo. Thanks for the offer of guiding me through the process but I think I'm not the right person to take this on as don't really understand how electric works and I'm a noob at macros.

tobias09:04:36

@U09K620SG is this possibly something the #C7Q9GSHFV team would consider for the future?

borkdude09:04:40

FYI @U09K620SG I'd be available in helping this

Dustin Getz10:04:49

certainly we want to include this

nonrecursive14:04:15

hey y’all, I’m doing some local library development and I’m running into an issue where I’ll update a library to say, add a function, but clj-kondo isn’t recognizing that function in another project that uses the updated library. how do I resolve this?

borkdude14:04:42

@U0AQ1R7FG are you using clj-kondo directly in emacs or via clojure-lsp?

nonrecursive14:04:03

via clojure-lsp

borkdude14:04:29

then it's just a matter of doing lsp-workspace-restart I think

borkdude14:04:42

in the project that uses the library

nonrecursive14:04:17

oh great, thanks!

nonrecursive14:04:32

that did it. thank you!

Hachmaninow17:04:15

Hi. Referring back to this older question: https://clojurians.slack.com/archives/CHY97NXE2/p1636046966102200 This answer was given: https://clojurians.slack.com/archives/CHY97NXE2/p1636047101103800 I tried it, but for me it does not work. I also assumed maybe there is a typo in the response and it should rather be:

{:lint-as 
 {monger.operators/$set clojure.core/def
  monger.operators/$addToSet clojure.core/def}}
? Still, it has no effect… Is it possible that clojure-lsp (with Neovim) does not respect a project-local .clj-kondo/config.edn?

borkdude17:04:05

This only has an effect if you lint the code again in which the vars are def-ed

borkdude17:04:47

Feel free to provide a small repro project so I can check locally

Hachmaninow17:04:16

After deleting the cache directory it works now. Thank you so much @U04V15CAJ!

👍 2