Fork me on GitHub
#malli
<
2022-04-27
>
Ferdinand Beyer13:04:48

I might have found a bug Malli’s clj-kondo type config generation when using :re schemas. Instead of expecting a string matching a regular expression, clj-kondo expects an argument to be of regular expression type. Or did I misunderstand something?

dvingo15:04:13

can you share the clj-kondo configuration for that function?

Ferdinand Beyer15:04:07

Unfortunately I deleted this example file already, but I can confirm that I get :regex in the config, and I agree that this should probably be :string

Ferdinand Beyer15:04:42

Having said that, I never worked with clj-kondo that deeply so I don’t know what ops/types it accepts

dvingo17:04:12

looks like the :regex type in kondo expects a regex: https://github.com/clj-kondo/clj-kondo/blob/master/doc/types.md added this to the config:

$ cat .clj-kondo/config.edn
{:linters
 {:type-mismatch
  {:level :warning
   :namespaces {foo {foo {:arities {1 {:args [:regex] :ret :string}}}}}}}}

dvingo17:04:31

and then:

$ clj-kondo --lint - <<<'(ns bar (:require [foo :refer [foo]])) (foo "")'
<stdin>:1:45: warning: Expected: regular expression, received: string.
linting took 12ms, errors: 0, warnings: 1
$ clj-kondo --lint - <<<'(ns bar (:require [foo :refer [foo]])) (foo #"")'
linting took 11ms, errors: 0, warnings: 0

ikitommi08:05:00

Merged, thanks!

Ferdinand Beyer08:05:44

That was fast, thanks 🙂

Keith Houser18:04:26

Why does humanize not have "Wrong!!" message when wrong value is in the first position?

({:forms (d),
  :human [["should be a" "should be b" "should be c"]]}
 {:forms (a d c),
  :human [nil ["should be a" "should be b" "should be c" "Wrong!!"]]})