clj-kondo

borkdude 2026-01-08T11:14:06.085809Z

@dpsutton @escherize Some interesting findings in the metabase test suite by @jonurnieta https://github.com/clj-kondo/clj-kondo/pull/2706/files#diff-297302157a95b47ba8139cfe7a67d9d09a9ba2e753d1bbf1f8ecf8770ddfd0b4 Mostly by using test conditions where they should not be

πŸ‘€ 2
dpsutton 2026-01-08T14:36:23.399949Z

https://github.com/metabase/metabase/blob/master/test/metabase/lib/aggregation_test.cljc#L819-L823 I’m not sure i follow the warning

borkdude 2026-01-08T14:36:56.835939Z

that's the wrong file

dpsutton 2026-01-08T14:37:23.081499Z

metabase/test/metabase/lib/aggregation_test.cljc ?

dpsutton 2026-01-08T14:37:30.579469Z

"test-regression/checkouts/metabase/test/metabase/lib/aggregation_test.cljc",

borkdude 2026-01-08T14:37:33.071629Z

oh sorry, my bad

borkdude 2026-01-08T14:37:37.883609Z

let's see

jramosg 2026-01-08T14:38:57.665729Z

looks like test-regression/checkouts/ code is not the same as in he current master because of SHA

borkdude 2026-01-08T14:39:01.659249Z

this is the location, I'm still on SHA aa0cdb546d7c9e4ef5c52ad23c656272b7599e23

borkdude 2026-01-08T14:39:48.828829Z

maybe it would be nice to print github links along with the findings with the right SHA so you can click on them :)

borkdude 2026-01-08T14:40:09.346939Z

@dpsutton the issue there is that is is nested

dpsutton 2026-01-08T14:40:40.074299Z

ah i see. yeah. the nested is will only be evaluated if the outer fails? i wonder what happens here

borkdude 2026-01-08T14:41:03.777699Z

don't know about evaluation but it's likely just a paredit typo or so

borkdude 2026-01-08T14:41:25.374839Z

this PR detected several of them in various projects

dpsutton 2026-01-08T14:41:47.857889Z

yeah. they both evaluate. and i bet you are right it’s possibly a parinfer issue?

dpsutton 2026-01-08T14:42:25.784159Z

nah probably paredit. The author didn’t use parinfer. Parinfer was my guess because it can move stuff around more easily

borkdude 2026-01-08T14:42:42.942719Z

I also found some of these:

(is (= foo 1) (= foo 3))
which makes the last expression not count as a test

jramosg 2026-01-08T14:43:20.477069Z

docstring says that second argument is a message:

(defmacro is
  "Generic assertion macro.  'form' is any predicate test.
  'msg' is an optional message to attach to the assertion.

borkdude 2026-01-08T14:43:27.350919Z

yep

jramosg 2026-01-08T14:43:32.240149Z

so it will not be evaluated as a test

dpsutton 2026-01-08T14:43:47.577009Z

user=> (is (= 1 1) (is (= 1 3)))

FAIL in () (NO_SOURCE_FILE:18)
expected: 1
  actual: 3
    diff: - 1
          + 3
true

borkdude 2026-01-08T14:43:50.759139Z

yes, so as long as the first test succeeds, you will never noticde it

dpsutton 2026-01-08T14:44:06.130969Z

the original one worked in a very weird way but did work

dpsutton 2026-01-08T14:44:24.554899Z

agree if the second arg to is is an assertion without it’s own is wrapper

borkdude 2026-01-08T14:44:50.503049Z

one such case here: https://github.com/nextjournal/clerk/pull/795

πŸ‘€ 1
borkdude 2026-01-08T22:42:04.492059Z

(is false? ...)

escherize 2026-01-08T22:42:34.607789Z

Thank you. I have a PR for this, I'll add this one to it

borkdude 2026-01-08T22:43:21.950749Z

There's more. https://github.com/clj-kondo/clj-kondo/pull/2722/files#diff-297302157a95b47ba8139cfe7a67d9d09a9ba2e753d1bbf1f8ecf8770ddfd0b4 Note that this is all based on commit aa0cdb546d7c9e4ef5c52ad23c656272b7599e23 Thanks to @jonurnieta for finding these

❀️ 1
πŸ™ 1
borkdude 2026-01-08T22:46:07.012349Z

(not an exhaustive list, but just sampling through and they look legit)

borkdude 2026-01-08T22:46:36.203909Z

does @bronsa now also work for metabase? I saw a commit of his

escherize 2026-01-08T22:46:47.659989Z

he does

borkdude 2026-01-08T22:46:55.125699Z

nice

πŸŽ‰ 2
jramosg 2026-01-08T15:36:35.437599Z

is this an error?

clojure -M:clj-kondo/dev --config '{:linters {:condition-always-true {:level :warning}}}' --lint - <<< "(if true 1 2) (if inc 1 2)"

<stdin>:1:19: warning: Condition always true
the (if true 1 2) does not warn about condition-always-true

borkdude 2026-01-08T15:37:36.682099Z

This is by design since sometimes you just want to enable a condition explicitly. So we don't wan on booleans in condition always true.

jramosg 2026-01-08T15:38:03.695649Z

okey, I suspected that. Thanks!

borkdude 2026-01-08T15:39:45.498709Z

@jonurnieta @tomd Unless you have more in the pipeline, I think we already have enough new stuff to publish a new version...

πŸ‘ 1
jramosg 2026-01-08T15:40:21.634259Z

I'm adding condition-always true to clojure.test/is https://github.com/clj-kondo/clj-kondo/issues/2340

borkdude 2026-01-08T15:41:33.246659Z

Nice. Actually I encountered (is true (contains? ...)) since your types for clojure.test So warning on that does make sense probably

jramosg 2026-01-08T15:41:53.179879Z

yes, I was just writting a comment

jramosg 2026-01-08T15:42:28.978469Z

but first argument can be warned

borkdude 2026-01-08T15:42:45.431299Z

I did detect that case already through the type system so that was already good

borkdude 2026-01-08T15:43:05.749019Z

but warning on a literal in is seems like a thing that can be warned about

borkdude 2026-01-08T15:43:13.527449Z

unless it's a local reference

Alex Miller (Clojure team) 2026-01-08T15:44:51.916099Z

might want to think about always true tests that exist to test flow control (like whether an exception was thrown)

borkdude 2026-01-08T15:45:18.910639Z

example?

Alex Miller (Clojure team) 2026-01-08T15:49:14.801509Z

(try
  ;; something that I expect to throw an exception
  (is false "oops!")
  (catch Exception e (is true))

borkdude 2026-01-08T15:50:02.522859Z

yeah, that shouldn't be detected by clj-kondo (and currently isn't)

borkdude 2026-01-08T15:50:47.622949Z

so maybe we should keep not warning on literal booleans

Alex Miller (Clojure team) 2026-01-08T15:52:03.858019Z

(is true) and (is false) in particular are often used for flow control testing, but maybe other cases are more likely bugs, don't know

borkdude 2026-01-08T15:52:28.294279Z

that's the heuristic we used for condition-always-true so far

jramosg 2026-01-08T15:52:45.030809Z

found this one in metabase

(ns mage.start-db-test
  (:require
   [clojure.test :refer [deftest testing is]]))

(deftest start-db-tests
  (testing "DB starts"
    (is "TODO add tests here")))

borkdude 2026-01-08T15:52:56.829469Z

wonderful :)

Alex Miller (Clojure team) 2026-01-08T15:53:10.508579Z

seems like a good test to me :)

jramosg 2026-01-08T15:53:24.855669Z

hahah

borkdude 2026-01-08T15:54:02.882419Z

I guess so. The more interesting ones were found here where accidentally tests were added in the msg position of is https://github.com/clj-kondo/clj-kondo/pull/2706/files#diff-297302157a95b47ba8139cfe7a67d9d09a9ba2e753d1bbf1f8ecf8770ddfd0b4

borkdude 2026-01-08T15:54:31.145269Z

like:

(is (= 1 1) (= 1 2))