Acton
Linting rules

E013: mutable-parameter-can-be-immutable

Checks for parameters that are declared as mutable (`mutate`) but are never mutated.

Metadata

  • Code: E013
  • Rule: mutable-parameter-can-be-immutable
  • Status: Stable since v0.0.1
  • Quick fix: always available

What it does

Checks for parameters that are declared as mutable (mutate) but are never mutated.

Why is this bad?

Using immutable parameters makes the function contract clearer and reduces accidental mutations.

Example

fun increment(mutate value: int): int {
E013: parameter can be immutable
return value + 1; }

Use instead:

fun increment(value: int): int {
    return value + 1;
}

Behavior notes

  • Parameters with zero usages are not reported by this rule.
  • Passing a parameter as mutate a counts as write usage and suppresses this diagnostic.
  • Autofix removes the mutate keyword (and one trailing whitespace if present).
Source code

Last updated on

On this page