Open
Description
Tried with sdk 7fa9a67.
Input:
class Test {
List<int> lengthDelimited = <int>[];
List<int> varints = <int>[];
List<int> fixed32s = <int>[];
List<int> fixed64s = <int>[];
List<int> groups = <int>[];
List get values => <int>[]
..addAll(lengthDelimited)
..addAll(varints)
..addAll(fixed32s)
..addAll(fixed64s)
..addAll(groups);
}
void main() {}
dart analyze
output:
info - protobuf_test.dart:9:7 - Use spread collections when possible. - prefer_spread_collections
File after running dart fix --apply
:
class Test {
List<int> lengthDelimited = <int>[];
List<int> varints = <int>[];
List<int> fixed32s = <int>[];
List<int> fixed64s = <int>[];
List<int> groups = <int>[];
List get values => <int>[...lengthDelimited, ...varints, ...fixed32s, ...fixed64s]
..addAll(groups);
}
void main() {}
Note that groups
is not moved to the list syntax, and the new file has the same lint error.
Interestingly if I remove ..addAll(groups)
in the original program then dart fix --apply
doesn't leave the last addAll
outside the list syntax and produces lint-free output. Is there a hard-coded limit on the depth of the tree to transform maybe?