This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-04
Channels
- # announcements (1)
- # architecture (7)
- # beginners (44)
- # biff (11)
- # calva (15)
- # cider (5)
- # clerk (9)
- # clj-kondo (20)
- # clj-on-windows (19)
- # clj-yaml (2)
- # cljs-dev (39)
- # clojure (52)
- # clojure-czech (2)
- # clojure-dev (11)
- # clojure-europe (28)
- # clojure-hamburg (10)
- # clojure-hungary (3)
- # clojure-nl (1)
- # clojure-norway (59)
- # clojure-uk (5)
- # clojured (2)
- # clojurescript (33)
- # conjure (2)
- # datahike (1)
- # datomic (5)
- # defnpodcast (5)
- # emacs (18)
- # figwheel (2)
- # funcool (6)
- # graphql (1)
- # hyperfiddle (11)
- # jobs (3)
- # joyride (13)
- # malli (6)
- # music (4)
- # off-topic (45)
- # polylith (11)
- # practicalli (3)
- # rdf (3)
- # releases (1)
- # scittle (8)
- # shadow-cljs (13)
- # specter (2)
- # squint (8)
- # testing (6)
- # tools-deps (21)
- # xtdb (2)
Hi, all! If clj-kondo is suggesting a change somewhere in my source code other than where the cursor currently is, how do I accept the suggestion, either with the mouse or (once I’ve clicked the suggestion site) with a keystroke? I’m on a Mac, and control-space / command-dot don’t do the trick. (I’m new to VS Code, so my question may be a VS Code question rather than a Calva one.)
Not sure I follow. But command-dot (quick-fix) is the way to get to know what fixes are available. If you don’t see any fixes for the problem, then probably there is none. I have a feeling I am missing what the problem is, though…
Sorry - pics would be better! clj-kondo suggests, but quick-fix doesn’t know about the suggestion.
It knows as much as you can suppress it. 😃 Jokes aside, this means that clojure-lsp (which provides the linting and the quick-fixes) does not have a quick-fix. You’re supposed to fix this manually (or suppress the warning, or live with the squiggle).
Maybe the wording of the lint message is what makes you think there is a fix you don’t find?
Yes. Idiomatic style is to check for emptiness of a collection using (seq foo)
, which returns nil
if the collection is empty, which is falsey (equivalent to false
as a conditional). clj-kondo is telling you that you are using a non-idiomatic style.
(seq foo)
returns a sequenced collection if not empty, or nil
if it is empty. Your code can be rewritten as
(filter seq (map process collection))
Or as
(remove empty? (map process collection))
which I think is a bit clearer about the intention (and preserves the type of the tested collections).I might suggest to Eric Dallo to add this as a quick fix. Except it only takes a small amount of experience before you will simply quit looking toward (not (empty? foo))
and not need a quick fix for it.
My point was that since the message is worded like a quick fix could be worded, maybe that created the expectation that there would be some way to get it done?
Yes, that was my problem - I was assuming that since a suggestion was being made, a corresponding quick fix would also be offered. Thanks for the clarifications, anyway!
The message reads like a suggestion, but is actually the error message for that particular clj-kondo linting rule. It's saying "to satisfy this rule, you must use seq
idiom." Quick fixes are implementd by clojure-lsp.
But the lines between clj-kondo and LSP can definitely seem pretty fuzzy, especially when new to Calva.