Closed sodapopcan closed 1 day ago
Thanks a lot. I will take a look at the weekend.
Already not looked at the code, but my suggestion for the name would be UnnecessaryIfUnless
. As the name suggests, the implementation should also include unless
.
To rewrite if expr, do: false, else: true
to not expr
would be nice, but we can leave this for later (or never).
All feedback has been addressed including rewriting the corresponding unless
es.
I'm happy to squash a succinct commit if/when you're happy with it!
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
lib/recode/task/unnecessary_if_unless.ex | 20 | 21 | 95.24% | ||
<!-- | Total: | 20 | 21 | 95.24% | --> |
Totals | |
---|---|
Change from base Build a97ec42c4b51b478e237027cea09efa4e41f3539: | 0.08% |
Covered Lines: | 958 |
Relevant Lines: | 1047 |
Do you want me to squash this or does your CI handle that?
Do you want me to squash this or does your CI handle that?
I will handle this with GitHub.
Here's my first pass at collapsing what I'm calling "redundant booleans," ie:
I don't quite like that name and am still thinking on it but I needed something! It only takes case of
do: true, else: false
because I realized it could be taken further but I decided that isn't worth it.do: false, else: true
could protentially be re-written with theif
expression negated. You have to chose between!
andnot
(possibly making it configurable) and it seems like one of those things that should just be a credo warning.I only dealt with leading comments on the
if
line though I can be more thorough. Again, it just didn't seem worth it since people usually write these "redundant booleans" pretty absent-mindedly and can't imagine they'd be full of comments in thedo/else
bodies. I'm also not exactly sure how to keep comments on the same line. "Leading comments" are comments both above and after a line. I'll study Sourceror a little more but I just wanted to get this up for review.I'm certainly open to different ideas on the name! I was even thinking something as dumb as
NoDoTrueElseFalse
π π πThanks!