Commit 9b56c1c5 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

enable always_put_control_body_on_new_line lint (#9950)

parent e4546584
......@@ -66,7 +66,7 @@ linter:
# === style rules ===
- always_declare_return_types
# - always_put_control_body_on_new_line # not yet tested
- always_put_control_body_on_new_line
- always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
......
......@@ -64,7 +64,7 @@ linter:
# === style rules ===
- always_declare_return_types
# - always_put_control_body_on_new_line # not yet tested
- always_put_control_body_on_new_line
- always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
......
......@@ -102,7 +102,8 @@ Future<TestStepResult> resultOfHandshake(
dynamic error,
) async {
assert(message != nothing);
while (received.length < 2) received.add(nothing);
while (received.length < 2)
received.add(nothing);
TestStatus status;
if (!_deepEquals(messageEcho, message) ||
received.length != 2 ||
......@@ -136,11 +137,16 @@ String _toString(dynamic message) {
}
bool _deepEquals(dynamic a, dynamic b) {
if (a == b) return true;
if (a is double && a.isNaN) return b is double && b.isNaN;
if (a is ByteData) return b is ByteData && _deepEqualsByteData(a, b);
if (a is List) return b is List && _deepEqualsList(a, b);
if (a is Map) return b is Map && _deepEqualsMap(a, b);
if (a == b)
return true;
if (a is double && a.isNaN)
return b is double && b.isNaN;
if (a is ByteData)
return b is ByteData && _deepEqualsByteData(a, b);
if (a is List)
return b is List && _deepEqualsList(a, b);
if (a is Map)
return b is Map && _deepEqualsMap(a, b);
return false;
}
......@@ -152,17 +158,21 @@ bool _deepEqualsByteData(ByteData a, ByteData b) {
}
bool _deepEqualsList(List<dynamic> a, List<dynamic> b) {
if (a.length != b.length) return false;
if (a.length != b.length)
return false;
for (int i = 0; i < a.length; i++) {
if (!_deepEquals(a[i], b[i])) return false;
if (!_deepEquals(a[i], b[i]))
return false;
}
return true;
}
bool _deepEqualsMap(Map<dynamic, dynamic> a, Map<dynamic, dynamic> b) {
if (a.length != b.length) return false;
if (a.length != b.length)
return false;
for (dynamic key in a.keys) {
if (!b.containsKey(key) || !_deepEquals(a[key], b[key])) return false;
if (!b.containsKey(key) || !_deepEquals(a[key], b[key]))
return false;
}
return true;
}
......@@ -206,19 +206,23 @@ class _UsNumberTextInputFormatter extends TextInputFormatter {
final StringBuffer newText = new StringBuffer();
if (newTextLength >= 1) {
newText.write('(');
if (newValue.selection.end >= 1) selectionIndex++;
if (newValue.selection.end >= 1)
selectionIndex++;
}
if (newTextLength >= 4) {
newText.write(newValue.text.substring(0, usedSubstringIndex = 3) + ') ');
if (newValue.selection.end >= 3) selectionIndex += 2;
if (newValue.selection.end >= 3)
selectionIndex += 2;
}
if (newTextLength >= 7) {
newText.write(newValue.text.substring(3, usedSubstringIndex = 6) + '-');
if (newValue.selection.end >= 6) selectionIndex++;
if (newValue.selection.end >= 6)
selectionIndex++;
}
if (newTextLength >= 11) {
newText.write(newValue.text.substring(6, usedSubstringIndex = 10) + ' ');
if (newValue.selection.end >= 10) selectionIndex++;
if (newValue.selection.end >= 10)
selectionIndex++;
}
// Dump the rest.
if (newTextLength >= usedSubstringIndex)
......
......@@ -14,7 +14,8 @@ void main() {
});
tearDownAll(() async {
if (driver != null) driver.close();
if (driver != null)
driver.close();
});
test('tap on the button, verify result', () async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment