This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-21
Channels
- # announcements (1)
- # architecture (392)
- # babashka (3)
- # beginners (1)
- # calva (2)
- # cider (1)
- # clojure (30)
- # clojure-denmark (2)
- # clojure-dev (9)
- # clojure-europe (13)
- # clojure-italy (2)
- # clojure-japan (17)
- # clojure-korea (8)
- # clojure-nl (1)
- # clojure-norway (74)
- # clojure-uk (3)
- # clojurescript (6)
- # code-reviews (8)
- # conjure (1)
- # data-science (1)
- # datascript (7)
- # datomic (1)
- # fulcro (1)
- # graalvm (9)
- # humbleui (3)
- # hyperfiddle (11)
- # leiningen (4)
- # lsp (7)
- # malli (7)
- # off-topic (57)
- # other-languages (9)
- # overtone (7)
- # shadow-cljs (30)
- # sql (15)
- # squint (3)
- # timbre (3)
- # vim (6)
Hi! How do you usually use *warn-on-reflection*
in code bases for products that you are building?
I am discussing this in a code review, where we have used https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#warn-on-reflection to point out files where we do Java interop. For any such file, clj-kondo will say error: Var *warn-on-reflection* is not set in this namespace.
if there is no line (set! *warn-on-reflection* true)
in that file. And based on those reports, we are now reviewing code where we have inserted a bunch of lines like (set! *warn-on-reflection* true)
in different source files that do Java interop. But I am a bit hesitant whether or not it is a good idea to leave these lines in source code. I consider them more of a debugging tool that would usually not be part of the implementation. Instead, I would probably set *warn-on-reflection*
for the entire code base from the deps.edn
file instead, as suggested in https://stackoverflow.com/a/69790639 . What pros/cons do you see with either approach? That is, sprinkling (set! *warn-on-reflection* true)
throughout the code versus having a single setting in deps.edn
?
Are you using tools.build? clojure.tools.build.api/compile-clj
takes binding option as an argument.
It looks like we do. Thanks for the suggestion!
@U03JZS99P27 At work, we require that in every source file (and fail the CI build if someone checks in a file without it). We also run athos/clj-check
across all our code and fail the build if new reflection warnings appear.