Skip to content

Commit 2150d03

Browse files
committed
Sync with analysis_options.yaml in flutter/packages
Some packages require package upgrade rather than simple modification (ex: google_maps_flutter) Therefore, the rules below are temporarily ignored. Any necessary modifications can be applied in a later PR. flutter/packages#4060 - unnecessary_null_comparison flutter/packages#4067 - unawaited_futures flutter/packages#5717 - dangling_library_doc_comments - no_literal_bool_comparisons - unnecessary_library_directive - use_colored_box - use_enums - use_string_in_part_of_directives
1 parent 0bbced7 commit 2150d03

File tree

5 files changed

+53
-36
lines changed

5 files changed

+53
-36
lines changed

analysis_options.yaml

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
# This file is a copy of analysis_options.yaml from flutter/packages repo
2-
# as of 2023-03-07.
1+
# Specify analysis options.
2+
#
3+
# This file is a copy of analysis_options.yaml from flutter repo
4+
# as of 2023-12-18, but with some modifications marked with
5+
# "DIFFERENT FROM FLUTTER/FLUTTER" below. The file is expected to
6+
# be kept in sync with the master file from the flutter repo.
37

48
analyzer:
59
language:
610
strict-casts: true
11+
strict-inference: true
712
strict-raw-types: true
813
errors:
9-
# allow self-reference to deprecated members (we do this because otherwise we have
10-
# to annotate every member in every test, assert, etc, when we deprecate something)
14+
# allow deprecated members (we do this because otherwise we have to annotate
15+
# every member in every test, assert, etc, when we or the Dart SDK deprecates
16+
# something (https://github.com/flutter/flutter/issues/143312)
17+
deprecated_member_use: ignore
1118
deprecated_member_use_from_same_package: ignore
12-
# Turned off until null-safe rollout is complete.
13-
unnecessary_null_comparison: ignore
19+
unnecessary_null_comparison: ignore # Temporarily ingnored from flutter-tizen.
1420
exclude: # DIFFERENT FROM FLUTTER/FLUTTER
1521
# Ignore generated files
1622
- '**/*.g.dart'
@@ -19,19 +25,18 @@ analyzer:
1925
linter:
2026
rules:
2127
# This list is derived from the list of all available lints located at
22-
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
28+
# https://github.com/dart-lang/linter/blob/main/example/all.yaml
2329
- always_declare_return_types
2430
- always_put_control_body_on_new_line
2531
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
26-
- always_require_non_null_named_parameters
2732
- always_specify_types
2833
# - always_use_package_imports # we do this commonly
2934
- annotate_overrides
3035
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
3136
- avoid_bool_literals_in_conditional_expressions
3237
# - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
3338
# - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
34-
- avoid_classes_with_only_static_members
39+
# - avoid_classes_with_only_static_members # we do this commonly for `abstract final class`es
3540
- avoid_double_and_int_checks
3641
- avoid_dynamic_calls
3742
- avoid_empty_else
@@ -40,7 +45,7 @@ linter:
4045
- avoid_field_initializers_in_const_classes
4146
# - avoid_final_parameters # incompatible with prefer_final_parameters
4247
- avoid_function_literals_in_foreach_calls
43-
- avoid_implementing_value_types
48+
# - avoid_implementing_value_types # see https://github.com/dart-lang/linter/issues/4558
4449
- avoid_init_to_null
4550
- avoid_js_rounded_ints
4651
# - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
@@ -52,8 +57,6 @@ linter:
5257
- avoid_relative_lib_imports
5358
- avoid_renaming_method_parameters
5459
- avoid_return_types_on_setters
55-
- avoid_returning_null
56-
- avoid_returning_null_for_future
5760
- avoid_returning_null_for_void
5861
# - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives
5962
- avoid_setters_without_getters
@@ -74,17 +77,20 @@ linter:
7477
# - cascade_invocations # doesn't match the typical style of this repo
7578
- cast_nullable_to_non_nullable
7679
# - close_sinks # not reliable enough
77-
# - combinators_ordering # DIFFERENT FROM FLUTTER/FLUTTER: This isn't available on stable yet.
80+
- collection_methods_unrelated_type
81+
- combinators_ordering
7882
# - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
7983
- conditional_uri_does_not_exist
8084
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
8185
- control_flow_in_finally
8286
- curly_braces_in_flow_control_structures
87+
# - dangling_library_doc_comments # Temporarily ingnored from flutter-tizen.
8388
- depend_on_referenced_packages
8489
- deprecated_consistency
90+
# - deprecated_member_use_from_same_package # we allow self-references to deprecated members
8591
# - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
8692
- directives_ordering
87-
# - discarded_futures # not yet tested
93+
# - discarded_futures # too many false positives, similar to unawaited_futures
8894
# - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
8995
- empty_catches
9096
- empty_constructor_bodies
@@ -95,23 +101,29 @@ linter:
95101
- flutter_style_todos
96102
- hash_and_equals
97103
- implementation_imports
98-
- iterable_contains_unrelated_type
104+
- implicit_call_tearoffs
105+
- implicit_reopen
106+
- invalid_case_patterns
99107
# - join_return_with_assignment # not required by flutter style
100108
- leading_newlines_in_multiline_strings
109+
- library_annotations
101110
- library_names
102111
- library_prefixes
103112
- library_private_types_in_public_api
104113
# - lines_longer_than_80_chars # not required by flutter style
105-
- list_remove_unrelated_type
106-
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
114+
- literal_only_boolean_expressions
115+
# - matching_super_parameters # blocked on https://github.com/dart-lang/language/issues/2509
107116
- missing_whitespace_between_adjacent_strings
108117
- no_adjacent_strings_in_list
109118
- no_default_cases
110119
- no_duplicate_case_values
111120
- no_leading_underscores_for_library_prefixes
112121
- no_leading_underscores_for_local_identifiers
122+
# - no_literal_bool_comparisons # Temporarily ingnored from flutter-tizen.
113123
- no_logic_in_create_state
114124
- no_runtimeType_toString # DIFFERENT FROM FLUTTER/FLUTTER
125+
- no_self_assignments
126+
- no_wildcard_variable_uses
115127
- non_constant_identifier_names
116128
- noop_primitive_operations
117129
- null_check_on_nullable_type_parameter
@@ -136,12 +148,11 @@ linter:
136148
# - prefer_constructors_over_static_methods # far too many false positives
137149
- prefer_contains
138150
# - prefer_double_quotes # opposite of prefer_single_quotes
139-
- prefer_equal_for_default_values
140151
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
141152
- prefer_final_fields
142153
- prefer_final_in_for_each
143154
- prefer_final_locals
144-
# - prefer_final_parameters # we should enable this one day when it can be auto-fixed (https://github.com/dart-lang/linter/issues/3104), see also parameter_assignments
155+
# - prefer_final_parameters # adds too much verbosity
145156
- prefer_for_elements_to_map_fromIterable
146157
- prefer_foreach
147158
- prefer_function_declarations_over_variables
@@ -156,7 +167,7 @@ linter:
156167
- prefer_is_not_empty
157168
- prefer_is_not_operator
158169
- prefer_iterable_whereType
159-
# - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
170+
- prefer_mixin
160171
# - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
161172
- prefer_null_aware_operators
162173
- prefer_relative_imports
@@ -167,10 +178,10 @@ linter:
167178
- provide_deprecation_message
168179
- public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER
169180
- recursive_getters
170-
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
181+
# - require_trailing_commas # would be nice, but requires a lot of manual work: 10,000+ code locations would need to be reformatted by hand after bulk fix is applied
171182
- secure_pubspec_urls
172183
- sized_box_for_whitespace
173-
# - sized_box_shrink_expand # not yet tested
184+
- sized_box_shrink_expand
174185
- slash_for_doc_comments
175186
- sort_child_properties_last
176187
- sort_constructors_first
@@ -181,15 +192,18 @@ linter:
181192
- tighten_type_of_initializing_formals
182193
# - type_annotate_public_apis # subset of always_specify_types
183194
- type_init_formals
184-
# - unawaited_futures # too many false positives, especially with the way AnimationController works
195+
- type_literal_in_constant_pattern
196+
# - unawaited_futures # DIFFERENT FROM FLUTTER/FLUTTER: It's disabled there for "too many false positives"; that's not an issue here, and missing awaits have caused production issues in plugins. # Temporarily ingnored from flutter-tizen.
185197
- unnecessary_await_in_return
186198
- unnecessary_brace_in_string_interps
199+
- unnecessary_breaks
187200
- unnecessary_const
188201
- unnecessary_constructor_name
189202
# - unnecessary_final # conflicts with prefer_final_locals
190203
- unnecessary_getters_setters
191204
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
192205
- unnecessary_late
206+
# - unnecessary_library_directive # Temporarily ingnored from flutter-tizen.
193207
- unnecessary_new
194208
- unnecessary_null_aware_assignments
195209
- unnecessary_null_aware_operator_on_extension_on_nullable
@@ -204,12 +218,13 @@ linter:
204218
- unnecessary_string_interpolations
205219
- unnecessary_this
206220
- unnecessary_to_list_in_spreads
221+
- unreachable_from_main
207222
- unrelated_type_equality_checks
208223
- unsafe_html
209224
- use_build_context_synchronously
210-
# - use_colored_box # not yet tested
211-
# - use_decorated_box # not yet tested
212-
# - use_enums # not yet tested
225+
# - use_colored_box # Temporarily ingnored from flutter-tizen.
226+
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
227+
# - use_enums # Temporarily ingnored from flutter-tizen.
213228
- use_full_hex_values_for_flutter_colors
214229
- use_function_type_syntax_for_parameters
215230
- use_if_null_to_convert_nulls_to_bools
@@ -221,6 +236,7 @@ linter:
221236
- use_rethrow_when_possible
222237
- use_setters_to_change_properties
223238
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
239+
# - use_string_in_part_of_directives # Temporarily ingnored from flutter-tizen.
224240
- use_super_parameters
225241
- use_test_throws_matchers
226242
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review

packages/messageport/example/integration_test/messageport_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void main() {
2626

2727
testWidgets('Create remote port', (WidgetTester tester) async {
2828
final LocalPort localPort = await LocalPort.create(kTestPort);
29-
localPort.register((dynamic message, [RemotePort? remotePort]) => null);
29+
localPort.register((dynamic message, [RemotePort? remotePort]) => () {});
3030

3131
final RemotePort remotePort =
3232
await RemotePort.connect(kTestAppId, kTestPort);
@@ -40,7 +40,7 @@ void main() {
4040
(WidgetTester tester) async {
4141
final LocalPort localPort =
4242
await LocalPort.create(kTestPort, trusted: false);
43-
localPort.register((dynamic message, [RemotePort? remotePort]) => null);
43+
localPort.register((dynamic message, [RemotePort? remotePort]) => () {});
4444

4545
await expectLater(
4646
() => RemotePort.connect(kTestAppId, kTestPort),
@@ -52,7 +52,7 @@ void main() {
5252

5353
testWidgets('Check for remote', (WidgetTester tester) async {
5454
final LocalPort localPort = await LocalPort.create(kTestPort);
55-
localPort.register((dynamic message, [RemotePort? remotePort]) => null);
55+
localPort.register((dynamic message, [RemotePort? remotePort]) => () {});
5656

5757
final RemotePort remotePort =
5858
await RemotePort.connect(kTestAppId, kTestPort);

packages/messageport/lib/messageport_tizen.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ MessagePortManager _manager = MessagePortManager();
1111
/// Called when a message is received on message port.
1212
///
1313
/// This is used by [LocalPort.register].
14-
typedef OnMessageReceived = Function(dynamic message, [RemotePort? remotePort]);
14+
typedef OnMessageReceived = void Function(dynamic message,
15+
[RemotePort? remotePort]);
1516

1617
/// Local message port for receiving messages.
1718
class LocalPort {

packages/video_player_avplay/example/lib/main.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ class _GetVideoTrackButton extends StatelessWidget {
632632
if (videotracks == null) {
633633
return;
634634
}
635-
await showDialog(
635+
await showDialog<void>(
636636
context: context,
637637
builder: (BuildContext context) {
638638
return AlertDialog(
@@ -676,7 +676,7 @@ class _GetAudioTrackButton extends StatelessWidget {
676676
if (audioTracks == null) {
677677
return;
678678
}
679-
await showDialog(
679+
await showDialog<void>(
680680
context: context,
681681
builder: (BuildContext context) {
682682
return AlertDialog(
@@ -720,7 +720,7 @@ class _GetTextTrackButton extends StatelessWidget {
720720
if (textTracks == null) {
721721
return;
722722
}
723-
await showDialog(
723+
await showDialog<void>(
724724
context: context,
725725
builder: (BuildContext context) {
726726
return AlertDialog(

packages/video_player_videohole/example/lib/main.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ class _GetVideoTrackButton extends StatelessWidget {
567567
if (videotracks == null) {
568568
return;
569569
}
570-
await showDialog(
570+
await showDialog<void>(
571571
context: context,
572572
builder: (BuildContext context) {
573573
return AlertDialog(
@@ -611,7 +611,7 @@ class _GetAudioTrackButton extends StatelessWidget {
611611
if (audioTracks == null) {
612612
return;
613613
}
614-
await showDialog(
614+
await showDialog<void>(
615615
context: context,
616616
builder: (BuildContext context) {
617617
return AlertDialog(
@@ -655,7 +655,7 @@ class _GetTextTrackButton extends StatelessWidget {
655655
if (textTracks == null) {
656656
return;
657657
}
658-
await showDialog(
658+
await showDialog<void>(
659659
context: context,
660660
builder: (BuildContext context) {
661661
return AlertDialog(

0 commit comments

Comments
 (0)