Skip to content

Remove-Unreachable-Code

Sourcery rule id: remove-unreachable-code

Description

Remove unreachable code.

Before

if (true) {
  return;
  do_something();
}

After

if (true) {
  return;
}

Explanation

Statements after a return, break, continue or throw will never be executed. Leaving them in the code confuses the reader, who may believe that these statements have some effect. They should therefore be removed.