Fork me on GitHub
#clj-kondo
<
2023-03-10
>
Sam Ritchie00:03:11

question on kondo invoked from a bb.edn task… I noticed that my warnings are not causing CI failure https://github.com/mentat-collective/emmy/actions/runs/4379015980/jobs/7664467312 here is my bb.edn:

{:pods {clj-kondo/clj-kondo {:version "2023.01.20"}}
 :tasks
 {:requires ([pod.borkdude.clj-kondo :as clj-kondo])

  lint
  {:doc "Lint with clj-kondo."
   :task (clj-kondo/print!
          (clj-kondo/run! {:lint ["src" "test"]}))}}}

borkdude14:03:15

This is because you're running clj-kondo manually, you should manually handle errors and failures

Sam Ritchie14:03:05

nice, like

lint
{:doc "Lint with clj-kondo."
   :task (clj-kondo/exec {:lint ["src" "test"]})}
?

borkdude14:03:22

:task (exec 'clj-kondo.core/exec)
:exec-args {:lint ["src" "test"]}

borkdude14:03:07

This might need better docs 😅

borkdude14:03:27

You can then pass additional args with --lint foo bar on the command line

borkdude14:03:35

but not all arguments are properly babashka.cli-ified

Sam Ritchie14:03:22

[sritchie@wintermute ~/code/clj/emmy (sritchie/docstrings)]$ bb lint
----- Error --------------------------------------------------------------------
Type:     java.lang.NullPointerException
Location: <expr>:20:1

----- Context ------------------------------------------------------------------
16: (when-not (resolve 'run)
17:   (intern *ns* 'run babashka.tasks/run))
18:
19: (when-not (resolve 'exec)
20:   (intern *ns* 'exec @(var babashka.tasks/exec)))
    ^---
21:
22: nil
23: (def lint (binding [
24:   babashka.tasks/*task* '{:name lint, :doc "Lint with clj-kondo.", :task (exec 'clj-kondo.core/exec), :exec-args {:lint ["src" "test"]}}]
25:   nil

----- Stack trace --------------------------------------------------------------
exec-af4cd7c4-a77a-487a-a098-1c4e132ebcc0/exec - <expr>:20:1
exec-af4cd7c4-a77a-487a-a098-1c4e132ebcc0      - <expr>:4:1
user-49a145ee-67a2-44ef-868b-b6368ff89c06      - <expr>:26:1

Sam Ritchie14:03:01

This is with

{:pods {clj-kondo/clj-kondo {:version "2023.01.20"}}
 :tasks
 {:requires ([pod.borkdude.clj-kondo :as clj-kondo])

  lint
  {:doc "Lint with clj-kondo."
   :task (exec 'clj-kondo.core/exec)
   :exec-args {:lint ["src" "test"]}}}}

borkdude14:03:01

Have you added this dependency to your bb.edn?

borkdude14:03:17

remove the pod stuff and add the dependency

borkdude14:03:56

I'm still torn between "bb-clj-kondo" and "clj-kondo-bb"

Sam Ritchie14:03:49

that worked, thank you! time to upgrade all my projects…

Sam Ritchie14:03:10

I like the suffix version personally, mirroring the file extension

borkdude14:03:19

right, thanks :)

Sam Ritchie14:03:38

I think you inspired me to do that for mathbox.cljs etc, and then I saw you moved back to dashes!

borkdude14:03:40

I first actually had http://clj-kondo.bb but then all kinds of apps made that into a hyperlink to a non-existing website facepalm

Sam Ritchie14:03:48

haha yes that was it

Sam Ritchie14:03:16

how did you get GitHub to syntax-highlight bb files as Clojure? or is it doing inference on the file contents?

borkdude14:03:34

by making bb popular enough? 😆

borkdude14:03:44

I guess eventually someone made a PR to this linguist thing

👍 2
Sam Ritchie20:03:38

this is a bit strange, @borkdude… digging in now, but on CI, after this change,

Downloading: org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar from central
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Could not resolve symbol: exec
Phase:    analysis

Error: Process completed with exit code 1.

Sam Ritchie20:03:14

let me upgrade babaska there and see what happens

borkdude20:03:22

yes, upgrade babashka :)

borkdude20:03:56

babashka 0.8.156 😱 that's old :)

Sam Ritchie20:03:22

haha hadn’t done any gardening in the actions for a while

borkdude20:03:57

btw I use setup-clojure for almost everything in github actions now and just say: bb: latest

Sam Ritchie20:03:11

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install babashka
        uses: just-sultanov/setup-babashka@v2
        with:
          version: '1.2.174'

      - name: Cache kondo directory
        uses: actions/cache@v2
        with:
          path: ~/.clj-kondo/.cache
          key: ${{ runner.os }}-kondo
          restore-keys: ${{ runner.os }}-kondo

      - name: Run clj-kondo
        run: bb lint --config '{:output {:pattern "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}"}}'
time for me to upgrade this too!

Sam Ritchie20:03:19

I bet latest would work here as well

borkdude20:03:06

Is this to please github with inline annotations? "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}"}

Sam Ritchie20:03:31

woah, look at this antique

Sam Ritchie20:03:50

@borkdude yeah that’s right

Sam Ritchie00:03:56

with the CLI tool, the default level fails on warn…

--fail-level <level>: minimum severity for exit with error code.  Supported values:
    warning, error.  The default level if unspecified is warning.
what change should I make to have the task set a nonzero exit code?

john03:03:45

I tried bringing in an old library I wrote a while back that had some clj-kondo exports configured. https://github.com/johnmn3/dispacio/blob/master/.clj-kondo/test.clj @borkdude you helped me out with it in the past and added that test file. In my new project, I'm seeing this error:

borkdude14:03:55

Hi. Can we discuss in a thread?

borkdude14:03:28

Can you point me to the code of your hook?

borkdude14:03:06

right, and what is wrong with this one?

john14:03:35

It might just be a clojure dependency issue

john14:03:17

that test file in there, I believe that's what is causing a downstream consuming project to cause that read-string error above

borkdude14:03:19

I will check out your dependency and run it locally

john14:03:39

and that's the only place I see it being used in the code base

borkdude14:03:28

$ clj-kondo --lint .clj-kondo/test.clj
linting took 31ms, errors: 0, warnings: 0

borkdude14:03:56

the test.clj file isn't exposed to other libraries since it's not on your exported files

john14:03:10

Was just about to ask that 🙂

borkdude14:03:22

only what is inside clj-kondo.exports is going into your jar

john14:03:18

well all of my defp statements like that, they are correctly interpreting the defmethod syntax inside it, but the outer bracket has that red underscoe

john14:03:38

and it's complaining about the read-string unresolved symbol

borkdude14:03:39

can you make a repro of that in the test.clj file?

john14:03:18

It's in clojurescript

borkdude14:03:32

I need a repro to look at

john14:03:50

which might be the problem. Let me try adding up to date clojure libs

borkdude14:03:51

is it in the dispacio library itself?

john14:03:07

No it's a project I'm working on locally

borkdude14:03:32

can you make a screenshot of the surroundings? the first screenshot was very local and not informative

john03:03:05

Which is because of:

john03:03:49

And so as you can see in that file, I've updated the file to include a require statement for clojure.edn

john03:03:41

And so I updated the dep in my project to the latest git hash for that repo, but I'm still seeing the error. Does clj-kondo only auto-checkout exports from clojar releases?

john03:03:56

Or will it work off the latest git hash as well?

john03:03:56

I have tried deleting my caches

jakemcc16:03:57

I ran into this earlier this week and I am wondering if building a clj-kondo checker would be possible? A check for invalid number of arguments to the function passed to update /`swap!` style functions.

(defn two-args
  [coll x]
  (conj coll x))

(update {:a [1]} :a two-args) ;; uh-oh, wrong number of args to two-args but not flagged

(two-args []) ;; flagged as invalid-arity

borkdude16:03:40

yeah, I think we could do this in clj-kondo itself: arity checking for update

borkdude16:03:08

feel free to log an issue

👍 2
borkdude10:03:49

Already supported on master

jakemcc17:03:07

so fast 🏃 gratitude-thank-you

dotemacs17:03:56

Drive by message: thank you for clj-kondo! ❤️

❤️ 18
2