diff --git a/pkg/test_runner/analysis_options.yaml b/pkg/test_runner/analysis_options.yaml index 788c451113d..406b0a11140 100644 --- a/pkg/test_runner/analysis_options.yaml +++ b/pkg/test_runner/analysis_options.yaml @@ -8,8 +8,6 @@ linter: # - non_constant_identifier_names # - only_throw_errors # - prefer_interpolation_to_compose_strings -# - prefer_is_empty -# - prefer_is_not_empty # - prefer_single_quotes - avoid_bool_literals_in_conditional_expressions - avoid_empty_else @@ -60,6 +58,8 @@ linter: - prefer_final_fields - prefer_generic_function_type_aliases - prefer_initializing_formals + - prefer_is_empty + - prefer_is_not_empty - prefer_null_aware_operators - prefer_typing_uninitialized_variables - recursive_getters diff --git a/pkg/test_runner/lib/src/android.dart b/pkg/test_runner/lib/src/android.dart index 8f1c4d3bfda..aa8fa5cd90c 100644 --- a/pkg/test_runner/lib/src/android.dart +++ b/pkg/test_runner/lib/src/android.dart @@ -382,7 +382,7 @@ class AdbDevicePool { static Future create() async { var names = await AdbHelper.listDevices(); var devices = names.map((id) => AdbDevice(id)).toList(); - if (devices.length == 0) { + if (devices.isEmpty) { throw Exception('No android devices found. ' 'Please make sure "adb devices" shows your device!'); } diff --git a/pkg/test_runner/lib/src/browser.dart b/pkg/test_runner/lib/src/browser.dart index 67238df3c8c..521e3c98e0e 100644 --- a/pkg/test_runner/lib/src/browser.dart +++ b/pkg/test_runner/lib/src/browser.dart @@ -54,7 +54,7 @@ String pathToJSIdentifier(String path) { /// Escape [name] to make it into a valid identifier. String _toJSIdentifier(String name) { - if (name.length == 0) return r'$'; + if (name.isEmpty) return r'$'; // Escape any invalid characters StringBuffer buffer; diff --git a/pkg/test_runner/lib/src/browser_controller.dart b/pkg/test_runner/lib/src/browser_controller.dart index 75a89ad95e5..708d185873f 100644 --- a/pkg/test_runner/lib/src/browser_controller.dart +++ b/pkg/test_runner/lib/src/browser_controller.dart @@ -1105,7 +1105,7 @@ class BrowserTestRunner { } void printDoubleReportingTests() { - if (doubleReportingOutputs.length == 0) return; + if (doubleReportingOutputs.isEmpty) return; // TODO(ricow): die on double reporting. // Currently we just report this here, we could have a callback to the // encapsulating environment. diff --git a/pkg/test_runner/lib/src/options.dart b/pkg/test_runner/lib/src/options.dart index 14eb334bbd0..3ebeaee5111 100644 --- a/pkg/test_runner/lib/src/options.dart +++ b/pkg/test_runner/lib/src/options.dart @@ -504,7 +504,7 @@ compiler.''', case _OptionValueType.string: // Validate against the allowed values. - if (!option.values.isEmpty) { + if (option.values.isNotEmpty) { validate(String value) { if (!option.values.contains(value)) { _fail('Unknown value "$value" for option "$command".'); diff --git a/pkg/test_runner/lib/src/path.dart b/pkg/test_runner/lib/src/path.dart index 5c9003d8d9b..ecf982f102a 100644 --- a/pkg/test_runner/lib/src/path.dart +++ b/pkg/test_runner/lib/src/path.dart @@ -200,7 +200,7 @@ class Path { var isAbs = isAbsolute; var segs = segments(); String drive; - if (isAbs && !segs.isEmpty && segs[0].length == 2 && segs[0][1] == ':') { + if (isAbs && segs.isNotEmpty && segs[0].length == 2 && segs[0][1] == ':') { drive = segs[0]; segs.removeRange(0, 1); } diff --git a/pkg/test_runner/lib/src/process_queue.dart b/pkg/test_runner/lib/src/process_queue.dart index 7be0d7481a4..6d7a58c9118 100644 --- a/pkg/test_runner/lib/src/process_queue.dart +++ b/pkg/test_runner/lib/src/process_queue.dart @@ -405,7 +405,7 @@ class CommandQueue { void _tryRunNextCommand() { _checkDone(); - if (_numProcesses < _maxProcesses && !_runQueue.isEmpty) { + if (_numProcesses < _maxProcesses && _runQueue.isNotEmpty) { var command = _runQueue.removeFirst(); var isBrowserCommand = command is BrowserTestCommand; diff --git a/pkg/test_runner/lib/src/reset_safari.dart b/pkg/test_runner/lib/src/reset_safari.dart index 3d579102174..212de216d50 100644 --- a/pkg/test_runner/lib/src/reset_safari.dart +++ b/pkg/test_runner/lib/src/reset_safari.dart @@ -143,7 +143,7 @@ Future killSafari({Uri bundle}) async { if (result.exitCode == 0) { var stdout = result.stdout as String; var pids = - stdout.split("\n").where((String line) => !line.isEmpty).toList(); + stdout.split("\n").where((String line) => line.isNotEmpty).toList(); var timer = Timer(const Duration(seconds: 10), () { print("Kill -9 Safari $pids"); kill(pids, force: true); diff --git a/pkg/test_runner/lib/src/test_case.dart b/pkg/test_runner/lib/src/test_case.dart index fb4a908d38b..159b6366e3b 100644 --- a/pkg/test_runner/lib/src/test_case.dart +++ b/pkg/test_runner/lib/src/test_case.dart @@ -113,7 +113,7 @@ class TestCase { } CommandOutput get lastCommandOutput { - if (commandOutputs.length == 0) { + if (commandOutputs.isEmpty) { throw Exception("CommandOutputs is empty, maybe no command was run? (" "displayName: '$displayName', " "configurationString: '$configurationString')"); @@ -122,7 +122,7 @@ class TestCase { } Command get lastCommandExecuted { - if (commandOutputs.length == 0) { + if (commandOutputs.isEmpty) { throw Exception("CommandOutputs is empty, maybe no command was run? (" "displayName: '$displayName', " "configurationString: '$configurationString')"); diff --git a/pkg/test_runner/lib/src/test_configurations.dart b/pkg/test_runner/lib/src/test_configurations.dart index 93de2109ba0..dbd8d79ee25 100644 --- a/pkg/test_runner/lib/src/test_configurations.dart +++ b/pkg/test_runner/lib/src/test_configurations.dart @@ -254,7 +254,7 @@ Future testConfigurations(List configurations) async { } // Start all the HTTP servers required before starting the process queue. - if (!serverFutures.isEmpty) { + if (serverFutures.isNotEmpty) { await Future.wait(serverFutures); } diff --git a/pkg/test_runner/lib/src/test_suite.dart b/pkg/test_runner/lib/src/test_suite.dart index 2a2bfb4ac23..02d1f3e2c7d 100644 --- a/pkg/test_runner/lib/src/test_suite.dart +++ b/pkg/test_runner/lib/src/test_suite.dart @@ -595,14 +595,14 @@ class StandardTestSuite extends TestSuite { var commonArguments = _commonArgumentsFromFile(testFile); var vmOptionsList = getVmOptions(testFile); - assert(!vmOptionsList.isEmpty); + assert(vmOptionsList.isNotEmpty); for (var vmOptionsVariant = 0; vmOptionsVariant < vmOptionsList.length; vmOptionsVariant++) { var vmOptions = vmOptionsList[vmOptionsVariant]; var allVmOptions = vmOptions; - if (!extraVmOptions.isEmpty) { + if (extraVmOptions.isNotEmpty) { allVmOptions = vmOptions.toList()..addAll(extraVmOptions); } @@ -623,7 +623,7 @@ class StandardTestSuite extends TestSuite { var commonArguments = _commonArgumentsFromFile(testFile); var vmOptionsList = getVmOptions(testFile); - assert(!vmOptionsList.isEmpty); + assert(vmOptionsList.isNotEmpty); var emitDdsTest = false; for (var i = 0; i < 2; ++i) { @@ -632,7 +632,7 @@ class StandardTestSuite extends TestSuite { vmOptionsVariant++) { var vmOptions = vmOptionsList[vmOptionsVariant]; var allVmOptions = vmOptions; - if (!extraVmOptions.isEmpty) { + if (extraVmOptions.isNotEmpty) { allVmOptions = vmOptions.toList()..addAll(extraVmOptions); } if (emitDdsTest) { diff --git a/pkg/test_runner/lib/src/testing_servers.dart b/pkg/test_runner/lib/src/testing_servers.dart index f46956c3028..5e9df6842d3 100644 --- a/pkg/test_runner/lib/src/testing_servers.dart +++ b/pkg/test_runner/lib/src/testing_servers.dart @@ -241,7 +241,7 @@ class TestingServers { Uri _getFileUriFromRequestUri(Uri request) { // Go to the top of the file to see an explanation of the URL path scheme. var pathSegments = request.normalizePath().pathSegments; - if (pathSegments.length == 0) return null; + if (pathSegments.isEmpty) return null; var packagesIndex = pathSegments.indexOf('packages'); if (packagesIndex != -1) { var packageUri = Uri( diff --git a/pkg/test_runner/lib/src/vendored_pkg/args/src/parser.dart b/pkg/test_runner/lib/src/vendored_pkg/args/src/parser.dart index d3ca35683a5..990dbf7cbc4 100644 --- a/pkg/test_runner/lib/src/vendored_pkg/args/src/parser.dart +++ b/pkg/test_runner/lib/src/vendored_pkg/args/src/parser.dart @@ -50,7 +50,7 @@ class Parser { }); // Parse the args. - while (args.length > 0) { + while (args.isNotEmpty) { if (current == '--') { // Reached the argument terminator, so stop here. args.removeAt(0); @@ -98,7 +98,7 @@ class Parser { /// that there is a valid value there. void readNextArgAsValue(Option option) { // Take the option argument from the next command line arg. - validate(args.length > 0, 'Missing argument for "${option.name}".'); + validate(args.isNotEmpty, 'Missing argument for "${option.name}".'); // Make sure it isn't an option itself. validate(!_ABBR_OPT.hasMatch(current) && !_LONG_OPT.hasMatch(current), diff --git a/pkg/test_runner/lib/src/vendored_pkg/args/src/usage.dart b/pkg/test_runner/lib/src/vendored_pkg/args/src/usage.dart index 27504f39b1f..60d4a9ee027 100644 --- a/pkg/test_runner/lib/src/vendored_pkg/args/src/usage.dart +++ b/pkg/test_runner/lib/src/vendored_pkg/args/src/usage.dart @@ -144,11 +144,11 @@ class Usage { var lines = text.split('\n'); // Strip leading and trailing empty lines. - while (lines.length > 0 && lines[0].trim() == '') { + while (lines.isNotEmpty && lines[0].trim() == '') { lines.removeRange(0, 1); } - while (lines.length > 0 && lines[lines.length - 1].trim() == '') { + while (lines.isNotEmpty && lines[lines.length - 1].trim() == '') { lines.removeLast(); }