avoid-unused-assignment
preset: recommended
Warns when an assignment is not used in the subsequent statements.
Example
❌ Bad:
void fn1() {
var v = 'used';
doSomething(v);
v = 'unused'; // LINT: This assigned value is not used in subsequent statements. Try removing this assignment.
}
void fn2(bool condition) {
var v = 'used';
if (condition) {
v = 'unused'; // LINT: This assigned value is not used in subsequent statements. Try removing this assignment.
return;
}
doSomething(v);
}
✅ Good:
void fn1() {
var v = 'used';
doSomething(v);
}
void fn2(bool condition) {
var v = 'used';
if (condition) {
return;
}
doSomething(v);
}