This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-04
Channels
- # announcements (1)
- # asami (61)
- # babashka (71)
- # beginners (170)
- # biff (1)
- # calva (14)
- # clj-kondo (23)
- # cljsrn (28)
- # clojars (1)
- # clojure (152)
- # clojure-australia (2)
- # clojure-europe (65)
- # clojure-nl (2)
- # clojure-spec (8)
- # clojure-sweden (3)
- # clojure-uk (45)
- # clojurescript (1)
- # css (12)
- # cursive (16)
- # datomic (9)
- # devcards (2)
- # emacs (1)
- # events (1)
- # graalvm (31)
- # honeysql (10)
- # jackdaw (2)
- # jobs (5)
- # lambdaisland (9)
- # lsp (4)
- # malli (11)
- # meander (43)
- # off-topic (6)
- # pathom (7)
- # polylith (1)
- # portal (14)
- # re-frame (7)
- # releases (1)
- # remote-jobs (1)
- # rewrite-clj (6)
- # shadow-cljs (101)
- # specter (1)
- # tools-deps (26)
- # vim (9)
- # xtdb (2)
does anyone know of a tool that would remove dead branches of code assuming test conditions like (if (= 1 1) :a :b)
or (if true :a :b)
I might work on something like this (got a nice starting point from @borkdude in https://gist.github.com/borkdude/77369ba1b2d0fbd2608a8d12f518ade3) but was just wondering if there might be something out there for this particular thing already
The approach I’d take now is splitting it into two separate scripts/steps:
1. replace the feature test with it’s literal value, e.g. (feature1-enabled?)
gets replaced with true
2. a more general script that tries to find dead conditional branches and removes code / reformats accordingly
It seems like 2. could be part of a tool like carve
if that were to expand scope from just vars to generally finding & removing dead code
yeah, or clojure-lsp. but I don't think it's very common to have dead code based on "always true" conditions
yeah, the (if true ,,,)
case is pretty unusual I guess but I think in context of replacing a more complex form with true
it kind of makes sense and would allow for a nice separation