|
1 | | -# Specify analysis options. |
| 1 | +# In general, the regular analysis_options.yaml file found at the root of the |
| 2 | +# repo also applies to engine code. |
2 | 3 | # |
3 | | -# This file is a copy of analysis_options.yaml from flutter repo |
4 | | -# as of 2025-01-13, but with some modifications marked with |
5 | | -# "DIFFERENT FROM FLUTTER/FLUTTER" below. |
| 4 | +# This file applies some engine-specific settings to the general rule set. |
| 5 | +# Deviations from the general rules are rare. They should be kept to a |
| 6 | +# minimum to ensure a unified style across the repo. |
| 7 | +# |
| 8 | +# The reasoning for deviating from the general style must be documented below. |
| 9 | + |
| 10 | +include: ../../../analysis_options.yaml |
6 | 11 |
|
7 | 12 | analyzer: |
8 | | - language: |
9 | | - strict-casts: true |
10 | | - strict-inference: true |
11 | | - strict-raw-types: true |
12 | | - errors: |
13 | | - # allow deprecated members (we do this because otherwise we have to annotate |
14 | | - # every member in every test, assert, etc, when we or the Dart SDK deprecates |
15 | | - # something (https://github.com/flutter/flutter/issues/143312) |
16 | | - deprecated_member_use: ignore |
17 | | - deprecated_member_use_from_same_package: ignore |
18 | | - exclude: # DIFFERENT FROM FLUTTER/FLUTTER |
| 13 | + exclude: |
19 | 14 | - examples |
20 | 15 | # Fixture depends on dart:ui and raises false positives. |
21 | 16 | - flutter_frontend_server/test/fixtures/lib/main.dart |
22 | 17 | - prebuilts |
23 | 18 | - third_party |
24 | 19 | - shell/platform/fuchsia |
25 | 20 |
|
26 | | -formatter: |
27 | | - page_width: 100 |
28 | | - |
29 | 21 | linter: |
30 | 22 | rules: |
31 | | - # This list is derived from the list of all available lints located at |
32 | | - # https://github.com/dart-lang/linter/blob/main/example/all.yaml |
33 | | - - always_declare_return_types |
34 | | - - always_put_control_body_on_new_line |
35 | | - # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219 |
36 | | - # - always_specify_types # DIFFERENT FROM FLUTTER/FLUTTER; see https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#dart |
37 | | - # - always_use_package_imports # we do this commonly |
38 | | - - annotate_overrides |
39 | | - - annotate_redeclares |
40 | | - # - avoid_annotating_with_dynamic # conflicts with always_specify_types |
41 | | - - avoid_bool_literals_in_conditional_expressions |
42 | | - # - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023 |
43 | | - # - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/4998 |
44 | | - # - avoid_classes_with_only_static_members # we do this commonly for `abstract final class`es |
45 | | - - avoid_double_and_int_checks |
46 | | - - avoid_dynamic_calls |
47 | | - - avoid_empty_else |
48 | | - # - avoid_equals_and_hash_code_on_mutable_classes # DIFFERENT FROM FLUTTER/FLUTTER (can't import the meta package here) |
49 | | - - avoid_escaping_inner_quotes |
50 | | - - avoid_field_initializers_in_const_classes |
51 | | - # - avoid_final_parameters # incompatible with prefer_final_parameters |
52 | | - - avoid_function_literals_in_foreach_calls |
53 | | - # - avoid_futureor_void # not yet tested |
54 | | - # - avoid_implementing_value_types # see https://github.com/dart-lang/linter/issues/4558 |
55 | | - - avoid_init_to_null |
56 | | - - avoid_js_rounded_ints |
57 | | - # - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to |
58 | | - - avoid_null_checks_in_equality_operators |
59 | | - # - avoid_positional_boolean_parameters # would have been nice to enable this but by now there's too many places that break it |
60 | | - - avoid_print |
61 | | - # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356) |
62 | | - - avoid_redundant_argument_values |
63 | | - - avoid_relative_lib_imports |
64 | | - - avoid_renaming_method_parameters |
65 | | - - avoid_return_types_on_setters |
66 | | - - avoid_returning_null_for_void |
67 | | - # - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives |
68 | | - - avoid_setters_without_getters |
69 | | - - avoid_shadowing_type_parameters |
70 | | - - avoid_single_cascade_in_expression_statements |
71 | | - - avoid_slow_async_io |
72 | | - - avoid_type_to_string |
73 | | - - avoid_types_as_parameter_names |
74 | | - # - avoid_types_on_closure_parameters # conflicts with always_specify_types |
75 | | - - avoid_unnecessary_containers |
76 | | - - avoid_unused_constructor_parameters |
77 | | - - avoid_void_async |
78 | | - # - avoid_web_libraries_in_flutter # we use web libraries in web-specific code, and our tests prevent us from using them elsewhere |
79 | | - - await_only_futures |
80 | | - - camel_case_extensions |
81 | | - - camel_case_types |
82 | | - - cancel_subscriptions |
83 | | - # - cascade_invocations # doesn't match the typical style of this repo |
84 | | - - cast_nullable_to_non_nullable |
85 | | - # - close_sinks # not reliable enough |
86 | | - - collection_methods_unrelated_type |
87 | | - - combinators_ordering |
88 | | - # - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142 |
89 | | - - conditional_uri_does_not_exist |
90 | | - # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204 |
91 | | - - control_flow_in_finally |
92 | | - - curly_braces_in_flow_control_structures |
93 | | - - dangling_library_doc_comments |
94 | | - - depend_on_referenced_packages |
95 | | - - deprecated_consistency |
96 | | - # - deprecated_member_use_from_same_package # we allow self-references to deprecated members |
97 | | - # - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib) |
98 | | - - directives_ordering |
99 | | - # - discarded_futures # too many false positives, similar to unawaited_futures |
100 | | - # - 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 |
102 | | - - empty_catches |
103 | | - - empty_constructor_bodies |
104 | | - - empty_statements |
105 | | - - eol_at_end_of_file |
106 | | - - exhaustive_cases |
107 | | - - file_names |
108 | | - - flutter_style_todos |
109 | | - - hash_and_equals |
110 | | - - implementation_imports |
111 | | - - implicit_call_tearoffs |
112 | | - - implicit_reopen |
113 | | - - invalid_case_patterns |
114 | | - - invalid_runtime_check_with_js_interop_types |
115 | | - # - join_return_with_assignment # not required by flutter style |
116 | | - - leading_newlines_in_multiline_strings |
117 | | - - library_annotations |
118 | | - - library_names |
119 | | - - library_prefixes |
120 | | - - library_private_types_in_public_api |
121 | | - # - lines_longer_than_80_chars # not required by flutter style |
122 | | - - literal_only_boolean_expressions |
123 | | - # - matching_super_parameters # blocked on https://github.com/dart-lang/language/issues/2509 |
124 | | - - missing_code_block_language_in_doc_comment |
125 | | - # - missing_whitespace_between_adjacent_strings # DIFFERENT FROM FLUTTER/FLUTTER (too many false positives) |
126 | | - - no_adjacent_strings_in_list |
127 | | - - no_default_cases |
128 | | - - no_duplicate_case_values |
129 | | - - no_leading_underscores_for_library_prefixes |
130 | | - - no_leading_underscores_for_local_identifiers |
131 | | - - no_literal_bool_comparisons |
132 | | - - no_logic_in_create_state |
133 | | - # - no_runtimeType_toString # ok in tests; we enable this only in packages/ |
134 | | - - no_self_assignments |
135 | | - - no_wildcard_variable_uses |
136 | | - - non_constant_identifier_names |
137 | | - - noop_primitive_operations |
138 | | - - null_check_on_nullable_type_parameter |
139 | | - - null_closures |
140 | | - # - 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 |
143 | | - # - one_member_abstracts # too many false positives |
144 | | - - only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al |
145 | | - - overridden_fields |
146 | | - - package_names |
147 | | - - package_prefixed_library_names |
148 | | - # - parameter_assignments # we do this commonly |
149 | | - - prefer_adjacent_string_concatenation |
150 | | - - prefer_asserts_in_initializer_lists |
151 | | - # - prefer_asserts_with_message # not required by flutter style |
152 | | - - prefer_collection_literals |
153 | | - - prefer_conditional_assignment |
154 | | - - prefer_const_constructors |
155 | | - - prefer_const_constructors_in_immutables |
156 | | - - prefer_const_declarations |
157 | | - - prefer_const_literals_to_create_immutables |
158 | | - # - prefer_constructors_over_static_methods # far too many false positives |
159 | | - - prefer_contains |
160 | | - # - prefer_double_quotes # opposite of prefer_single_quotes |
161 | | - # - prefer_expression_function_bodies # conflicts with ./docs/contributing/Style-guide-for-Flutter-repo.md#consider-using--for-short-functions-and-methods |
162 | | - - prefer_final_fields |
163 | | - - prefer_final_in_for_each |
164 | | - - prefer_final_locals |
165 | | - # - prefer_final_parameters # adds too much verbosity |
166 | | - - prefer_for_elements_to_map_fromIterable |
167 | | - - prefer_foreach |
168 | | - - prefer_function_declarations_over_variables |
169 | | - - prefer_generic_function_type_aliases |
170 | | - - prefer_if_elements_to_conditional_expressions |
171 | | - - prefer_if_null_operators |
172 | | - - prefer_initializing_formals |
173 | | - - prefer_inlined_adds |
174 | | - # - prefer_int_literals # conflicts with ./docs/contributing/Style-guide-for-Flutter-repo.md#use-double-literals-for-double-constants |
175 | | - - prefer_interpolation_to_compose_strings |
176 | | - - prefer_is_empty |
177 | | - - prefer_is_not_empty |
178 | | - - prefer_is_not_operator |
179 | | - - prefer_iterable_whereType |
180 | | - - prefer_mixin |
181 | | - # - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere |
182 | | - - prefer_null_aware_operators |
183 | | - - prefer_relative_imports |
184 | | - - prefer_single_quotes |
185 | | - - prefer_spread_collections |
186 | | - - prefer_typing_uninitialized_variables |
187 | | - - prefer_void_to_null |
188 | | - - provide_deprecation_message |
189 | | - - public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER |
190 | | - - recursive_getters |
191 | | - # - 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 |
192 | | - - secure_pubspec_urls |
193 | | - - sized_box_for_whitespace |
194 | | - - sized_box_shrink_expand |
195 | | - - slash_for_doc_comments |
196 | | - - sort_child_properties_last |
197 | | - - sort_constructors_first |
198 | | - # - sort_pub_dependencies # prevents separating pinned transitive dependencies |
199 | | - - 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 |
203 | | - - test_types_in_equals |
204 | | - - throw_in_finally |
205 | | - - tighten_type_of_initializing_formals |
206 | | - - type_annotate_public_apis # DIFFERENT FROM FLUTTER/FLUTTER; this repo disable always_specify_types (https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#dart) |
207 | | - - type_init_formals |
208 | | - - type_literal_in_constant_pattern |
209 | | - # - 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 |
212 | | - - unnecessary_await_in_return |
213 | | - - unnecessary_brace_in_string_interps |
214 | | - - unnecessary_breaks |
215 | | - - unnecessary_const |
216 | | - - unnecessary_constructor_name |
217 | | - # - unnecessary_final # conflicts with prefer_final_locals |
218 | | - - unnecessary_getters_setters |
219 | | - # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498 |
220 | | - - unnecessary_late |
221 | | - - unnecessary_library_directive |
222 | | - # - unnecessary_library_name # blocked on https://github.com/dart-lang/dartdoc/issues/3882 |
223 | | - - unnecessary_new |
224 | | - - unnecessary_null_aware_assignments |
225 | | - - unnecessary_null_aware_operator_on_extension_on_nullable |
226 | | - - unnecessary_null_checks |
227 | | - - unnecessary_null_in_if_null_operators |
228 | | - - unnecessary_nullable_for_final_variable_declarations |
229 | | - - unnecessary_overrides |
230 | | - - unnecessary_parenthesis |
231 | | - # - unnecessary_raw_strings # what's "necessary" is a matter of opinion; consistency across strings can help readability more than this lint |
232 | | - - unnecessary_statements |
233 | | - - unnecessary_string_escapes |
234 | | - - unnecessary_string_interpolations |
235 | | - - unnecessary_this |
236 | | - - unnecessary_to_list_in_spreads |
237 | | - - unnecessary_underscores |
238 | | - - unreachable_from_main |
239 | | - - unrelated_type_equality_checks |
240 | | - # - unsafe_variance # not yet tested |
241 | | - - use_build_context_synchronously |
242 | | - - use_colored_box |
243 | | - # - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding) |
244 | | - - use_enums |
245 | | - - use_full_hex_values_for_flutter_colors |
246 | | - - use_function_type_syntax_for_parameters |
247 | | - - use_if_null_to_convert_nulls_to_bools |
248 | | - - use_is_even_rather_than_modulo |
249 | | - - use_key_in_widget_constructors |
250 | | - - use_late_for_private_fields_and_variables |
251 | | - - use_named_constants |
252 | | - - use_raw_strings |
253 | | - - use_rethrow_when_possible |
254 | | - - use_setters_to_change_properties |
255 | | - # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182 |
256 | | - # - use_string_in_part_of_directives # DIFFERENT FROM FLUTTER/FLUTTER (needs to be evaluated, dart:ui does this frequently) |
257 | | - - use_super_parameters |
258 | | - - use_test_throws_matchers |
259 | | - # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review |
260 | | - - use_truncating_division |
261 | | - - valid_regexps |
262 | | - - void_checks |
| 23 | + always_specify_types: false # see https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#dart |
| 24 | + avoid_equals_and_hash_code_on_mutable_classes: false # cannot import the meta package here |
| 25 | + missing_whitespace_between_adjacent_strings: false # too many false positives |
| 26 | + public_member_api_docs: true # dart:ui is public API |
| 27 | + type_annotate_public_apis: true # to compensate for disabeling always_specify_types, see https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#dart |
| 28 | + use_string_in_part_of_directives: false # needs to be evaluated, dart:ui frequently uses non-strings |
0 commit comments