Enable unnecessary_await_in_return lint (#77434)

This commit is contained in:
Michael Goderbauer
2021-03-05 18:38:15 -08:00
committed by GitHub
parent 8a9042ba91
commit cb867bbedc
91 changed files with 183 additions and 183 deletions

View File

@@ -1203,7 +1203,7 @@ Future<EvalResult> _evalCommand(String executable, List<String> arguments, {
Future<void> _runFlutterAnalyze(String workingDirectory, {
List<String> options = const <String>[],
}) async {
return await runCommand(
return runCommand(
flutter,
<String>['analyze', '--dartdocs', ...options],
workingDirectory: workingDirectory,
@@ -1214,7 +1214,7 @@ final RegExp _importPattern = RegExp(r'''^\s*import (['"])package:flutter/([^.]+
final RegExp _importMetaPattern = RegExp(r'''^\s*import (['"])package:meta/meta\.dart\1''');
Future<Set<String>> _findFlutterDependencies(String srcPath, List<String> errors, { bool checkForMeta = false }) async {
return await _allFiles(srcPath, 'dart', minimumMatches: 1)
return _allFiles(srcPath, 'dart', minimumMatches: 1)
.map<Set<String>>((File file) {
final Set<String> result = <String>{};
for (final String line in file.readAsLinesSync()) {

View File

@@ -669,7 +669,7 @@ class ArchivePublisher {
if (dest.endsWith('.json')) {
mimeType = 'application/json';
}
return await _runGsUtil(<String>[
return _runGsUtil(<String>[
// Use our preferred MIME type for the files we care about
// and let gsutil figure it out for anything else.
if (mimeType != null) ...<String>['-h', 'Content-Type:$mimeType'],

View File

@@ -377,7 +377,7 @@ void main() {
'$gsutilCall -- stat $gsArchivePath': <ProcessResult>[ProcessResult(0, 0, '', '')],
};
processManager.fakeResults = calls;
expect(() async => await publisher.publishArchive(false), throwsException);
expect(() async => publisher.publishArchive(false), throwsException);
processManager.verifyCalls(calls.keys.toList());
});

View File

@@ -383,7 +383,7 @@ class ArchiveUnpublisher {
if (mimeType != null) ...<String>['-h', 'Content-Type:$mimeType'],
...<String>['cp', src, dest],
];
return await _runGsUtil(args, confirm: confirmed);
return _runGsUtil(args, confirm: confirmed);
}
}

View File

@@ -38,7 +38,7 @@ class NewGalleryWebCompileTest {
() async {
await flutter('doctor');
return await WebCompileTest.runSingleBuildTest(
return WebCompileTest.runSingleBuildTest(
directory: galleryDir.path,
metric: metricKeyPrefix,
measureBuildTime: true,

View File

@@ -33,6 +33,6 @@ Future<void> main() async {
});
final TaskFunction taskFunction = createPlatformViewStartupTest();
return await taskFunction();
return taskFunction();
});
}

View File

@@ -22,7 +22,7 @@ void main() {
final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui'));
section('TEST WHETHER `flutter drive --route` WORKS');
await inDirectory(appDir, () async {
return await flutter(
return flutter(
'drive',
options: <String>['--verbose', '-d', device.deviceId, '--route', '/smuggle-it', 'lib/route.dart'],
canFail: false,

View File

@@ -8,6 +8,6 @@ import 'package:flutter_devicelab/tasks/web_benchmarks.dart';
/// Runs all Web benchmarks using the CanvasKit rendering backend.
Future<void> main() async {
await task(() async {
return await runWebBenchmark(useCanvasKit: true);
return runWebBenchmark(useCanvasKit: true);
});
}

View File

@@ -8,6 +8,6 @@ import 'package:flutter_devicelab/tasks/web_benchmarks.dart';
/// Runs all Web benchmarks using the HTML rendering backend.
Future<void> main() async {
await task(() async {
return await runWebBenchmark(useCanvasKit: false);
return runWebBenchmark(useCanvasKit: false);
});
}

View File

@@ -210,7 +210,7 @@ class ApkExtractor {
/// Gets the content of the `AndroidManifest.xml`.
Future<String> getAndroidManifest(String apk) async {
return await _evalApkAnalyzer(
return _evalApkAnalyzer(
<String>[
'manifest',
'print',

View File

@@ -750,7 +750,7 @@ Future<int> gitClone({String path, String repo}) async {
await Directory(path).create(recursive: true);
return await inDirectory<int>(
return inDirectory<int>(
path,
() => exec('git', <String>['clone', repo]),
);

View File

@@ -35,13 +35,13 @@ TaskFunction createMicrobenchmarkTask() {
device.deviceId,
];
options.add(benchmarkPath);
return await _startFlutter(
return _startFlutter(
options: options,
canFail: false,
);
});
return await _readJsonResults(flutterProcess);
return _readJsonResults(flutterProcess);
}
return _run();
}

View File

@@ -29,7 +29,7 @@ class NewGalleryPerfTest extends PerfTest {
// turns out to be updated frequently in the future, we can set up an auto
// roller to update this version.
await getNewGallery(galleryVersion, galleryDir);
return await super.run();
return super.run();
}
final Directory galleryDir;

View File

@@ -486,7 +486,7 @@ class StartupTest {
final bool reportMetrics;
Future<TaskResult> run() async {
return await inDirectory<TaskResult>(testDirectory, () async {
return inDirectory<TaskResult>(testDirectory, () async {
final Device device = await devices.workingDevice;
const int iterations = 5;
final List<Map<String, dynamic>> results = <Map<String, dynamic>>[];
@@ -995,7 +995,7 @@ class CompileTest {
final bool reportPackageContentSizes;
Future<TaskResult> run() async {
return await inDirectory<TaskResult>(testDirectory, () async {
return inDirectory<TaskResult>(testDirectory, () async {
final Device device = await devices.workingDevice;
await device.unlock();
await flutter('packages', options: <String>['get']);

View File

@@ -25,7 +25,7 @@ Future<TaskResult> runWebBenchmark({ @required bool useCanvasKit }) async {
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
Logger.root.level = Level.INFO;
final String macrobenchmarksDirectory = path.join(flutterDirectory.path, 'dev', 'benchmarks', 'macrobenchmarks');
return await inDirectory(macrobenchmarksDirectory, () async {
return inDirectory(macrobenchmarksDirectory, () async {
await evalFlutter('build', options: <String>[
'web',
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',

View File

@@ -116,7 +116,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
final ThemeData theme = Theme.of(context);
final TextStyle dialogTextStyle = theme.textTheme.subtitle1!.copyWith(color: theme.textTheme.caption!.color);
return await (showDialog<bool>(
return showDialog<bool>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
@@ -140,7 +140,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
],
);
},
) as Future<bool>);
) as Future<bool>;
}
@override

View File

@@ -143,7 +143,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
if (form == null || !_formWasEdited || form.validate())
return true;
return await (showDialog<bool>(
return showDialog<bool>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
@@ -161,7 +161,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
],
);
},
) as Future<bool>);
) as Future<bool>;
}
@override

View File

@@ -38,7 +38,7 @@ Future<String> getAndroidKeyCodes() async {
Future<String> getWindowsKeyCodes() async {
final Uri keyCodesUri = Uri.parse('https://raw.githubusercontent.com/tpn/winsdk-10/master/Include/10.0.10240.0/um/WinUser.h');
return await http.read(keyCodesUri);
return http.read(keyCodesUri);
}
/// Get contents of the file that contains the scan codes in Android source.
@@ -54,12 +54,12 @@ Future<String> getAndroidScanCodes() async {
Future<String> getGlfwKeyCodes() async {
final Uri keyCodesUri = Uri.parse('https://raw.githubusercontent.com/glfw/glfw/master/include/GLFW/glfw3.h');
return await http.read(keyCodesUri);
return http.read(keyCodesUri);
}
Future<String> getGtkKeyCodes() async {
final Uri keyCodesUri = Uri.parse('https://gitlab.gnome.org/GNOME/gtk/-/raw/master/gdk/gdkkeysyms.h');
return await http.read(keyCodesUri);
return http.read(keyCodesUri);
}
Future<void> main(List<String> rawArguments) async {

View File

@@ -69,7 +69,7 @@ void main() {
test('throws exception if not run from macos', () async {
createRunner(operatingSystem: 'linux');
expect(
() async => await runner.run(<String>['codesign']),
() async => runner.run(<String>['codesign']),
throwsExceptionWith('Error! Expected operating system "macos"'),
);
});
@@ -77,7 +77,7 @@ void main() {
test('throws exception if verify flag is not provided', () async {
createRunner();
expect(
() async => await runner.run(<String>['codesign']),
() async => runner.run(<String>['codesign']),
throwsExceptionWith(
'Sorry, but codesigning is not implemented yet. Please pass the --$kVerify flag to verify signatures'),
);
@@ -240,7 +240,7 @@ void main() {
...codesignCheckCommands,
]);
expect(
() async => await runner.run(<String>['codesign', '--$kVerify', '--$kRevision', revision]),
() async => runner.run(<String>['codesign', '--$kVerify', '--$kRevision', revision]),
throwsExceptionWith('Test failed because unsigned binaries detected.'),
);
expect(processManager.hasRemainingExpectations, false);
@@ -325,7 +325,7 @@ void main() {
...codesignCheckCommands,
]);
expect(
() async => await runner.run(<String>['codesign', '--$kVerify', '--$kRevision', revision]),
() async => runner.run(<String>['codesign', '--$kVerify', '--$kRevision', revision]),
throwsExceptionWith('Test failed because files found with the wrong entitlements'),
);
expect(processManager.hasRemainingExpectations, false);