Acton
Linting rules

E005: write-only-variable

Checks for variables that are written to but never read.

Metadata

  • Code: E005
  • Rule: write-only-variable
  • Status: Stable since v0.0.1
  • Quick fix: not available

What it does

Checks for variables that are written to but never read.

Why is this bad?

A variable that is only written to but never read is likely a bug or redundant code.

Example

fun main() {
    var x = 1;
E005: variable is only written to but never read
x = 2; println("hello"); }

Use instead:

fun main() {
    println("hello");
}

Behavior notes

  • Locals prefixed with _ are ignored.
  • Mutable parameters (mutate) are ignored.
  • Variables with zero usages are handled by unused-variable.
  • This rule only reports variables with writes and no reads. Operations that imply reads (for example +=) do not match this rule.
Source code

Last updated on

On this page