Unreachable code should not be used

  • UNREACHABLE_CODE
  • Error
  • Medium
  • cwe

This rule applies when code is unreachable.

Statements after return, throw, break and continue are not executed so that it might not be a programmer's intent.

Noncompliant Code Example

function foo() {
    return;

    // UNREACHABLE_CODE alarm
    var bar = 1;
}

Compliant Code Example

// In case when 'return' statement is a mistake
function foo() {
    var bar = 1;
}

// In case when you do not need statements after 'return' statement
function foo() {
    return;
}

Version

This rule was introduced in DeepScan 1.0.0-alpha.

See