-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
The analyzer should report when a library uses some elements which are provided by more than one import directive (with the same prefix).
If any such import directive provides fewer elements which are used by the library than any of the other relevant imports, then that import directive is unnecessary. Removing each unnecessary import is strictly safe.
If any such import directive provides the exact same elements which are used by the library as one or more of the other relevant imports, then it is redundant. Removing one redundant import is strictly safe, but removing all redundant imports is not safe, and the analyzer should use a heuristic to decide what action to recommend.
Examples:
Simple unnecessary import
import 'one.dart' show A, B;
import 'two.dart' show A;
A? a;
B? b;
The import of two.dart
is unnecessary.
Simple redundant import
import 'one.dart' show A;
import 'two.dart' show A;
A? a;
Each import is redundant; neither is unnecessary.
More interesting unnecessary imports
import 'one.dart' show A;
import 'two.dart' show A, B;
import 'three.dart' show A, B, C;
A? a;
B? b;
C? c;
The imports of one.dart
and two.dart
are unnecessary.
More interesting redundant imports
import 'one.dart' show A, B;
import 'two.dart' show A, C;
import 'three.dart' show B, C;
A? a;
B? b;
C? c;
Each of the three imports is redundant, but ultimately, only one can be safely removed.