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
I'm not aware of something like that
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