enable lint prefer_final_in_for_each (#47724)
This commit is contained in:
committed by
GitHub
parent
fa337f5922
commit
4f9b6cf017
@@ -59,7 +59,7 @@ Future<void> main(List<String> rawArgs) async {
|
||||
final String localEngine = args['local-engine'] as String;
|
||||
final String localEngineSrcPath = args['local-engine-src-path'] as String;
|
||||
|
||||
for (String taskName in _taskNames) {
|
||||
for (final String taskName in _taskNames) {
|
||||
section('Running task "$taskName"');
|
||||
final Map<String, dynamic> result = await runTask(
|
||||
taskName,
|
||||
@@ -95,7 +95,7 @@ void addTasks({
|
||||
}
|
||||
// Only start skipping if user specified a task to continue from
|
||||
final String stage = args['stage'] as String;
|
||||
for (ManifestTask task in tasks) {
|
||||
for (final ManifestTask task in tasks) {
|
||||
final bool isQualifyingStage = stage == null || task.stage == stage;
|
||||
final bool isQualifyingHost = !(args['match-host-platform'] as bool) || task.isSupportedByHost();
|
||||
if (isQualifyingHost && isQualifyingStage) {
|
||||
@@ -116,7 +116,7 @@ final ArgParser _argParser = ArgParser()
|
||||
'\n'
|
||||
'This option may be repeated to specify multiple tasks.',
|
||||
callback: (List<String> value) {
|
||||
for (String nameOrPath in value) {
|
||||
for (final String nameOrPath in value) {
|
||||
final List<String> fragments = path.split(nameOrPath);
|
||||
final bool isDartFile = fragments.last.endsWith('.dart');
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ Future<void> main() async {
|
||||
|
||||
section('Check profile, release builds has Dart AOT dylib');
|
||||
|
||||
for (String mode in <String>['Profile', 'Release']) {
|
||||
for (final String mode in <String>['Profile', 'Release']) {
|
||||
final String appFrameworkPath = path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
@@ -159,7 +159,7 @@ Future<void> main() async {
|
||||
|
||||
section("Check all modes' engine dylib");
|
||||
|
||||
for (String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
for (final String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
final String engineFrameworkPath = path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
@@ -194,7 +194,7 @@ Future<void> main() async {
|
||||
|
||||
section("Check all modes' engine header");
|
||||
|
||||
for (String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
for (final String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
checkFileContains(
|
||||
<String>['#include "FlutterEngine.h"'],
|
||||
path.join(outputPath, mode, 'Flutter.framework', 'Headers', 'Flutter.h'),
|
||||
@@ -203,7 +203,7 @@ Future<void> main() async {
|
||||
|
||||
section("Check all modes' have plugin dylib");
|
||||
|
||||
for (String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
for (final String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
final String pluginFrameworkPath = path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
@@ -237,7 +237,7 @@ Future<void> main() async {
|
||||
|
||||
section("Check all modes' have generated plugin registrant");
|
||||
|
||||
for (String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
for (final String mode in <String>['Debug', 'Profile', 'Release']) {
|
||||
final String registrantFrameworkPath = path.join(
|
||||
outputPath,
|
||||
mode,
|
||||
|
||||
@@ -40,7 +40,7 @@ Future<void> main() async {
|
||||
print('^ not sure what to do with that line ^');
|
||||
}
|
||||
}
|
||||
await for (String entry in analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
|
||||
await for (final String entry in analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
|
||||
print('analyzer stderr: $entry');
|
||||
if (entry.contains(' (ran in ') && !sawFinalLine) {
|
||||
// ignore this line once
|
||||
|
||||
@@ -16,7 +16,7 @@ Future<void> main() async {
|
||||
|
||||
final List<String> benchmarkScoreKeys = <String>[];
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
for (String key in withSemantics.benchmarkScoreKeys) {
|
||||
for (final String key in withSemantics.benchmarkScoreKeys) {
|
||||
final String deltaKey = 'delta_$key';
|
||||
data[deltaKey] = withSemantics.data[key] - withoutSemantics.data[key];
|
||||
data['semantics_$key'] = withSemantics.data[key];
|
||||
|
||||
@@ -49,7 +49,7 @@ Future<int> runTest({bool coverage = false}) async {
|
||||
);
|
||||
int badLines = 0;
|
||||
TestStep step = TestStep.starting;
|
||||
await for (String entry in analysis.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
|
||||
await for (final String entry in analysis.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
|
||||
print('test stdout ($step): $entry');
|
||||
if (step == TestStep.starting && entry == 'Building flutter tool...') {
|
||||
// ignore this line
|
||||
@@ -82,7 +82,7 @@ Future<int> runTest({bool coverage = false}) async {
|
||||
}
|
||||
}
|
||||
}
|
||||
await for (String entry in analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
|
||||
await for (final String entry in analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
|
||||
print('test stderr: $entry');
|
||||
badLines += 1;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ Future<void> main() async {
|
||||
final String pubspecString = pubspecFile.readAsStringSync();
|
||||
|
||||
final StringBuffer iosOnlyPubspec = StringBuffer();
|
||||
for (String line in pubspecString.split('\n')) {
|
||||
for (final String line in pubspecString.split('\n')) {
|
||||
if (line.startsWith(' androidPackage:')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ Future<double> findCostsForFile(File file) async {
|
||||
return 0.0;
|
||||
final bool isTest = file.path.endsWith('_test.dart');
|
||||
double total = 0.0;
|
||||
for (String line in await file.readAsLines()) {
|
||||
for (final String line in await file.readAsLines()) {
|
||||
if (line.contains(todoPattern))
|
||||
total += todoCost;
|
||||
if (line.contains(ignorePattern))
|
||||
@@ -60,7 +60,7 @@ Future<int> findGlobalsForFile(File file) async {
|
||||
if (path.extension(file.path) != '.dart')
|
||||
return 0;
|
||||
int total = 0;
|
||||
for (String line in await file.readAsLines()) {
|
||||
for (final String line in await file.readAsLines()) {
|
||||
if (line.contains(globalsPattern))
|
||||
total += 1;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ Future<double> findCostsForRepo() async {
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
double total = 0.0;
|
||||
await for (String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()))
|
||||
await for (final String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()))
|
||||
total += await findCostsForFile(File(path.join(flutterDirectory.path, entry)));
|
||||
final int gitExitCode = await git.exitCode;
|
||||
if (gitExitCode != 0)
|
||||
@@ -89,7 +89,7 @@ Future<int> findGlobalsForTool() async {
|
||||
workingDirectory: flutterDirectory.path,
|
||||
);
|
||||
int total = 0;
|
||||
await for (String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()))
|
||||
await for (final String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()))
|
||||
total += await findGlobalsForFile(File(path.join(flutterDirectory.path, entry)));
|
||||
final int gitExitCode = await git.exitCode;
|
||||
if (gitExitCode != 0)
|
||||
|
||||
@@ -37,7 +37,7 @@ Future<void> main() async {
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter());
|
||||
|
||||
await for (String line in lines) {
|
||||
await for (final String line in lines) {
|
||||
print(line);
|
||||
if (line.contains('ERROR caught by framework')) {
|
||||
passed = true;
|
||||
|
||||
@@ -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` '
|
||||
|
||||
@@ -50,7 +50,7 @@ class GalleryTransitionTest {
|
||||
file('${galleryDirectory.path}/build/transition_durations.timeline.json').readAsStringSync(),
|
||||
) as Map<String, dynamic>;
|
||||
final Map<String, List<int>> transitions = <String, List<int>>{};
|
||||
for (String key in original.keys) {
|
||||
for (final String key in original.keys) {
|
||||
transitions[key.replaceAll('/', '')] = List<int>.from(original[key] as List<dynamic>);
|
||||
}
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ class CompileTest {
|
||||
|
||||
final RegExp metricExpression = RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)');
|
||||
final Map<String, dynamic> metrics = <String, dynamic>{};
|
||||
for (Match m in metricExpression.allMatches(compileLog)) {
|
||||
for (final Match m in metricExpression.allMatches(compileLog)) {
|
||||
metrics[_sdkNameToMetricName(m.group(1))] = int.parse(m.group(2));
|
||||
}
|
||||
if (metrics.length != _kSdkNameToMetricNameMapping.length) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
/// Combines several TaskFunctions with trivial success value into one.
|
||||
TaskFunction combine(List<TaskFunction> tasks) {
|
||||
return () async {
|
||||
for (TaskFunction task in tasks) {
|
||||
for (final TaskFunction task in tasks) {
|
||||
final TaskResult result = await task();
|
||||
if (result.failed) {
|
||||
return result;
|
||||
|
||||
@@ -120,14 +120,14 @@ Future<void> saveCatalogScreenshots({
|
||||
String prefix, // Prefix for all file names.
|
||||
}) async {
|
||||
final List<String> screenshots = <String>[
|
||||
for (FileSystemEntity entity in directory.listSync())
|
||||
for (final FileSystemEntity entity in directory.listSync())
|
||||
if (entity is File && entity.path.endsWith('.png'))
|
||||
entity.path,
|
||||
];
|
||||
|
||||
final List<String> largeNames = <String>[]; // Cloud storage names for the full res screenshots.
|
||||
final List<String> smallNames = <String>[]; // Likewise for the scaled down screenshots.
|
||||
for (String path in screenshots) {
|
||||
for (final String path in screenshots) {
|
||||
final String name = screenshotName(path);
|
||||
largeNames.add('$commit/$prefix$name.png');
|
||||
smallNames.add('$commit/$prefix${name}_small.png');
|
||||
|
||||
@@ -19,7 +19,7 @@ void main() {
|
||||
expect(task.stage, 'devicelab');
|
||||
expect(task.requiredAgentCapabilities, <String>['linux/android']);
|
||||
|
||||
for (ManifestTask task in manifest.tasks) {
|
||||
for (final ManifestTask task in manifest.tasks) {
|
||||
final File taskFile = File('bin/tasks/${task.name}.dart');
|
||||
expect(taskFile.existsSync(), true,
|
||||
reason: 'File ${taskFile.path} corresponding to manifest task "${task.name}" not found');
|
||||
|
||||
@@ -19,7 +19,7 @@ void main() {
|
||||
final ProcessResult scriptProcess = processManager.runSync(<String>[
|
||||
dart,
|
||||
'bin/run.dart',
|
||||
for (String testName in testNames) ...<String>['-t', testName],
|
||||
for (final String testName in testNames) ...<String>['-t', testName],
|
||||
]);
|
||||
return scriptProcess;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user