Refactor Set.add following !Set.contains (#2295)
The `.add` method returns a boolean indicating whether then value was
not already contained in the set. Find a few places where both are used
unnecessarily and refactor to only call `.add` and use the returned
boolean.
diff --git a/lib/src/io.dart b/lib/src/io.dart
index 1c90a27..cc79541 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -140,8 +140,7 @@
/// This accepts paths to non-links or broken links, and returns them as-is.
String _resolveLink(String link) {
var seen = <String>{};
- while (linkExists(link) && !seen.contains(link)) {
- seen.add(link);
+ while (linkExists(link) && seen.add(link)) {
link =
path.normalize(path.join(path.dirname(link), Link(link).targetSync()));
}
diff --git a/lib/src/solver/version_solver.dart b/lib/src/solver/version_solver.dart
index c8a2988..11c36de 100644
--- a/lib/src/solver/version_solver.dart
+++ b/lib/src/solver/version_solver.dart
@@ -323,9 +323,7 @@
if (_useLatest.contains(candidate.name) &&
candidate.source.hasMultipleVersions) {
var ref = candidate.toRef();
- if (!_haveUsedLatest.contains(ref)) {
- _haveUsedLatest.add(ref);
-
+ if (_haveUsedLatest.add(ref)) {
// All versions of [ref] other than the latest are forbidden.
var latestVersion = (await _packageLister(ref).latest).version;
_addIncompatibility(Incompatibility([