forked from firka/flutter
enable no_literal_bool_comparisons lint (#126647)
This commit is contained in:
committed by
GitHub
parent
b45f9b36e8
commit
5e1ba701ed
@@ -328,7 +328,7 @@ class AOTSnapshotter {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assert(stripAfterBuild == false);
|
||||
assert(!stripAfterBuild);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ void main() {
|
||||
);
|
||||
|
||||
int errorCount = 0;
|
||||
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first;
|
||||
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => !analyzing).first;
|
||||
server.onErrors.listen((FileAnalysisErrors errors) => errorCount += errors.errors.length);
|
||||
|
||||
await server.start();
|
||||
@@ -144,7 +144,7 @@ void main() {
|
||||
);
|
||||
|
||||
int errorCount = 0;
|
||||
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first;
|
||||
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => !analyzing).first;
|
||||
server.onErrors.listen((FileAnalysisErrors errors) {
|
||||
errorCount += errors.errors.length;
|
||||
});
|
||||
@@ -172,7 +172,7 @@ void main() {
|
||||
);
|
||||
|
||||
int errorCount = 0;
|
||||
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first;
|
||||
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => !analyzing).first;
|
||||
server.onErrors.listen((FileAnalysisErrors errors) {
|
||||
errorCount += errors.errors.length;
|
||||
});
|
||||
|
||||
@@ -224,7 +224,7 @@ void main() {
|
||||
FlutterProject setupProjectUnderTest(Directory currentDirectory, bool setupXcodeWorkspace) {
|
||||
// This needs to be run within testWithoutContext and not setUp since FlutterProject uses context.
|
||||
final FlutterProject projectUnderTest = FlutterProject.fromDirectory(currentDirectory);
|
||||
if (setupXcodeWorkspace == true) {
|
||||
if (setupXcodeWorkspace) {
|
||||
projectUnderTest.ios.hostAppRoot.childDirectory('Runner.xcworkspace').createSync(recursive: true);
|
||||
projectUnderTest.macos.hostAppRoot.childDirectory('Runner.xcworkspace').createSync(recursive: true);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class FakePub extends Fake implements Pub {
|
||||
PubOutputMode outputMode = PubOutputMode.all,
|
||||
}) async {
|
||||
project.directory.childFile('.packages').createSync();
|
||||
if (offline == true) {
|
||||
if (offline) {
|
||||
calledGetOffline += 1;
|
||||
} else {
|
||||
calledOnline += 1;
|
||||
|
||||
@@ -1278,10 +1278,10 @@ class FakeDevice extends Fake implements Device {
|
||||
bool ipv6 = false,
|
||||
String? userIdentifier,
|
||||
}) async {
|
||||
if (startAppSuccess == false) {
|
||||
if (!startAppSuccess) {
|
||||
return LaunchResult.failed();
|
||||
}
|
||||
if (startAppSuccess == true) {
|
||||
if (startAppSuccess) {
|
||||
return LaunchResult.succeeded();
|
||||
}
|
||||
final String dartFlags = debuggingOptions.dartFlags;
|
||||
|
||||
@@ -124,7 +124,7 @@ void verifyCommand(Command<Object?> runner) {
|
||||
final String firstDescriptionLine = runner.description.split('\n').first;
|
||||
expect(firstDescriptionLine, matches(_allowedTrailingPatterns), reason: "command ${runner.name}'s description does not end with the expected single period that a full sentence should end with");
|
||||
|
||||
if (runner.hidden == false && runner.parent == null) {
|
||||
if (!runner.hidden && runner.parent == null) {
|
||||
expect(
|
||||
runner.category,
|
||||
anyOf(
|
||||
|
||||
@@ -163,7 +163,7 @@ void main() {
|
||||
final Iterable<String> rows = testLogger.statusText
|
||||
.split('\n')
|
||||
.map((String line) => line.trim())
|
||||
.where((String line) => line.isNotEmpty == true)
|
||||
.where((String line) => line.isNotEmpty)
|
||||
.skip(1); // remove `Flutter channels:` line
|
||||
|
||||
expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']);
|
||||
@@ -194,7 +194,7 @@ void main() {
|
||||
final Iterable<String> rows = testLogger.statusText
|
||||
.split('\n')
|
||||
.map((String line) => line.trim())
|
||||
.where((String line) => line.isNotEmpty == true)
|
||||
.where((String line) => line.isNotEmpty)
|
||||
.skip(1); // remove `Flutter channels:` line
|
||||
|
||||
expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']);
|
||||
|
||||
Reference in New Issue
Block a user