Skip to content

no-unused-variables

Forbid unused variables

INFO

☑️ The predefined configuration "mslint:recommended" enables this rule.

Rule details

This rule prohibits unused variables and function parameters.

Example of incorrect code for this rule:

maniascript
Integer FunctionA(
  Integer _A, // [!code error]
  Integer _B
) {
  return _B + 10;
}

main() {
  declare Integer C;
  declare Integer D;
  D = 1; //< Assigning a value is not enough, the variable must be read to be considered used
}

Example of correct code for this rule:

maniascript
Integer FunctionA(
  Integer _A, // [!code hl]
  Integer _B
) {
  return _B + _A;
}

main() {
  declare Integer C;
  declare Integer D;
  D = 1;
  Function(C);
  if (D > 0) {

  }
}

Resources