Auto-format Framework (#160545)

This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -27,10 +27,7 @@ List<Object?> _makeTestBuffer(int size) {
];
}
Future<double> _runBasicStandardSmall(
BasicMessageChannel<Object?> basicStandard,
int count,
) async {
Future<double> _runBasicStandardSmall(BasicMessageChannel<Object?> basicStandard, int count) async {
final Stopwatch watch = Stopwatch();
watch.start();
for (int i = 0; i < count; ++i) {
@@ -56,8 +53,7 @@ void _runBasicStandardParallelRecurse(
completer.complete(counter.count);
} else if (counter.count < count) {
basicStandard.send(payload).then((Object? result) {
_runBasicStandardParallelRecurse(
basicStandard, counter, count, completer, payload);
_runBasicStandardParallelRecurse(basicStandard, counter, count, completer, payload);
});
}
}
@@ -74,8 +70,7 @@ Future<double> _runBasicStandardParallel(
watch.start();
for (int i = 0; i < parallel; ++i) {
basicStandard.send(payload).then((Object? result) {
_runBasicStandardParallelRecurse(
basicStandard, counter, count, completer, payload);
_runBasicStandardParallelRecurse(basicStandard, counter, count, completer, payload);
});
}
await completer.future;
@@ -92,17 +87,14 @@ Future<double> _runBasicStandardLarge(
final Stopwatch watch = Stopwatch();
watch.start();
for (int i = 0; i < count; ++i) {
final List<Object?>? result =
await basicStandard.send(largeBuffer) as List<Object?>?;
final List<Object?>? result = await basicStandard.send(largeBuffer) as List<Object?>?;
// This check should be tiny compared to the actual channel send/receive.
size += (result == null) ? 0 : result.length;
}
watch.stop();
if (size != largeBuffer.length * count) {
throw Exception(
"There is an error with the echo channel, the results don't add up: $size",
);
throw Exception("There is an error with the echo channel, the results don't add up: $size");
}
return watch.elapsedMicroseconds / count;
@@ -123,9 +115,7 @@ Future<double> _runBasicBinary(
}
watch.stop();
if (size != buffer.lengthInBytes * count) {
throw Exception(
"There is an error with the echo channel, the results don't add up: $size",
);
throw Exception("There is an error with the echo channel, the results don't add up: $size");
}
return watch.elapsedMicroseconds / count;
@@ -153,23 +143,18 @@ Future<void> _runTest({
Future<void> _runTests() async {
if (kDebugMode) {
throw Exception(
"Must be run in profile mode! Use 'flutter run --profile'.",
);
throw Exception("Must be run in profile mode! Use 'flutter run --profile'.");
}
const BasicMessageChannel<Object?> resetChannel =
BasicMessageChannel<Object?>(
const BasicMessageChannel<Object?> resetChannel = BasicMessageChannel<Object?>(
'dev.flutter.echo.reset',
StandardMessageCodec(),
);
const BasicMessageChannel<Object?> basicStandard =
BasicMessageChannel<Object?>(
const BasicMessageChannel<Object?> basicStandard = BasicMessageChannel<Object?>(
'dev.flutter.echo.basic.standard',
StandardMessageCodec(),
);
const BasicMessageChannel<ByteData> basicBinary =
BasicMessageChannel<ByteData>(
const BasicMessageChannel<ByteData> basicBinary = BasicMessageChannel<ByteData>(
'dev.flutter.echo.basic.binary',
BinaryCodec(),
);
@@ -178,8 +163,7 @@ Future<void> _runTests() async {
/// `Large` tests. Instead make a different test. The size of largeBuffer
/// serialized is 14214 bytes.
final List<Object?> largeBuffer = _makeTestBuffer(1000);
final ByteData largeBufferBytes =
const StandardMessageCodec().encodeMessage(largeBuffer)!;
final ByteData largeBufferBytes = const StandardMessageCodec().encodeMessage(largeBuffer)!;
final ByteData oneMB = ByteData(1024 * 1024);
const int numMessages = 2500;
@@ -221,14 +205,12 @@ Future<void> _runTests() async {
test: (int x) => _runBasicStandardParallel(basicStandard, x, 1234, 3),
resetChannel: resetChannel,
printer: printer,
description:
'BasicMessageChannel/StandardMessageCodec/Flutter->Host/SmallParallel3',
description: 'BasicMessageChannel/StandardMessageCodec/Flutter->Host/SmallParallel3',
name: 'platform_channel_basic_standard_2host_small_parallel_3',
numMessages: numMessages,
);
// Background platform channels aren't yet implemented for iOS.
const BasicMessageChannel<Object?> backgroundStandard =
BasicMessageChannel<Object?>(
const BasicMessageChannel<Object?> backgroundStandard = BasicMessageChannel<Object?>(
'dev.flutter.echo.background.standard',
StandardMessageCodec(),
);
@@ -236,8 +218,7 @@ Future<void> _runTests() async {
test: (int x) => _runBasicStandardSmall(backgroundStandard, x),
resetChannel: resetChannel,
printer: printer,
description:
'BasicMessageChannel/StandardMessageCodec/Flutter->Host (background)/Small',
description: 'BasicMessageChannel/StandardMessageCodec/Flutter->Host (background)/Small',
name: 'platform_channel_basic_standard_2hostbackground_small',
numMessages: numMessages,
);