Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 3993fa7

Browse files
Re-sync analysis_options.yaml with flutter/flutter (#5695)
The analysis options have gotten behind; this re-syncs to the current state of flutter/flutter. For options that are non-trivial to enable, either because they are non-trivial to fix, or touch a very large number of files, they are locally disabled with clear "LOCAL CHANGE" markers so that it's obvious where we are out of sync. For options that are simple to resolve, they are enabled in the PR. Part of flutter/flutter#76229
1 parent 2ca342c commit 3993fa7

File tree

135 files changed

+412
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+412
-292
lines changed

analysis_options.yaml

Lines changed: 79 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,21 @@
99

1010
# Specify analysis options.
1111
#
12-
# Until there are meta linter rules, each desired lint must be explicitly enabled.
13-
# See: https://github.com/dart-lang/linter/issues/288
14-
#
1512
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
1613
# See the configuration guide for more
17-
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
14+
# https://github.com/dart-lang/sdk/tree/main/pkg/analyzer#configuring-the-analyzer
1815
#
1916
# There are other similar analysis options files in the flutter repos,
2017
# which should be kept in sync with this file:
2118
#
2219
# - analysis_options.yaml (this file)
2320
# - packages/flutter/lib/analysis_options_user.yaml
24-
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
25-
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
21+
# - https://github.com/flutter/flutter/blob/master/analysis_options.yaml
22+
# - https://github.com/flutter/engine/blob/main/analysis_options.yaml
23+
# - https://github.com/flutter/packages/blob/main/analysis_options.yaml
2624
#
27-
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
28-
# Android Studio, and the `flutter analyze` command.
25+
# This file contains the analysis options used for code in the flutter/plugins
26+
# repository.
2927

3028
analyzer:
3129
strong-mode:
@@ -36,7 +34,7 @@ analyzer:
3634
missing_required_param: warning
3735
# treat missing returns as a warning (not a hint)
3836
missing_return: warning
39-
# allow having TODOs in the code
37+
# allow having TODO comments in the code
4038
todo: ignore
4139
# allow self-reference to deprecated members (we do this because otherwise we have
4240
# to annotate every member in every test, assert, etc, when we deprecate something)
@@ -45,9 +43,10 @@ analyzer:
4543
# Stream and not importing dart:async
4644
# Please see https://github.com/flutter/flutter/pull/24528 for details.
4745
sdk_version_async_exported_from_core: ignore
46+
# Turned off until null-safe rollout is complete.
47+
unnecessary_null_comparison: ignore
4848
### Local flutter/plugins changes ###
4949
# Allow null checks for as long as mixed mode is officially supported.
50-
unnecessary_null_comparison: false
5150
always_require_non_null_named_parameters: false # not needed with nnbd
5251
exclude:
5352
# Ignore generated files
@@ -58,8 +57,7 @@ analyzer:
5857

5958
linter:
6059
rules:
61-
# these rules are documented on and in the same order as
62-
# the Dart Lint rules page to make maintenance easier
60+
# This list is derived from the list of all available lints located at
6361
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
6462
- always_declare_return_types
6563
- always_put_control_body_on_new_line
@@ -69,62 +67,68 @@ linter:
6967
# - always_use_package_imports # we do this commonly
7068
- annotate_overrides
7169
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
72-
# - avoid_as # required for implicit-casts: true
7370
- avoid_bool_literals_in_conditional_expressions
74-
# - avoid_catches_without_on_clauses # we do this commonly
75-
# - avoid_catching_errors # we do this commonly
71+
# - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
72+
# - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
7673
- avoid_classes_with_only_static_members
77-
# - avoid_double_and_int_checks # only useful when targeting JS runtime
74+
- avoid_double_and_int_checks
75+
# - avoid_dynamic_calls # LOCAL CHANGE - Needs to be enabled and violations fixed.
7876
- avoid_empty_else
7977
- avoid_equals_and_hash_code_on_mutable_classes
80-
# - avoid_escaping_inner_quotes # not yet tested
78+
- avoid_escaping_inner_quotes
8179
- avoid_field_initializers_in_const_classes
80+
# - avoid_final_parameters # incompatible with prefer_final_parameters
8281
- avoid_function_literals_in_foreach_calls
83-
# - avoid_implementing_value_types # not yet tested
82+
# - avoid_implementing_value_types # LOCAL CHANGE - Needs to be enabled and violations fixed.
8483
- avoid_init_to_null
85-
# - avoid_js_rounded_ints # only useful when targeting JS runtime
84+
- avoid_js_rounded_ints
85+
# - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
8686
- avoid_null_checks_in_equality_operators
87-
# - avoid_positional_boolean_parameters # not yet tested
88-
# - avoid_print # not yet tested
87+
# - avoid_positional_boolean_parameters # would have been nice to enable this but by now there's too many places that break it
88+
# - avoid_print # LOCAL CHANGE - Needs to be enabled and violations fixed.
8989
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
90-
# - avoid_redundant_argument_values # not yet tested
90+
# - avoid_redundant_argument_values # LOCAL CHANGE - Needs to be enabled and violations fixed.
9191
- avoid_relative_lib_imports
9292
- avoid_renaming_method_parameters
9393
- avoid_return_types_on_setters
94-
# - avoid_returning_null # there are plenty of valid reasons to return null
95-
# - avoid_returning_null_for_future # not yet tested
94+
# - avoid_returning_null # still violated by some pre-nnbd code that we haven't yet migrated
95+
- avoid_returning_null_for_future
9696
- avoid_returning_null_for_void
97-
# - avoid_returning_this # there are plenty of valid reasons to return this
98-
# - avoid_setters_without_getters # not yet tested
97+
# - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives
98+
- avoid_setters_without_getters
9999
- avoid_shadowing_type_parameters
100100
- avoid_single_cascade_in_expression_statements
101101
- avoid_slow_async_io
102-
# - avoid_type_to_string # we do this commonly
102+
- avoid_type_to_string
103103
- avoid_types_as_parameter_names
104104
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
105-
# - avoid_unnecessary_containers # not yet tested
105+
- avoid_unnecessary_containers
106106
- avoid_unused_constructor_parameters
107107
- avoid_void_async
108-
# - avoid_web_libraries_in_flutter # not yet tested
108+
# - avoid_web_libraries_in_flutter # we use web libraries in web-specific code, and our tests prevent us from using them elsewhere
109109
- await_only_futures
110110
- camel_case_extensions
111111
- camel_case_types
112112
- cancel_subscriptions
113-
# - cascade_invocations # not yet tested
113+
# - cascade_invocations # doesn't match the typical style of this repo
114114
- cast_nullable_to_non_nullable
115115
# - close_sinks # not reliable enough
116-
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
116+
# - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
117+
# - conditional_uri_does_not_exist # not yet tested
117118
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
118119
- control_flow_in_finally
119120
# - curly_braces_in_flow_control_structures # not required by flutter style
120-
# - diagnostic_describe_all_properties # not yet tested
121+
# - depend_on_referenced_packages # LOCAL CHANGE - Needs to be enabled and violations fixed.
122+
- deprecated_consistency
123+
# - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
121124
- directives_ordering
122-
# - do_not_use_environment # we do this commonly
125+
# - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
123126
- empty_catches
124127
- empty_constructor_bodies
125128
- empty_statements
129+
- eol_at_end_of_file
126130
- exhaustive_cases
127-
# - file_names # not yet tested
131+
- file_names
128132
- flutter_style_todos
129133
- hash_and_equals
130134
- implementation_imports
@@ -137,22 +141,25 @@ linter:
137141
- library_private_types_in_public_api
138142
# - lines_longer_than_80_chars # not required by flutter style
139143
- list_remove_unrelated_type
140-
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
141-
# - missing_whitespace_between_adjacent_strings # not yet tested
144+
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
145+
- missing_whitespace_between_adjacent_strings
142146
- no_adjacent_strings_in_list
143-
# - no_default_cases # too many false positives
147+
# - no_default_cases # LOCAL CHANGE - Needs to be enabled and violations fixed.
144148
- no_duplicate_case_values
149+
- no_leading_underscores_for_library_prefixes
150+
# - no_leading_underscores_for_local_identifiers # LOCAL CHANGE - Needs to be enabled and violations fixed.
145151
- no_logic_in_create_state
146152
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
147153
- non_constant_identifier_names
154+
- noop_primitive_operations
148155
- null_check_on_nullable_type_parameter
149-
# - null_closures # not required by flutter style
156+
- null_closures
150157
# - omit_local_variable_types # opposite of always_specify_types
151158
# - one_member_abstracts # too many false positives
152-
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
159+
# - only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al # LOCAL CHANGE - Needs to be enabled and violations fixed.
153160
- overridden_fields
154161
- package_api_docs
155-
# - package_names # non conforming packages in sdk
162+
- package_names
156163
- package_prefixed_library_names
157164
# - parameter_assignments # we do this commonly
158165
- prefer_adjacent_string_concatenation
@@ -172,74 +179,90 @@ linter:
172179
- prefer_final_fields
173180
- prefer_final_in_for_each
174181
- prefer_final_locals
182+
# - 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
175183
- prefer_for_elements_to_map_fromIterable
176184
- prefer_foreach
177-
# - prefer_function_declarations_over_variables # not yet tested
185+
- prefer_function_declarations_over_variables
178186
- prefer_generic_function_type_aliases
179187
- prefer_if_elements_to_conditional_expressions
180188
- prefer_if_null_operators
181189
- prefer_initializing_formals
182190
- prefer_inlined_adds
183-
# - prefer_int_literals # not yet tested
184-
# - prefer_interpolation_to_compose_strings # not yet tested
191+
# - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants
192+
- prefer_interpolation_to_compose_strings
185193
- prefer_is_empty
186194
- prefer_is_not_empty
187195
- prefer_is_not_operator
188196
- prefer_iterable_whereType
189-
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
190-
# - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
191-
# - prefer_relative_imports # not yet tested
197+
# - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
198+
# - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
199+
- prefer_null_aware_operators
200+
# - prefer_relative_imports # LOCAL CHANGE - Needs to be enabled and violations fixed.
192201
- prefer_single_quotes
193202
- prefer_spread_collections
194203
- prefer_typing_uninitialized_variables
195204
- prefer_void_to_null
196-
# - provide_deprecation_message # not yet tested
205+
- provide_deprecation_message
197206
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
198207
- recursive_getters
199-
# - sized_box_for_whitespace # not yet tested
208+
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
209+
- secure_pubspec_urls
210+
# - sized_box_for_whitespace # LOCAL CHANGE - Needs to be enabled and violations fixed.
211+
# - sized_box_shrink_expand # not yet tested
200212
- slash_for_doc_comments
201213
- sort_child_properties_last
202214
- sort_constructors_first
215+
# - sort_pub_dependencies # prevents separating pinned transitive dependencies
203216
- sort_unnamed_constructors_first
204217
- test_types_in_equals
205218
- throw_in_finally
206219
- tighten_type_of_initializing_formals
207220
# - type_annotate_public_apis # subset of always_specify_types
208221
- type_init_formals
209-
# - unawaited_futures # too many false positives
210-
# - unnecessary_await_in_return # not yet tested
222+
# - unawaited_futures # too many false positives, especially with the way AnimationController works
223+
# - unnecessary_await_in_return # LOCAL CHANGE - Needs to be enabled and violations fixed.
211224
- unnecessary_brace_in_string_interps
212225
- unnecessary_const
226+
- unnecessary_constructor_name
213227
# - unnecessary_final # conflicts with prefer_final_locals
214228
- unnecessary_getters_setters
215229
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
230+
- unnecessary_late
216231
- unnecessary_new
217232
- unnecessary_null_aware_assignments
218-
# - unnecessary_null_checks # not yet tested
233+
- unnecessary_null_checks
219234
- unnecessary_null_in_if_null_operators
220235
- unnecessary_nullable_for_final_variable_declarations
221236
- unnecessary_overrides
222237
- unnecessary_parenthesis
223-
# - unnecessary_raw_strings # not yet tested
238+
# - unnecessary_raw_strings # what's "necessary" is a matter of opinion; consistency across strings can help readability more than this lint
224239
- unnecessary_statements
225240
- unnecessary_string_escapes
226241
- unnecessary_string_interpolations
227242
- unnecessary_this
228243
- unrelated_type_equality_checks
229-
# - unsafe_html # not yet tested
244+
- unsafe_html
245+
# - use_build_context_synchronously # LOCAL CHANGE - Needs to be enabled and violations fixed.
246+
# - use_colored_box # not yet tested
247+
# - use_decorated_box # not yet tested
248+
# - use_enums # not yet tested
230249
- use_full_hex_values_for_flutter_colors
231-
# - use_function_type_syntax_for_parameters # not yet tested
250+
- use_function_type_syntax_for_parameters
251+
- use_if_null_to_convert_nulls_to_bools
232252
- use_is_even_rather_than_modulo
233253
- use_key_in_widget_constructors
234254
- use_late_for_private_fields_and_variables
255+
# - use_named_constants # LOCAL CHANGE - Needs to be enabled and violations fixed.
235256
- use_raw_strings
236257
- use_rethrow_when_possible
237-
# - use_setters_to_change_properties # not yet tested
258+
- use_setters_to_change_properties
238259
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
260+
- use_super_parameters
261+
- use_test_throws_matchers
239262
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
240263
- valid_regexps
241264
- void_checks
242-
### Local flutter/plugins changes ###
265+
### Local flutter/plugins additions ###
243266
# These are from flutter/flutter/packages, so will need to be preserved
244267
# separately when moving to a shared file.
245268
- no_runtimeType_toString # use objectRuntimeType from package:foundation

packages/camera/camera/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.4+23
2+
3+
* Minor fixes for new analysis options.
4+
15
## 0.9.4+22
26

37
* Removes unnecessary imports.

packages/camera/camera/example/lib/main.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,14 +575,13 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
575575
Widget _cameraTogglesRowWidget() {
576576
final List<Widget> toggles = <Widget>[];
577577

578-
final Null Function(CameraDescription? description) onChanged =
579-
(CameraDescription? description) {
578+
void onChanged(CameraDescription? description) {
580579
if (description == null) {
581580
return;
582581
}
583582

584583
onNewCameraSelected(description);
585-
};
584+
}
586585

587586
if (_cameras.isEmpty) {
588587
_ambiguate(SchedulerBinding.instance)?.addPostFrameCallback((_) async {

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
44
Dart.
55
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
7-
version: 0.9.4+22
7+
version: 0.9.4+23
88

99
environment:
1010
sdk: ">=2.14.0 <3.0.0"

packages/camera/camera_web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.1+6
2+
3+
* Minor fixes for new analysis options.
4+
15
## 0.2.1+5
26

37
* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors

packages/camera/camera_web/example/integration_test/camera_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ void main() {
14771477
});
14781478

14791479
group('dispose', () {
1480-
testWidgets('resets the video element\'s source',
1480+
testWidgets("resets the video element's source",
14811481
(WidgetTester tester) async {
14821482
final Camera camera = Camera(
14831483
textureId: textureId,

packages/camera/camera_web/example/integration_test/camera_web_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ void main() {
498498
isA<CameraException>().having(
499499
(CameraException e) => e.code,
500500
'code',
501-
exception.code.toString(),
501+
exception.code,
502502
),
503503
),
504504
);
@@ -759,7 +759,7 @@ void main() {
759759
isA<PlatformException>().having(
760760
(PlatformException e) => e.code,
761761
'code',
762-
exception.name.toString(),
762+
exception.name,
763763
),
764764
),
765765
);
@@ -2495,7 +2495,7 @@ void main() {
24952495
equals(
24962496
CameraErrorEvent(
24972497
cameraId,
2498-
'Error code: ${CameraErrorCode.abort}, error message: The video element\'s source has not fully loaded.',
2498+
"Error code: ${CameraErrorCode.abort}, error message: The video element's source has not fully loaded.",
24992499
),
25002500
),
25012501
);

packages/camera/camera_web/example/integration_test/helpers/mocks.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class FakeElementStream<T extends Event> extends Fake
113113
final Stream<T> _stream;
114114

115115
@override
116-
StreamSubscription<T> listen(void onData(T event)?,
117-
{Function? onError, void onDone()?, bool? cancelOnError}) {
116+
StreamSubscription<T> listen(void Function(T event)? onData,
117+
{Function? onError, void Function()? onDone, bool? cancelOnError}) {
118118
return _stream.listen(
119119
onData,
120120
onError: onError,

packages/camera/camera_web/lib/src/camera.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ class Camera {
138138

139139
/// A builder to merge a list of blobs into a single blob.
140140
@visibleForTesting
141+
// TODO(stuartmorgan): Remove this 'ignore' once we don't analyze using 2.10
142+
// any more. It's a false positive that is fixed in later versions.
143+
// ignore: prefer_function_declarations_over_variables
141144
html.Blob Function(List<html.Blob> blobs, String type) blobBuilder =
142145
(List<html.Blob> blobs, String type) => html.Blob(blobs, type);
143146

packages/camera/camera_web/lib/src/camera_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class CameraService {
8282
throw CameraWebException(
8383
cameraId,
8484
CameraErrorCode.type,
85-
'The camera options are incorrect or attempted'
85+
'The camera options are incorrect or attempted '
8686
'to access the media input from an insecure context.',
8787
);
8888
case 'AbortError':

0 commit comments

Comments
 (0)