clj-kondo 2024-10-23

Hey there. These "suddenly" turned up as files to be committed. Should they be ignored or committed to my repo? (ignore .gitignore)

I generally commit them. I only ignore .clj-kondo/.cache but I suspect some people ignore them. They are imported configurations of libraries you use, so that clj-kondo understands them better.

➕ 2

(they should only change when your dependencies change, and that would be committed so I consider it part of "library version changes")

Makes sense, thank you!

yeah, I also commit them

👍🏻 1

on clj-kondo v2024.09.27, I'm seeing what looks like a regression of https://github.com/clj-kondo/clj-kondo/issues/1455. Can anyone reproduce? I just started using kondo on this project, so I don't know in what version the regression would have first appeared

;; no warnings
(let [z "z"]
  (clojure.string/replace "x" "y" z))

;; error: String match arg requires string replacement arg
(let [^String z "z"]
  (clojure.string/replace "x" "y" z))

oh, looks like it's not quite the same problem. The second test case from that issue doesn't produce an error, yet if I tweak it slightly then it does

;; no warnings
(defn fun2 [^String replacement]
  (str/replace "foo" #"foo" replacement))

;; error: String match arg requires string replacement arg
(defn fun2 [^String replacement]
  (str/replace "foo" "foo" replacement))

interestingly, if I type hint my own example as (let [z ^String "z"] then the error goes away

that isn't valid clojure code though

user=> ^String "foo"
Syntax error reading source at (REPL:1:14).
Metadata can only be applied to IMetas
user=> 

you're right, I should have written something like (let [z ^String (str "z")]

which also makes the linting error go away

@mgardner2 thanks, this seems to be a false positive:

(let [^String z "z"]
  (clojure.string/replace "x" "y" z))
I'll post an issue for that

thank you @borkdude for the fix!