-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: unnecessary_to_list_in_spreads
#2965
Comments
In most places where you immediately iterate the result, calling I think "immediately iterates" is currently just spreads and Say, something like: for (var value in set.toList()) {
if (!relevant(value)) set.remove(value);
} So, hinting that a I think it'll be safe enough to do it on spreads. Maybe also in a It could probably be extended to immediately calling |
@jakemac53 @natebosch @munificent : this feels like a reasonable core lint but I think we need to get the scope just right. Would love to hear your thoughts. |
I agree with Lasse. I think linting on |
@pq any news about this one? If not, i'd like to nominate this for q1? |
SGTM |
My thinking is to push ahead on a lint scoped to spreads. Spitballing names, how about |
@pq any news about this one? |
Hey @mit-mit. This is still in the queue. Maybe we can get some more feedback from core lints folks? If there's a consensus this should be suggested style, it'd help bump the priority. |
unnecessary_to_list_in_spreads
If we had it, I'd make it a recommended lint. doing I'm not going to recommend increasing priority without knowing what it's competing with :) |
Sounds like a useful lint for "recommended" to me. |
+1 for linting on |
Lots of Dart UI code operates on lists (e.g. a list of Widgets in Flutter). As some core library functions return iterables, some developers have a habit of calling
toList()
on those without reflecting on it. One example I often see is doing this in conjunction with the spread operator, where calling toList is not needed, as the spread can be called on the iterable directly.Examples
BAD:
GOOD:
The text was updated successfully, but these errors were encountered: