From 842ae94fde61595a470ef4029146aa386a9ad60d Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Mon, 17 May 2021 14:25:01 -0400 Subject: [PATCH] Migrate some tool commands to NNBD (#3899) Now that individual commands can be migrated, migrate several commands that are trivially migratable. Part of https://github.com/flutter/flutter/issues/81912 --- script/tool/lib/src/analyze_command.dart | 2 -- .../tool/lib/src/build_examples_command.dart | 20 +++++++------------ .../tool/lib/src/drive_examples_command.dart | 2 -- script/tool/lib/src/format_command.dart | 2 -- script/tool/lib/src/java_test_command.dart | 2 -- .../tool/lib/src/license_check_command.dart | 2 -- script/tool/lib/src/list_command.dart | 2 -- script/tool/lib/src/test_command.dart | 2 -- script/tool/test/analyze_command_test.dart | 6 ++---- .../test/build_examples_command_test.dart | 6 ++---- .../test/drive_examples_command_test.dart | 6 ++---- script/tool/test/java_test_command_test.dart | 4 +--- .../tool/test/license_check_command_test.dart | 12 +++++------ script/tool/test/list_command_test.dart | 4 +--- script/tool/test/mocks.dart | 4 +--- script/tool/test/test_command_test.dart | 4 +--- 16 files changed, 22 insertions(+), 58 deletions(-) diff --git a/script/tool/lib/src/analyze_command.dart b/script/tool/lib/src/analyze_command.dart index ec22e06839..0ed6c2caa5 100644 --- a/script/tool/lib/src/analyze_command.dart +++ b/script/tool/lib/src/analyze_command.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:file/file.dart'; diff --git a/script/tool/lib/src/build_examples_command.dart b/script/tool/lib/src/build_examples_command.dart index f712986563..75bff3b25d 100644 --- a/script/tool/lib/src/build_examples_command.dart +++ b/script/tool/lib/src/build_examples_command.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'dart:io' as io; @@ -52,11 +50,7 @@ class BuildExamplesCommand extends PluginCommand { kWeb, kWindows, ]; - final Map platforms = { - for (final String platform in platformSwitches) - platform: getBoolArg(platform) - }; - if (!platforms.values.any((bool enabled) => enabled)) { + if (!platformSwitches.any((String platform) => getBoolArg(platform))) { print( 'None of ${platformSwitches.map((String platform) => '--$platform').join(', ')} ' 'were specified, so not building anything.'); @@ -73,7 +67,7 @@ class BuildExamplesCommand extends PluginCommand { final String packageName = p.relative(example.path, from: packagesDir.path); - if (platforms[kLinux]) { + if (getBoolArg(kLinux)) { print('\nBUILDING Linux for $packageName'); if (isLinuxPlugin(plugin, fileSystem)) { final int buildExitCode = await processRunner.runAndStream( @@ -93,7 +87,7 @@ class BuildExamplesCommand extends PluginCommand { } } - if (platforms[kMacos]) { + if (getBoolArg(kMacos)) { print('\nBUILDING macOS for $packageName'); if (isMacOsPlugin(plugin, fileSystem)) { final int exitCode = await processRunner.runAndStream( @@ -113,7 +107,7 @@ class BuildExamplesCommand extends PluginCommand { } } - if (platforms[kWeb]) { + if (getBoolArg(kWeb)) { print('\nBUILDING web for $packageName'); if (isWebPlugin(plugin, fileSystem)) { final int buildExitCode = await processRunner.runAndStream( @@ -133,7 +127,7 @@ class BuildExamplesCommand extends PluginCommand { } } - if (platforms[kWindows]) { + if (getBoolArg(kWindows)) { print('\nBUILDING Windows for $packageName'); if (isWindowsPlugin(plugin, fileSystem)) { final int buildExitCode = await processRunner.runAndStream( @@ -153,7 +147,7 @@ class BuildExamplesCommand extends PluginCommand { } } - if (platforms[kIpa]) { + if (getBoolArg(kIpa)) { print('\nBUILDING IPA for $packageName'); if (isIosPlugin(plugin, fileSystem)) { final int exitCode = await processRunner.runAndStream( @@ -174,7 +168,7 @@ class BuildExamplesCommand extends PluginCommand { } } - if (platforms[kApk]) { + if (getBoolArg(kApk)) { print('\nBUILDING APK for $packageName'); if (isAndroidPlugin(plugin, fileSystem)) { final int exitCode = await processRunner.runAndStream( diff --git a/script/tool/lib/src/drive_examples_command.dart b/script/tool/lib/src/drive_examples_command.dart index 76ba8205e1..15f465f535 100644 --- a/script/tool/lib/src/drive_examples_command.dart +++ b/script/tool/lib/src/drive_examples_command.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:file/file.dart'; import 'package:path/path.dart' as p; diff --git a/script/tool/lib/src/format_command.dart b/script/tool/lib/src/format_command.dart index b3a8bd04ed..51ab7957d8 100644 --- a/script/tool/lib/src/format_command.dart +++ b/script/tool/lib/src/format_command.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'dart:convert'; import 'dart:io' as io; diff --git a/script/tool/lib/src/java_test_command.dart b/script/tool/lib/src/java_test_command.dart index dff83d3731..5df97627ce 100644 --- a/script/tool/lib/src/java_test_command.dart +++ b/script/tool/lib/src/java_test_command.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:file/file.dart'; diff --git a/script/tool/lib/src/license_check_command.dart b/script/tool/lib/src/license_check_command.dart index cc4eb96fac..a6528640b8 100644 --- a/script/tool/lib/src/license_check_command.dart +++ b/script/tool/lib/src/license_check_command.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:file/file.dart'; diff --git a/script/tool/lib/src/list_command.dart b/script/tool/lib/src/list_command.dart index cac6cfcf35..f834c8aa50 100644 --- a/script/tool/lib/src/list_command.dart +++ b/script/tool/lib/src/list_command.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:file/file.dart'; diff --git a/script/tool/lib/src/test_command.dart b/script/tool/lib/src/test_command.dart index c4aeab7022..7455095eff 100644 --- a/script/tool/lib/src/test_command.dart +++ b/script/tool/lib/src/test_command.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:file/file.dart'; diff --git a/script/tool/test/analyze_command_test.dart b/script/tool/test/analyze_command_test.dart index 1e656b4f75..5adebe708a 100644 --- a/script/tool/test/analyze_command_test.dart +++ b/script/tool/test/analyze_command_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'package:args/command_runner.dart'; import 'package:file/file.dart'; import 'package:flutter_plugin_tools/src/analyze_command.dart'; @@ -14,8 +12,8 @@ import 'mocks.dart'; import 'util.dart'; void main() { - RecordingProcessRunner processRunner; - CommandRunner runner; + late RecordingProcessRunner processRunner; + late CommandRunner runner; setUp(() { initializeFakePackages(); diff --git a/script/tool/test/build_examples_command_test.dart b/script/tool/test/build_examples_command_test.dart index 7b488879f3..7a8aa85fc8 100644 --- a/script/tool/test/build_examples_command_test.dart +++ b/script/tool/test/build_examples_command_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'package:args/command_runner.dart'; import 'package:file/file.dart'; import 'package:flutter_plugin_tools/src/build_examples_command.dart'; @@ -15,8 +13,8 @@ import 'util.dart'; void main() { group('test build_example_command', () { - CommandRunner runner; - RecordingProcessRunner processRunner; + late CommandRunner runner; + late RecordingProcessRunner processRunner; final String flutterCommand = const LocalPlatform().isWindows ? 'flutter.bat' : 'flutter'; diff --git a/script/tool/test/drive_examples_command_test.dart b/script/tool/test/drive_examples_command_test.dart index 7905bb279f..6fb8b8d335 100644 --- a/script/tool/test/drive_examples_command_test.dart +++ b/script/tool/test/drive_examples_command_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'package:args/command_runner.dart'; import 'package:file/file.dart'; import 'package:flutter_plugin_tools/src/common.dart'; @@ -16,8 +14,8 @@ import 'util.dart'; void main() { group('test drive_example_command', () { - CommandRunner runner; - RecordingProcessRunner processRunner; + late CommandRunner runner; + late RecordingProcessRunner processRunner; final String flutterCommand = const LocalPlatform().isWindows ? 'flutter.bat' : 'flutter'; setUp(() { diff --git a/script/tool/test/java_test_command_test.dart b/script/tool/test/java_test_command_test.dart index cfa8d448f3..2ce231651b 100644 --- a/script/tool/test/java_test_command_test.dart +++ b/script/tool/test/java_test_command_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'package:args/command_runner.dart'; import 'package:file/file.dart'; import 'package:flutter_plugin_tools/src/java_test_command.dart'; @@ -14,7 +12,7 @@ import 'util.dart'; void main() { group('$JavaTestCommand', () { - CommandRunner runner; + late CommandRunner runner; final RecordingProcessRunner processRunner = RecordingProcessRunner(); setUp(() { diff --git a/script/tool/test/license_check_command_test.dart b/script/tool/test/license_check_command_test.dart index a0c74fc6ac..7b49fa8e9e 100644 --- a/script/tool/test/license_check_command_test.dart +++ b/script/tool/test/license_check_command_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'package:args/command_runner.dart'; import 'package:file/file.dart'; import 'package:file/memory.dart'; @@ -13,10 +11,10 @@ import 'package:test/test.dart'; void main() { group('$LicenseCheckCommand', () { - CommandRunner runner; - FileSystem fileSystem; - List printedMessages; - Directory root; + late CommandRunner runner; + late FileSystem fileSystem; + late List printedMessages; + late Directory root; setUp(() { fileSystem = MemoryFileSystem(); @@ -28,7 +26,7 @@ void main() { final LicenseCheckCommand command = LicenseCheckCommand( packagesDir, fileSystem, - print: (Object message) => printedMessages.add(message.toString()), + print: (Object? message) => printedMessages.add(message.toString()), ); runner = CommandRunner('license_test', 'Test for $LicenseCheckCommand'); diff --git a/script/tool/test/list_command_test.dart b/script/tool/test/list_command_test.dart index a767671be5..e97474dedf 100644 --- a/script/tool/test/list_command_test.dart +++ b/script/tool/test/list_command_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'package:args/command_runner.dart'; import 'package:file/file.dart'; import 'package:flutter_plugin_tools/src/list_command.dart'; @@ -13,7 +11,7 @@ import 'util.dart'; void main() { group('$ListCommand', () { - CommandRunner runner; + late CommandRunner runner; setUp(() { initializeFakePackages(); diff --git a/script/tool/test/mocks.dart b/script/tool/test/mocks.dart index a83ca75438..b984247af9 100644 --- a/script/tool/test/mocks.dart +++ b/script/tool/test/mocks.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'dart:io' as io; @@ -35,5 +33,5 @@ class MockIOSink extends Mock implements IOSink { List lines = []; @override - void writeln([Object obj = '']) => lines.add(obj.toString()); + void writeln([Object? obj = '']) => lines.add(obj.toString()); } diff --git a/script/tool/test/test_command_test.dart b/script/tool/test/test_command_test.dart index 550249169b..dc951f6ea9 100644 --- a/script/tool/test/test_command_test.dart +++ b/script/tool/test/test_command_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'package:args/command_runner.dart'; import 'package:file/file.dart'; import 'package:flutter_plugin_tools/src/test_command.dart'; @@ -13,7 +11,7 @@ import 'util.dart'; void main() { group('$TestCommand', () { - CommandRunner runner; + late CommandRunner runner; final RecordingProcessRunner processRunner = RecordingProcessRunner(); setUp(() {