Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit aeb506c

Browse files
authored
Require Dart 3.2, update lints (#140)
1 parent 4735a33 commit aeb506c

31 files changed

+141
-163
lines changed

.github/workflows/test-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
matrix:
4848
# Add macos-latest and/or windows-latest if relevant for this package.
4949
os: [ubuntu-latest]
50-
sdk: [3.0.0, dev]
50+
sdk: [3.2, dev]
5151
steps:
5252
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
5353
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.3.1-wip
2+
3+
- Require Dart 3.2
4+
15
## 2.3.0
26

37
- Only send updates on frames and pings being received when there are listeners, as to not fill up memory.

analysis_options.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
include: package:lints/recommended.yaml
1+
# https://dart.dev/tools/analysis#the-analysis-options-file
2+
include: package:dart_flutter_team_lints/analysis_options.yaml
23

34
analyzer:
45
language:
56
strict-casts: true
67
errors:
7-
unused_element: error
8-
unused_import: error
9-
unused_local_variable: error
10-
dead_code: error
11-
12-
linter:
13-
rules:
148
# Disabled as there are several dozen violations.
15-
constant_identifier_names: false
9+
constant_identifier_names: ignore

lib/multiprotocol_server.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class MultiProtocolHttpServer {
4545
///
4646
/// See also [startServing].
4747
static Future<MultiProtocolHttpServer> bind(
48-
address, int port, SecurityContext context,
48+
Object? address, int port, SecurityContext context,
4949
{http2.ServerSettings? settings}) async {
5050
context.setAlpnProtocols(['h2', 'h2-14', 'http/1.1'], true);
5151
var secureServer = await SecureServerSocket.bind(address, port, context);

lib/src/async_utils/async_utils.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,9 @@ class BufferedSink {
6060
bufferIndicator.markBuffered();
6161

6262
_controller
63-
..onListen = () {
64-
bufferIndicator.markUnBuffered();
65-
}
66-
..onPause = () {
67-
bufferIndicator.markBuffered();
68-
}
69-
..onResume = () {
70-
bufferIndicator.markUnBuffered();
71-
}
63+
..onListen = bufferIndicator.markUnBuffered
64+
..onPause = bufferIndicator.markBuffered
65+
..onResume = bufferIndicator.markUnBuffered
7266
..onCancel = () {
7367
// TODO: We may want to propagate cancel events as errors.
7468
// Currently `_doneFuture` will just complete normally if the sink

lib/src/connection.dart

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ abstract class Connection {
188188
var settings = _decodeSettings(settingsObject);
189189

190190
// Do the initial settings handshake (possibly with pushes disabled).
191-
_settingsHandler.changeSettings(settings).catchError((error) {
191+
_settingsHandler.changeSettings(settings).catchError((Object error) {
192192
// TODO: The [error] can contain sensitive information we now expose via
193193
// a [Goaway] frame. We should somehow ensure we're only sending useful
194194
// but non-sensitive information.
@@ -271,15 +271,15 @@ abstract class Connection {
271271
}
272272

273273
/// Pings the remote peer (can e.g. be used for measuring latency).
274-
Future ping() {
274+
Future<void> ping() {
275275
return _pingHandler.ping().catchError((e, s) {
276-
return Future.error(
276+
return Future<void>.error(
277277
TransportException('The connection has been terminated.'));
278278
}, test: (e) => e is TerminatedException);
279279
}
280280

281281
/// Finishes this connection.
282-
Future finish() {
282+
Future<void> finish() {
283283
_finishing(active: true);
284284

285285
// TODO: There is probably more we need to wait for.
@@ -288,7 +288,7 @@ abstract class Connection {
288288
}
289289

290290
/// Terminates this connection forcefully.
291-
Future terminate([int? errorCode]) {
291+
Future<void> terminate([int? errorCode]) {
292292
return _terminate(errorCode ?? ErrorCode.NO_ERROR);
293293
}
294294

@@ -441,16 +441,15 @@ abstract class Connection {
441441
_settingsHandler.terminate(exception);
442442

443443
return Future.wait([cancelFuture, closeFuture])
444-
.catchError((_) => const []);
444+
.catchError((_) => const <void>[]);
445445
}
446-
return Future.value();
446+
return Future<void>.value();
447447
}
448448
}
449449

450450
class ClientConnection extends Connection implements ClientTransportConnection {
451-
ClientConnection._(Stream<List<int>> incoming, StreamSink<List<int>> outgoing,
452-
Settings settings)
453-
: super(incoming, outgoing, settings, isClientConnection: true);
451+
ClientConnection._(super.incoming, super.outgoing, super.settings)
452+
: super(isClientConnection: true);
454453

455454
factory ClientConnection(Stream<List<int>> incoming,
456455
StreamSink<List<int>> outgoing, ClientSettings clientSettings) {
@@ -489,9 +488,8 @@ class ClientConnection extends Connection implements ClientTransportConnection {
489488
}
490489

491490
class ServerConnection extends Connection implements ServerTransportConnection {
492-
ServerConnection._(Stream<List<int>> incoming, StreamSink<List<int>> outgoing,
493-
Settings settings)
494-
: super(incoming, outgoing, settings, isClientConnection: false);
491+
ServerConnection._(super.incoming, super.outgoing, super.settings)
492+
: super(isClientConnection: false);
495493

496494
factory ServerConnection(Stream<List<int>> incoming,
497495
StreamSink<List<int>> outgoing, ServerSettings serverSettings) {

lib/src/connection_preface.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,14 @@ Stream<List<int>> readConnectionPreface(Stream<List<int>> incoming) {
9696
}
9797

9898
result.onListen = () {
99-
subscription = incoming.listen(onData,
100-
onError: (Object e, StackTrace s) => result.addError(e, s),
101-
onDone: () {
102-
if (!connectionPrefaceRead) {
103-
terminate('EOS before connection preface could be read.');
104-
} else {
105-
result.close();
106-
}
107-
});
99+
subscription =
100+
incoming.listen(onData, onError: result.addError, onDone: () {
101+
if (!connectionPrefaceRead) {
102+
terminate('EOS before connection preface could be read.');
103+
} else {
104+
result.close();
105+
}
106+
});
108107
result
109108
..onPause = subscription.pause
110109
..onResume = subscription.resume

lib/src/error_handler.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mixin TerminatableMixin {
1111
bool _terminated = false;
1212

1313
/// Terminates this stream message queue. Further operations on it will fail.
14-
void terminate([error]) {
14+
void terminate([Object? error]) {
1515
if (!wasTerminated) {
1616
_terminated = true;
1717
onTerminated(error);
@@ -60,7 +60,7 @@ mixin CancellableMixin {
6060
/// Used by classes which may be closed.
6161
mixin ClosableMixin {
6262
bool _closing = false;
63-
final Completer _completer = Completer();
63+
final Completer _completer = Completer<void>();
6464

6565
Future get done => _completer.future;
6666

@@ -91,13 +91,13 @@ mixin ClosableMixin {
9191
return f();
9292
}
9393

94-
void closeWithValue([value]) {
94+
void closeWithValue([Object? value]) {
9595
if (!wasClosed) {
9696
_completer.complete(value);
9797
}
9898
}
9999

100-
void closeWithError(error) {
100+
void closeWithError(Object? error) {
101101
if (!wasClosed) {
102102
_completer.complete(error);
103103
}

lib/src/flowcontrol/connection_queues.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import 'dart:async';
1010
import 'dart:collection';
1111

1212
import '../../transport.dart';
13-
1413
import '../byte_utils.dart';
1514
import '../error_handler.dart';
1615
import '../frames/frames.dart';
17-
1816
import 'queue_messages.dart';
1917
import 'stream_queues.dart';
2018
import 'window_handler.dart';
@@ -66,7 +64,7 @@ class ConnectionMessageQueueOut extends Object
6664
}
6765

6866
@override
69-
void onTerminated(error) {
67+
void onTerminated(Object? error) {
7068
_messages.clear();
7169
closeWithError(error);
7270
}
@@ -182,7 +180,7 @@ class ConnectionMessageQueueIn extends Object
182180
final IncomingWindowHandler _windowUpdateHandler;
183181

184182
/// Catches any protocol errors and acts upon them.
185-
final Function _catchProtocolErrors;
183+
final void Function(void Function()) _catchProtocolErrors;
186184

187185
/// A mapping from stream-id to the corresponding stream-specific
188186
/// [StreamMessageQueueIn].
@@ -200,7 +198,7 @@ class ConnectionMessageQueueIn extends Object
200198
this._windowUpdateHandler, this._catchProtocolErrors);
201199

202200
@override
203-
void onTerminated(error) {
201+
void onTerminated(Object? error) {
204202
// NOTE: The higher level will be shutdown first, so all streams
205203
// should have been removed at this point.
206204
assert(_stream2messageQueue.isEmpty);

lib/src/flowcontrol/stream_queues.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class StreamMessageQueueOut extends Object
8484
}
8585

8686
@override
87-
void onTerminated(error) {
87+
void onTerminated(Object? error) {
8888
_messages.clear();
8989
closeWithError(error);
9090
}
@@ -183,11 +183,7 @@ class StreamMessageQueueIn extends Object
183183
_tryUpdateBufferIndicator();
184184
}
185185
}
186-
..onPause = () {
187-
_tryUpdateBufferIndicator();
188-
// TODO: Would we ever want to decrease the window size in this
189-
// situation?
190-
}
186+
..onPause = _tryUpdateBufferIndicator
191187
..onResume = () {
192188
if (!wasClosed && !wasTerminated) {
193189
_tryDispatch();

lib/src/flowcontrol/window_handler.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ abstract class AbstractOutgoingWindowHandler {
5858

5959
/// Handles the connection window for outgoing data frames.
6060
class OutgoingConnectionWindowHandler extends AbstractOutgoingWindowHandler {
61-
OutgoingConnectionWindowHandler(Window window) : super(window);
61+
OutgoingConnectionWindowHandler(super.window);
6262
}
6363

6464
/// Handles the window for outgoing messages to the peer.
6565
class OutgoingStreamWindowHandler extends AbstractOutgoingWindowHandler {
66-
OutgoingStreamWindowHandler(Window window) : super(window);
66+
OutgoingStreamWindowHandler(super.window);
6767

6868
/// Update the peer window by adding [difference] to it.
6969
///

lib/src/frames/frame_reader.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
part of http2.src.frames;
5+
part of 'frames.dart';
66

77
/// Used for converting a `Stream<List<int>>` to a `Stream<Frame>`.
88
class FrameReader {

0 commit comments

Comments
 (0)