ALL-CONT0001 · superfluous_else_after_jump
Count else clauses a jump in the block above them already made unnecessary.
This is a deterministic rule for all languages. Read its implementation.
Definition
Section titled “Definition”Report a branch whose last statement before the alternative leaves the block for good, through a return, a raise, a throw, a break, or a continue. Once that statement runs nothing else in the block runs, so the else adds no information a reader did not already have. What it does add is a level of indentation, and every level costs the reader one more condition to hold in mind while reading the rest of the work.
The alternative is read at the branch’s own indentation, which is else in Python and
} else { in C, C++, Rust, and TypeScript, and the jump is read from the first word of the
statement before it. Both readings are language neutral, so one rule answers for every frontend
that fills a tree, and a frontend that states no statements inside a branch still gets an
answer from the source the branch carries.
Continue with evidence and references, or open the examples.