Skip to content

Commit 6ed92e2

Browse files
chore: upgrade very_good_analysis to ^10.1.0-rc.1
1 parent 5473fac commit 6ed92e2

30 files changed

+275
-360
lines changed

bin/very_good.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ Future<void> main(List<String> args) async {
1111
/// This returns a Future that will never complete, since the program will have
1212
/// exited already. This is useful to prevent Future chains from proceeding
1313
/// after you've decided to exit.
14-
Future<void> _flushThenExit(int status) {
15-
return Future.wait<void>([
16-
stdout.close(),
17-
stderr.close(),
18-
]).then<void>((_) => exit(status));
19-
}
14+
Future<void> _flushThenExit(int status) => Future.wait<void>([
15+
stdout.close(),
16+
stderr.close(),
17+
]).then<void>((_) => exit(status));

bricks/test_optimizer/hooks/lib/pre_gen.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ Future<void> run(HookContext context) async {
6363
}
6464

6565
extension on FileSystemEntity {
66-
bool get isTest {
67-
return this is File && path.basename(this.path).endsWith('_test.dart');
68-
}
66+
bool get isTest =>
67+
this is File && path.basename(this.path).endsWith('_test.dart');
6968
}
7069

7170
Future<List<String>> getNotOptimizedTests(

bricks/test_optimizer/hooks/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ dependencies:
1313
dev_dependencies:
1414
mocktail: ^1.0.0
1515
test: ^1.25.0
16-
very_good_analysis: ^10.0.0
16+
very_good_analysis: ^10.1.0-rc.1

e2e/helpers/command_helper.dart

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,16 @@ class _MockProgress extends Mock implements Progress {}
1111

1212
class _MockPubUpdater extends Mock implements PubUpdater {}
1313

14-
void Function() _overridePrint(void Function(List<String>) fn) {
15-
return () {
16-
final printLogs = <String>[];
17-
final spec = ZoneSpecification(
18-
print: (_, _, _, String msg) {
19-
printLogs.add(msg);
20-
},
21-
);
14+
void Function() _overridePrint(void Function(List<String>) fn) => () {
15+
final printLogs = <String>[];
16+
final spec = ZoneSpecification(
17+
print: (_, _, _, msg) {
18+
printLogs.add(msg);
19+
},
20+
);
2221

23-
return Zone.current
24-
.fork(specification: spec)
25-
.run<void>(() => fn(printLogs));
26-
};
27-
}
22+
return Zone.current.fork(specification: spec).run<void>(() => fn(printLogs));
23+
};
2824

2925
void Function() withRunner(
3026
FutureOr<void> Function(
@@ -35,39 +31,37 @@ void Function() withRunner(
3531
List<String> progressLogs,
3632
)
3733
runnerFn,
38-
) {
39-
return _overridePrint((printLogs) async {
40-
final logger = _MockLogger();
41-
final progress = _MockProgress();
42-
final pubUpdater = _MockPubUpdater();
43-
final progressLogs = <String>[];
44-
final commandRunner = VeryGoodCommandRunner(
45-
logger: logger,
46-
pubUpdater: pubUpdater,
47-
environment: {'CI': 'true'},
48-
);
34+
) => _overridePrint((printLogs) async {
35+
final logger = _MockLogger();
36+
final progress = _MockProgress();
37+
final pubUpdater = _MockPubUpdater();
38+
final progressLogs = <String>[];
39+
final commandRunner = VeryGoodCommandRunner(
40+
logger: logger,
41+
pubUpdater: pubUpdater,
42+
environment: {'CI': 'true'},
43+
);
4944

50-
when(() => progress.complete(any())).thenAnswer((invocation) {
51-
final message = invocation.positionalArguments.first as String?;
52-
if (message != null) progressLogs.add(message);
53-
});
54-
when(() => logger.progress(any())).thenReturn(progress);
55-
when(
56-
() => pubUpdater.isUpToDate(
57-
packageName: any(named: 'packageName'),
58-
currentVersion: any(named: 'currentVersion'),
59-
),
60-
).thenAnswer((_) => Future.value(true));
61-
when(
62-
() => pubUpdater.getLatestVersion(any()),
63-
).thenAnswer((_) => Future.value('1.0.0'));
64-
65-
await runnerFn(
66-
commandRunner,
67-
logger,
68-
pubUpdater,
69-
printLogs,
70-
progressLogs,
71-
);
45+
when(() => progress.complete(any())).thenAnswer((invocation) {
46+
final message = invocation.positionalArguments.first as String?;
47+
if (message != null) progressLogs.add(message);
7248
});
73-
}
49+
when(() => logger.progress(any())).thenReturn(progress);
50+
when(
51+
() => pubUpdater.isUpToDate(
52+
packageName: any(named: 'packageName'),
53+
currentVersion: any(named: 'currentVersion'),
54+
),
55+
).thenAnswer((_) => Future.value(true));
56+
when(
57+
() => pubUpdater.getLatestVersion(any()),
58+
).thenAnswer((_) => Future.value('1.0.0'));
59+
60+
await runnerFn(
61+
commandRunner,
62+
logger,
63+
pubUpdater,
64+
printLogs,
65+
progressLogs,
66+
);
67+
});

e2e/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ dev_dependencies:
1313
pub_updater: ^0.5.0
1414
test: ^1.25.0
1515
universal_io: ^2.0.4
16-
very_good_analysis: ^10.0.0
16+
very_good_analysis: ^10.1.0-rc.1
1717
very_good_cli:
1818
path: ../

lib/src/cli/cli.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:async';
22
import 'dart:math';
3+
34
import 'package:collection/collection.dart';
45
import 'package:coverage/coverage.dart' as coverage;
56
import 'package:glob/glob.dart';
@@ -50,9 +51,8 @@ abstract class ProcessOverrides {
5051
/// * [ProcessOverrides.runZoned] to provide [ProcessOverrides]
5152
/// in a fresh [Zone].
5253
///
53-
static ProcessOverrides? get current {
54-
return Zone.current[_token] as ProcessOverrides?;
55-
}
54+
static ProcessOverrides? get current =>
55+
Zone.current[_token] as ProcessOverrides?;
5656

5757
/// Runs [body] in a fresh [Zone] using the provided overrides.
5858
static R runZoned<R>(R Function() body, {RunProcess? runProcess}) {
@@ -71,9 +71,8 @@ class _ProcessOverridesScope extends ProcessOverrides {
7171
final RunProcess? _runProcess;
7272

7373
@override
74-
RunProcess get runProcess {
75-
return _runProcess ?? _previous?.runProcess ?? super.runProcess;
76-
}
74+
RunProcess get runProcess =>
75+
_runProcess ?? _previous?.runProcess ?? super.runProcess;
7776
}
7877

7978
/// Abstraction for running commands via command-line.

lib/src/cli/dart_cli.dart

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,22 @@ class Dart {
111111
void Function(String)? stderr,
112112
GeneratorBuilder buildGenerator = MasonGenerator.fromBundle,
113113
String? reportOn,
114-
}) async {
115-
return TestCLIRunner.test(
116-
logger: logger,
117-
testType: TestRunType.dart,
118-
cwd: cwd,
119-
recursive: recursive,
120-
collectCoverage: collectCoverage,
121-
optimizePerformance: optimizePerformance,
122-
ignore: ignore,
123-
minCoverage: minCoverage,
124-
excludeFromCoverage: excludeFromCoverage,
125-
randomSeed: randomSeed,
126-
forceAnsi: forceAnsi,
127-
arguments: arguments,
128-
stdout: stdout,
129-
stderr: stderr,
130-
reportOn: reportOn,
131-
buildGenerator: buildGenerator,
132-
);
133-
}
114+
}) async => TestCLIRunner.test(
115+
logger: logger,
116+
testType: TestRunType.dart,
117+
cwd: cwd,
118+
recursive: recursive,
119+
collectCoverage: collectCoverage,
120+
optimizePerformance: optimizePerformance,
121+
ignore: ignore,
122+
minCoverage: minCoverage,
123+
excludeFromCoverage: excludeFromCoverage,
124+
randomSeed: randomSeed,
125+
forceAnsi: forceAnsi,
126+
arguments: arguments,
127+
stdout: stdout,
128+
stderr: stderr,
129+
reportOn: reportOn,
130+
buildGenerator: buildGenerator,
131+
);
134132
}

lib/src/cli/flutter_cli.dart

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ abstract class ProcessSignalOverrides {
1818
/// See also:
1919
/// * [ProcessSignalOverrides.runZoned] to provide [ProcessSignalOverrides]
2020
/// in a fresh [Zone].
21-
static ProcessSignalOverrides? get current {
22-
return Zone.current[_token] as ProcessSignalOverrides?;
23-
}
21+
static ProcessSignalOverrides? get current =>
22+
Zone.current[_token] as ProcessSignalOverrides?;
2423

2524
/// Runs [body] in a fresh [Zone] using the provided overrides.
2625
static R runZoned<R>(
@@ -50,9 +49,7 @@ class _ProcessSignalOverridesScope extends ProcessSignalOverrides {
5049
}
5150

5251
@override
53-
Stream<ProcessSignal>? get sigintWatch {
54-
return _sigintStreamController?.stream;
55-
}
52+
Stream<ProcessSignal>? get sigintWatch => _sigintStreamController?.stream;
5653
}
5754

5855
/// Thrown when `flutter pub get` is executed without a `pubspec.yaml`.
@@ -165,25 +162,23 @@ class Flutter {
165162
void Function(String)? stdout,
166163
void Function(String)? stderr,
167164
GeneratorBuilder buildGenerator = MasonGenerator.fromBundle,
168-
}) async {
169-
return TestCLIRunner.test(
170-
logger: logger,
171-
testType: TestRunType.flutter,
172-
cwd: cwd,
173-
recursive: recursive,
174-
collectCoverage: collectCoverage,
175-
optimizePerformance: optimizePerformance,
176-
ignore: ignore,
177-
minCoverage: minCoverage,
178-
excludeFromCoverage: excludeFromCoverage,
179-
randomSeed: randomSeed,
180-
forceAnsi: forceAnsi,
181-
arguments: arguments,
182-
stdout: stdout,
183-
stderr: stderr,
184-
buildGenerator: buildGenerator,
185-
);
186-
}
165+
}) async => TestCLIRunner.test(
166+
logger: logger,
167+
testType: TestRunType.flutter,
168+
cwd: cwd,
169+
recursive: recursive,
170+
collectCoverage: collectCoverage,
171+
optimizePerformance: optimizePerformance,
172+
ignore: ignore,
173+
minCoverage: minCoverage,
174+
excludeFromCoverage: excludeFromCoverage,
175+
randomSeed: randomSeed,
176+
forceAnsi: forceAnsi,
177+
arguments: arguments,
178+
stdout: stdout,
179+
stderr: stderr,
180+
buildGenerator: buildGenerator,
181+
);
187182
}
188183

189184
/// Ensures all git dependencies are reachable for the pubspec
@@ -274,17 +269,11 @@ extension on Duration {
274269
}
275270

276271
extension on int {
277-
String formatSuccess() {
278-
return this > 0 ? lightGreen.wrap('+$this')! : '';
279-
}
272+
String formatSuccess() => this > 0 ? lightGreen.wrap('+$this')! : '';
280273

281-
String formatFailure() {
282-
return this > 0 ? lightRed.wrap('-$this')! : '';
283-
}
274+
String formatFailure() => this > 0 ? lightRed.wrap('-$this')! : '';
284275

285-
String formatSkipped() {
286-
return this > 0 ? lightYellow.wrap('~$this')! : '';
287-
}
276+
String formatSkipped() => this > 0 ? lightYellow.wrap('~$this')! : '';
288277
}
289278

290279
extension on String {
@@ -294,7 +283,6 @@ extension on String {
294283
return '...$truncated';
295284
}
296285

297-
String toSingleLine() {
298-
return replaceAll('\n', '').replaceAll(RegExp(r'\s\s+'), ' ');
299-
}
286+
String toSingleLine() =>
287+
replaceAll('\n', '').replaceAll(RegExp(r'\s\s+'), ' ');
300288
}

lib/src/cli/git_cli.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ class UnreachableGitDependency implements Exception {
1111
final Uri remote;
1212

1313
@override
14-
String toString() {
15-
return '''
14+
String toString() =>
15+
'''
1616
$remote is unreachable.
1717
Make sure the remote exists and you have the correct access rights.''';
18-
}
1918
}
2019

2120
/// Git CLI

lib/src/cli/test_cli_runner.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,12 @@ class TestCLIRunner {
256256
);
257257
}
258258

259-
static List<File> _dartCoverageFilesToProcess(String absPath) {
260-
return Directory(absPath)
261-
.listSync(recursive: true)
262-
.whereType<File>()
263-
.where((e) => e.path.endsWith('.json'))
264-
.toList();
265-
}
259+
static List<File> _dartCoverageFilesToProcess(String absPath) =>
260+
Directory(absPath)
261+
.listSync(recursive: true)
262+
.whereType<File>()
263+
.where((e) => e.path.endsWith('.json'))
264+
.toList();
266265
}
267266

268267
Future<int> _testCommand({

0 commit comments

Comments
 (0)