This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-09
Channels
- # announcements (3)
- # babashka (17)
- # beginners (75)
- # calva (43)
- # cider (1)
- # clj-kondo (54)
- # cljdoc (8)
- # cljs-dev (70)
- # clojure (83)
- # clojure-europe (27)
- # clojure-nl (4)
- # clojure-norway (4)
- # clojure-spec (8)
- # clojure-uk (13)
- # clojured (2)
- # clojurescript (47)
- # community-development (4)
- # conjure (2)
- # cursive (3)
- # datomic (5)
- # emacs (5)
- # events (3)
- # fulcro (13)
- # graalvm-mobile (19)
- # helix (2)
- # introduce-yourself (1)
- # jobs (2)
- # jobs-discuss (28)
- # kaocha (9)
- # livestream (11)
- # malli (15)
- # meander (24)
- # nextjournal (8)
- # off-topic (26)
- # pathom (1)
- # pedestal (8)
- # polylith (2)
- # portal (31)
- # re-frame (4)
- # reagent (10)
- # reitit (8)
- # remote-jobs (3)
- # sci (1)
- # shadow-cljs (66)
- # spacemacs (20)
- # testing (6)
- # vim (15)
- # xtdb (7)
If you want clj-kondo to find "redundant fn wrappers" please take this for a spin!
clojure -Sdeps '{:deps {clj-kondo/clj-kondo {:git/url "" :git/sha "2cc9777752d9f54ed91baa4c6ddaa0c2b8812049"}}}' -M -m clj-kondo.main --config "^:replace {:linters {:redundant-fn-wrapper {:level :warning}}}" --lint src
and š report any false positives as a reply to this message.is this a false positive?
(defn sub-sequence? [seq-a seq-b]
(->> (map #(= % %2) seq-a seq-b)
(every? true?)))
(Im guessing its not, I can replace #(= % %2)
with =
, is this what this linter is looking for?)
can you paste an inline config that uses only that linter? Quite interested to run it but will get lots of other output at the moment (i think)
i threw
(defn foo [x]
(let [inc' #(inc %)]
(inc' x)))
in a file iām working on and
clojure -Sdeps '{:deps {clj-kondo/clj-kondo {:git/url "" :git/sha "2cc9777752d9f54ed91baa4c6ddaa0c2b8812049"}}}' -M -m clj-kondo.main --config "^:replace {:linters {:redundant-fn-wrapper :warning}}" --lint src
and got no warning--config "^:replace {:linters {:redundant-fn-wrapper {:level :warning}}}"
worked for me locally herehmm, with the version I previously compiled, but maybe not with the branch. taking a closer look
it also works for me when I remove that config, there must be something wrong with that part
This worked:
$ clojure -Sdeps '{:deps {clj-kondo/clj-kondo {:git/url "" :git/sha "2cc9777752d9f54ed91baa4c6ddaa0c2b8812049"}}}' -M -m clj-kondo.main --config "^:replace {:linters {:redundant-fn-wrapper {:level :warning}}}" --lint /tmp/dude.clj
(map (fn [join rhs]
(rhso join rhs))
joins rhses)
is of course
(map rhso joins rhses)
makes me think of some core set of default enabled linters, and an easy way to enable all new linters that havenāt made their way into core yet?
but yeah i agree maybe not by default. but i wonder how many people use non-default linters
right, the original cause for this linter was that beginners tend to write (update foo :bar #(inc %))
clj-kondo, a linter for clojure (code) that sparks joy, v2022.02.09 āØ
2022.02.09.
⢠Feature https://github.com/clj-kondo/clj-kondo/issues/1549: detect and warn on cyclic task dependencies in bb.edn (https://github.com/mknoszlig)
⢠Feature https://github.com/clj-kondo/clj-kondo/issues/1547: catch tasks undefined tasks present in `:depends`. (https://github.com/mknoszlig)
⢠Feature https://github.com/clj-kondo/clj-kondo/issues/783: `:keys` can be used in `:ret` position, also fixes types return map call as input for another typed map function. (https://github.com/pfeodrippe)
⢠Feature https://github.com/clj-kondo/clj-kondo/issues/1526: detect redundant fn wrappers, like `#(inc %)`. See https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#redundant-fn-wrapper. This linter is
:off
by default, but may be enabled by default in future versions after more testing.
⢠Feature https://github.com/clj-kondo/clj-kondo/issues/1560: lint task definition keys in bb.edn (https://github.com/mknoszlig)
⢠Feature https://github.com/clj-kondo/clj-kondo/issues/1484: Add analysis information about protocol implementations. (https://github.com/ericdallo)
⢠Fix https://github.com/clj-kondo/clj-kondo/issues/1563: vector inside list should not be linted as function call when inside tagged literal.
⢠Fix https://github.com/clj-kondo/clj-kondo/issues/1540: imported class flagged as unused when it only appears in annotation metadata.
⢠Fix https://github.com/clj-kondo/clj-kondo/issues/1571: ignore spliced reader conditionals wrt. namespace sorting.
⢠Fix https://github.com/clj-kondo/clj-kondo/issues/1574: def usage context contains reference of the re-frame reg-sub it is used in. (https://github.com/benedekfazekas)
https://github.com/clj-commons/rewrite-clj/commit/d9eda955f09d09fd1246244ce9d8a4ec5b247ea8!
For people not noticing that @lee posted a link to a commit where he applied :redundant-fn-wrapper
, he did. @ericdallo Perhaps clojure-lsp could also automatically clean this :)
Not as dramatic as my ācoolioā above, but still awesome!: https://github.com/lread/test-doc-blocks/commit/9518b27c0cdeca88e5cebce9d1abe706c12ca869.
For the curious, https://github.com/cljdoc/cljdoc/commit/abb606f8229feec8b3b83a4bc94fc119aa542aaf.
@borkdude we can for sure create a code action on clojure-lsp to auto remove that when that lint exists on the line :)
What do you think about a linter :simplify-not-equal
which check if you typed (not (= :foo :bar))
suggesting to replace with (not= :foo :bar)
?
there's been a previous attempt to this but it wasn't so clear cut that one form is always desirable over another
(not (= ā¦))
all the way :)