The rule should detect unreachable branches. These unreachable branches contain dead code, and therefore logically unused code.
What problems does it solve:
Unreachable branches are an indicator of either:
Error: errors in logical thinking, which the user should be made aware of
Error: Usage of the wrong variable used instead of another of the same type
work in progress that should be finished
Simplification: code that could be simplified
Example of things the rule would report:
if (value == stringLiteral)thenif (value != stringLiteral)then-- you can prove that this is dead codeelse-- nested elseelse-- outer else
Example of things the rule would not report:
if (value == stringLiteral)then-- nested elseelse-- outer else
When (not) to enable this rule:
Should this rule also warn about cases where the condition can be evaluated statically (like if True then or if a == a then), or should this be the task of another rule? (I'm leaning towards a different rule, but maybe in a different package.
Do you see a more fitting name for the rule?
Can you think of reasons not to have an automatic fix?
Should the rule handle case expressions too?
case value ofFoo->case value ofFoo->1Bar->2-- dead branch, we know value == FooBar->2
I am wondering whether this will not be annoying in cases where you'll need to destructure again, but I think that's unwarranted concern 🤔
I think the first iteration of the rule can concentrate on handling if expressions only anyway.
The text was updated successfully, but these errors were encountered: