Dead variables should not be used

  • UNUSED_VAR_ASSIGN
  • Code Quality
  • Low
  • cwe

This rule applies when a variable is assigned a value that is not used by subsequent code or is overwritten by another assignment without use.

The value is dead so that it might imply a mistake or unnecessary code.

Note: Not applied for the assignment with initialization values like "", '', 0, true, !0, false, !1, null, undefined, void …, {}, [].

Noncompliant Code Example

function foo(url) {
    var target = url + "user" + user; // UNUSED_VAR_ASSIGN alarm
    target = url.replace(/\.|\?|\&|\/|\=|\:|\-|\s/gi, "");
}

Compliant Code Example

function foo(url) {
    var target = url + "user" + user;
    target = target.replace(/\.|\?|\&|\/|\=|\:|\-|\s/gi, "");
}

Version

This rule was introduced in DeepScan 1.0.0-alpha.

See