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