Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useless for expression not reported as an unused value #2309

Closed
1 task done
cjohansen opened this issue Apr 3, 2024 · 0 comments
Closed
1 task done

Useless for expression not reported as an unused value #2309

cjohansen opened this issue Apr 3, 2024 · 0 comments

Comments

@cjohansen
Copy link

  • I have read the Clojure etiquette and will respect it when communicating on this platform.

version

borkdude/brew/clj-kondo: stable 2024.03.13

platform

via clojure-lsp

editor

Emacs, clojure-lsp

problem

I modified a Java object in a for, but since it's lazy and not returned or otherwise evaluated, the code never runs. This should probably be linted as an unused value?

repro

(defn map->Headers [headers]
  (let [headers-obj ^Headers (Headers.)]
    (for [[k v] headers]
      (->> (cond-> v
             (not (coll? v)) vector)
           (map str)
           (.add headers-obj (name k))))
    headers-obj))

expected behavior

I would have expected clj-kondo to inform me that the for here is useless.

@borkdude borkdude changed the title Useless lazy construct is not reported as an unused value Useless lazy construct in let is not reported as an unused value Apr 3, 2024
@borkdude borkdude changed the title Useless lazy construct in let is not reported as an unused value Useless for expression not reported as an unused value Apr 5, 2024
borkdude added a commit that referenced this issue Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

1 participant