enable lint prefer_final_in_for_each (#47724)
This commit is contained in:
committed by
GitHub
parent
fa337f5922
commit
4f9b6cf017
@@ -68,7 +68,7 @@ class _AndroidBuilderImpl extends AndroidBuilder {
|
||||
// Module projects artifacts are located in `build/host`.
|
||||
outputDirectory = outputDirectory.childDirectory('host');
|
||||
}
|
||||
for (AndroidBuildInfo androidBuildInfo in androidBuildInfo) {
|
||||
for (final AndroidBuildInfo androidBuildInfo in androidBuildInfo) {
|
||||
await buildGradleAar(
|
||||
project: project,
|
||||
androidBuildInfo: androidBuildInfo,
|
||||
|
||||
@@ -732,7 +732,7 @@ class AndroidDevice extends Device {
|
||||
Map<String, String> parseAdbDeviceProperties(String str) {
|
||||
final Map<String, String> properties = <String, String>{};
|
||||
final RegExp propertyExp = RegExp(r'\[(.*?)\]: \[(.*?)\]');
|
||||
for (Match match in propertyExp.allMatches(str)) {
|
||||
for (final Match match in propertyExp.allMatches(str)) {
|
||||
properties[match.group(1)] = match.group(2);
|
||||
}
|
||||
return properties;
|
||||
@@ -932,7 +932,7 @@ void parseADBDeviceOutput(
|
||||
return;
|
||||
}
|
||||
|
||||
for (String line in text.trim().split('\n')) {
|
||||
for (final String line in text.trim().split('\n')) {
|
||||
// Skip lines like: * daemon started successfully *
|
||||
if (line.startsWith('* daemon ')) {
|
||||
continue;
|
||||
@@ -958,7 +958,7 @@ void parseADBDeviceOutput(
|
||||
final Map<String, String> info = <String, String>{};
|
||||
if (rest != null && rest.isNotEmpty) {
|
||||
rest = rest.trim();
|
||||
for (String data in rest.split(' ')) {
|
||||
for (final String data in rest.split(' ')) {
|
||||
if (data.contains(':')) {
|
||||
final List<String> fields = data.split(':');
|
||||
info[fields[0]] = fields[1];
|
||||
@@ -1165,7 +1165,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder {
|
||||
}
|
||||
|
||||
final List<String> lines = LineSplitter.split(stdout).toList();
|
||||
for (String line in lines) {
|
||||
for (final String line in lines) {
|
||||
if (!line.startsWith(device.id)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1260,7 +1260,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder {
|
||||
|
||||
@override
|
||||
Future<void> dispose() async {
|
||||
for (ForwardedPort port in forwardedPorts) {
|
||||
for (final ForwardedPort port in forwardedPorts) {
|
||||
await unforward(port);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ List<AndroidEmulator> getEmulatorAvds() {
|
||||
/// Parse the given `emulator -list-avds` output in [text], and fill out the given list
|
||||
/// of emulators by reading information from the relevant ini files.
|
||||
void extractEmulatorAvdInfo(String text, List<AndroidEmulator> emulators) {
|
||||
for (String id in text.trim().split('\n').where((String l) => l != '')) {
|
||||
for (final String id in text.trim().split('\n').where((String l) => l != '')) {
|
||||
emulators.add(_loadEmulatorInfo(id));
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ Map<String, String> parseIniLines(List<String> contents) {
|
||||
// Split into name/value
|
||||
.map<List<String>>((String l) => l.split('='));
|
||||
|
||||
for (List<String> property in properties) {
|
||||
for (final List<String> property in properties) {
|
||||
results[property[0].trim()] = property[1].trim();
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ class AndroidNdk {
|
||||
.map<String>((String line) => line.trim())
|
||||
.where((String line) => line.isNotEmpty);
|
||||
final Map<String, String> properties = <String, String>{};
|
||||
for (String line in propertiesFileLines) {
|
||||
for (final String line in propertiesFileLines) {
|
||||
final List<String> parts = line.split(' = ');
|
||||
if (parts.length == 2) {
|
||||
properties[parts[0]] = parts[1];
|
||||
|
||||
@@ -183,7 +183,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
|
||||
.directory(path)
|
||||
.listSync(followLinks: false)
|
||||
.whereType<Directory>();
|
||||
for (Directory directory in directories) {
|
||||
for (final Directory directory in directories) {
|
||||
final String name = directory.basename;
|
||||
// An exact match, or something like 'Android Studio 3.0 Preview.app'.
|
||||
if (name.startsWith('Android Studio') && name.endsWith('.app')) {
|
||||
@@ -236,7 +236,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
|
||||
// Read all $HOME/.AndroidStudio*/system/.home files. There may be several
|
||||
// pointing to the same installation, so we grab only the latest one.
|
||||
if (homeDirPath != null && globals.fs.directory(homeDirPath).existsSync()) {
|
||||
for (FileSystemEntity entity in globals.fs.directory(homeDirPath).listSync(followLinks: false)) {
|
||||
for (final FileSystemEntity entity in globals.fs.directory(homeDirPath).listSync(followLinks: false)) {
|
||||
if (entity is Directory && entity.basename.startsWith('.AndroidStudio')) {
|
||||
final AndroidStudio studio = AndroidStudio.fromHomeDot(entity);
|
||||
if (studio != null && !_hasStudioAt(studio.directory, newerThan: studio.version)) {
|
||||
|
||||
@@ -116,7 +116,7 @@ bool _isSupportedVersion(AndroidProject project) {
|
||||
if (!appGradle.existsSync()) {
|
||||
return false;
|
||||
}
|
||||
for (String line in appGradle.readAsLinesSync()) {
|
||||
for (final String line in appGradle.readAsLinesSync()) {
|
||||
if (line.contains(RegExp(r'apply from: .*/flutter.gradle')) ||
|
||||
line.contains("def flutterPluginVersion = 'managed'")) {
|
||||
return true;
|
||||
@@ -184,7 +184,7 @@ void createSettingsAarGradle(Directory androidDirectory) {
|
||||
existingVariants.add(settingsAarContent);
|
||||
|
||||
bool exactMatch = false;
|
||||
for (String fileContentVariant in existingVariants) {
|
||||
for (final String fileContentVariant in existingVariants) {
|
||||
if (currentFileContent.trim() == fileContentVariant.trim()) {
|
||||
exactMatch = true;
|
||||
break;
|
||||
@@ -465,7 +465,7 @@ Future<void> buildGradleApp({
|
||||
final File apkShaFile = apkDirectory.childFile('app.apk.sha1');
|
||||
apkShaFile.writeAsStringSync(_calculateSha(apkFiles.first));
|
||||
|
||||
for (File apkFile in apkFiles) {
|
||||
for (final File apkFile in apkFiles) {
|
||||
final String appSize = (buildInfo.mode == BuildMode.debug)
|
||||
? '' // Don't display the size when building a debug variant.
|
||||
: ' (${getSizeAsMB(apkFile.lengthSync())})';
|
||||
@@ -618,7 +618,7 @@ ${globals.terminal.bolden('Consuming the Module')}
|
||||
|
||||
dependencies {''');
|
||||
|
||||
for (String buildMode in buildModes) {
|
||||
for (final String buildMode in buildModes) {
|
||||
globals.printStatus('''
|
||||
${buildMode}Implementation '$androidPackage:flutter_$buildMode:$buildNumber''');
|
||||
}
|
||||
@@ -647,7 +647,7 @@ ${globals.terminal.bolden('Consuming the Module')}
|
||||
|
||||
String _hex(List<int> bytes) {
|
||||
final StringBuffer result = StringBuffer();
|
||||
for (int part in bytes) {
|
||||
for (final int part in bytes) {
|
||||
result.write('${part < 16 ? '0' : ''}${part.toRadixString(16)}');
|
||||
}
|
||||
return result.toString();
|
||||
@@ -707,7 +707,7 @@ Future<void> buildPluginsAsAar(
|
||||
return;
|
||||
}
|
||||
final List<String> plugins = flutterPluginFile.readAsStringSync().split('\n');
|
||||
for (String plugin in plugins) {
|
||||
for (final String plugin in plugins) {
|
||||
final List<String> pluginParts = plugin.split('=');
|
||||
if (pluginParts.length != 2) {
|
||||
continue;
|
||||
@@ -882,7 +882,7 @@ String _getLocalArtifactVersion(String pomPath) {
|
||||
}
|
||||
final Iterable<xml.XmlElement> project = document.findElements('project');
|
||||
assert(project.isNotEmpty);
|
||||
for (xml.XmlElement versionElement in document.findAllElements('version')) {
|
||||
for (final xml.XmlElement versionElement in document.findAllElements('version')) {
|
||||
if (versionElement.parent == project.first) {
|
||||
return versionElement.text;
|
||||
}
|
||||
@@ -919,7 +919,7 @@ Directory _getLocalEngineRepo({
|
||||
'flutter_embedding_$buildMode.pom',
|
||||
)
|
||||
);
|
||||
for (String artifact in const <String>['pom', 'jar']) {
|
||||
for (final String artifact in const <String>['pom', 'jar']) {
|
||||
// The Android embedding artifacts.
|
||||
_createSymlink(
|
||||
globals.fs.path.join(
|
||||
|
||||
@@ -283,7 +283,7 @@ final GradleHandledError flavorUndefinedHandler = GradleHandledError(
|
||||
);
|
||||
// Extract build types and product flavors.
|
||||
final Set<String> variants = <String>{};
|
||||
for (String task in tasksRunResult.stdout.split('\n')) {
|
||||
for (final String task in tasksRunResult.stdout.split('\n')) {
|
||||
final Match match = _assembleTaskPattern.matchAsPrefix(task);
|
||||
if (match != null) {
|
||||
final String variant = match.group(1).toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user