avoid-multi-assignment
- Group
- Suspicious
- Path
lint/suspicious/avoid-multi-assignment- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 91 of 512
Split chained assignments into separate statements.
Invalid
example.dartdart
void f(dynamic a, dynamic b, dynamic c, dynamic d) {
a = b = 1;
a = (b = 2);
a = b = c = 3;
a.value = b.value = 4;
a += b = 5;
d..value = b = 6;
}Split chained assignments into separate statements.
1
void f(dynamic a, dynamic b, dynamic c, dynamic d) {2
a = b = 1;Split chained assignments into separate statements.
2
a = b = 1;3
a = (b = 2);Split chained assignments into separate statements.
3
a = (b = 2);4
a = b = c = 3;Split chained assignments into separate statements.
4
a = b = c = 3;5
a.value = b.value = 4;Split chained assignments into separate statements.
5
a.value = b.value = 4;6
a += b = 5;Split chained assignments into separate statements.
6
a += b = 5;7
d..value = b = 6;Valid
example.dartdart
void f(dynamic a, dynamic b) {
a = 1;
b = 1;
a += 2;
b ??= 3;
a = b + 1;
a..value = 1..other = 2;
}Configure avoid-multi-assignment
Set its severity in falcon.json. See the configuration guide.
falcon.jsonjson
{
"linter": {
"rules": {
"suspicious": {
"avoid-multi-assignment": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
example.dartdart
// falcon-ignore lint/suspicious/avoid-multi-assignment: <reason>More suspicious rules
- avoid-mutating-parameters
Detects writes through named function, method and constructor parameter objects.
- avoid-negated-conditions
Prefer positive conditions when both branches can be swapped.
- avoid-nested-assignments
Require assignments to be standalone statements, arrow bodies or loop operations.
- avoid-non-final-exception-class-fields
Exception and Error payloads should not change after construction.
- avoid-passing-async-when-sync-expected
avoid-passing-async-when-sync-expectedrecommendedFlags an
asyncclosure passed to a proven synchronous callback parameter. - avoid-passing-bloc-to-blocbloc
Rejects direct Bloc and Cubit arguments to other blocs.
- avoid-passing-bloc-to-widgetbloc
Rejects direct Bloc and Cubit arguments to Flutter widget constructors.
- avoid-passing-build-context-to-blocsbloc
Keeps Flutter
BuildContextarguments outside Bloc and Cubit APIs.