Skip to content

Commit c07f96f

Browse files
authored
Update to latest lints, required Dart 3.7 (#55)
- updated code formatting
1 parent dc54465 commit c07f96f

File tree

6 files changed

+42
-34
lines changed

6 files changed

+42
-34
lines changed

.github/workflows/publish.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ jobs:
1212
publish:
1313
if: ${{ github.repository_owner == 'google' }}
1414
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
15+
permissions:
16+
id-token: write # Required for authentication using OIDC
17+
pull-requests: write # Required for writing the pull request note

.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, dev]
50+
sdk: [3.7, dev]
5151
steps:
5252
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
5353
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 0.3.2-wip
22

3-
* Require Dart 3.0
3+
* Require Dart 3.7
44

55
## 0.3.1
66

lib/src/sync_http.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class SyncHttpClientRequest {
6363
final RawSynchronousSocket _socket;
6464

6565
SyncHttpClientRequest._(this.method, this.uri, bool body)
66-
: _body = body ? BytesBuilder() : null,
67-
_socket = RawSynchronousSocket.connectSync(uri.host, uri.port);
66+
: _body = body ? BytesBuilder() : null,
67+
_socket = RawSynchronousSocket.connectSync(uri.host, uri.port);
6868

6969
/// Write content into the body of the HTTP request.
7070
void write(Object? obj) {
@@ -259,7 +259,7 @@ class _SyncHttpClientRequestHeaders implements HttpHeaders {
259259
HttpHeaders.connectionHeader,
260260
HttpHeaders.contentLengthHeader,
261261
HttpHeaders.contentTypeHeader,
262-
HttpHeaders.hostHeader
262+
HttpHeaders.hostHeader,
263263
].forEach(forEachFunc);
264264
_headers.keys.forEach(forEachFunc);
265265
}
@@ -401,7 +401,8 @@ class SyncHttpClientResponse {
401401
headers[name]!.add(value);
402402
} else if (line.startsWith('HTTP/1.1') || line.startsWith('HTTP/1.0')) {
403403
statusCode = int.parse(
404-
line.substring('HTTP/1.x '.length, 'HTTP/1.x xxx'.length));
404+
line.substring('HTTP/1.x '.length, 'HTTP/1.x xxx'.length),
405+
);
405406
reasonPhrase = line.substring('HTTP/1.x xxx '.length);
406407
inHeader = true;
407408
} else {
@@ -430,15 +431,20 @@ class SyncHttpClientResponse {
430431
}
431432
}
432433

433-
return SyncHttpClientResponse._(headers,
434-
reasonPhrase: reasonPhrase,
435-
statusCode: statusCode,
436-
body: body.toString());
434+
return SyncHttpClientResponse._(
435+
headers,
436+
reasonPhrase: reasonPhrase,
437+
statusCode: statusCode,
438+
body: body.toString(),
439+
);
437440
}
438441

439-
SyncHttpClientResponse._(Map<String, List<String>> headers,
440-
{this.reasonPhrase, this.statusCode, this.body})
441-
: headers = _SyncHttpClientResponseHeaders(headers);
442+
SyncHttpClientResponse._(
443+
Map<String, List<String>> headers, {
444+
this.reasonPhrase,
445+
this.statusCode,
446+
this.body,
447+
}) : headers = _SyncHttpClientResponseHeaders(headers);
442448
}
443449

444450
class _SyncHttpClientResponseHeaders implements HttpHeaders {

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ description: Synchronous HTTP client for Dart.
44
repository: https://github.com/google/sync_http.dart
55

66
environment:
7-
sdk: ^3.0.0
7+
sdk: ^3.7.0
88

99
dev_dependencies:
10-
dart_flutter_team_lints: ^2.0.0
11-
test: ^1.16.0
10+
dart_flutter_team_lints: ^3.0.0
11+
test: ^1.16.6

test/http_basic_test.dart

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ class TestServerMain {
4949
}
5050
}
5151

52-
enum TestServerCommandState {
53-
start,
54-
stop,
55-
}
52+
enum TestServerCommandState { start, stop }
5653

5754
class TestServerCommand {
5855
TestServerCommand.start() : _command = TestServerCommandState.start;
@@ -66,11 +63,7 @@ class TestServerCommand {
6663
final TestServerCommandState _command;
6764
}
6865

69-
enum TestServerStatusState {
70-
started,
71-
stopped,
72-
error,
73-
}
66+
enum TestServerStatusState { started, stopped, error }
7467

7568
class TestServerStatus {
7669
TestServerStatus.started(this._port) : _state = TestServerStatusState.started;
@@ -226,8 +219,9 @@ Future<void> testGET() async {
226219
final completer = Completer<void>();
227220
final testServerMain = TestServerMain();
228221
testServerMain.setServerStartedHandler((int? port) {
229-
final request =
230-
SyncHttpClient.getUrl(Uri.http('localhost:$port', '/0123456789'));
222+
final request = SyncHttpClient.getUrl(
223+
Uri.http('localhost:$port', '/0123456789'),
224+
);
231225
final response = request.close();
232226
expect(HttpStatus.ok, equals(response.statusCode));
233227
expect(11, equals(response.contentLength));
@@ -249,8 +243,9 @@ Future<void> testPOST() async {
249243
void runTest(int? port) {
250244
var count = 0;
251245
void sendRequest() {
252-
final request =
253-
SyncHttpClient.postUrl(Uri.http('localhost:$port', '/echo'));
246+
final request = SyncHttpClient.postUrl(
247+
Uri.http('localhost:$port', '/echo'),
248+
);
254249
request.write(data);
255250
final response = request.close();
256251
expect(HttpStatus.ok, equals(response.statusCode));
@@ -276,8 +271,9 @@ Future<void> test404() async {
276271
final completer = Completer<void>();
277272
final testServerMain = TestServerMain();
278273
testServerMain.setServerStartedHandler((int? port) {
279-
final request =
280-
SyncHttpClient.getUrl(Uri.http('localhost:$port', '/thisisnotfound'));
274+
final request = SyncHttpClient.getUrl(
275+
Uri.http('localhost:$port', '/thisisnotfound'),
276+
);
281277
final response = request.close();
282278
expect(HttpStatus.notFound, equals(response.statusCode));
283279
expect('Page not found', equals(response.body));
@@ -292,12 +288,15 @@ Future<void> testReasonPhrase() async {
292288
final completer = Completer<void>();
293289
final testServerMain = TestServerMain();
294290
testServerMain.setServerStartedHandler((int? port) {
295-
final request =
296-
SyncHttpClient.getUrl(Uri.http('localhost:$port', '/reasonformoving'));
291+
final request = SyncHttpClient.getUrl(
292+
Uri.http('localhost:$port', '/reasonformoving'),
293+
);
297294
final response = request.close();
298295
expect(HttpStatus.movedPermanently, equals(response.statusCode));
299296
expect(
300-
"Don't come looking here any more\r\n", equals(response.reasonPhrase));
297+
"Don't come looking here any more\r\n",
298+
equals(response.reasonPhrase),
299+
);
301300
testServerMain.close();
302301
completer.complete();
303302
});

0 commit comments

Comments
 (0)