This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-12
Channels
- # announcements (2)
- # babashka (22)
- # babashka-sci-dev (15)
- # beginners (62)
- # calva (2)
- # cider (8)
- # clj-kondo (33)
- # clojure (52)
- # clojure-europe (46)
- # clojure-losangeles (1)
- # clojure-norway (5)
- # clojure-spec (7)
- # clojurescript (31)
- # conjure (20)
- # data-science (4)
- # datalevin (16)
- # fulcro (28)
- # hyperfiddle (71)
- # introduce-yourself (3)
- # lsp (50)
- # off-topic (16)
- # polylith (8)
- # portal (3)
- # practicalli (1)
- # reitit (1)
- # releases (2)
- # tools-build (22)
- # vim (8)
- # xtdb (17)
morning, the following triggers a warning: Unused private var nextjournal.clerk.eval/nippy-tweaks
(defonce ^:private nippy-tweaks (do ,,,))
I’m using the defonce
to run setup code that I’d like to only run once so I don’t think it should trigger a warning. Can file an issue if you agree. Or is there another recommended pattern?I've just hit the same problem 🙂 (adding one custom, global listener to the awt event dispatcher)
Like I said:
#_{:clj-kondo/ignore [:unused-private-var]}
(defonce ^:private dude 42)
There are cases in which you do want the warning. If you only use defonce for side effects (which is only a subset of what you can use defonce for), just use this.in this case clj-kondo cannot read your mind why you are using defonce, it can be argued both ways
Why are you even creating a var when all you want is some piece of code to be executed once. I think it's just evidence of an edge case of an edge case. Automatically deciding no not warn here is too opinionated. This is exactly why we have ignore hints.
if you want kondo to warn when in doubt I’ll know not to bring up things like this in the future
I don't find the evidence to change the current behavior compelling enough, I can see cases where it would work against you
> hmm, work against you = some dead code at worst? exactly, clj-kondo first and foremost is a tool to keep your code clean and minimal, hence the name :) I've used defonce myself in this way but it's not the only way people use defonce. I think not warning would go against the name of the tool ;)
so just use the ignore hint is the current advice. we could introduce some convention for unused vars that start with an underscore, but this is pretty rare, in the sense that, it has never come up before. I'd be open to that option though
I think it's easier to make a mess than to keep things tidy, clj-kondo errs on the side of the latter
done: https://github.com/clj-kondo/clj-kondo/commit/d539034340fa046b139ac3268b43287a34e974fb
After upgrading clojure-lsp
and using the new-ish feature that allows clj-kondo
metadata to be added to macros (eg {:clj-kondo/lint-as 'clojure.test/deftest}
), I’m now seeing .lock
files in my .clj-kondo
directories.
What are these .lock
files? Should I commit them into version control?
There are also inline-configs
directories. Should I commit them into version control?
(Sorry if I’ve missed documentation that covers this.)