enable lint avoid_function_literals_in_foreach_calls (#12607)
This commit is contained in:
parent
79fbf8bb03
commit
700dc9f752
@ -80,7 +80,7 @@ linter:
|
||||
# - avoid_catches_without_on_clauses # not yet tested
|
||||
# - avoid_catching_errors # not yet tested
|
||||
# - avoid_classes_with_only_static_members # not yet tested
|
||||
# - avoid_function_literals_in_foreach_calls # not yet tested
|
||||
- avoid_function_literals_in_foreach_calls
|
||||
- avoid_init_to_null
|
||||
- avoid_null_checks_in_equality_operators
|
||||
# - avoid_positional_boolean_parameters # not yet tested
|
||||
|
@ -74,7 +74,7 @@ linter:
|
||||
# - avoid_catches_without_on_clauses # not yet tested
|
||||
# - avoid_catching_errors # not yet tested
|
||||
# - avoid_classes_with_only_static_members # not yet tested
|
||||
# - avoid_function_literals_in_foreach_calls # not yet tested
|
||||
- avoid_function_literals_in_foreach_calls
|
||||
- avoid_init_to_null
|
||||
- avoid_null_checks_in_equality_operators
|
||||
# - avoid_positional_boolean_parameters # not yet tested
|
||||
|
@ -120,12 +120,12 @@ Future<Null> saveCatalogScreenshots({
|
||||
String prefix, // Prefix for all file names.
|
||||
}) async {
|
||||
final List<String> screenshots = <String>[];
|
||||
directory.listSync().forEach((FileSystemEntity entity) {
|
||||
for (FileSystemEntity entity in directory.listSync()) {
|
||||
if (entity is File && entity.path.endsWith('.png')) {
|
||||
final File file = entity;
|
||||
screenshots.add(file.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.
|
||||
|
@ -146,13 +146,13 @@ void generate(String commit) {
|
||||
initialize();
|
||||
|
||||
final List<SampleInfo> samples = <SampleInfo>[];
|
||||
sampleDirectory.listSync().forEach((FileSystemEntity entity) {
|
||||
for (FileSystemEntity entity in sampleDirectory.listSync()) {
|
||||
if (entity is File && entity.path.endsWith('.dart')) {
|
||||
final SampleInfo sample = new SampleInfo(entity, commit);
|
||||
if (sample.initialize()) // skip files that lack the Sample Catalog comment
|
||||
samples.add(sample);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Causes the generated imports to appear in alphabetical order.
|
||||
// Avoid complaints from flutter lint.
|
||||
|
@ -74,7 +74,8 @@ class TestRoute extends LocalHistoryRoute<String> {
|
||||
@override
|
||||
void dispose() {
|
||||
log('dispose');
|
||||
_entries.forEach((OverlayEntry entry) { entry.remove(); });
|
||||
for (OverlayEntry entry in _entries)
|
||||
entry.remove();
|
||||
_entries.clear();
|
||||
routes.remove(this);
|
||||
super.dispose();
|
||||
|
@ -64,12 +64,12 @@ void main() {
|
||||
|
||||
expect(find.text(expectedMonthYearHeader), findsOneWidget);
|
||||
|
||||
expectedDaysOfWeek.forEach((String dayOfWeek) {
|
||||
for (String dayOfWeek in expectedDaysOfWeek) {
|
||||
expect(find.text(dayOfWeek), findsWidgets);
|
||||
});
|
||||
}
|
||||
|
||||
Offset previousCellOffset;
|
||||
expectedDaysOfMonth.forEach((String dayOfMonth) {
|
||||
for (String dayOfMonth in expectedDaysOfMonth) {
|
||||
final Finder dayCell = find.descendant(of: find.byType(GridView), matching: find.text(dayOfMonth));
|
||||
expect(dayCell, findsOneWidget);
|
||||
|
||||
@ -84,7 +84,7 @@ void main() {
|
||||
}
|
||||
}
|
||||
previousCellOffset = offset;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -100,7 +100,7 @@ Future<GradleProject> _readGradleProject() async {
|
||||
if (flutterPluginVersion == FlutterPluginVersion.managed) {
|
||||
// Handle known exceptions. This will exit if handled.
|
||||
handleKnownGradleExceptions(e);
|
||||
|
||||
|
||||
// Print a general Gradle error and exit.
|
||||
printError('* Error running Gradle:\n$e\n');
|
||||
throwToolExit('Please review your Gradle project setup in the android/ folder.');
|
||||
@ -355,14 +355,14 @@ class GradleProject {
|
||||
|
||||
// Extract build types and product flavors.
|
||||
final Set<String> variants = new Set<String>();
|
||||
properties.split('\n').forEach((String s) {
|
||||
for (String s in properties.split('\n')) {
|
||||
final Match match = _assembleTaskPattern.matchAsPrefix(s);
|
||||
if (match != null) {
|
||||
final String variant = match.group(1).toLowerCase();
|
||||
if (!variant.endsWith('test'))
|
||||
variants.add(variant);
|
||||
}
|
||||
});
|
||||
}
|
||||
final Set<String> buildTypes = new Set<String>();
|
||||
final Set<String> productFlavors = new Set<String>();
|
||||
for (final String variant1 in variants) {
|
||||
|
@ -82,7 +82,7 @@ void copyDirectorySync(Directory srcDir, Directory destDir, [void onFileCopied(F
|
||||
if (!destDir.existsSync())
|
||||
destDir.createSync(recursive: true);
|
||||
|
||||
srcDir.listSync().forEach((FileSystemEntity entity) {
|
||||
for (FileSystemEntity entity in srcDir.listSync()) {
|
||||
final String newPath = destDir.fileSystem.path.join(destDir.path, entity.basename);
|
||||
if (entity is File) {
|
||||
final File newFile = destDir.fileSystem.file(newPath);
|
||||
@ -94,7 +94,7 @@ void copyDirectorySync(Directory srcDir, Directory destDir, [void onFileCopied(F
|
||||
} else {
|
||||
throw new Exception('${entity.path} is neither File nor Directory');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets a directory to act as a recording destination, creating the directory
|
||||
|
@ -132,22 +132,22 @@ class PackageDependencyTracker {
|
||||
final File dotPackages = fs.file(dotPackagesPath);
|
||||
if (dotPackages.existsSync()) {
|
||||
// this directory has opinions about what we should be using
|
||||
dotPackages
|
||||
final Iterable<String> lines = dotPackages
|
||||
.readAsStringSync()
|
||||
.split('\n')
|
||||
.where((String line) => !line.startsWith(new RegExp(r'^ *#')))
|
||||
.forEach((String line) {
|
||||
final int colon = line.indexOf(':');
|
||||
if (colon > 0) {
|
||||
final String packageName = line.substring(0, colon);
|
||||
final String packagePath = fs.path.fromUri(line.substring(colon+1));
|
||||
// Ensure that we only add `analyzer` and dependent packages defined in the vended SDK (and referred to with a local
|
||||
// fs.path. directive). Analyzer package versions reached via transitive dependencies (e.g., via `test`) are ignored
|
||||
// since they would produce spurious conflicts.
|
||||
if (!_vendedSdkPackages.contains(packageName) || packagePath.startsWith('..'))
|
||||
add(packageName, fs.path.normalize(fs.path.absolute(directory.path, packagePath)), dotPackagesPath);
|
||||
}
|
||||
});
|
||||
.where((String line) => !line.startsWith(new RegExp(r'^ *#')));
|
||||
for (String line in lines) {
|
||||
final int colon = line.indexOf(':');
|
||||
if (colon > 0) {
|
||||
final String packageName = line.substring(0, colon);
|
||||
final String packagePath = fs.path.fromUri(line.substring(colon+1));
|
||||
// Ensure that we only add `analyzer` and dependent packages defined in the vended SDK (and referred to with a local
|
||||
// fs.path. directive). Analyzer package versions reached via transitive dependencies (e.g., via `test`) are ignored
|
||||
// since they would produce spurious conflicts.
|
||||
if (!_vendedSdkPackages.contains(packageName) || packagePath.startsWith('..'))
|
||||
add(packageName, fs.path.normalize(fs.path.absolute(directory.path, packagePath)), dotPackagesPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,8 @@ class Daemon {
|
||||
|
||||
void shutdown({dynamic error}) {
|
||||
_commandSubscription?.cancel();
|
||||
_domainMap.values.forEach((Domain domain) => domain.dispose());
|
||||
for (Domain domain in _domainMap.values)
|
||||
domain.dispose();
|
||||
if (!_onExitCompleter.isCompleted) {
|
||||
if (error == null)
|
||||
_onExitCompleter.complete(0);
|
||||
|
@ -636,7 +636,8 @@ class VM extends ServiceObjectOwner {
|
||||
void _removeDeadIsolates(List<Isolate> newIsolates) {
|
||||
// Build a set of new isolates.
|
||||
final Set<String> newIsolateSet = new Set<String>();
|
||||
newIsolates.forEach((Isolate iso) => newIsolateSet.add(iso.id));
|
||||
for (Isolate iso in newIsolates)
|
||||
newIsolateSet.add(iso.id);
|
||||
|
||||
// Remove any old isolates which no longer exist.
|
||||
final List<String> toRemove = <String>[];
|
||||
|
@ -15,39 +15,37 @@ void main() {
|
||||
bool _isNotWhitelisted(FileSystemEntity entity) => entity.path != whitelistedPath;
|
||||
|
||||
for (String dirName in <String>['lib', 'bin']) {
|
||||
fs.directory(fs.path.join(flutterTools, dirName))
|
||||
final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName))
|
||||
.listSync(recursive: true)
|
||||
.where(_isDartFile)
|
||||
.where(_isNotWhitelisted)
|
||||
.map(_asFile)
|
||||
.forEach((File file) {
|
||||
for (String line in file.readAsLinesSync()) {
|
||||
if (line.startsWith(new RegExp(r'import.*dart:io')) &&
|
||||
!line.contains('ignore: dart_io_import')) {
|
||||
final String relativePath = fs.path.relative(file.path, from:flutterTools);
|
||||
fail("$relativePath imports 'dart:io'; import 'lib/src/base/io.dart' instead");
|
||||
}
|
||||
.map(_asFile);
|
||||
for (File file in files) {
|
||||
for (String line in file.readAsLinesSync()) {
|
||||
if (line.startsWith(new RegExp(r'import.*dart:io')) &&
|
||||
!line.contains('ignore: dart_io_import')) {
|
||||
final String relativePath = fs.path.relative(file.path, from:flutterTools);
|
||||
fail("$relativePath imports 'dart:io'; import 'lib/src/base/io.dart' instead");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('no unauthorized imports of package:path', () {
|
||||
for (String dirName in <String>['lib', 'bin', 'test']) {
|
||||
fs.directory(fs.path.join(flutterTools, dirName))
|
||||
final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName))
|
||||
.listSync(recursive: true)
|
||||
.where(_isDartFile)
|
||||
.map(_asFile)
|
||||
.forEach((File file) {
|
||||
for (String line in file.readAsLinesSync()) {
|
||||
if (line.startsWith(new RegExp(r'import.*package:path/path.dart'))) {
|
||||
final String relativePath = fs.path.relative(file.path, from:flutterTools);
|
||||
fail("$relativePath imports 'package:path/path.dart'; use 'fs.path' instead");
|
||||
}
|
||||
.map(_asFile);
|
||||
for (File file in files) {
|
||||
for (String line in file.readAsLinesSync()) {
|
||||
if (line.startsWith(new RegExp(r'import.*package:path/path.dart'))) {
|
||||
final String relativePath = fs.path.relative(file.path, from:flutterTools);
|
||||
fail("$relativePath imports 'package:path/path.dart'; use 'fs.path' instead");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user