Stop depending on pkg:charcode and pkg:pedantic. (#191)
Stop depending on pkg:charcode and pkg:pedantic.
Use pkg:lints instead of pkg:pedantic (and update code as necessary).
Use a local constant instead of depending on pkg:charcode.
Remove unnecessary clutter in analysis_options.yaml, but do retain
`analyzer`/`strong-mode`/`implicit-casts: false`
diff --git a/analysis_options.yaml b/analysis_options.yaml
index b58ef99..5c78135 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,15 +1,7 @@
-include: package:pedantic/analysis_options.yaml
+include: package:lints/recommended.yaml
analyzer:
strong-mode:
implicit-casts: false
errors:
todo: ignore
- # Lint provided by pkg:pedantic – should fix this!
- unawaited_futures: ignore
- enable-experiment:
- - non-nullable
-
-linter:
- rules:
- - prefer_typing_uninitialized_variables
diff --git a/lib/src/chunked_stream_reader.dart b/lib/src/chunked_stream_reader.dart
index a896341..fd9be92 100644
--- a/lib/src/chunked_stream_reader.dart
+++ b/lib/src/chunked_stream_reader.dart
@@ -118,7 +118,7 @@
}
_reading = true;
- final substream = () async* {
+ Stream<List<T>> substream() async* {
// While we have data to read
while (size > 0) {
// Read something into the buffer, if buffer has been consumed.
@@ -158,7 +158,7 @@
yield output;
}
}
- };
+ }
final c = StreamController<List<T>>();
c.onListen = () => c.addStream(substream()).whenComplete(c.close);
diff --git a/lib/src/stream_group.dart b/lib/src/stream_group.dart
index c8414f4..51e43b4 100644
--- a/lib/src/stream_group.dart
+++ b/lib/src/stream_group.dart
@@ -74,7 +74,7 @@
Stream<void> get onIdle =>
(_onIdleController ??= StreamController.broadcast()).stream;
- StreamController<Null>? _onIdleController;
+ StreamController<void>? _onIdleController;
/// Streams that have been added to the group, and their subscriptions if they
/// have been subscribed to.
@@ -169,7 +169,7 @@
/// [StreamSubscription.cancel]'s return value. Otherwise, it returns `null`.
Future? remove(Stream<T> stream) {
var subscription = _subscriptions.remove(stream);
- var future = subscription == null ? null : subscription.cancel();
+ var future = subscription?.cancel();
if (_subscriptions.isEmpty) {
_onIdleController?.add(null);
diff --git a/lib/src/stream_sink_transformer.dart b/lib/src/stream_sink_transformer.dart
index de48d39..d42d19c 100644
--- a/lib/src/stream_sink_transformer.dart
+++ b/lib/src/stream_sink_transformer.dart
@@ -53,7 +53,7 @@
/// This means that calls to [StreamSink.add] on the returned sink may throw a
/// [TypeError] if the argument type doesn't match the reified type of the
/// sink.
- @deprecated
+ @Deprecated("Will be removed in future version")
// TODO remove TypeSafeStreamSinkTransformer
static StreamSinkTransformer<S, T> typed<S, T>(
StreamSinkTransformer transformer) =>
diff --git a/lib/src/stream_sink_transformer/reject_errors.dart b/lib/src/stream_sink_transformer/reject_errors.dart
index a8d130f..7e15d26 100644
--- a/lib/src/stream_sink_transformer/reject_errors.dart
+++ b/lib/src/stream_sink_transformer/reject_errors.dart
@@ -112,7 +112,10 @@
if (_closed) return done;
_closed = true;
- if (!_canceled) _doneCompleter.complete(_inner.close());
+ if (!_canceled) {
+ // ignore: void_checks
+ _doneCompleter.complete(_inner.close());
+ }
return done;
}
diff --git a/pubspec.yaml b/pubspec.yaml
index abfc12c..c636de6 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: async
-version: 2.8.2
+version: 2.8.3
description: Utility functions and classes related to the 'dart:async' library.
repository: https://github.com/dart-lang/async
@@ -12,8 +12,7 @@
meta: ^1.1.7
dev_dependencies:
- charcode: ^1.3.0
fake_async: ^1.2.0
- pedantic: ^1.10.0
+ lints: ^1.0.0
stack_trace: ^1.10.0
test: ^1.16.0
diff --git a/test/io_sink_impl.dart b/test/io_sink_impl.dart
index bd761b9..832eb71 100644
--- a/test/io_sink_impl.dart
+++ b/test/io_sink_impl.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-@deprecated
+@Deprecated("Tests deprecated functionality")
library io_sink_impl;
import 'dart:io';
diff --git a/test/result/result_captureAll_test.dart b/test/result/result_captureAll_test.dart
index c00395a..fb52836 100644
--- a/test/result/result_captureAll_test.dart
+++ b/test/result/result_captureAll_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// ignore_for_file: file_names
+
import 'dart:async';
import 'dart:math' show Random;
diff --git a/test/result/result_flattenAll_test.dart b/test/result/result_flattenAll_test.dart
index b87fec4..2521e9e 100644
--- a/test/result/result_flattenAll_test.dart
+++ b/test/result/result_flattenAll_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// ignore_for_file: file_names
+
import 'package:async/async.dart';
import 'package:test/test.dart';
diff --git a/test/sink_base_test.dart b/test/sink_base_test.dart
index 8ecf8c3..33958dd 100644
--- a/test/sink_base_test.dart
+++ b/test/sink_base_test.dart
@@ -2,17 +2,18 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-@deprecated
+@Deprecated("Tests deprecated functionality")
library sink_base_test;
import 'dart:async';
import 'dart:convert';
-import 'package:charcode/charcode.dart';
import 'package:test/test.dart';
import 'package:async/async.dart';
+const int letterA = 0x41;
+
void main() {
// We don't explicitly test [EventSinkBase] because it shares all the relevant
// implementation with [StreamSinkBase].
@@ -54,7 +55,6 @@
var controller = StreamController<int>();
var addStreamCompleted = false;
sink.addStream(controller.stream).then((_) => addStreamCompleted = true);
- ;
await pumpEventQueue();
expect(addStreamCompleted, isFalse);
@@ -277,7 +277,7 @@
var sink = _IOSink(onAdd: expectAsync1((data) {
expect(data, equals(utf8.encode('A')));
}));
- sink.writeCharCode($A);
+ sink.writeCharCode(letterA);
});
test('respects the encoding', () async {
@@ -292,7 +292,7 @@
test('throws if the sink is closed', () async {
var sink = _IOSink(onAdd: expectAsync1((_) {}, count: 0));
expect(sink.close(), completes);
- expect(() => sink.writeCharCode($A), throwsStateError);
+ expect(() => sink.writeCharCode(letterA), throwsStateError);
});
});
diff --git a/test/stream_queue_test.dart b/test/stream_queue_test.dart
index 74c91e6..1d45a8c 100644
--- a/test/stream_queue_test.dart
+++ b/test/stream_queue_test.dart
@@ -543,7 +543,7 @@
test('returns the result of closing the underlying subscription',
() async {
var controller =
- StreamController<int>(onCancel: () => Future.value(42));
+ StreamController<int>(onCancel: () => Future<int>.value(42));
var events = StreamQueue<int>(controller.stream);
expect(await events.cancel(immediate: true), 42);
});
diff --git a/test/subscription_transformer_test.dart b/test/subscription_transformer_test.dart
index 8278ea0..a95c7c4 100644
--- a/test/subscription_transformer_test.dart
+++ b/test/subscription_transformer_test.dart
@@ -13,8 +13,9 @@
group('with no callbacks', () {
test('forwards cancellation', () async {
var isCanceled = false;
- var cancelCompleter = Completer();
- var controller = StreamController(onCancel: expectAsync0(() {
+ var cancelCompleter = Completer<void>();
+ var controller =
+ StreamController(onCancel: expectAsync0<Future<void>>(() {
isCanceled = true;
return cancelCompleter.future;
}));