This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-17
Channels
- # ai (1)
- # announcements (1)
- # aws (38)
- # babashka (25)
- # beginners (84)
- # biff (11)
- # calva (58)
- # clerk (14)
- # clj-kondo (14)
- # cljdoc (9)
- # cljs-dev (2)
- # clojars (2)
- # clojure (93)
- # clojure-czech (2)
- # clojure-dev (13)
- # clojure-europe (19)
- # clojure-nl (1)
- # clojure-spec (13)
- # clojure-uk (2)
- # clojurescript (6)
- # conjure (1)
- # core-async (9)
- # cursive (12)
- # data-science (7)
- # datahike (47)
- # datalevin (10)
- # datalog (3)
- # datomic (35)
- # emacs (3)
- # events (4)
- # fulcro (49)
- # gratitude (7)
- # humbleui (1)
- # hyperfiddle (42)
- # jobs-discuss (19)
- # kaocha (5)
- # lsp (20)
- # malli (3)
- # meander (2)
- # membrane (2)
- # off-topic (22)
- # pathom (2)
- # polylith (14)
- # practicalli (1)
- # rdf (3)
- # reitit (2)
- # shadow-cljs (11)
- # squint (3)
- # tools-deps (32)
- # vim (9)
- # xtdb (16)
‘lo all. I generally want a way to lint just the classpaths of my code (and not the code of the dependencies). If I do something like clj-kondo --lint $(clojure -Spath -M:test:dev)
, the clojure -Spath
understandably returns the full classpath, including the dependencies, and clj-kondo --lint
happily lints those too 🙂 . However, I really only want it to lint the :paths
and :extra-paths
, not the :deps
and :extra-deps
. I’ve got a workaround filtering the classpath for only relative paths. It works, but it feels hacky and that I’m probably missing something obvious, or there’s a piece of tribal knowledge I’m missing out on. What are others’ approaches to this? Am I thinking about it wrong (which is always a distinct possibility)?
FWIW, here’s my little bb filter:
% clojure -Spath -M:test:dev | bb -i '(->> (str/split (first *input*) #":") (remove (fn [p] (.isAbsolute (io/file p)))) (str/join ":") print)'
test/clojure:src/clojure
Makes sense. Right now I’ve got it as a shell script. I’m thinking of porting it to a bb.edn task. Would it make sense to leverage deps.clj instead of clojure -Spath
do you think?
(looks like it invokes a clojure process anyway, so I’m unlikely to see speed gains there. Not that the speed of the current method is a problem, but faster is nice :)
In bb.edn you can use the (clojure …) task which invokes deps.clj but shelling out to Clojure should work too
Does the clojure task create a separate clojure process? That was my reading of https://book.babashka.org/#tasks:clojure
> The clojure
function starts a Clojure process using https://github.com/borkdude/deps.clj.
Here’s what I came up with:
% cat build/src/build/elf.clj
(ns build.elf
(:require
[ :as io]
[clojure.string :as str]))
(set! *warn-on-reflection* true)
(defn relative-classpath [cp]
(->> (str/split cp #":")
(remove (fn [p] (.isAbsolute (io/file p))))
(str/join ":")))
% cat bb.edn
{:paths ["build/src"]
:tasks
{:requires ([build.elf :as elf])
lint (let [relative-cp (-> (with-out-str (clojure "-Spath -A:test"))
(elf/relative-classpath))]
(shell (str "clj-kondo --lint " relative-cp)))}}
% bb lint
linting took 131ms, errors: 0, warnings: 0
For a gut check, is this seem like a reasonable thing to want to do? (programmatically determine the paths of just the project)
well, I've contemplated this, but then there will be people who say: I want to lint this alias, but not that alias and sometimes this and sometimes that. :)
Oh, I’m not asking for this being built into anything: it a feature that’s likely to be really hard to implement and satisfy everyone. I’m just trying to figure out an idiomatic way this could be approached: munging the cp string works but feels janky. inspecting deps.edn directly also feels a bit over-involved. I’ll ask in clojure or tools-deps to see if anyone there has any ideas.