Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Require Dart 3.2, update lints #140

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.0.0, dev]
sdk: [3.2, dev]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.3.1-wip

- Require Dart 3.2

## 2.3.0

- Only send updates on frames and pings being received when there are listeners, as to not fill up memory.
Expand Down
12 changes: 3 additions & 9 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
include: package:lints/recommended.yaml
# https://dart.dev/tools/analysis#the-analysis-options-file
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error

linter:
rules:
# Disabled as there are several dozen violations.
constant_identifier_names: false
constant_identifier_names: ignore
2 changes: 1 addition & 1 deletion lib/multiprotocol_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MultiProtocolHttpServer {
///
/// See also [startServing].
static Future<MultiProtocolHttpServer> bind(
address, int port, SecurityContext context,
Object? address, int port, SecurityContext context,
{http2.ServerSettings? settings}) async {
context.setAlpnProtocols(['h2', 'h2-14', 'http/1.1'], true);
var secureServer = await SecureServerSocket.bind(address, port, context);
Expand Down
12 changes: 3 additions & 9 deletions lib/src/async_utils/async_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,9 @@ class BufferedSink {
bufferIndicator.markBuffered();

_controller
..onListen = () {
bufferIndicator.markUnBuffered();
}
..onPause = () {
bufferIndicator.markBuffered();
}
..onResume = () {
bufferIndicator.markUnBuffered();
}
..onListen = bufferIndicator.markUnBuffered
..onPause = bufferIndicator.markBuffered
..onResume = bufferIndicator.markUnBuffered
..onCancel = () {
// TODO: We may want to propagate cancel events as errors.
// Currently `_doneFuture` will just complete normally if the sink
Expand Down
24 changes: 11 additions & 13 deletions lib/src/connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ abstract class Connection {
var settings = _decodeSettings(settingsObject);

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

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

/// Finishes this connection.
Future finish() {
Future<void> finish() {
_finishing(active: true);

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

/// Terminates this connection forcefully.
Future terminate([int? errorCode]) {
Future<void> terminate([int? errorCode]) {
return _terminate(errorCode ?? ErrorCode.NO_ERROR);
}

Expand Down Expand Up @@ -441,16 +441,15 @@ abstract class Connection {
_settingsHandler.terminate(exception);

return Future.wait([cancelFuture, closeFuture])
.catchError((_) => const []);
.catchError((_) => const <void>[]);
}
return Future.value();
return Future<void>.value();
}
}

class ClientConnection extends Connection implements ClientTransportConnection {
ClientConnection._(Stream<List<int>> incoming, StreamSink<List<int>> outgoing,
Settings settings)
: super(incoming, outgoing, settings, isClientConnection: true);
ClientConnection._(super.incoming, super.outgoing, super.settings)
: super(isClientConnection: true);

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

class ServerConnection extends Connection implements ServerTransportConnection {
ServerConnection._(Stream<List<int>> incoming, StreamSink<List<int>> outgoing,
Settings settings)
: super(incoming, outgoing, settings, isClientConnection: false);
ServerConnection._(super.incoming, super.outgoing, super.settings)
: super(isClientConnection: false);

factory ServerConnection(Stream<List<int>> incoming,
StreamSink<List<int>> outgoing, ServerSettings serverSettings) {
Expand Down
17 changes: 8 additions & 9 deletions lib/src/connection_preface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@ Stream<List<int>> readConnectionPreface(Stream<List<int>> incoming) {
}

result.onListen = () {
subscription = incoming.listen(onData,
onError: (Object e, StackTrace s) => result.addError(e, s),
onDone: () {
if (!connectionPrefaceRead) {
terminate('EOS before connection preface could be read.');
} else {
result.close();
}
});
subscription =
incoming.listen(onData, onError: result.addError, onDone: () {
if (!connectionPrefaceRead) {
terminate('EOS before connection preface could be read.');
} else {
result.close();
}
});
result
..onPause = subscription.pause
..onResume = subscription.resume
Expand Down
8 changes: 4 additions & 4 deletions lib/src/error_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mixin TerminatableMixin {
bool _terminated = false;

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

Future get done => _completer.future;

Expand Down Expand Up @@ -91,13 +91,13 @@ mixin ClosableMixin {
return f();
}

void closeWithValue([value]) {
void closeWithValue([Object? value]) {
if (!wasClosed) {
_completer.complete(value);
}
}

void closeWithError(error) {
void closeWithError(Object? error) {
if (!wasClosed) {
_completer.complete(error);
}
Expand Down
8 changes: 3 additions & 5 deletions lib/src/flowcontrol/connection_queues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import 'dart:async';
import 'dart:collection';

import '../../transport.dart';

import '../byte_utils.dart';
import '../error_handler.dart';
import '../frames/frames.dart';

import 'queue_messages.dart';
import 'stream_queues.dart';
import 'window_handler.dart';
Expand Down Expand Up @@ -66,7 +64,7 @@ class ConnectionMessageQueueOut extends Object
}

@override
void onTerminated(error) {
void onTerminated(Object? error) {
_messages.clear();
closeWithError(error);
}
Expand Down Expand Up @@ -182,7 +180,7 @@ class ConnectionMessageQueueIn extends Object
final IncomingWindowHandler _windowUpdateHandler;

/// Catches any protocol errors and acts upon them.
final Function _catchProtocolErrors;
final void Function(void Function()) _catchProtocolErrors;

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

@override
void onTerminated(error) {
void onTerminated(Object? error) {
// NOTE: The higher level will be shutdown first, so all streams
// should have been removed at this point.
assert(_stream2messageQueue.isEmpty);
Expand Down
8 changes: 2 additions & 6 deletions lib/src/flowcontrol/stream_queues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class StreamMessageQueueOut extends Object
}

@override
void onTerminated(error) {
void onTerminated(Object? error) {
_messages.clear();
closeWithError(error);
}
Expand Down Expand Up @@ -183,11 +183,7 @@ class StreamMessageQueueIn extends Object
_tryUpdateBufferIndicator();
}
}
..onPause = () {
_tryUpdateBufferIndicator();
// TODO: Would we ever want to decrease the window size in this
// situation?
}
..onPause = _tryUpdateBufferIndicator
..onResume = () {
if (!wasClosed && !wasTerminated) {
_tryDispatch();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/flowcontrol/window_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ abstract class AbstractOutgoingWindowHandler {

/// Handles the connection window for outgoing data frames.
class OutgoingConnectionWindowHandler extends AbstractOutgoingWindowHandler {
OutgoingConnectionWindowHandler(Window window) : super(window);
OutgoingConnectionWindowHandler(super.window);
}

/// Handles the window for outgoing messages to the peer.
class OutgoingStreamWindowHandler extends AbstractOutgoingWindowHandler {
OutgoingStreamWindowHandler(Window window) : super(window);
OutgoingStreamWindowHandler(super.window);

/// Update the peer window by adding [difference] to it.
///
Expand Down
2 changes: 1 addition & 1 deletion lib/src/frames/frame_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.

part of http2.src.frames;
part of 'frames.dart';

/// Used for converting a `Stream<List<int>>` to a `Stream<Frame>`.
class FrameReader {
Expand Down
Loading
Loading