enable lint prefer_final_in_for_each (#47724)
This commit is contained in:
committed by
GitHub
parent
fa337f5922
commit
4f9b6cf017
@@ -144,7 +144,7 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
final List<String> output = (await eval(adbPath, <String>['devices', '-l'], canFail: false))
|
||||
.trim().split('\n');
|
||||
final List<String> results = <String>[];
|
||||
for (String line in output) {
|
||||
for (final String line in output) {
|
||||
// Skip lines like: * daemon started successfully *
|
||||
if (line.startsWith('* daemon '))
|
||||
continue;
|
||||
@@ -172,7 +172,7 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
@override
|
||||
Future<Map<String, HealthCheckResult>> checkDevices() async {
|
||||
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
|
||||
for (String deviceId in await discoverDevices()) {
|
||||
for (final String deviceId in await discoverDevices()) {
|
||||
try {
|
||||
final AndroidDevice device = AndroidDevice(deviceId: deviceId);
|
||||
// Just a smoke test that we can read wakefulness state
|
||||
@@ -432,7 +432,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
@override
|
||||
Future<Map<String, HealthCheckResult>> checkDevices() async {
|
||||
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
|
||||
for (String deviceId in await discoverDevices()) {
|
||||
for (final String deviceId in await discoverDevices()) {
|
||||
// TODO(ianh): do a more meaningful connectivity check than just recording the ID
|
||||
results['ios-device-$deviceId'] = HealthCheckResult.success();
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ Future<String> getAndroidManifest(String apk) async {
|
||||
/// Checks that the classes are contained in the APK, throws otherwise.
|
||||
Future<void> checkApkContainsClasses(File apk, List<String> classes) async {
|
||||
final ApkExtractor extractor = ApkExtractor(apk);
|
||||
for (String className in classes) {
|
||||
for (final String className in classes) {
|
||||
if (!(await extractor.containsClass(className))) {
|
||||
throw Exception('APK doesn\'t contain class `$className`.');
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ class TaskResult {
|
||||
message = 'success' {
|
||||
const JsonEncoder prettyJson = JsonEncoder.withIndent(' ');
|
||||
if (benchmarkScoreKeys != null) {
|
||||
for (String key in benchmarkScoreKeys) {
|
||||
for (final String key in benchmarkScoreKeys) {
|
||||
if (!data.containsKey(key)) {
|
||||
throw 'Invalid Golem score key "$key". It does not exist in task '
|
||||
'result data ${prettyJson.convert(data)}';
|
||||
|
||||
@@ -160,7 +160,7 @@ void _checkIsNotBlank(dynamic value, String variableName, String ownerName) {
|
||||
}
|
||||
|
||||
void _checkKeys(Map<dynamic, dynamic> map, String variableName, List<String> allowedKeys) {
|
||||
for (String key in map.keys.cast<String>()) {
|
||||
for (final String key in map.keys.cast<String>()) {
|
||||
if (!allowedKeys.contains(key)) {
|
||||
throw ManifestError(
|
||||
'Unrecognized property "$key" in $variableName. '
|
||||
|
||||
@@ -100,7 +100,7 @@ Stream<RunningProcessInfo> windowsRunningProcesses(String processName) async* {
|
||||
print(result.stdout);
|
||||
return;
|
||||
}
|
||||
for (RunningProcessInfo info in processPowershellOutput(result.stdout as String)) {
|
||||
for (final RunningProcessInfo info in processPowershellOutput(result.stdout as String)) {
|
||||
yield info;
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ Iterable<RunningProcessInfo> processPowershellOutput(String output) sync* {
|
||||
int creationDateHeaderEnd;
|
||||
int commandLineHeaderStart;
|
||||
bool inTableBody = false;
|
||||
for (String line in output.split('\n')) {
|
||||
for (final String line in output.split('\n')) {
|
||||
if (line.startsWith('ProcessId')) {
|
||||
commandLineHeaderStart = line.indexOf('CommandLine');
|
||||
creationDateHeaderEnd = commandLineHeaderStart - 1;
|
||||
@@ -191,7 +191,7 @@ Stream<RunningProcessInfo> posixRunningProcesses(
|
||||
print(result.stdout);
|
||||
return;
|
||||
}
|
||||
for (RunningProcessInfo info in processPsOutput(result.stdout as String, processName)) {
|
||||
for (final RunningProcessInfo info in processPsOutput(result.stdout as String, processName)) {
|
||||
yield info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class HealthCheckResult {
|
||||
if (details != null && details.trim().isNotEmpty) {
|
||||
buf.writeln();
|
||||
// Indent details by 4 spaces
|
||||
for (String line in details.trim().split('\n')) {
|
||||
for (final String line in details.trim().split('\n')) {
|
||||
buf.writeln(' $line');
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void recursiveCopy(Directory source, Directory target) {
|
||||
if (!target.existsSync())
|
||||
target.createSync();
|
||||
|
||||
for (FileSystemEntity entity in source.listSync(followLinks: false)) {
|
||||
for (final FileSystemEntity entity in source.listSync(followLinks: false)) {
|
||||
final String name = path.basename(entity.path);
|
||||
if (entity is Directory && !entity.path.contains('.dart_tool'))
|
||||
recursiveCopy(entity, Directory(path.join(target.path, name)));
|
||||
@@ -286,7 +286,7 @@ Future<void> forceQuitRunningProcesses() async {
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
|
||||
// Whatever's left, kill it.
|
||||
for (ProcessInfo p in _runningProcesses) {
|
||||
for (final ProcessInfo p in _runningProcesses) {
|
||||
print('Force-quitting process:\n$p');
|
||||
if (!p.process.kill()) {
|
||||
print('Failed to force quit process');
|
||||
@@ -636,7 +636,7 @@ void checkFileNotExists(String file) {
|
||||
|
||||
/// Check that `collection` contains all entries in `values`.
|
||||
void checkCollectionContains<T>(Iterable<T> values, Iterable<T> collection) {
|
||||
for (T value in values) {
|
||||
for (final T value in values) {
|
||||
if (!collection.contains(value)) {
|
||||
throw TaskResult.failure('Expected to find `$value` in `${collection.toString()}`.');
|
||||
}
|
||||
@@ -645,7 +645,7 @@ void checkCollectionContains<T>(Iterable<T> values, Iterable<T> collection) {
|
||||
|
||||
/// Check that `collection` does not contain any entries in `values`
|
||||
void checkCollectionDoesNotContain<T>(Iterable<T> values, Iterable<T> collection) {
|
||||
for (T value in values) {
|
||||
for (final T value in values) {
|
||||
if (collection.contains(value)) {
|
||||
throw TaskResult.failure('Did not expect to find `$value` in `$collection`.');
|
||||
}
|
||||
@@ -656,7 +656,7 @@ void checkCollectionDoesNotContain<T>(Iterable<T> values, Iterable<T> collection
|
||||
/// [Pattern]s, otherwise throws a [TaskResult].
|
||||
void checkFileContains(List<Pattern> patterns, String filePath) {
|
||||
final String fileContent = File(filePath).readAsStringSync();
|
||||
for (Pattern pattern in patterns) {
|
||||
for (final Pattern pattern in patterns) {
|
||||
if (!fileContent.contains(pattern)) {
|
||||
throw TaskResult.failure(
|
||||
'Expected to find `$pattern` in `$filePath` '
|
||||
|
||||
Reference in New Issue
Block a user