charlescyt / pyramid_lint

Linting tool for Dart and Flutter projects.

Home Page:https://pub.dev/packages/pyramid_lint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Iterable.first quick fix fails on nested array index lookup

imsamgarg opened this issue · comments

Is there an existing issue for this bug?

Bug Description

Here's the issue.

list_first.webm

Steps to Reproduce

Use any nested array lookup with the main array lookup index to be 0.

Additional Information

No response

We probably should use

if (!analysisError.sourceRange.covers(node.sourceRange)) return;

instead of

if (!analysisError.sourceRange.intersects(node.sourceRange)) return;

Yeah this fixes the issue.

I think it makes sense to use covers instead of intersects for all the quick fixes as well.
#33 only changes prefer_iterable_first and prefer_iterable_last