This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-18
Channels
- # adventofcode (69)
- # babashka (21)
- # beginners (246)
- # calva (49)
- # chlorine-clover (19)
- # circleci (3)
- # clj-kondo (38)
- # cljsrn (1)
- # clojure (52)
- # clojure-australia (2)
- # clojure-europe (41)
- # clojure-nl (5)
- # clojure-spec (4)
- # clojure-taiwan (2)
- # clojure-uk (28)
- # clojurescript (12)
- # cryogen (6)
- # cursive (6)
- # datahike (3)
- # deps-new (5)
- # fulcro (2)
- # garden (1)
- # graalvm (3)
- # hoplon (48)
- # jackdaw (6)
- # jobs (3)
- # kaocha (6)
- # malli (3)
- # off-topic (51)
- # rdf (1)
- # reagent (40)
- # reitit (32)
- # remote-jobs (1)
- # reveal (24)
- # shadow-cljs (21)
- # startup-in-a-month (5)
- # xtdb (8)
Hey @borkdude, I just noticed the :unused-namespace
type from :findings
in clj-kondo don't contain which namespace is unused, am I missing something?
for example a code like this:
(ns foo.bar (:require [bar :as b]))
Gives me the finding
:
{:type :unused-namespace,
:message "namespace bar is required but never used",
:level :warning,
:row 1,
:end-row 1,
:end-col 21,
:col 18,
:filename "/a.clj"}
Findings generally don't have this information (since this is not output to linter editor integration in general) but I think we could add it, without breaking things :)
thanks 🙂 I don't know clj-kondo code, any tips on what/where change it? I'd love to help 🙂
grep for "is required but never used" and this should be relatively easy to plug in. Usually this is tested either in main_test.clj or unused_namespace_test.clj (or something like this). Grep should also show where this is tested
hmm, but the tests round-trip from the text output, so a test calling the core namespace should be added separately to test for the :ns addition
What do you think it's the best, merging https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/impl/linters.clj#L405`node->line` with something like {:ns ns-sym}
and {:refer :refer-sym}
for unused-refer lint or adding a name
or extra
arg for node->line
?
Any reason why load the ns with cider fails because of missing deps me.raynes.conch
?
To be honest, with clj-kondo development, I almost never use a REPL. I always just use the command line
@borkdude the tests on main_test
don't return the added :ns
, I think this is what you meant above right?
how can I test that?
This is the draft atm https://github.com/clj-kondo/clj-kondo/pull/1132
@UKFSJSM38 yeah, instead of (lint! ...)
you just call (-> (with-in-str "your-code" (clj-kondo.core/run! {:lint ["-"]}) :findings)
so as an API call basically. lint!
mimics the command line usage (the primary way in which clj-kondo was initially used)
but also feel free to move the existing ones to unused_namespace_test.clj
if that doesn't exist yet
Done @borkdude, thank you for the help during this 🙂 LMK if any issues with the PR: https://github.com/clj-kondo/clj-kondo/pull/1132
I merged a new linter called :unresolved-var
to master now. It will give a warning on the following: (require '[clojure.set :as set]) (set/onion #{1 2 3})
: "No such var: set/onion"
.
The default level is :off
but will be bumped to :error
when this is done (there are 2 TODO items left).
You can download a binary from the CircleCI builds if you would like to give this a spin in your daily dev (or use on the JVM). Testing is highly appreciated.