diff --git a/pkg/dartdev/analysis_options.yaml b/pkg/dartdev/analysis_options.yaml index 225c181425b..c12a7ce280d 100644 --- a/pkg/dartdev/analysis_options.yaml +++ b/pkg/dartdev/analysis_options.yaml @@ -4,6 +4,8 @@ analyzer: errors: # Disable implementation_imports. implementation_imports: ignore + language: + strict-raw-types: true linter: rules: diff --git a/pkg/dartdev/lib/src/analysis_server.dart b/pkg/dartdev/lib/src/analysis_server.dart index ac55d08bb6d..9b3c4f66613 100644 --- a/pkg/dartdev/lib/src/analysis_server.dart +++ b/pkg/dartdev/lib/src/analysis_server.dart @@ -290,7 +290,7 @@ class AnalysisServer { _streamController(event).add(params.cast()); } } else if (response case {'id': final String id}) { - if (response case {'error': final Map error}) { + if (response case {'error': final Map error}) { _requestCompleters.remove(id)?.completeError( RequestError.parse(error.cast())); } else { diff --git a/pkg/dartdev/lib/src/core.dart b/pkg/dartdev/lib/src/core.dart index ac08f8c3b59..1eda0d3919c 100644 --- a/pkg/dartdev/lib/src/core.dart +++ b/pkg/dartdev/lib/src/core.dart @@ -71,7 +71,7 @@ abstract class DartdevCommand extends Command { ArgParser(usageLineLength: dartdevUsageLineLength); } -extension DartDevCommand on Command { +extension DartDevCommand on Command { /// Return whether commands should emit verbose output. bool get verbose => globalResults!.flag('verbose'); @@ -105,7 +105,7 @@ Future runProcess( void Function(String str)? listener, String? cwd, }) async { - Future forward(Stream> output, bool isStderr) { + Future forward(Stream> output, bool isStderr) { return _streamLineTransform(output, (line) { final trimmed = line.trimRight(); logToTrace @@ -129,7 +129,7 @@ Future runProcess( return exitCode; } -Future _streamLineTransform( +Future _streamLineTransform( Stream> stream, Function(String line) handler, ) { diff --git a/pkg/dartdev/lib/src/dds_runner.dart b/pkg/dartdev/lib/src/dds_runner.dart index 05535f8741f..f387d3303a5 100644 --- a/pkg/dartdev/lib/src/dds_runner.dart +++ b/pkg/dartdev/lib/src/dds_runner.dart @@ -34,9 +34,8 @@ class DDSRunner { if (!isAot) { // On ia32 sdks we do not have an AOT runtime and so we would be // using the regular executable. - snapshotName = fullSdk - ? sdk.ddsSnapshot - : absolute(sdkDir, 'dds.dart.snapshot'); + snapshotName = + fullSdk ? sdk.ddsSnapshot : absolute(sdkDir, 'dds.dart.snapshot'); if (!Sdk.checkArtifactExists(snapshotName)) { return false; } @@ -64,7 +63,7 @@ class DDSRunner { const devToolsMessagePrefix = 'The Dart DevTools debugger and profiler is available at:'; if (debugDds) { - late final StreamSubscription stdoutSub; + late final StreamSubscription stdoutSub; stdoutSub = process.stdout .transform(utf8.decoder) .transform(const LineSplitter()) diff --git a/pkg/dartdev/test/analytics_test.dart b/pkg/dartdev/test/analytics_test.dart index 3d8716b77a0..2c3247b8d12 100644 --- a/pkg/dartdev/test/analytics_test.dart +++ b/pkg/dartdev/test/analytics_test.dart @@ -16,11 +16,13 @@ import 'package:unified_analytics/unified_analytics.dart'; import 'experiment_util.dart'; import 'utils.dart'; -List extractAnalytics(io.ProcessResult result) { +List> extractAnalytics(io.ProcessResult result) { return LineSplitter.split(result.stderr) .where((line) => line.startsWith('[analytics]: ')) - .map((line) => json.decode(line.substring('[analytics]: '.length)) as Map) - .toList(); + .map((line) { + return (json.decode(line.substring('[analytics]: '.length)) as Map) + .cast(); + }).toList(); } void main() { diff --git a/pkg/dartdev/test/commands/create_integration_test.dart b/pkg/dartdev/test/commands/create_integration_test.dart index fe4262d2231..ec052b0b6fc 100644 --- a/pkg/dartdev/test/commands/create_integration_test.dart +++ b/pkg/dartdev/test/commands/create_integration_test.dart @@ -122,8 +122,8 @@ void defineCreateTests() { if (isLastCommand && (isServerTemplate || isWebTemplate)) { final completer = Completer(); - late StreamSubscription stdoutSub; - late StreamSubscription stderrSub; + late final StreamSubscription stdoutSub; + late final StreamSubscription stderrSub; // Listen for well-known output from specific templates to determine // if they've executed correctly. These templates won't exit on their // own, so we'll need to terminate the process once we've verified it diff --git a/pkg/dartdev/test/commands/devtools_test.dart b/pkg/dartdev/test/commands/devtools_test.dart index f6025e2bc59..4868d56ac0f 100644 --- a/pkg/dartdev/test/commands/devtools_test.dart +++ b/pkg/dartdev/test/commands/devtools_test.dart @@ -79,7 +79,7 @@ void devtools() { final devToolsServedCompleter = Completer(); final dtdServedCompleter = Completer(); - late StreamSubscription sub; + late final StreamSubscription sub; sub = process!.stdout .transform(utf8.decoder) .transform(const LineSplitter()) @@ -157,7 +157,7 @@ void devtools() { bool startedDds = false; bool startedDtd = false; final devToolsServedCompleter = Completer(); - late StreamSubscription sub; + late final StreamSubscription sub; sub = process.stdout .transform(utf8.decoder) .transform(const LineSplitter()) @@ -228,7 +228,7 @@ Future main() async { ); final serviceUriCompleter = Completer(); - late StreamSubscription sub; + late final StreamSubscription sub; sub = targetProjectInstance!.stdout .transform(utf8.decoder) .transform(const LineSplitter()) diff --git a/pkg/dartdev/test/commands/flag_test.dart b/pkg/dartdev/test/commands/flag_test.dart index 2aa42e0e6d2..42b1c871c9a 100644 --- a/pkg/dartdev/test/commands/flag_test.dart +++ b/pkg/dartdev/test/commands/flag_test.dart @@ -33,7 +33,7 @@ void command() { test('description formatting', () { DartdevRunner(['--suppress-analytics']) .commands - .forEach((String commandKey, Command command) { + .forEach((String commandKey, Command command) { expect(commandKey, isNotEmpty); expect(command.description, isNotEmpty); expect(command.description.split('\n').first, endsWith('.')); @@ -45,7 +45,7 @@ void command() { test('argParser usageLineLength', () { DartdevRunner(['--suppress-analytics']) .commands - .forEach((String commandKey, Command command) { + .forEach((String commandKey, Command command) { if (command.name != 'help' && command.name != 'format' && command.name != 'pub' && diff --git a/pkg/dartdev/test/commands/help_test.dart b/pkg/dartdev/test/commands/help_test.dart index 77ca650971f..429bd787c38 100644 --- a/pkg/dartdev/test/commands/help_test.dart +++ b/pkg/dartdev/test/commands/help_test.dart @@ -22,7 +22,7 @@ void help() { ]; DartdevRunner(['--suppress-analytics']) .commands - .forEach((String commandKey, Command command) { + .forEach((String commandKey, Command command) { if (!commandsNotTested.contains(commandKey)) { test('(help $commandKey == $commandKey --help)', () async { p = project(); @@ -57,7 +57,7 @@ void help() { test('(--help flags also have -h abbr)', () { DartdevRunner(['--suppress-analytics']) .commands - .forEach((String commandKey, Command command) { + .forEach((String commandKey, Command command) { var helpOption = command.argParser.options['help']; // Some commands (like pub which use // "argParser = ArgParser.allowAnything()") may not have the help Option diff --git a/pkg/dartdev/test/commands/language_server_test.dart b/pkg/dartdev/test/commands/language_server_test.dart index 1f200109360..b9b2f7a87a7 100644 --- a/pkg/dartdev/test/commands/language_server_test.dart +++ b/pkg/dartdev/test/commands/language_server_test.dart @@ -27,7 +27,7 @@ void defineLanguageServerTests() { late utils.TestProject project; Process? process; - Future runWithLsp(List args) async { + Future runWithLsp(List args) async { project = utils.project(); process = await project.start(args); diff --git a/pkg/dartdev/test/commands/run_test.dart b/pkg/dartdev/test/commands/run_test.dart index 5aac1d53f94..4164c189577 100644 --- a/pkg/dartdev/test/commands/run_test.dart +++ b/pkg/dartdev/test/commands/run_test.dart @@ -531,7 +531,7 @@ void main(List args) => print("$b $args"); p.relativeFilePath, ]); final completer = Completer(); - late StreamSubscription sub; + late final StreamSubscription sub; sub = process.stdout.transform(utf8.decoder).listen((event) async { if (event.contains(dartVMServiceRegExp)) { await sub.cancel(); @@ -834,7 +834,7 @@ main() => print('b:b'); final readyCompleter = Completer(); final completer = Completer(); - late StreamSubscription sub; + late final StreamSubscription sub; sub = process.stdout.transform(utf8.decoder).listen((event) async { if (event.contains('ready')) { readyCompleter.complete(); @@ -912,8 +912,8 @@ main() => print('b:b'); final completer = Completer(); - late StreamSubscription sub; - late String uri; + late final StreamSubscription sub; + late final String uri; sub = process.stdout.transform(utf8.decoder).listen((event) async { if (event.contains(dartVMServiceRegExp)) { uri = dartVMServiceRegExp.firstMatch(event)!.group(1)!; diff --git a/pkg/dartdev/test/commands/test_test.dart b/pkg/dartdev/test/commands/test_test.dart index 8794d53f23a..1b70a6f8b12 100644 --- a/pkg/dartdev/test/commands/test_test.dart +++ b/pkg/dartdev/test/commands/test_test.dart @@ -185,7 +185,7 @@ void main() { RegExp(r'(http:\/\/127.0.0.1:\d*\/[\da-zA-Z-_]*=\/)'); final process = await p.start(['test', '--pause-after-load']); final completer = Completer(); - late StreamSubscription sub; + late final StreamSubscription sub; sub = process.stdout .transform(utf8.decoder) .transform(const LineSplitter()) diff --git a/pkg/dartdev/test/smoke/smoke_test.dart b/pkg/dartdev/test/smoke/smoke_test.dart index 48073abed10..ea7a1014889 100644 --- a/pkg/dartdev/test/smoke/smoke_test.dart +++ b/pkg/dartdev/test/smoke/smoke_test.dart @@ -107,7 +107,7 @@ void main() { ], ); final completer = Completer(); - late StreamSubscription sub; + late final StreamSubscription sub; bool sawServiceMsg = false; void onData(event) { print(event); diff --git a/pkg/dartdev/tool/sdk_size.dart b/pkg/dartdev/tool/sdk_size.dart index d6691779452..6fdcc26c0de 100644 --- a/pkg/dartdev/tool/sdk_size.dart +++ b/pkg/dartdev/tool/sdk_size.dart @@ -55,7 +55,8 @@ void main(List arguments) { String sizeMB(int size) => '${(size / (1024.0 * 1024)).toStringAsFixed(1)}MB'; -Map build(FileSystemEntity entity, {Map extra = const {}}) { +Map build(FileSystemEntity entity, + {Map extra = const {}}) { const fsBlockSize = 4096.0; if (entity is File) {