Skip to content

Commit

Permalink
[various] Sync lints with flutter/flutter (flutter#5717)
Browse files Browse the repository at this point in the history
Applying the latest analysis_options.yaml from flutter/flutter to this
repo. Most fixes were auto-generated by `dart fix`.
  • Loading branch information
goderbauer committed Jan 3, 2024
1 parent 6b2249f commit bb97da8
Show file tree
Hide file tree
Showing 282 changed files with 527 additions and 947 deletions.
48 changes: 30 additions & 18 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Specify analysis options.
#
# This file is a copy of analysis_options.yaml from flutter repo
# as of 2022-07-27, but with some modifications marked with
# as of 2023-12-18, but with some modifications marked with
# "DIFFERENT FROM FLUTTER/FLUTTER" below. The file is expected to
# be kept in sync with the master file from the flutter repo.

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
# allow self-reference to deprecated members (we do this because otherwise we have
Expand All @@ -21,19 +22,18 @@ analyzer:
linter:
rules:
# This list is derived from the list of all available lints located at
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
# https://github.com/dart-lang/linter/blob/main/example/all.yaml
- always_declare_return_types
- always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- always_require_non_null_named_parameters
- always_specify_types
# - always_use_package_imports # we do this commonly
- annotate_overrides
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
- avoid_bool_literals_in_conditional_expressions
# - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
# - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
- avoid_classes_with_only_static_members
# - avoid_classes_with_only_static_members # we do this commonly for `abstract final class`es
- avoid_double_and_int_checks
- avoid_dynamic_calls
- avoid_empty_else
Expand All @@ -42,7 +42,7 @@ linter:
- avoid_field_initializers_in_const_classes
# - avoid_final_parameters # incompatible with prefer_final_parameters
- avoid_function_literals_in_foreach_calls
- avoid_implementing_value_types
# - avoid_implementing_value_types # see https://github.com/dart-lang/linter/issues/4558
- avoid_init_to_null
- avoid_js_rounded_ints
# - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
Expand All @@ -54,8 +54,6 @@ linter:
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_null_for_void
# - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives
- avoid_setters_without_getters
Expand All @@ -77,17 +75,19 @@ linter:
- cast_nullable_to_non_nullable
# - close_sinks # not reliable enough
- collection_methods_unrelated_type
# - combinators_ordering # DIFFERENT FROM FLUTTER/FLUTTER: This isn't available on stable yet.
- combinators_ordering
# - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
- conditional_uri_does_not_exist
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
- control_flow_in_finally
- curly_braces_in_flow_control_structures
- dangling_library_doc_comments
- depend_on_referenced_packages
- deprecated_consistency
# - deprecated_member_use_from_same_package # we allow self-references to deprecated members
# - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
- directives_ordering
# - discarded_futures # not yet tested
# - discarded_futures # too many false positives, similar to unawaited_futures
# - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
- empty_catches
- empty_constructor_bodies
Expand All @@ -98,21 +98,29 @@ linter:
- flutter_style_todos
- hash_and_equals
- implementation_imports
- implicit_call_tearoffs
- implicit_reopen
- invalid_case_patterns
# - join_return_with_assignment # not required by flutter style
- leading_newlines_in_multiline_strings
- library_annotations
- library_names
- library_prefixes
- library_private_types_in_public_api
# - lines_longer_than_80_chars # not required by flutter style
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
- literal_only_boolean_expressions
# - matching_super_parameters # blocked on https://github.com/dart-lang/language/issues/2509
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_default_cases
- no_duplicate_case_values
- no_leading_underscores_for_library_prefixes
- no_leading_underscores_for_local_identifiers
- no_literal_bool_comparisons
- no_logic_in_create_state
- no_runtimeType_toString # DIFFERENT FROM FLUTTER/FLUTTER
- no_self_assignments
- no_wildcard_variable_uses
- non_constant_identifier_names
- noop_primitive_operations
- null_check_on_nullable_type_parameter
Expand All @@ -137,12 +145,11 @@ linter:
# - prefer_constructors_over_static_methods # far too many false positives
- prefer_contains
# - prefer_double_quotes # opposite of prefer_single_quotes
- prefer_equal_for_default_values
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
# - 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
# - prefer_final_parameters # adds too much verbosity
- prefer_for_elements_to_map_fromIterable
- prefer_foreach
- prefer_function_declarations_over_variables
Expand All @@ -157,7 +164,7 @@ linter:
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_iterable_whereType
# - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
# - prefer_mixin # DIFFERENT FROM FLUTTER/FLUTTER: enable when v2.1.7 of plugin_platform_interface is the oldest supported version (which makes MockPlatformInterfaceMixin a mixin class)
# - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
- prefer_null_aware_operators
- prefer_relative_imports
Expand All @@ -168,10 +175,10 @@ linter:
- provide_deprecation_message
- public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER
- recursive_getters
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
# - 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
- secure_pubspec_urls
- sized_box_for_whitespace
# - sized_box_shrink_expand # not yet tested
- sized_box_shrink_expand
- slash_for_doc_comments
- sort_child_properties_last
- sort_constructors_first
Expand All @@ -182,15 +189,18 @@ linter:
- tighten_type_of_initializing_formals
# - type_annotate_public_apis # subset of always_specify_types
- type_init_formals
- type_literal_in_constant_pattern
- 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.
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_breaks
- unnecessary_const
- unnecessary_constructor_name
# - unnecessary_final # conflicts with prefer_final_locals
- unnecessary_getters_setters
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
- unnecessary_late
- unnecessary_library_directive
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_aware_operator_on_extension_on_nullable
Expand All @@ -205,12 +215,13 @@ linter:
- unnecessary_string_interpolations
- unnecessary_this
- unnecessary_to_list_in_spreads
- unreachable_from_main
- unrelated_type_equality_checks
- unsafe_html
- use_build_context_synchronously
# - use_colored_box # not yet tested
# - use_decorated_box # not yet tested
# - use_enums # not yet tested
- use_colored_box
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
- use_enums
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
- use_if_null_to_convert_nulls_to_bools
Expand All @@ -222,6 +233,7 @@ linter:
- use_rethrow_when_possible
- use_setters_to_change_properties
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
- use_string_in_part_of_directives
- use_super_parameters
- use_test_throws_matchers
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
Expand Down
4 changes: 4 additions & 0 deletions packages/animations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.11

* Fixes new lint warnings.

## 2.0.10

* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
Expand Down
2 changes: 1 addition & 1 deletion packages/animations/example/lib/container_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class _ExampleCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
child: Container(
child: ColoredBox(
color: Colors.black38,
child: Center(
child: Image.asset(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class _ExampleCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
child: Container(
child: ColoredBox(
color: Colors.black26,
child: Padding(
padding: const EdgeInsets.all(30.0),
Expand Down
2 changes: 1 addition & 1 deletion packages/animations/lib/src/fade_through_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class FadeThroughTransition extends StatelessWidget {
Widget build(BuildContext context) {
return _ZoomedFadeInFadeOut(
animation: animation,
child: Container(
child: ColoredBox(
color: fillColor ?? Theme.of(context).canvasColor,
child: _ZoomedFadeInFadeOut(
animation: ReverseAnimation(secondaryAnimation),
Expand Down
9 changes: 0 additions & 9 deletions packages/animations/lib/src/open_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,8 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
switch (status) {
case AnimationStatus.dismissed:
_toggleHideable(hide: false);
break;
case AnimationStatus.completed:
_toggleHideable(hide: true);
break;
case AnimationStatus.forward:
case AnimationStatus.reverse:
break;
Expand Down Expand Up @@ -699,23 +697,19 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
case AnimationStatus.completed:
case AnimationStatus.dismissed:
isInProgress = false;
break;
case AnimationStatus.forward:
case AnimationStatus.reverse:
isInProgress = true;
break;
case null:
break;
}
switch (_lastAnimationStatus) {
case AnimationStatus.completed:
case AnimationStatus.dismissed:
wasInProgress = false;
break;
case AnimationStatus.forward:
case AnimationStatus.reverse:
wasInProgress = true;
break;
case null:
break;
}
Expand Down Expand Up @@ -769,7 +763,6 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
openOpacityTween = _openOpacityTween;
colorTween = _colorTween;
scrimTween = _scrimFadeInTween;
break;
case AnimationStatus.reverse:
if (_transitionWasInterrupted) {
closedOpacityTween = _closedOpacityTween;
Expand All @@ -782,10 +775,8 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
openOpacityTween = _openOpacityTween.flipped;
colorTween = _colorTween.flipped;
scrimTween = _scrimFadeOutTween;
break;
case AnimationStatus.completed:
assert(false); // Unreachable.
break;
}
assert(colorTween != null);
assert(closedOpacityTween != null);
Expand Down
6 changes: 3 additions & 3 deletions packages/animations/lib/src/shared_axis_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class _ExitTransition extends StatelessWidget {

return FadeTransition(
opacity: _fadeOutTransition.animate(animation),
child: Container(
child: ColoredBox(
color: fillColor,
child: AnimatedBuilder(
animation: animation,
Expand All @@ -432,7 +432,7 @@ class _ExitTransition extends StatelessWidget {

return FadeTransition(
opacity: _fadeOutTransition.animate(animation),
child: Container(
child: ColoredBox(
color: fillColor,
child: AnimatedBuilder(
animation: animation,
Expand All @@ -449,7 +449,7 @@ class _ExitTransition extends StatelessWidget {
case SharedAxisTransitionType.scaled:
return FadeTransition(
opacity: _fadeOutTransition.animate(animation),
child: Container(
child: ColoredBox(
color: fillColor,
child: ScaleTransition(
scale: (!reverse ? _scaleUpTransition : _scaleDownTransition)
Expand Down
2 changes: 1 addition & 1 deletion packages/animations/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: animations
description: Fancy pre-built animations that can easily be integrated into any Flutter application.
repository: https://github.com/flutter/packages/tree/main/packages/animations
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+animations%22
version: 2.0.10
version: 2.0.11

environment:
sdk: ">=3.2.0 <4.0.0"
Expand Down
Loading

0 comments on commit bb97da8

Please sign in to comment.