Skip to content

Commit 9b56c1c

Browse files
authored
enable always_put_control_body_on_new_line lint (flutter#9950)
1 parent e454658 commit 9b56c1c

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

.analysis_options

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ linter:
6666

6767
# === style rules ===
6868
- always_declare_return_types
69-
# - always_put_control_body_on_new_line # not yet tested
69+
- always_put_control_body_on_new_line
7070
- always_require_non_null_named_parameters
7171
- always_specify_types
7272
- annotate_overrides

.analysis_options_repo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ linter:
6464

6565
# === style rules ===
6666
- always_declare_return_types
67-
# - always_put_control_body_on_new_line # not yet tested
67+
- always_put_control_body_on_new_line
6868
- always_require_non_null_named_parameters
6969
- always_specify_types
7070
- annotate_overrides

dev/integration_tests/channels/lib/src/test_step.dart

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ Future<TestStepResult> resultOfHandshake(
102102
dynamic error,
103103
) async {
104104
assert(message != nothing);
105-
while (received.length < 2) received.add(nothing);
105+
while (received.length < 2)
106+
received.add(nothing);
106107
TestStatus status;
107108
if (!_deepEquals(messageEcho, message) ||
108109
received.length != 2 ||
@@ -136,11 +137,16 @@ String _toString(dynamic message) {
136137
}
137138

138139
bool _deepEquals(dynamic a, dynamic b) {
139-
if (a == b) return true;
140-
if (a is double && a.isNaN) return b is double && b.isNaN;
141-
if (a is ByteData) return b is ByteData && _deepEqualsByteData(a, b);
142-
if (a is List) return b is List && _deepEqualsList(a, b);
143-
if (a is Map) return b is Map && _deepEqualsMap(a, b);
140+
if (a == b)
141+
return true;
142+
if (a is double && a.isNaN)
143+
return b is double && b.isNaN;
144+
if (a is ByteData)
145+
return b is ByteData && _deepEqualsByteData(a, b);
146+
if (a is List)
147+
return b is List && _deepEqualsList(a, b);
148+
if (a is Map)
149+
return b is Map && _deepEqualsMap(a, b);
144150
return false;
145151
}
146152

@@ -152,17 +158,21 @@ bool _deepEqualsByteData(ByteData a, ByteData b) {
152158
}
153159

154160
bool _deepEqualsList(List<dynamic> a, List<dynamic> b) {
155-
if (a.length != b.length) return false;
161+
if (a.length != b.length)
162+
return false;
156163
for (int i = 0; i < a.length; i++) {
157-
if (!_deepEquals(a[i], b[i])) return false;
164+
if (!_deepEquals(a[i], b[i]))
165+
return false;
158166
}
159167
return true;
160168
}
161169

162170
bool _deepEqualsMap(Map<dynamic, dynamic> a, Map<dynamic, dynamic> b) {
163-
if (a.length != b.length) return false;
171+
if (a.length != b.length)
172+
return false;
164173
for (dynamic key in a.keys) {
165-
if (!b.containsKey(key) || !_deepEquals(a[key], b[key])) return false;
174+
if (!b.containsKey(key) || !_deepEquals(a[key], b[key]))
175+
return false;
166176
}
167177
return true;
168178
}

examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,23 @@ class _UsNumberTextInputFormatter extends TextInputFormatter {
206206
final StringBuffer newText = new StringBuffer();
207207
if (newTextLength >= 1) {
208208
newText.write('(');
209-
if (newValue.selection.end >= 1) selectionIndex++;
209+
if (newValue.selection.end >= 1)
210+
selectionIndex++;
210211
}
211212
if (newTextLength >= 4) {
212213
newText.write(newValue.text.substring(0, usedSubstringIndex = 3) + ') ');
213-
if (newValue.selection.end >= 3) selectionIndex += 2;
214+
if (newValue.selection.end >= 3)
215+
selectionIndex += 2;
214216
}
215217
if (newTextLength >= 7) {
216218
newText.write(newValue.text.substring(3, usedSubstringIndex = 6) + '-');
217-
if (newValue.selection.end >= 6) selectionIndex++;
219+
if (newValue.selection.end >= 6)
220+
selectionIndex++;
218221
}
219222
if (newTextLength >= 11) {
220223
newText.write(newValue.text.substring(6, usedSubstringIndex = 10) + ' ');
221-
if (newValue.selection.end >= 10) selectionIndex++;
224+
if (newValue.selection.end >= 10)
225+
selectionIndex++;
222226
}
223227
// Dump the rest.
224228
if (newTextLength >= usedSubstringIndex)

examples/platform_channel/test_driver/button_tap_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ void main() {
1414
});
1515

1616
tearDownAll(() async {
17-
if (driver != null) driver.close();
17+
if (driver != null)
18+
driver.close();
1819
});
1920

2021
test('tap on the button, verify result', () async {

0 commit comments

Comments
 (0)