This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-27
Channels
- # announcements (1)
- # aws (10)
- # babashka (53)
- # calva (133)
- # clj-kondo (46)
- # cljdoc (6)
- # cljs-dev (33)
- # clojure (105)
- # clojure-boston (1)
- # clojure-europe (11)
- # clojure-nl (4)
- # clojure-poland (1)
- # clojure-switzerland (6)
- # clojure-uk (13)
- # clojurescript (106)
- # cursive (1)
- # datascript (2)
- # emacs (13)
- # events (1)
- # figwheel-main (4)
- # fulcro (17)
- # graphql (8)
- # heroku (2)
- # honeysql (8)
- # lsp (76)
- # luminus (30)
- # malli (12)
- # meander (23)
- # music (1)
- # nextjournal (83)
- # off-topic (6)
- # pathom (3)
- # polylith (19)
- # re-frame (8)
- # reagent (2)
- # reveal (3)
- # shadow-cljs (54)
- # sql (9)
- # testing (11)
- # tools-deps (15)
- # xtdb (14)
I’d like to re-record a refactoring gif. What Emacs theme do you use @ericdallo?
Well, that’s a very thorough answer! Thanks! I’ve been thinking about trying out NixOS… /goes down a rabbit hole
Here’s the re-recorded gif. The MacOS tools for optimizing aren’t great, so it’s still pretty large (463K vs the original which was shorter but only 137K). @ericdallo would you like me to add it to the https://github.com/clojure-lsp/clojure-lsp/pull/716 or do you want to record it on your machine?
@U07M2C8TT I intend to do a release this week, do you think we should wait to include your PR?
Up to you. I’ve been using it regularly and it’s been fine, but I know you wanted to do a bit more testing on it. There’s no rush.
I’m having an issue with some lsp highlighting on unused public vars. We have a macro called defendpoint
that creates our routes. clj-kondo/lsp consider this an unused public var which is fine I guess, I can ignore that. But the problem is that when my cursor is in the form it highlights it for me and makes it hard to read.
this is because defendpoint is linted using a config macro and all warnings appear on the opening paren, but perhaps this doesn't work nicely with the public var linter
[email protected]:metabase/metabase.git
I think this could happen if you didn't configure the hook for that macro to use the proper row/col/end-row/end-col right @U04V15CAJ?
this just uses the :macroexpand
:hook
which is a simplified way of writing hooks with the trade-off that you lose your locations for warnings and all of them are propagated to the top
i’d be fine if it just highlighted the macro’s form api/defendpoint
rather than the entire form
you can already see that there are 0 references for this var, so maybe disable the public var linter locally as this is basically the same info
I suspect this will happen for every linter that uses macroexpand, not only unused-var
@U11BV7MTK you can disable the linter for specific namespaces or vars as well
seems like all of our api namespaces will have an issue. Its also finding some unused bindings > src/metabase/api/email.clj:68:1: warning: unused binding p1__19760#
yeah, I already wrote some hooks for metabase, so probably take that as examples :)
@ericdallo that’s an lsp feature not clj-kondo? The config you sent me is for lsp but i’m reading the warnings from clj-kondo --lint src:shared/src
@U11BV7MTK :clojure-lsp/unused-public-var`` is a custom lint fn that clojure-lsp has using clj-kondo custom lint feature
should i file an issue about the macro warning line information? or is that just a user problem because i am not providing a hook?
I don't see nothing wrong on clojure-lsp side, and kondo can't know for sure the correct location, so probably this is a user problem indeed
it's a "do I want to pay the time for writing a better hook vs getting a slightly worse editor experience" problem
I'd go with writing the hook, but this is your call @U11BV7MTK 😄
@ericdallo FYI, I recently brought down the errors on metabase to 0 in one day :)
:linters {:clojure-lsp/unused-public-var {:level :warning
:exclude-when-defined-by #{metabase.api.common/defendpoint}}}
should do it then?if that does what i think it does, exclude-when-defined-by
is a very thoughtful addition.
it might be a clj-kondo error inside of the macro and the line information is the entire form then
since the location is wrong, there is no way to disable that unless fixing the hook
the location is not wrong, it's just propagated to the top. any linter can display information at the top (first paren)
@U04V15CAJ the issue is not the linter, but the row/col on the analysis or the name-row/col
the location of every node in the macro-expansion will be the location of the outer expr
:macroexpand
is usually used for simple things like (declare foo bar baz)
where nothing can go wrong, but this macro is a bit involved
I confirmed the behavior on metabase local @U11BV7MTK, it's indeed multiple elements at same outer position:
[{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:ns metabase.api.util,
:name GET_stats,
:defined-by clojure.core/def,
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:col 1,
:name-col 1,
:end-col 33,
:doc "foo",
:bucket :var-definitions,
:row 25},
:definition
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:ns metabase.api.util,
:name GET_stats,
:defined-by clojure.core/def,
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:col 1,
:name-col 1,
:end-col 33,
:doc "foo",
:bucket :var-definitions,
:row 25},
:semantic-tokens
[{:token-type :function, :token-modifier [:definition]}]}
{:element
{:fixed-arities #{1},
:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name defendpoint*,
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:macro true,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:arity 1,
:bucket :var-usages,
:row 25,
:to metabase.api.common},
:definition
{:fixed-arities #{1},
:end-row 257,
:name-end-col 23,
:name-end-row 247,
:name-row 247,
:ns metabase.api.common,
:name defendpoint*,
:defined-by clojure.core/defmacro,
:filename "/home/greg/dev/metabase/src/metabase/api/common.clj",
:macro true,
:col 1,
:name-col 11,
:end-col 16,
:arglist-strs
["[{:keys [method route fn-name docstr args body]}]"],
:doc "Impl macro for `defendpoint`; don't use this directly.",
:bucket :var-definitions,
:row 247},
:semantic-tokens [{:token-type :macro, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name do,
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:bucket :var-usages,
:row 25,
:to clojure.core},
:semantic-tokens [{:token-type :function, :token-modifier []}]}
{:element
{:fixed-arities #{0},
:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name check-superuser,
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:alias api,
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:arity 0,
:bucket :var-usages,
:row 25,
:to metabase.api.common},
:definition
{:fixed-arities #{0},
:end-row 95,
:name-end-col 22,
:name-end-row 92,
:name-row 92,
:ns metabase.api.common,
:name check-superuser,
:defined-by clojure.core/defn,
:filename "/home/greg/dev/metabase/src/metabase/api/common.clj",
:col 1,
:name-col 7,
:end-col 31,
:arglist-strs ["[]"],
:doc
"Check that `*current-user*` is a superuser or throw a 403. This doesn't require a DB call.",
:bucket :var-definitions,
:row 92},
:semantic-tokens
[{:token-type :type, :token-modifier []}
{:token-type :event, :token-modifier []}
{:token-type :function, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name anonymous-usage-stats,
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:alias stats,
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:arity 0,
:bucket :var-usages,
:row 25,
:to metabase.analytics.stats},
:definition
{:fixed-arities #{0},
:end-row 389,
:name-end-col 28,
:name-end-row 369,
:name-row 369,
:ns metabase.analytics.stats,
:name anonymous-usage-stats,
:defined-by clojure.core/defn,
:filename
"/home/greg/dev/metabase/src/metabase/analytics/stats.clj",
:col 1,
:name-col 7,
:end-col 53,
:arglist-strs ["[]"],
:doc "generate a map of the usage stats for this instance",
:bucket :var-definitions,
:row 369},
:semantic-tokens
[{:token-type :type, :token-modifier []}
{:token-type :event, :token-modifier []}
{:token-type :function, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name do,
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:arity 2,
:bucket :var-usages,
:row 25,
:to clojure.core},
:semantic-tokens [{:token-type :function, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name GET,
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:arity 6,
:bucket :var-usages,
:row 25,
:to compojure.core},
:semantic-tokens [{:token-type :function, :token-modifier []}]}
{:element
{:fixed-arities #{1 3 2},
:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name def,
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:macro true,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:arity 2,
:bucket :var-usages,
:row 25,
:to clojure.core},
:semantic-tokens [{:token-type :macro, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "line",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:bucket :keywords,
:row 25},
:definition
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "line",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:bucket :keywords,
:row 25},
:semantic-tokens [{:token-type :keyword, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "column",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:bucket :keywords,
:row 25},
:definition
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "column",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:bucket :keywords,
:row 25},
:semantic-tokens [{:token-type :keyword, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "doc",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:bucket :keywords,
:row 25},
:definition
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "doc",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:bucket :keywords,
:row 25},
:semantic-tokens [{:token-type :keyword, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "is-endpoint?",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:bucket :keywords,
:row 25},
:definition
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "is-endpoint?",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:end-col 33,
:bucket :keywords,
:row 25},
:semantic-tokens [{:token-type :keyword, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "line",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:bucket :keywords,
:row 25},
:definition
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "line",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:bucket :keywords,
:row 25},
:semantic-tokens [{:token-type :keyword, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "column",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:bucket :keywords,
:row 25},
:definition
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "column",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:bucket :keywords,
:row 25},
:semantic-tokens [{:token-type :keyword, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "line",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:bucket :keywords,
:row 25},
:definition
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "line",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:bucket :keywords,
:row 25},
:semantic-tokens [{:token-type :keyword, :token-modifier []}]}
{:element
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "column",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:bucket :keywords,
:row 25},
:definition
{:end-row 30,
:name-end-col 33,
:name-end-row 30,
:name-row 25,
:name "column",
:filename "/home/greg/dev/metabase/src/metabase/api/util.clj",
:from metabase.api.util,
:col 1,
:name-col 1,
:context {},
:from-var GET_stats,
:end-col 33,
:bucket :keywords,
:row 25},
:semantic-tokens [{:token-type :keyword, :token-modifier []}]}]
(BTW this is a really handful tricky when debugging kondo analysis, lsp-clojure-cursor-info
)
there is a custom request called clojure/cursorInfo
which brings information about the element at cursor position like kondo analysis, element definition and semantic tokens for that element!
uh nice, I’ll have to build that into Calva. Thanks!
I was about to suggest exactly that @U02EMBDU2JU :)