Skip to content

Commit 864289b

Browse files
goderbauermaheshj01
authored andcommitted
Last Engine<>Framework lint sync (flutter#161560)
This is the last time we have to do this because in flutter#161554 I am refactoring the engine's analysis_options.yaml to just import the one from the root of the repository. When that lands, lints only have to be enabled in one place to apply across framework and engine. Before we can do that we have to do one last sync to make sure the engine code base is ready. This PR implements that last sync and fixing all lints that came up.
1 parent e1691db commit 864289b

File tree

8 files changed

+36
-20
lines changed

8 files changed

+36
-20
lines changed

engine/src/flutter/analysis_options.yaml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Specify analysis options.
22
#
33
# This file is a copy of analysis_options.yaml from flutter repo
4-
# as of 2023-12-18, but with some modifications marked with
4+
# as of 2025-01-13, but with some modifications marked with
55
# "DIFFERENT FROM FLUTTER/FLUTTER" below.
66

77
analyzer:
@@ -36,10 +36,11 @@ linter:
3636
# - always_specify_types # DIFFERENT FROM FLUTTER/FLUTTER; see https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#dart
3737
# - always_use_package_imports # we do this commonly
3838
- annotate_overrides
39+
- annotate_redeclares
3940
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
4041
- avoid_bool_literals_in_conditional_expressions
4142
# - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
42-
# - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
43+
# - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/4998
4344
# - avoid_classes_with_only_static_members # we do this commonly for `abstract final class`es
4445
- avoid_double_and_int_checks
4546
- avoid_dynamic_calls
@@ -49,6 +50,7 @@ linter:
4950
- avoid_field_initializers_in_const_classes
5051
# - avoid_final_parameters # incompatible with prefer_final_parameters
5152
- avoid_function_literals_in_foreach_calls
53+
# - avoid_futureor_void # not yet tested
5254
# - avoid_implementing_value_types # see https://github.com/dart-lang/linter/issues/4558
5355
- avoid_init_to_null
5456
- avoid_js_rounded_ints
@@ -96,6 +98,7 @@ linter:
9698
- directives_ordering
9799
# - discarded_futures # too many false positives, similar to unawaited_futures
98100
# - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
101+
# - document_ignores # not yet tested
99102
- empty_catches
100103
- empty_constructor_bodies
101104
- empty_statements
@@ -108,6 +111,7 @@ linter:
108111
- implicit_call_tearoffs
109112
- implicit_reopen
110113
- invalid_case_patterns
114+
- invalid_runtime_check_with_js_interop_types
111115
# - join_return_with_assignment # not required by flutter style
112116
- leading_newlines_in_multiline_strings
113117
- library_annotations
@@ -134,6 +138,8 @@ linter:
134138
- null_check_on_nullable_type_parameter
135139
- null_closures
136140
# - omit_local_variable_types # opposite of always_specify_types
141+
# - omit_obvious_local_variable_types # not yet tested
142+
# - omit_obvious_property_types # not yet tested
137143
# - one_member_abstracts # too many false positives
138144
- only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al
139145
- overridden_fields
@@ -152,7 +158,7 @@ linter:
152158
# - prefer_constructors_over_static_methods # far too many false positives
153159
- prefer_contains
154160
# - prefer_double_quotes # opposite of prefer_single_quotes
155-
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
161+
# - prefer_expression_function_bodies # conflicts with ./docs/contributing/Style-guide-for-Flutter-repo.md#consider-using--for-short-functions-and-methods
156162
- prefer_final_fields
157163
- prefer_final_in_for_each
158164
- prefer_final_locals
@@ -165,7 +171,7 @@ linter:
165171
- prefer_if_null_operators
166172
- prefer_initializing_formals
167173
- prefer_inlined_adds
168-
# - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants
174+
# - prefer_int_literals # conflicts with ./docs/contributing/Style-guide-for-Flutter-repo.md#use-double-literals-for-double-constants
169175
- prefer_interpolation_to_compose_strings
170176
- prefer_is_empty
171177
- prefer_is_not_empty
@@ -191,13 +197,18 @@ linter:
191197
- sort_constructors_first
192198
# - sort_pub_dependencies # prevents separating pinned transitive dependencies
193199
- sort_unnamed_constructors_first
200+
# - specify_nonobvious_local_variable_types # not yet tested
201+
# - specify_nonobvious_property_types # not yet tested
202+
- strict_top_level_inference
194203
- test_types_in_equals
195204
- throw_in_finally
196205
- tighten_type_of_initializing_formals
197206
- type_annotate_public_apis # DIFFERENT FROM FLUTTER/FLUTTER; this repo disable always_specify_types (https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#dart)
198207
- type_init_formals
199208
- type_literal_in_constant_pattern
200209
# - unawaited_futures # too many false positives, especially with the way AnimationController works
210+
# - unintended_html_in_doc_comment # blocked on https://github.com/dart-lang/linter/issues/5065
211+
# - unnecessary_async # not yet tested
201212
- unnecessary_await_in_return
202213
- unnecessary_brace_in_string_interps
203214
- unnecessary_breaks
@@ -208,6 +219,7 @@ linter:
208219
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
209220
- unnecessary_late
210221
- unnecessary_library_directive
222+
# - unnecessary_library_name # blocked on https://github.com/dart-lang/dartdoc/issues/3882
211223
- unnecessary_new
212224
- unnecessary_null_aware_assignments
213225
- unnecessary_null_aware_operator_on_extension_on_nullable
@@ -222,8 +234,10 @@ linter:
222234
- unnecessary_string_interpolations
223235
- unnecessary_this
224236
- unnecessary_to_list_in_spreads
237+
- unnecessary_underscores
225238
- unreachable_from_main
226239
- unrelated_type_equality_checks
240+
# - unsafe_variance # not yet tested
227241
- use_build_context_synchronously
228242
- use_colored_box
229243
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
@@ -243,5 +257,6 @@ linter:
243257
- use_super_parameters
244258
- use_test_throws_matchers
245259
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
260+
- use_truncating_division
246261
- valid_regexps
247262
- void_checks

engine/src/flutter/lib/web_ui/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ linter:
1010
rules:
1111
avoid_print: false
1212
avoid_setters_without_getters: false
13+
invalid_runtime_check_with_js_interop_types: false
1314
library_private_types_in_public_api: false
1415
no_default_cases: false
1516
prefer_relative_imports: false

engine/src/flutter/lib/web_ui/lib/src/engine/initialization.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Future<void> initializeEngineServices({
141141
//
142142
// This extension does not need to clean-up Dart statics. Those are cleaned
143143
// up by the compiler.
144-
developer.registerExtension('ext.flutter.disassemble', (_, __) {
144+
developer.registerExtension('ext.flutter.disassemble', (_, _) {
145145
for (final ui.VoidCallback listener in _hotRestartListeners) {
146146
listener();
147147
}

engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher/app_lifecycle_state.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class _BrowserAppLifecycleState extends AppLifecycleState {
104104
}
105105
});
106106

107-
void _onViewCountChanged(_) {
107+
void _onViewCountChanged(int _) {
108108
if (_viewManager.views.isEmpty) {
109109
onAppLifecycleStateChange(ui.AppLifecycleState.detached);
110110
} else {

engine/src/flutter/lib/web_ui/test/engine/composition_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ GloballyPositionedTextEditingStrategy _enableEditingStrategy({
4343

4444
owner.debugTextEditingStrategyOverride = editingStrategy;
4545

46-
editingStrategy.enable(owner.configuration!, onChange: onChange ?? (_, __) {}, onAction: (_) {});
46+
editingStrategy.enable(owner.configuration!, onChange: onChange ?? (_, _) {}, onAction: (_) {});
4747
return editingStrategy;
4848
}
4949

engine/src/flutter/lib/web_ui/test/engine/pointer_binding/event_position_helper_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void doTests() {
111111

112112
textEditing.strategy.enable(
113113
InputConfiguration(viewId: view.viewId),
114-
onChange: (_, __) {},
114+
onChange: (_, _) {},
115115
onAction: (_) {},
116116
);
117117

engine/src/flutter/lib/web_ui/test/engine/semantics/text_field_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void testMain() {
153153
int actionCount = 0;
154154
strategy.enable(
155155
singlelineConfig,
156-
onChange: (_, __) {
156+
onChange: (_, _) {
157157
changeCount++;
158158
},
159159
onAction: (_) {
@@ -218,7 +218,7 @@ void testMain() {
218218
});
219219

220220
test('Does not overwrite text value and selection editing state on semantic updates', () {
221-
strategy.enable(singlelineConfig, onChange: (_, __) {}, onAction: (_) {});
221+
strategy.enable(singlelineConfig, onChange: (_, _) {}, onAction: (_) {});
222222

223223
final textFieldSemantics = createTextFieldSemantics(
224224
value: 'hello',
@@ -242,7 +242,7 @@ void testMain() {
242242
test('Updates editing state when receiving framework messages from the text input channel', () {
243243
expect(owner().semanticsHost.ownerDocument?.activeElement, domDocument.body);
244244

245-
strategy.enable(singlelineConfig, onChange: (_, __) {}, onAction: (_) {});
245+
strategy.enable(singlelineConfig, onChange: (_, _) {}, onAction: (_) {});
246246

247247
final textFieldSemantics = createTextFieldSemantics(
248248
value: 'hello',
@@ -280,7 +280,7 @@ void testMain() {
280280
test('Gives up focus after DOM blur', () {
281281
expect(owner().semanticsHost.ownerDocument?.activeElement, domDocument.body);
282282

283-
strategy.enable(singlelineConfig, onChange: (_, __) {}, onAction: (_) {});
283+
strategy.enable(singlelineConfig, onChange: (_, _) {}, onAction: (_) {});
284284
final textFieldSemantics = createTextFieldSemantics(value: 'hello', isFocused: true);
285285

286286
final textField = textFieldSemantics.semanticRole! as SemanticTextField;
@@ -294,7 +294,7 @@ void testMain() {
294294
});
295295

296296
test('Does not dispose and recreate dom elements in persistent mode', () async {
297-
strategy.enable(singlelineConfig, onChange: (_, __) {}, onAction: (_) {});
297+
strategy.enable(singlelineConfig, onChange: (_, _) {}, onAction: (_) {});
298298

299299
// It doesn't create a new DOM element.
300300
expect(strategy.domElement, isNull);
@@ -323,7 +323,7 @@ void testMain() {
323323
});
324324

325325
test('Refocuses when setting editing state', () {
326-
strategy.enable(singlelineConfig, onChange: (_, __) {}, onAction: (_) {});
326+
strategy.enable(singlelineConfig, onChange: (_, _) {}, onAction: (_) {});
327327

328328
createTextFieldSemantics(value: 'hello', isFocused: true);
329329
expect(strategy.domElement, isNotNull);
@@ -352,15 +352,15 @@ void testMain() {
352352
});
353353

354354
test('Works in multi-line mode', () {
355-
strategy.enable(multilineConfig, onChange: (_, __) {}, onAction: (_) {});
355+
strategy.enable(multilineConfig, onChange: (_, _) {}, onAction: (_) {});
356356
createTextFieldSemantics(value: 'hello', isFocused: true, isMultiline: true);
357357

358358
final textArea = strategy.domElement! as DomHTMLTextAreaElement;
359359
expect(textArea.style.getPropertyValue('-webkit-text-security'), '');
360360

361361
expect(owner().semanticsHost.ownerDocument?.activeElement, strategy.domElement);
362362

363-
strategy.enable(singlelineConfig, onChange: (_, __) {}, onAction: (_) {});
363+
strategy.enable(singlelineConfig, onChange: (_, _) {}, onAction: (_) {});
364364

365365
textArea.blur();
366366
expect(owner().semanticsHost.ownerDocument?.activeElement, domDocument.body);
@@ -373,7 +373,7 @@ void testMain() {
373373
});
374374

375375
test('multi-line and obscured', () {
376-
strategy.enable(multilineConfig, onChange: (_, __) {}, onAction: (_) {});
376+
strategy.enable(multilineConfig, onChange: (_, _) {}, onAction: (_) {});
377377
createTextFieldSemantics(
378378
value: 'hello',
379379
isFocused: true,
@@ -391,7 +391,7 @@ void testMain() {
391391
}, skip: ui_web.browser.browserEngine == ui_web.BrowserEngine.firefox);
392392

393393
test('Does not position or size its DOM element', () {
394-
strategy.enable(singlelineConfig, onChange: (_, __) {}, onAction: (_) {});
394+
strategy.enable(singlelineConfig, onChange: (_, _) {}, onAction: (_) {});
395395

396396
// Send width and height that are different from semantics values on
397397
// purpose.
@@ -450,7 +450,7 @@ void testMain() {
450450
}
451451

452452
test('Changes focus from one text field to another through a semantics update', () {
453-
strategy.enable(singlelineConfig, onChange: (_, __) {}, onAction: (_) {});
453+
strategy.enable(singlelineConfig, onChange: (_, _) {}, onAction: (_) {});
454454

455455
// Switch between the two fields a few times.
456456
for (int i = 0; i < 5; i++) {

engine/src/flutter/lib/web_ui/test/engine/window_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ Future<void> testMain() async {
279279
final Zone innerZone = Zone.current.fork();
280280

281281
innerZone.runGuarded(() {
282-
void callback(String _, ByteData? __, void Function(ByteData?)? ___) {
282+
void callback(String _, ByteData? _, void Function(ByteData?)? _) {
283283
expect(Zone.current, innerZone);
284284
}
285285

0 commit comments

Comments
 (0)