Skip to main content

avoid-unused-assignment

added in: 1.22.0
Pro+

Warns when an assignment is not used in the subsequent statements.

Example

❌ Bad:

void fn1() {
var v = 'used';
doSomething(v);
v = 'unused'; // LINT
}

void fn2(bool condition) {
var v = 'used';
if (condition) {
v = 'unused'; // LINT
return;
}
doSomething(v);
}

✅ Good:

void fn1() {
var v = 'used';
doSomething(v);
}

void fn2(bool condition) {
var v = 'used';
if (condition) {
return;
}
doSomething(v);
}