Fork me on GitHub
#clj-kondo
<
2022-02-10
>
oly13:02:27

Tried looking for this is there an easy way to run clj-kondo on a polylith project perhaps doing a glob or something so i can match any file under a /src/ folder or something

borkdude13:02:14

@oliver.marks you can use clojure -Spath to get a classpath in your project and then you could filter out directories that fall within the project maybe?

borkdude13:02:23

using a babashka script or otherwise

borkdude13:02:59

e.g.:

$ clojure -Spath | bb -e '(->> (str/split (str/trim (slurp *in*)) #":") (filter fs/directory?))'
("src" "shared/src" "resources" "java/target/classes" "/Users/borkdude/Dropbox/dev/clojure/metabase/java/target/classes")

oly13:02:07

okay I was kind of hoping for a more built in so I can use it in my github action, and not have to add a list of folders

borkdude13:02:00

clj-kondo is agnostic of build tooling, it has nothing built in regarding deps.edn, polylith, lein or whatever. just give it the paths to lint and it will lint. You could also just do clj-kondo --lint .

oly13:02:24

- name: Code Linting
        uses: DeLaGuardo/clojure-lint-action@master
        with:
          clj-kondo-args: --lint workspace
          check-name: Linting
          github_token: ${{ secrets.GITHUB_TOKEN }}
This is the current step in the action

oly13:02:22

I guess to do the above i would need a different action to get the list and pass to clj-kondo

borkdude13:02:52

Are your sources in workspace?

borkdude13:02:57

then that should be sufficient

oly13:02:44

yeah that picks up output in resources folders so I get files like this linted

ublic/cljs-out/dev/reagent/impl/template.cljs

oly13:02:34

I am guessing clj-kondo does not work with .gitignore ?

borkdude13:02:36

and you want to avoid this?

oly13:02:04

the above I am getting locally by the way they are not in the repo on github but its more an example

borkdude13:02:26

you can do --config "{:output {:exclude-files ["resources"]}}"

oly13:02:43

well reagent is an external library

oly13:02:59

will that ignore them even if they are under sub directories

borkdude13:02:18

it's a regex

oly13:02:35

oh right that will work then awesome 🙂

oly13:02:28

Unexpected error. Please report an issue.
java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String
	at clojure.core$re_pattern.invokeStatic(core.clj:4834)
	at clj_kondo.impl.core$filter_findings$iter__16030__16034$fn__16035$fn__16036$fn__16039.invoke(core.clj:524)
	at clojure.core$some.invokeStatic(core.clj:2705)
	at clojure.core$some.invoke(core.clj:2696)
	at clojure.core$comp$fn__5826.invoke(core.clj:2574)
	at clj_kondo.impl.core$filter_findings$iter__16030__16034$fn__16035$fn__16036.invoke(core.clj:524)
	at clj_kondo.impl.core$filter_findings$iter__16030__16034$fn__16035.invoke(core.clj:511)
	at clojure.lang.LazySeq.sval(LazySeq.java:42)
	at clojure.lang.LazySeq.seq(LazySeq.java:51)
	at clojure.lang.RT.seq(RT.java:535)
	at clojure.core$seq__5420.invokeStatic(core.clj:139)
	at clojure.core$sort.invokeStatic(core.clj:3101)
	at clojure.core$sort_by.invokeStatic(core.clj:3107)
	at clojure.core$sort_by.invokeStatic(core.clj:3107)
	at clj_kondo.core$run_BANG_.invokeStatic(core.clj:181)
	at clj_kondo.main$main.invokeStatic(main.clj:130)
	at clj_kondo.main$main.doInvoke(main.clj:126)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clj_kondo.main$_main$fn__16234.invoke(main.clj:177)
	at clj_kondo.main$_main.invokeStatic(main.clj:177)
	at clj_kondo.main$_main.doInvoke(main.clj:175)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clj_kondo.main.main(Unknown Source)
hum that causes an exception 😞

borkdude13:02:49

what do you have in your config

borkdude13:02:56

probably a syntax mistake

oly13:02:02

ah thanks for the help copied your example exactly needed to escape the " 🙂

tomd21:02:24

I've noticed foo in the following example is an "unused binding" lint warning:

(let [foo "2022-02-10"
      bar #time/date foo]
  bar)
is this a bug or expected behaviour?

borkdude21:02:27

@tomd a bug. issue welcome

tomd21:02:39

great thanks - on it's way...

✅ 1