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

Commit d21f657

Browse files
authored
Post 3.0 lint sync (#40394)
Post 3.0 lint sync
1 parent 708bf70 commit d21f657

File tree

75 files changed

+68
-377
lines changed

Some content is hidden

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

75 files changed

+68
-377
lines changed

analysis_options.yaml

Lines changed: 16 additions & 12 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 2022-07-27, but with some modifications marked with
4+
# as of 2023-03-22, but with some modifications marked with
55
# "DIFFERENT FROM FLUTTER/FLUTTER" below.
66

77
analyzer:
@@ -23,7 +23,6 @@ linter:
2323
- always_declare_return_types
2424
- always_put_control_body_on_new_line
2525
# - 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
2726
- always_specify_types
2827
# - always_use_package_imports # we do this commonly
2928
- annotate_overrides
@@ -52,8 +51,6 @@ linter:
5251
- avoid_relative_lib_imports
5352
- avoid_renaming_method_parameters
5453
- avoid_return_types_on_setters
55-
- avoid_returning_null
56-
- avoid_returning_null_for_future
5754
- avoid_returning_null_for_void
5855
# - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives
5956
- avoid_setters_without_getters
@@ -74,17 +71,19 @@ linter:
7471
# - cascade_invocations # doesn't match the typical style of this repo
7572
- cast_nullable_to_non_nullable
7673
# - close_sinks # not reliable enough
74+
- collection_methods_unrelated_type
7775
- combinators_ordering
7876
# - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
7977
- conditional_uri_does_not_exist
8078
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
8179
- control_flow_in_finally
8280
- curly_braces_in_flow_control_structures
81+
- dangling_library_doc_comments
8382
- depend_on_referenced_packages
8483
- deprecated_consistency
8584
# - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
8685
- directives_ordering
87-
# - discarded_futures # not yet tested
86+
# - discarded_futures # too many false positives, similar to unawaited_futures
8887
# - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
8988
- empty_catches
9089
- empty_constructor_bodies
@@ -95,10 +94,12 @@ linter:
9594
- flutter_style_todos
9695
- hash_and_equals
9796
- implementation_imports
97+
- implicit_call_tearoffs
9898
- invalid_case_patterns
9999
- iterable_contains_unrelated_type
100100
# - join_return_with_assignment # not required by flutter style
101101
- leading_newlines_in_multiline_strings
102+
- library_annotations
102103
- library_names
103104
- library_prefixes
104105
- library_private_types_in_public_api
@@ -137,7 +138,6 @@ linter:
137138
# - prefer_constructors_over_static_methods # far too many false positives
138139
- prefer_contains
139140
# - prefer_double_quotes # opposite of prefer_single_quotes
140-
- prefer_equal_for_default_values
141141
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
142142
- prefer_final_fields
143143
- prefer_final_in_for_each
@@ -157,7 +157,7 @@ linter:
157157
- prefer_is_not_empty
158158
- prefer_is_not_operator
159159
- prefer_iterable_whereType
160-
# - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
160+
- prefer_mixin
161161
# - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
162162
- prefer_null_aware_operators
163163
- prefer_relative_imports
@@ -168,10 +168,10 @@ linter:
168168
- provide_deprecation_message
169169
- public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER
170170
- recursive_getters
171-
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
171+
# - 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
172172
- secure_pubspec_urls
173173
- sized_box_for_whitespace
174-
# - sized_box_shrink_expand # not yet tested
174+
- sized_box_shrink_expand
175175
- slash_for_doc_comments
176176
- sort_child_properties_last
177177
- sort_constructors_first
@@ -185,12 +185,14 @@ linter:
185185
# - unawaited_futures # too many false positives, especially with the way AnimationController works
186186
- unnecessary_await_in_return
187187
- unnecessary_brace_in_string_interps
188+
- unnecessary_breaks
188189
- unnecessary_const
189190
- unnecessary_constructor_name
190191
# - unnecessary_final # conflicts with prefer_final_locals
191192
- unnecessary_getters_setters
192193
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
193194
- unnecessary_late
195+
- unnecessary_library_directive
194196
- unnecessary_new
195197
- unnecessary_null_aware_assignments
196198
- unnecessary_null_aware_operator_on_extension_on_nullable
@@ -205,12 +207,13 @@ linter:
205207
- unnecessary_string_interpolations
206208
- unnecessary_this
207209
- unnecessary_to_list_in_spreads
210+
# - unreachable_from_main # Do not enable this rule until it is un-marked as "experimental" and carefully re-evaluated.
208211
- unrelated_type_equality_checks
209212
- unsafe_html
210213
- use_build_context_synchronously
211-
# - use_colored_box # not yet tested
212-
# - use_decorated_box # not yet tested
213-
# - use_enums # not yet tested
214+
- use_colored_box
215+
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
216+
- use_enums
214217
- use_full_hex_values_for_flutter_colors
215218
- use_function_type_syntax_for_parameters
216219
- use_if_null_to_convert_nulls_to_bools
@@ -222,6 +225,7 @@ linter:
222225
- use_rethrow_when_possible
223226
- use_setters_to_change_properties
224227
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
228+
# - use_string_in_part_of_directives # DIFFERENT FROM FLUTTER/FLUTTER (needs to be evaluated, dart:ui does this frequently)
225229
- use_super_parameters
226230
- use_test_throws_matchers
227231
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review

ci/bin/format.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -968,13 +968,10 @@ Future<int> main(List<String> arguments) async {
968968
switch (type) {
969969
case MessageType.message:
970970
stderr.writeln(message);
971-
break;
972971
case MessageType.error:
973972
stderr.writeln('ERROR: $message');
974-
break;
975973
case MessageType.warning:
976974
stderr.writeln('WARNING: $message');
977-
break;
978975
}
979976
}
980977

ci/licenses_golden/tool_signature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Signature: 90df0faca032ae220230aef5e61ca020
1+
Signature: 61adfda2905179c8e8b7d754d8660a7f
22

flutter_frontend_server/bin/starter.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
library frontend_server;
65

76
import 'dart:io';
87

flutter_frontend_server/lib/server.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// ignore_for_file: avoid_print
66

7-
library flutter_frontend_server;
87

98
import 'dart:async';
109
import 'dart:io' hide FileSystemEntity;

lib/ui/channel_buffers.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ class ChannelBuffers {
468468
}
469469
index += 1;
470470
resize(channelName, data.getUint32(index, Endian.host));
471-
break;
472471
case 'overflow':
473472
if (bytes[index] != 0x0C) { // 12 = value code for list
474473
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (arguments must be a two-element list, channel name and flag state)");
@@ -493,7 +492,6 @@ class ChannelBuffers {
493492
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (second argument must be a boolean)");
494493
}
495494
allowOverflow(channelName, bytes[index] == 0x01);
496-
break;
497495
default:
498496
throw Exception("Unrecognized method '$methodName' sent to $kControlChannelName");
499497
}

lib/ui/text.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,10 +2831,8 @@ class Paragraph extends NativeFieldWrapperClass1 {
28312831
switch (position.affinity) {
28322832
case TextAffinity.upstream:
28332833
characterPosition = position.offset - 1;
2834-
break;
28352834
case TextAffinity.downstream:
28362835
characterPosition = position.offset;
2837-
break;
28382836
}
28392837
final List<int> boundary = _getWordBoundary(characterPosition);
28402838
return TextRange(start: boundary[0], end: boundary[1]);

lib/web_ui/dev/test_platform.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,11 +1006,9 @@ class BrowserManager {
10061006

10071007
case 'restart':
10081008
_onRestartController.add(null);
1009-
break;
10101009

10111010
case 'resume':
10121011
_pauseCompleter?.complete();
1013-
break;
10141012

10151013
default:
10161014
// Unreachable.

lib/web_ui/lib/channel_buffers.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ class ChannelBuffers {
199199
}
200200
index += 1;
201201
resize(channelName, data.getUint32(index, Endian.host));
202-
break;
203202
case 'overflow':
204203
if (bytes[index] != 0x0C) {
205204
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (arguments must be a two-element list, channel name and flag state)");
@@ -224,7 +223,6 @@ class ChannelBuffers {
224223
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (second argument must be a boolean)");
225224
}
226225
allowOverflow(channelName, bytes[index] == 0x01);
227-
break;
228226
default:
229227
throw Exception("Unrecognized method '$methodName' sent to $kControlChannelName");
230228
}

lib/web_ui/lib/painting.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,8 @@ Future<Codec> createBmp(
559559
switch (format) {
560560
case PixelFormat.bgra8888:
561561
swapRedBlue = true;
562-
break;
563562
case PixelFormat.rgba8888:
564563
swapRedBlue = false;
565-
break;
566564
}
567565

568566
// See https://en.wikipedia.org/wiki/BMP_file_format for format examples.

0 commit comments

Comments
 (0)