Skip to content

Commit 131666a

Browse files
authored
Latest lints, require Dart ^3.1 (dart-archive/stack_trace#146)
1 parent 8d852b4 commit 131666a

File tree

11 files changed

+43
-55
lines changed

11 files changed

+43
-55
lines changed

pkgs/stack_trace/.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: [2.18.0, dev]
50+
sdk: [3.1, dev]
5151
steps:
5252
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
5353
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d

pkgs/stack_trace/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.11.2-wip
2+
3+
* Require Dart 3.1 or greater
4+
15
## 1.11.1
26

37
* Make use of `@pragma('vm:awaiter-link')` to make package work better with
Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# https://dart.dev/guides/language/analysis-options
2-
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
33

44
analyzer:
55
language:
@@ -8,37 +8,16 @@ analyzer:
88

99
linter:
1010
rules:
11-
- always_declare_return_types
12-
- avoid_catching_errors
13-
- avoid_dynamic_calls
1411
- avoid_private_typedef_functions
1512
- avoid_redundant_argument_values
1613
- avoid_unused_constructor_parameters
1714
- avoid_void_async
1815
- cancel_subscriptions
19-
- comment_references
20-
- directives_ordering
21-
- lines_longer_than_80_chars
2216
- literal_only_boolean_expressions
2317
- missing_whitespace_between_adjacent_strings
2418
- no_adjacent_strings_in_list
2519
- no_runtimeType_toString
26-
- omit_local_variable_types
2720
- package_api_docs
28-
- prefer_asserts_in_initializer_lists
29-
- prefer_const_constructors
3021
- prefer_const_declarations
31-
- prefer_relative_imports
32-
- prefer_single_quotes
33-
- sort_pub_dependencies
34-
- test_types_in_equals
35-
- throw_in_finally
36-
- type_annotate_public_apis
37-
- unawaited_futures
3822
- unnecessary_await_in_return
39-
- unnecessary_lambdas
40-
- unnecessary_parenthesis
41-
- unnecessary_statements
42-
- use_is_even_rather_than_modulo
4323
- use_string_buffers
44-
- use_super_parameters

pkgs/stack_trace/example/example.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ void main() {
77
}
88

99
void _scheduleAsync() {
10-
Future.delayed(const Duration(seconds: 1)).then((_) => _runAsync());
10+
Future<void>.delayed(const Duration(seconds: 1)).then((_) => _runAsync());
1111
}
1212

1313
void _runAsync() {
14-
throw 'oh no!';
14+
throw StateError('oh no!');
1515
}

pkgs/stack_trace/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: stack_trace
2-
version: 1.11.1
2+
version: 1.11.2-wip
33
description: A package for manipulating stack traces and printing them readably.
44
repository: https://github.com/dart-lang/stack_trace
55

66
environment:
7-
sdk: ">=2.18.0 <3.0.0"
7+
sdk: ^3.1.0
88

99
dependencies:
1010
path: ^1.8.0
1111

1212
dev_dependencies:
13-
lints: ^2.0.0
13+
dart_flutter_team_lints: ^2.0.0
1414
test: ^1.16.0

pkgs/stack_trace/test/chain/chain_test.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ import 'package:test/test.dart';
1010

1111
import 'utils.dart';
1212

13-
typedef ChainErrorCallback = void Function(dynamic stack, Chain chain);
14-
1513
void main() {
1614
group('Chain.parse()', () {
17-
test('parses a real Chain', () {
18-
return captureFuture(() => inMicrotask(() => throw 'error'))
19-
.then((chain) {
20-
expect(
21-
Chain.parse(chain.toString()).toString(), equals(chain.toString()));
22-
});
15+
test('parses a real Chain', () async {
16+
// ignore: only_throw_errors
17+
final chain = await captureFuture(() => inMicrotask(() => throw 'error'));
18+
19+
expect(
20+
Chain.parse(chain.toString()).toString(),
21+
equals(chain.toString()),
22+
);
2323
});
2424

2525
test('parses an empty string', () {
@@ -61,7 +61,7 @@ void main() {
6161
group('Chain.capture()', () {
6262
test('with onError blocks errors', () {
6363
Chain.capture(() {
64-
return Future.error('oh no');
64+
return Future<void>.error('oh no');
6565
}, onError: expectAsync2((error, chain) {
6666
expect(error, equals('oh no'));
6767
expect(chain, isA<Chain>());
@@ -71,7 +71,7 @@ void main() {
7171

7272
test('with no onError blocks errors', () {
7373
runZonedGuarded(() {
74-
Chain.capture(() => Future.error('oh no')).then(
74+
Chain.capture(() => Future<void>.error('oh no')).then(
7575
expectAsync1((_) {}, count: 0),
7676
onError: expectAsync2((_, __) {}, count: 0));
7777
}, expectAsync2((error, chain) {
@@ -81,7 +81,7 @@ void main() {
8181
});
8282

8383
test("with errorZone: false doesn't block errors", () {
84-
expect(Chain.capture(() => Future.error('oh no'), errorZone: false),
84+
expect(Chain.capture(() => Future<void>.error('oh no'), errorZone: false),
8585
throwsA('oh no'));
8686
});
8787

@@ -92,13 +92,13 @@ void main() {
9292

9393
group('with when: false', () {
9494
test("with no onError doesn't block errors", () {
95-
expect(Chain.capture(() => Future.error('oh no'), when: false),
95+
expect(Chain.capture(() => Future<void>.error('oh no'), when: false),
9696
throwsA('oh no'));
9797
});
9898

9999
test('with onError blocks errors', () {
100100
Chain.capture(() {
101-
return Future.error('oh no');
101+
return Future<void>.error('oh no');
102102
}, onError: expectAsync2((error, chain) {
103103
expect(error, equals('oh no'));
104104
expect(chain, isA<Chain>());

pkgs/stack_trace/test/chain/dart2js_test.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
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+
// ignore_for_file: only_throw_errors
6+
57
// dart2js chain tests are separated out because dart2js stack traces are
68
// inconsistent due to inlining and browser differences. These tests don't
79
// assert anything about the content of the traces, just the number of traces in
810
// a chain.
911
@TestOn('js')
12+
library;
1013

1114
import 'dart:async';
1215

@@ -73,7 +76,7 @@ void main() {
7376
});
7477

7578
test('multiple times', () {
76-
var completer = Completer();
79+
var completer = Completer<void>();
7780
var first = true;
7881

7982
Chain.capture(() {
@@ -138,7 +141,7 @@ void main() {
138141
});
139142

140143
test('and relays them to the parent zone', () {
141-
var completer = Completer();
144+
var completer = Completer<void>();
142145

143146
runZonedGuarded(() {
144147
Chain.capture(() {
@@ -164,7 +167,7 @@ void main() {
164167
});
165168

166169
test('capture() without onError passes exceptions to parent zone', () {
167-
var completer = Completer();
170+
var completer = Completer<void>();
168171

169172
runZonedGuarded(() {
170173
Chain.capture(() => inMicrotask(() => throw 'error'));

pkgs/stack_trace/test/chain/utils.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void inSyncFuture(void Function() callback) {
4747
///
4848
/// If [trace] is passed, it's used as the stack trace for the error.
4949
Future<void> completerErrorFuture([StackTrace? trace]) {
50-
var completer = Completer();
50+
var completer = Completer<void>();
5151
completer.completeError('error', trace);
5252
return completer.future;
5353
}
@@ -56,7 +56,7 @@ Future<void> completerErrorFuture([StackTrace? trace]) {
5656
///
5757
/// If [trace] is passed, it's used as the stack trace for the error.
5858
Stream<void> controllerErrorStream([StackTrace? trace]) {
59-
var controller = StreamController();
59+
var controller = StreamController<void>();
6060
controller.addError('error', trace);
6161
return controller.stream;
6262
}
@@ -71,7 +71,9 @@ Future<Chain> chainForTrace(
7171
// [new Future.sync] because those methods don't pass the exception through
7272
// the zone specification before propagating it, so there's no chance to
7373
// attach a chain to its stack trace. See issue 15105.
74-
Future.value().then((_) => callback()).catchError(completer.completeError);
74+
Future<void>.value()
75+
.then((_) => callback())
76+
.catchError(completer.completeError);
7577
});
7678

7779
return completer.future

pkgs/stack_trace/test/chain/vm_test.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
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+
// ignore_for_file: only_throw_errors
6+
57
// VM chain tests can rely on stronger guarantees about the contents of the
68
// stack traces than dart2js.
79
@TestOn('dart-vm')
10+
library;
811

912
import 'dart:async';
1013

@@ -136,7 +139,7 @@ void main() {
136139
});
137140

138141
test('multiple times', () {
139-
var completer = Completer();
142+
var completer = Completer<void>();
140143
var first = true;
141144

142145
Chain.capture(() {
@@ -231,7 +234,7 @@ void main() {
231234
});
232235

233236
test('and relays them to the parent zone', () {
234-
var completer = Completer();
237+
var completer = Completer<void>();
235238

236239
runZonedGuarded(() {
237240
Chain.capture(() {
@@ -260,7 +263,7 @@ void main() {
260263
});
261264

262265
test('capture() without onError passes exceptions to parent zone', () {
263-
var completer = Completer();
266+
var completer = Completer<void>();
264267

265268
runZonedGuarded(() {
266269
Chain.capture(() => inMicrotask(() => throw 'error'));

pkgs/stack_trace/test/trace_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import 'package:path/path.dart' as path;
66
import 'package:stack_trace/stack_trace.dart';
77
import 'package:test/test.dart';
88

9-
Trace getCurrentTrace([int level = 0]) => Trace.current(level);
10-
11-
Trace nestedGetCurrentTrace(int level) => getCurrentTrace(level);
12-
139
void main() {
1410
// This just shouldn't crash.
1511
test('a native stack trace is parseable', Trace.current);

0 commit comments

Comments
 (0)