Linting rules
E013: mutable-parameter-can-be-immutable
Checks for parameters that are declared as mutable (`mutate`) but are never mutated.
Metadata
Code:E013Rule:mutable-parameter-can-be-immutableStatus: Stable sincev0.0.1Quick 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 { 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 acounts as write usage and suppresses this diagnostic. - Autofix removes the
mutatekeyword (and one trailing whitespace if present).
Last updated on