Update collection-fors to prefer final (as per updated prefer_final_in_for_each) (#127511)

The newly updated lint will soon flag for-each in collections.

See discussion: https://github.com/dart-lang/linter/pull/4383

/cc @goderbauer
This commit is contained in:
Phil Quitslund
2023-05-26 16:34:36 -07:00
committed by GitHub
parent 1a062a0978
commit 5bf6318688
25 changed files with 32 additions and 32 deletions

View File

@@ -930,7 +930,7 @@ Iterable<String> listApkPaths(
];
if (androidBuildInfo.splitPerAbi) {
return <String>[
for (AndroidArch androidArch in androidBuildInfo.targetArchs)
for (final AndroidArch androidArch in androidBuildInfo.targetArchs)
<String>[
'app',
androidArch.archName,

View File

@@ -597,7 +597,7 @@ class ManifestAssetBundle implements AssetBundle {
if (packageName == null)
...manifest.fontsDescriptor
else
for (Font font in _parsePackageFonts(
for (final Font font in _parsePackageFonts(
manifest,
packageName,
packageConfig,

View File

@@ -324,7 +324,7 @@ class BuildInfo {
'-Pbundle-sksl-path=$bundleSkSLPath',
if (codeSizeDirectory != null)
'-Pcode-size-directory=$codeSizeDirectory',
for (String projectArg in androidProjectArgs)
for (final String projectArg in androidProjectArgs)
'-P$projectArg',
];
if (dartDefineConfigJsonMap != null) {

View File

@@ -178,7 +178,7 @@ class SourceVisitor implements ResolvedFiles {
.getArtifactPath(artifact, platform: platform, mode: mode);
if (environment.fileSystem.isDirectorySync(path)) {
sources.addAll(<File>[
for (FileSystemEntity entity in environment.fileSystem.directory(path).listSync(recursive: true))
for (final FileSystemEntity entity in environment.fileSystem.directory(path).listSync(recursive: true))
if (entity is File)
entity,
]);
@@ -206,7 +206,7 @@ class SourceVisitor implements ResolvedFiles {
final FileSystemEntity entity = environment.artifacts.getHostArtifact(artifact);
if (entity is Directory) {
sources.addAll(<File>[
for (FileSystemEntity entity in entity.listSync(recursive: true))
for (final FileSystemEntity entity in entity.listSync(recursive: true))
if (entity is File)
entity,
]);

View File

@@ -665,7 +665,7 @@ Future<void> _createStubAppFramework(File outputFile, Environment environment,
await globals.xcode!.clang(<String>[
'-x',
'c',
for (String arch in iosArchNames ?? <String>{}) ...<String>['-arch', arch],
for (final String arch in iosArchNames ?? <String>{}) ...<String>['-arch', arch],
stubSource.path,
'-dynamiclib',
// Keep version in sync with AOTSnapshotter flag

View File

@@ -74,12 +74,12 @@ class GenerateLocalizationsTarget extends Target {
<File>[
configFile,
if (inputs != null)
for (Object inputFile in inputs.whereType<Object>())
for (final Object inputFile in inputs.whereType<Object>())
environment.fileSystem.file(inputFile),
],
<File>[
if (outputs != null)
for (Object outputFile in outputs.whereType<Object>())
for (final Object outputFile in outputs.whereType<Object>())
environment.fileSystem.file(outputFile),
],
);

View File

@@ -1290,7 +1290,7 @@ String flattenNameSubdirs(Uri url, FileSystem fileSystem) {
/// something that doesn't.
String _flattenNameNoSubdirs(String fileName) {
final List<int> replacedCodeUnits = <int>[
for (int codeUnit in fileName.codeUnits)
for (final int codeUnit in fileName.codeUnits)
..._flattenNameSubstitutions[codeUnit] ?? <int>[codeUnit],
];
return String.fromCharCodes(replacedCodeUnits);

View File

@@ -147,7 +147,7 @@ abstract class BuildFrameworkCommand extends BuildSubCommand {
'xcrun',
'xcodebuild',
'-create-xcframework',
for (Directory framework in frameworks) ...<String>[
for (final Directory framework in frameworks) ...<String>[
'-framework',
framework.path,
...framework.parent

View File

@@ -682,7 +682,7 @@ Your $application code is in $relativeAppMain.
List<String> _getSupportedPlatformsFromTemplateContext(Map<String, Object?> templateContext) {
return <String>[
for (String platform in kAllCreatePlatforms)
for (final String platform in kAllCreatePlatforms)
if (templateContext[platform] == true) platform,
];
}

View File

@@ -64,7 +64,7 @@ class LinuxDoctorValidator extends DoctorValidator {
final Map<String, _VersionInfo?> installedVersions = <String, _VersionInfo?>{
// Sort the check to make the call order predictable for unit tests.
for (String binary in _requiredBinaryVersions.keys.toList()..sort())
for (final String binary in _requiredBinaryVersions.keys.toList()..sort())
binary: await _getBinaryVersion(binary),
};

View File

@@ -211,7 +211,7 @@ void main() {
FakeRequest(Uri.parse('http://localhost'), method: HttpMethod.put, responseError: const OSError('Connection Reset by peer')),
FakeRequest(Uri.parse('http://localhost'), method: HttpMethod.put, responseError: const OSError('Connection Reset by peer')),
// This is the value of `<int>[1, 2, 3, 4, 5]` run through `osUtils.gzipLevel1Stream`.
FakeRequest(Uri.parse('http://localhost'), method: HttpMethod.put, body: <int>[for (List<int> chunk in expectedEncoded) ...chunk]),
FakeRequest(Uri.parse('http://localhost'), method: HttpMethod.put, body: <int>[for (final List<int> chunk in expectedEncoded) ...chunk]),
]),
uploadRetryThrottle: Duration.zero,
);

View File

@@ -737,7 +737,7 @@ void main() {
method: kListViewsMethod,
jsonResponse: <String, Object>{
'views': <Object>[
for (FlutterView view in views) view.toJson(),
for (final FlutterView view in views) view.toJson(),
],
},
),