Migrate package to use `lints` package instead of `pedantic` package. (#197)
Address all new warnings.
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 483d38f..72e4a38 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,4 +1,4 @@
-include: package:pedantic/analysis_options.1.9.0.yaml
+include: package:lints/recommended.yaml
analyzer:
errors:
unused_element: error
@@ -8,18 +8,10 @@
linter:
rules:
# Errors
- - control_flow_in_finally
- - empty_statements
- - hash_and_equals
- - implementation_imports
- test_types_in_equals
- throw_in_finally
# Style
- avoid_private_typedef_functions
- - avoid_renaming_method_parameters
- - await_only_futures
- - camel_case_types
- directives_ordering
- - non_constant_identifier_names
- only_throw_errors
diff --git a/lib/src/algorithms.dart b/lib/src/algorithms.dart
index d589e1e..820d32b 100644
--- a/lib/src/algorithms.dart
+++ b/lib/src/algorithms.dart
@@ -227,9 +227,7 @@
var secondLength = end - middle;
// secondLength is always the same as firstLength, or one greater.
var scratchSpace = List<E>.filled(secondLength, elements[start]);
- // TODO(linter/2097): Remove ignore when no longer required by linter.
- // See: https://github.com/dart-lang/linter/issues/2097
- E Function(E) id = identity; // ignore: omit_local_variable_types
+ E Function(E) id = identity;
_mergeSort(elements, id, compare, middle, end, scratchSpace, 0);
var firstTarget = end - firstLength;
_mergeSort(elements, id, compare, start, middle, elements, firstTarget);
diff --git a/lib/src/canonicalized_map.dart b/lib/src/canonicalized_map.dart
index 5f97b25..de63908 100644
--- a/lib/src/canonicalized_map.dart
+++ b/lib/src/canonicalized_map.dart
@@ -50,7 +50,7 @@
V? operator [](Object? key) {
if (!_isValidKey(key)) return null;
var pair = _base[_canonicalize(key as K)];
- return pair == null ? null : pair.value;
+ return pair?.value;
}
@override
@@ -129,7 +129,7 @@
void removeWhere(bool Function(K key, V value) test) =>
_base.removeWhere((_, pair) => test(pair.key, pair.value));
- @deprecated
+ @Deprecated("Use cast instead")
Map<K2, V2> retype<K2, V2>() => cast<K2, V2>();
@override
diff --git a/lib/src/empty_unmodifiable_set.dart b/lib/src/empty_unmodifiable_set.dart
index 725dfc0..76f9f22 100644
--- a/lib/src/empty_unmodifiable_set.dart
+++ b/lib/src/empty_unmodifiable_set.dart
@@ -27,7 +27,7 @@
Iterable<E> followedBy(Iterable<E> other) => DelegatingIterable(other);
@override
E? lookup(Object? element) => null;
- @deprecated
+ @Deprecated("Use cast instead")
@override
EmptyUnmodifiableSet<T> retype<T>() => EmptyUnmodifiableSet<T>();
@override
diff --git a/lib/src/equality.dart b/lib/src/equality.dart
index eba3841..a6b464f 100644
--- a/lib/src/equality.dart
+++ b/lib/src/equality.dart
@@ -6,7 +6,7 @@
import 'comparators.dart';
-const int _HASH_MASK = 0x7fffffff;
+const int _hashMask = 0x7fffffff;
/// A generic equality relation on objects.
abstract class Equality<E> {
@@ -136,13 +136,13 @@
var hash = 0;
for (var element in elements) {
var c = _elementEquality.hash(element);
- hash = (hash + c) & _HASH_MASK;
- hash = (hash + (hash << 10)) & _HASH_MASK;
+ hash = (hash + c) & _hashMask;
+ hash = (hash + (hash << 10)) & _hashMask;
hash ^= (hash >> 6);
}
- hash = (hash + (hash << 3)) & _HASH_MASK;
+ hash = (hash + (hash << 3)) & _hashMask;
hash ^= (hash >> 11);
- hash = (hash + (hash << 15)) & _HASH_MASK;
+ hash = (hash + (hash << 15)) & _hashMask;
return hash;
}
@@ -188,13 +188,13 @@
var hash = 0;
for (var i = 0; i < list.length; i++) {
var c = _elementEquality.hash(list[i]);
- hash = (hash + c) & _HASH_MASK;
- hash = (hash + (hash << 10)) & _HASH_MASK;
+ hash = (hash + c) & _hashMask;
+ hash = (hash + (hash << 10)) & _hashMask;
hash ^= (hash >> 6);
}
- hash = (hash + (hash << 3)) & _HASH_MASK;
+ hash = (hash + (hash << 3)) & _hashMask;
hash ^= (hash >> 11);
- hash = (hash + (hash << 15)) & _HASH_MASK;
+ hash = (hash + (hash << 15)) & _hashMask;
return hash;
}
@@ -237,11 +237,11 @@
var hash = 0;
for (E element in elements) {
var c = _elementEquality.hash(element);
- hash = (hash + c) & _HASH_MASK;
+ hash = (hash + c) & _hashMask;
}
- hash = (hash + (hash << 3)) & _HASH_MASK;
+ hash = (hash + (hash << 3)) & _hashMask;
hash ^= (hash >> 11);
- hash = (hash + (hash << 15)) & _HASH_MASK;
+ hash = (hash + (hash << 15)) & _hashMask;
return hash;
}
}
@@ -287,15 +287,15 @@
/// using a combined hashCode and equality of the key and value.
class _MapEntry {
final MapEquality equality;
- final key;
- final value;
+ final Object? key;
+ final Object? value;
_MapEntry(this.equality, this.key, this.value);
@override
int get hashCode =>
(3 * equality._keyEquality.hash(key) +
7 * equality._valueEquality.hash(value)) &
- _HASH_MASK;
+ _hashMask;
@override
bool operator ==(Object other) =>
@@ -349,11 +349,11 @@
for (var key in map.keys) {
var keyHash = _keyEquality.hash(key);
var valueHash = _valueEquality.hash(map[key] as V);
- hash = (hash + 3 * keyHash + 7 * valueHash) & _HASH_MASK;
+ hash = (hash + 3 * keyHash + 7 * valueHash) & _hashMask;
}
- hash = (hash + (hash << 3)) & _HASH_MASK;
+ hash = (hash + (hash << 3)) & _hashMask;
hash ^= (hash >> 11);
- hash = (hash + (hash << 15)) & _HASH_MASK;
+ hash = (hash + (hash << 15)) & _hashMask;
return hash;
}
diff --git a/lib/src/iterable_extensions.dart b/lib/src/iterable_extensions.dart
index 1c82bc4..7bb4e22 100644
--- a/lib/src/iterable_extensions.dart
+++ b/lib/src/iterable_extensions.dart
@@ -420,7 +420,7 @@
Map<K, Set<T>> groupSetsBy<K>(K Function(T element) keyOf) {
var result = <K, Set<T>>{};
for (var element in this) {
- (result[keyOf(element)] ??= <T>{})..add(element);
+ (result[keyOf(element)] ??= <T>{}).add(element);
}
return result;
}
@@ -429,7 +429,7 @@
Map<K, List<T>> groupListsBy<K>(K Function(T element) keyOf) {
var result = <K, List<T>>{};
for (var element in this) {
- (result[keyOf(element)] ??= [])..add(element);
+ (result[keyOf(element)] ??= []).add(element);
}
return result;
}
diff --git a/lib/src/priority_queue.dart b/lib/src/priority_queue.dart
index 345d6f7..ae4ee9a 100644
--- a/lib/src/priority_queue.dart
+++ b/lib/src/priority_queue.dart
@@ -174,13 +174,13 @@
///
/// Number can be any positive value. Picking a size that gives a whole
/// number of "tree levels" in the heap is only done for aesthetic reasons.
- static const int _INITIAL_CAPACITY = 7;
+ static const int _initialCapacity = 7;
/// The comparison being used to compare the priority of elements.
final Comparator<E> comparison;
/// List implementation of a heap.
- List<E?> _queue = List<E?>.filled(_INITIAL_CAPACITY, null);
+ List<E?> _queue = List<E?>.filled(_initialCapacity, null);
/// Number of elements in queue.
///
@@ -451,7 +451,7 @@
/// Called when the list is full.
void _grow() {
var newCapacity = _queue.length * 2 + 1;
- if (newCapacity < _INITIAL_CAPACITY) newCapacity = _INITIAL_CAPACITY;
+ if (newCapacity < _initialCapacity) newCapacity = _initialCapacity;
var newQueue = List<E?>.filled(newCapacity, null);
newQueue.setRange(0, _length, _queue);
_queue = newQueue;
diff --git a/lib/src/queue_list.dart b/lib/src/queue_list.dart
index 3bf13f2..f013723 100644
--- a/lib/src/queue_list.dart
+++ b/lib/src/queue_list.dart
@@ -115,7 +115,7 @@
QueueList<T> cast<T>() => QueueList._castFrom<E, T>(this);
- @deprecated
+ @Deprecated("Use cast instead")
QueueList<T> retype<T>() => cast<T>();
@override
diff --git a/lib/src/wrappers.dart b/lib/src/wrappers.dart
index b5b61e3..e380350 100644
--- a/lib/src/wrappers.dart
+++ b/lib/src/wrappers.dart
@@ -79,7 +79,7 @@
@override
E reduce(E Function(E value, E element) combine) => _base.reduce(combine);
- @deprecated
+ @Deprecated("Use cast instead")
Iterable<T> retype<T>() => cast<T>();
@override
@@ -278,7 +278,7 @@
_base.retainWhere(test);
}
- @deprecated
+ @Deprecated("Use cast instead")
@override
List<T> retype<T>() => cast<T>();
@@ -379,7 +379,7 @@
_base.retainAll(elements);
}
- @deprecated
+ @Deprecated("Use cast instead")
@override
Set<T> retype<T>() => cast<T>();
@@ -462,7 +462,7 @@
_base.retainWhere(test);
}
- @deprecated
+ @Deprecated("Use cast instead")
@override
Queue<T> retype<T>() => cast<T>();
@@ -563,7 +563,7 @@
@override
void removeWhere(bool Function(K, V) test) => _base.removeWhere(test);
- @deprecated
+ @Deprecated("Use cast instead")
Map<K2, V2> retype<K2, V2>() => cast<K2, V2>();
@override
@@ -651,7 +651,7 @@
E lookup(Object? element) =>
throw UnsupportedError("MapKeySet doesn't support lookup().");
- @deprecated
+ @Deprecated("Use cast instead")
@override
Set<T> retype<T>() => Set.castFrom<E, T>(this);
@@ -822,7 +822,7 @@
void retainWhere(bool Function(V) test) =>
removeWhere((element) => !test(element));
- @deprecated
+ @Deprecated("Use cast instead")
@override
Set<T> retype<T>() => Set.castFrom<V, T>(this);
diff --git a/pubspec.yaml b/pubspec.yaml
index c8a468e..74f5bc3 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -8,5 +8,5 @@
sdk: ">=2.12.0 <3.0.0"
dev_dependencies:
- pedantic: ^1.10.0-nullsafety
+ lints: ^1.0.0
test: ^1.16.0-nullsafety
diff --git a/test/canonicalized_map_test.dart b/test/canonicalized_map_test.dart
index e5bd34e..dad9c87 100644
--- a/test/canonicalized_map_test.dart
+++ b/test/canonicalized_map_test.dart
@@ -160,7 +160,7 @@
});
group('CanonicalizedMap builds an informative string representation', () {
- var map;
+ dynamic map;
setUp(() {
map = CanonicalizedMap<int, String, dynamic>(int.parse,
isValidKey: RegExp(r'^\d+$').hasMatch);
diff --git a/test/queue_list_test.dart b/test/queue_list_test.dart
index 21b6056..57644da 100644
--- a/test/queue_list_test.dart
+++ b/test/queue_list_test.dart
@@ -219,7 +219,7 @@
});
group('throws a modification error for', () {
- var queue;
+ dynamic queue;
setUp(() {
queue = QueueList.from([1, 2, 3]);
});
diff --git a/test/union_set_test.dart b/test/union_set_test.dart
index fe9e204..d8897a4 100644
--- a/test/union_set_test.dart
+++ b/test/union_set_test.dart
@@ -7,7 +7,7 @@
void main() {
group('with an empty outer set', () {
- var set;
+ dynamic set;
setUp(() {
set = UnionSet<int>({});
});
@@ -39,7 +39,7 @@
});
group('with multiple disjoint sets', () {
- var set;
+ dynamic set;
setUp(() {
set = UnionSet.from([
{1, 2},
@@ -78,7 +78,7 @@
});
group('with multiple overlapping sets', () {
- var set;
+ dynamic set;
setUp(() {
set = UnionSet.from([
{1, 2, 3},
@@ -131,7 +131,7 @@
});
group('after an inner set was modified', () {
- var set;
+ dynamic set;
setUp(() {
var innerSet = {3, 7};
set = UnionSet.from([
@@ -175,7 +175,7 @@
});
group('after the outer set was modified', () {
- var set;
+ dynamic set;
setUp(() {
var innerSet = {6};
var outerSet = {
diff --git a/test/unmodifiable_collection_test.dart b/test/unmodifiable_collection_test.dart
index 1eaed3f..a0cb89c 100644
--- a/test/unmodifiable_collection_test.dart
+++ b/test/unmodifiable_collection_test.dart
@@ -123,9 +123,11 @@
test('$name - forEach', () {
var wrapCtr = 0;
var origCtr = 0;
+ // ignore: avoid_function_literals_in_foreach_calls
wrapped.forEach((x) {
wrapCtr += x;
});
+ // ignore: avoid_function_literals_in_foreach_calls
original.forEach((x) {
origCtr += x;
});
diff --git a/test/wrapper_test.dart b/test/wrapper_test.dart
index f31499b..00a2ccb 100644
--- a/test/wrapper_test.dart
+++ b/test/wrapper_test.dart
@@ -161,6 +161,7 @@
}
// Utility values to use as arguments in calls.
+// ignore: prefer_void_to_null
Null func0() => null;
dynamic func1(dynamic x) => null;
dynamic func2(dynamic x, dynamic y) => null;