enable no_literal_bool_comparisons lint (#126647)

This commit is contained in:
Michael Goderbauer
2023-05-16 18:14:23 +02:00
committed by GitHub
parent b45f9b36e8
commit 5e1ba701ed
46 changed files with 79 additions and 79 deletions

View File

@@ -328,7 +328,7 @@ class AOTSnapshotter {
}
}
} else {
assert(stripAfterBuild == false);
assert(!stripAfterBuild);
}
return 0;

View File

@@ -1101,7 +1101,7 @@ class PrefixedErrorLogger extends DelegatingLogger {
bool? wrap,
}) {
hadErrorOutput = true;
if (message.trim().isNotEmpty == true) {
if (message.trim().isNotEmpty) {
message = 'ERROR: $message';
}
super.printError(

View File

@@ -537,7 +537,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
String? description,
bool defaultsTo = true,
}) async {
final String defaultsToStr = defaultsTo == true ? '[Y/n]' : '[y/N]';
final String defaultsToStr = defaultsTo ? '[Y/n]' : '[y/N]';
logger.printStatus('$description $defaultsToStr (empty for default)');
while (true) {
final String input = await inputs.next;
@@ -784,7 +784,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
if (stringArg(_kJson) != null) {
return runNonInteractively();
}
if (boolArg(_kSsh) == true) {
if (boolArg(_kSsh)) {
return runInteractivelySsh();
}
throw UnsupportedError('Unknown run mode');

View File

@@ -793,7 +793,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
'--platform',
platformDill!,
],
if (unsafePackageSerialization == true) '--unsafe-package-serialization',
if (unsafePackageSerialization) '--unsafe-package-serialization',
// See: https://github.com/flutter/flutter/issues/103994
'--verbosity=error',
...?extraFrontEndOptions,

View File

@@ -706,7 +706,7 @@ class CustomDevice extends Device {
@override
Future<void> takeScreenshot(File outputFile) async {
if (supportsScreenshot == false) {
if (!supportsScreenshot) {
throw UnsupportedError('Screenshotting is not supported for this device.');
}
@@ -874,7 +874,7 @@ class CustomDevices extends PollingDeviceDiscovery {
);
// remove all the devices we couldn't reach.
pingedDevices.removeWhere((_, bool value) => value == false);
pingedDevices.removeWhere((_, bool value) => !value);
// return only the devices.
return pingedDevices.keys.toList();

View File

@@ -149,7 +149,7 @@ abstract class DesktopDevice extends Device {
unawaited(process.exitCode.then((_) => _runningProcesses.remove(process)));
_deviceLogReader.initializeProcess(process);
if (debuggingOptions.buildInfo.isRelease == true) {
if (debuggingOptions.buildInfo.isRelease) {
return LaunchResult.succeeded();
}
final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.vmService(_deviceLogReader,

View File

@@ -283,7 +283,7 @@ abstract class DeviceManager {
bool includeDevicesUnsupportedByProject = false,
}) {
FlutterProject? flutterProject;
if (includeDevicesUnsupportedByProject == false) {
if (!includeDevicesUnsupportedByProject) {
flutterProject = FlutterProject.current();
}
if (hasSpecifiedAllDevices) {
@@ -312,7 +312,7 @@ abstract class DeviceManager {
Device? getSingleEphemeralDevice(List<Device> devices){
if (!hasSpecifiedDeviceId) {
try {
return devices.singleWhere((Device device) => device.ephemeral == true);
return devices.singleWhere((Device device) => device.ephemeral);
} on StateError {
return null;
}

View File

@@ -410,7 +410,7 @@ class Doctor {
}
for (final ValidationMessage message in result.messages) {
if (!message.isInformation || verbose == true) {
if (!message.isInformation || verbose) {
int hangingIndent = 2;
int indent = 4;
final String indicator = showColor ? message.coloredIndicator : message.indicator;

View File

@@ -56,8 +56,8 @@ class EmulatorManager {
emulator.id.toLowerCase() == searchText ||
emulator.name.toLowerCase() == searchText;
bool startsWithEmulatorId(Emulator emulator) =>
emulator.id.toLowerCase().startsWith(searchText) == true ||
emulator.name.toLowerCase().startsWith(searchText) == true;
emulator.id.toLowerCase().startsWith(searchText) ||
emulator.name.toLowerCase().startsWith(searchText);
Emulator? exactMatch;
for (final Emulator emulator in emulators) {

View File

@@ -607,7 +607,7 @@ class IOSDevice extends Device {
// If the debugger is not attached, killing the ios-deploy process won't stop the app.
final IOSDeployDebugger? deployDebugger = iosDeployDebugger;
if (deployDebugger != null && deployDebugger.debuggerAttached) {
return deployDebugger.exit() == true;
return deployDebugger.exit();
}
return false;
}

View File

@@ -201,9 +201,9 @@ class XcodeProjectInterpreter {
if (buildContext.environmentType == EnvironmentType.simulator)
...<String>['-sdk', 'iphonesimulator'],
'-destination',
if (buildContext.isWatch == true && buildContext.environmentType == EnvironmentType.physical)
if (buildContext.isWatch && buildContext.environmentType == EnvironmentType.physical)
'generic/platform=watchOS'
else if (buildContext.isWatch == true)
else if (buildContext.isWatch)
'generic/platform=watchOS Simulator'
else if (deviceId != null)
'id=$deviceId'

View File

@@ -48,7 +48,7 @@ class CmakeCustomCommandMigration extends ProjectMigrator {
for (final RegExpMatch match in matches) {
final String? addCustomCommandOriginal = match.group(1);
if (addCustomCommandOriginal != null && addCustomCommandOriginal.contains('VERBATIM') == false) {
if (addCustomCommandOriginal != null && !addCustomCommandOriginal.contains('VERBATIM')) {
final String addCustomCommandReplacement = '$addCustomCommandOriginal\n VERBATIM';
newProjectContents = newProjectContents.replaceAll(addCustomCommandOriginal, addCustomCommandReplacement);
}

View File

@@ -638,7 +638,7 @@ class ProxiedPortForwarder extends DevicePortForwarder {
}
Future<ServerSocket> _defaultCreateServerSocket(Logger logger, int? hostPort, bool? ipv6) async {
if (ipv6 == null || ipv6 == false) {
if (ipv6 == null || !ipv6) {
try {
return await ServerSocket.bind(InternetAddress.loopbackIPv4, hostPort ?? 0);
} on SocketException {

View File

@@ -1172,7 +1172,7 @@ abstract class FlutterCommand extends Command<void> {
}
final bool treeShakeIcons = argParser.options.containsKey('tree-shake-icons')
&& buildMode.isPrecompiled == true
&& buildMode.isPrecompiled
&& boolArg('tree-shake-icons');
final String? bundleSkSLPath = argParser.options.containsKey(FlutterOptions.kBundleSkSLPathOption)

View File

@@ -508,7 +508,7 @@ class IosProject extends XcodeBasedProject {
// In newer versions of Xcode, the build settings of the watchOS companion
// app's scheme should contain the key INFOPLIST_KEY_WKCompanionAppBundleIdentifier.
final bool watchIdentifierFound = xcodeProjectInfoFile.readAsStringSync().contains('WKCompanionAppBundleIdentifier');
if (watchIdentifierFound == false) {
if (!watchIdentifierFound) {
return false;
}