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
Warn on cond
& condp
without default case
#1164
Comments
For https://twitter.com/puredanger/status/1116696133315760128 So as it stands, I don't think any changes are needed here. |
Maybe I was too trigger happy about
|
Yeah ok, throwing by design. I'd still like the warning for it. |
@neotyk Currently you can write a custom hook to check for $ clj-kondo --lint src
src/program.clj:3:1: warning: condp without default
linting took 14ms, errors: 0, warnings: 1
$ cat src/program.clj
(ns program)
(condp = 1
2 :foo)
$ cat .clj-kondo/config.edn
{:hooks {:analyze-call {clojure.core/condp hooks/condp-hook}}
:linters {:condp-without-default {:level :warning}}}
$ cat .clj-kondo/hooks.clj
(ns hooks
(:require [clj-kondo.hooks-api :as api]))
(defn condp-hook [{:keys [:node]}]
(let [children (rest (:children node))]
(when (even? (count children))
(api/reg-finding! (assoc (meta node)
:message "condp without default"
:type :condp-without-default))))) |
For me the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is your feature request related to a problem? Please describe.
It's perfectly valid to have
cond
orcondp
without default case, though exception is thrown when no matching case is found.Describe the solution you'd like
Warn on
cond
&condp
used without default case.Assuming this is really wanted I have some OSS time this Friday, just sayin'
The text was updated successfully, but these errors were encountered: