mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:45:06 +00:00
Turn on the "isEmpty" and "isNotEmpty" lints and fix violations.
Change-Id: Ia6d957ebcc2b19f8043fa58f0c6e2202b2c1104f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160982 Commit-Queue: Bob Nystrom <rnystrom@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Karl Klose <karlklose@google.com>
This commit is contained in:
parent
4e7848d17a
commit
8b21a49f61
|
@ -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
|
||||
|
|
|
@ -382,7 +382,7 @@ class AdbDevicePool {
|
|||
static Future<AdbDevicePool> 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!');
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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".');
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ Future<Null> 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);
|
||||
|
|
|
@ -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')");
|
||||
|
|
|
@ -254,7 +254,7 @@ Future testConfigurations(List<TestConfiguration> configurations) async {
|
|||
}
|
||||
|
||||
// Start all the HTTP servers required before starting the process queue.
|
||||
if (!serverFutures.isEmpty) {
|
||||
if (serverFutures.isNotEmpty) {
|
||||
await Future.wait(serverFutures);
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue