Use curly_braces_in_flow_control_structures for non-flutter packages (#104629)
* Use `curly_braces_in_flow_control_structures` for `packages/flutter_driver` * Use `curly_braces_in_flow_control_structures` for `packages/flutter_goldens` * Use `curly_braces_in_flow_control_structures` for `packages/flutter_goldens_client` * Use `curly_braces_in_flow_control_structures` for `packages/flutter_localizations` * Use `curly_braces_in_flow_control_structures` for `packages/flutter_test` * Use `curly_braces_in_flow_control_structures` for `packages/flutter_web_plugins` * fix comments * Use `curly_braces_in_flow_control_structures` for `packages/integration_test` * fix indentation
This commit is contained in:
@@ -21,8 +21,9 @@ class DriverError extends Error {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (originalError == null)
|
||||
if (originalError == null) {
|
||||
return 'DriverError: $message\n';
|
||||
}
|
||||
return '''
|
||||
DriverError: $message
|
||||
Original error: $originalError
|
||||
|
||||
@@ -205,8 +205,9 @@ class ByValueKey extends SerializableFinder {
|
||||
ByValueKey(this.keyValue)
|
||||
: keyValueString = '$keyValue',
|
||||
keyValueType = '${keyValue.runtimeType}' {
|
||||
if (!_supportedKeyValueTypes.contains(keyValue.runtimeType))
|
||||
if (!_supportedKeyValueTypes.contains(keyValue.runtimeType)) {
|
||||
throw _createInvalidKeyValueTypeError('$keyValue.runtimeType');
|
||||
}
|
||||
}
|
||||
|
||||
/// The true value of the key.
|
||||
|
||||
@@ -260,8 +260,9 @@ mixin CommandHandlerFactory {
|
||||
'This feature was deprecated after v1.9.3.'
|
||||
)
|
||||
Future<Result> _waitUntilNoTransientCallbacks(Command command) async {
|
||||
if (SchedulerBinding.instance.transientCallbackCount != 0)
|
||||
if (SchedulerBinding.instance.transientCallbackCount != 0) {
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
}
|
||||
return Result.empty;
|
||||
}
|
||||
|
||||
@@ -310,8 +311,9 @@ mixin CommandHandlerFactory {
|
||||
node = renderObject.debugSemantics;
|
||||
renderObject = renderObject.parent as RenderObject?;
|
||||
}
|
||||
if (node == null)
|
||||
if (node == null) {
|
||||
throw StateError('No semantics data found');
|
||||
}
|
||||
return GetSemanticsIdResult(node.id);
|
||||
}
|
||||
|
||||
@@ -464,26 +466,30 @@ mixin CommandHandlerFactory {
|
||||
|
||||
/// Runs `finder` repeatedly until it finds one or more [Element]s.
|
||||
Future<Finder> waitForElement(Finder finder) async {
|
||||
if (_frameSync)
|
||||
if (_frameSync) {
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
}
|
||||
|
||||
await _waitUntilFrame(() => finder.evaluate().isNotEmpty);
|
||||
|
||||
if (_frameSync)
|
||||
if (_frameSync) {
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
}
|
||||
|
||||
return finder;
|
||||
}
|
||||
|
||||
/// Runs `finder` repeatedly until it finds zero [Element]s.
|
||||
Future<Finder> waitForAbsentElement(Finder finder) async {
|
||||
if (_frameSync)
|
||||
if (_frameSync) {
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
}
|
||||
|
||||
await _waitUntilFrame(() => finder.evaluate().isEmpty);
|
||||
|
||||
if (_frameSync)
|
||||
if (_frameSync) {
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
}
|
||||
|
||||
return finder;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ abstract class Command {
|
||||
|
||||
static Duration? _parseTimeout(Map<String, String> json) {
|
||||
final String? timeout = json['timeout'];
|
||||
if (timeout == null)
|
||||
if (timeout == null) {
|
||||
return null;
|
||||
}
|
||||
return Duration(milliseconds: int.parse(timeout));
|
||||
}
|
||||
|
||||
@@ -52,8 +53,9 @@ abstract class Command {
|
||||
final Map<String, String> result = <String, String>{
|
||||
'command': kind,
|
||||
};
|
||||
if (timeout != null)
|
||||
if (timeout != null) {
|
||||
result['timeout'] = '${timeout!.inMilliseconds}';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,8 +95,9 @@ class NoTransientCallbacks extends SerializableWaitCondition {
|
||||
/// The [json] argument must not be null.
|
||||
factory NoTransientCallbacks.deserialize(Map<String, String> json) {
|
||||
assert(json != null);
|
||||
if (json['conditionName'] != 'NoTransientCallbacksCondition')
|
||||
if (json['conditionName'] != 'NoTransientCallbacksCondition') {
|
||||
throw SerializationException('Error occurred during deserializing the NoTransientCallbacksCondition JSON string: $json');
|
||||
}
|
||||
return const NoTransientCallbacks();
|
||||
}
|
||||
|
||||
@@ -115,8 +116,9 @@ class NoPendingFrame extends SerializableWaitCondition {
|
||||
/// The [json] argument must not be null.
|
||||
factory NoPendingFrame.deserialize(Map<String, String> json) {
|
||||
assert(json != null);
|
||||
if (json['conditionName'] != 'NoPendingFrameCondition')
|
||||
if (json['conditionName'] != 'NoPendingFrameCondition') {
|
||||
throw SerializationException('Error occurred during deserializing the NoPendingFrameCondition JSON string: $json');
|
||||
}
|
||||
return const NoPendingFrame();
|
||||
}
|
||||
|
||||
@@ -135,8 +137,9 @@ class FirstFrameRasterized extends SerializableWaitCondition {
|
||||
/// The [json] argument must not be null.
|
||||
factory FirstFrameRasterized.deserialize(Map<String, String> json) {
|
||||
assert(json != null);
|
||||
if (json['conditionName'] != 'FirstFrameRasterizedCondition')
|
||||
if (json['conditionName'] != 'FirstFrameRasterizedCondition') {
|
||||
throw SerializationException('Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: $json');
|
||||
}
|
||||
return const FirstFrameRasterized();
|
||||
}
|
||||
|
||||
@@ -158,8 +161,9 @@ class NoPendingPlatformMessages extends SerializableWaitCondition {
|
||||
/// The [json] argument must not be null.
|
||||
factory NoPendingPlatformMessages.deserialize(Map<String, String> json) {
|
||||
assert(json != null);
|
||||
if (json['conditionName'] != 'NoPendingPlatformMessagesCondition')
|
||||
if (json['conditionName'] != 'NoPendingPlatformMessagesCondition') {
|
||||
throw SerializationException('Error occurred during deserializing the NoPendingPlatformMessagesCondition JSON string: $json');
|
||||
}
|
||||
return const NoPendingPlatformMessages();
|
||||
}
|
||||
|
||||
@@ -181,8 +185,9 @@ class CombinedCondition extends SerializableWaitCondition {
|
||||
/// The [jsonMap] argument must not be null.
|
||||
factory CombinedCondition.deserialize(Map<String, String> jsonMap) {
|
||||
assert(jsonMap != null);
|
||||
if (jsonMap['conditionName'] != 'CombinedCondition')
|
||||
if (jsonMap['conditionName'] != 'CombinedCondition') {
|
||||
throw SerializationException('Error occurred during deserializing the CombinedCondition JSON string: $jsonMap');
|
||||
}
|
||||
if (jsonMap['conditions'] == null) {
|
||||
return const CombinedCondition(<SerializableWaitCondition>[]);
|
||||
}
|
||||
|
||||
@@ -410,23 +410,26 @@ class TimelineSummary {
|
||||
}
|
||||
|
||||
double _averageInMillis(Iterable<Duration> durations) {
|
||||
if (durations.isEmpty)
|
||||
if (durations.isEmpty) {
|
||||
throw ArgumentError('durations is empty!');
|
||||
}
|
||||
final double total = durations.fold<double>(0.0, (double t, Duration duration) => t + duration.inMicroseconds.toDouble() / 1000.0);
|
||||
return total / durations.length;
|
||||
}
|
||||
|
||||
double _percentileInMillis(Iterable<Duration> durations, double percentile) {
|
||||
if (durations.isEmpty)
|
||||
if (durations.isEmpty) {
|
||||
throw ArgumentError('durations is empty!');
|
||||
}
|
||||
assert(percentile >= 0.0 && percentile <= 100.0);
|
||||
final List<double> doubles = durations.map<double>((Duration duration) => duration.inMicroseconds.toDouble() / 1000.0).toList();
|
||||
return findPercentile(doubles, percentile);
|
||||
}
|
||||
|
||||
double _maxInMillis(Iterable<Duration> durations) {
|
||||
if (durations.isEmpty)
|
||||
if (durations.isEmpty) {
|
||||
throw ArgumentError('durations is empty!');
|
||||
}
|
||||
return durations
|
||||
.map<double>((Duration duration) => duration.inMicroseconds.toDouble() / 1000.0)
|
||||
.reduce(math.max);
|
||||
|
||||
@@ -321,14 +321,16 @@ class VMServiceFlutterDriver extends FlutterDriver {
|
||||
stackTrace,
|
||||
);
|
||||
}
|
||||
if ((response['isError'] as bool?) ?? false)
|
||||
if ((response['isError'] as bool?) ?? false) {
|
||||
throw DriverError('Error in Flutter application: ${response['response']}');
|
||||
}
|
||||
return response['response'] as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
void _logCommunication(String message) {
|
||||
if (_printCommunication)
|
||||
if (_printCommunication) {
|
||||
_log(message);
|
||||
}
|
||||
if (_logCommunicationToFile) {
|
||||
assert(_logFilePathName != null);
|
||||
final f.File file = fs.file(_logFilePathName);
|
||||
@@ -533,8 +535,9 @@ String _getWebSocketUrl(String url) {
|
||||
if (uri.pathSegments.isNotEmpty) uri.pathSegments.first,
|
||||
'ws',
|
||||
];
|
||||
if (uri.scheme == 'http')
|
||||
if (uri.scheme == 'http') {
|
||||
uri = uri.replace(scheme: 'ws', pathSegments: pathSegments);
|
||||
}
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -377,8 +377,9 @@ class FlutterDriverExtension with DeserializeFinderFactory, CreateFinderFactory,
|
||||
return _makeResponse(message, isError: true);
|
||||
} catch (error, stackTrace) {
|
||||
final String message = 'Uncaught extension error while executing $commandKind: $error\n$stackTrace';
|
||||
if (!_silenceErrors)
|
||||
if (!_silenceErrors) {
|
||||
_log(message);
|
||||
}
|
||||
return _makeResponse(message, isError: true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,9 @@ class _InternalNoTransientCallbacksCondition implements WaitCondition {
|
||||
/// The [condition] argument must not be null.
|
||||
factory _InternalNoTransientCallbacksCondition.deserialize(SerializableWaitCondition condition) {
|
||||
assert(condition != null);
|
||||
if (condition.conditionName != 'NoTransientCallbacksCondition')
|
||||
if (condition.conditionName != 'NoTransientCallbacksCondition') {
|
||||
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
|
||||
}
|
||||
return const _InternalNoTransientCallbacksCondition();
|
||||
}
|
||||
|
||||
@@ -71,8 +72,9 @@ class _InternalNoPendingFrameCondition implements WaitCondition {
|
||||
/// The [condition] argument must not be null.
|
||||
factory _InternalNoPendingFrameCondition.deserialize(SerializableWaitCondition condition) {
|
||||
assert(condition != null);
|
||||
if (condition.conditionName != 'NoPendingFrameCondition')
|
||||
if (condition.conditionName != 'NoPendingFrameCondition') {
|
||||
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
|
||||
}
|
||||
return const _InternalNoPendingFrameCondition();
|
||||
}
|
||||
|
||||
@@ -99,8 +101,9 @@ class _InternalFirstFrameRasterizedCondition implements WaitCondition {
|
||||
/// The [condition] argument must not be null.
|
||||
factory _InternalFirstFrameRasterizedCondition.deserialize(SerializableWaitCondition condition) {
|
||||
assert(condition != null);
|
||||
if (condition.conditionName != 'FirstFrameRasterizedCondition')
|
||||
if (condition.conditionName != 'FirstFrameRasterizedCondition') {
|
||||
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
|
||||
}
|
||||
return const _InternalFirstFrameRasterizedCondition();
|
||||
}
|
||||
|
||||
@@ -125,8 +128,9 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition {
|
||||
/// The [condition] argument must not be null.
|
||||
factory _InternalNoPendingPlatformMessagesCondition.deserialize(SerializableWaitCondition condition) {
|
||||
assert(condition != null);
|
||||
if (condition.conditionName != 'NoPendingPlatformMessagesCondition')
|
||||
if (condition.conditionName != 'NoPendingPlatformMessagesCondition') {
|
||||
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
|
||||
}
|
||||
return const _InternalNoPendingPlatformMessagesCondition();
|
||||
}
|
||||
|
||||
@@ -161,8 +165,9 @@ class _InternalCombinedCondition implements WaitCondition {
|
||||
/// The [condition] argument must not be null.
|
||||
factory _InternalCombinedCondition.deserialize(SerializableWaitCondition condition) {
|
||||
assert(condition != null);
|
||||
if (condition.conditionName != 'CombinedCondition')
|
||||
if (condition.conditionName != 'CombinedCondition') {
|
||||
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
|
||||
}
|
||||
final CombinedCondition combinedCondition = condition as CombinedCondition;
|
||||
final List<WaitCondition> conditions = combinedCondition.conditions.map(deserializeCondition).toList();
|
||||
return _InternalCombinedCondition(conditions);
|
||||
|
||||
Reference in New Issue
Block a user