Skip to content

Commit

Permalink
Reland "Post 3.0 lint sync (flutter#40394)" (flutter#40688)
Browse files Browse the repository at this point in the history
Reland "Post 3.0 lint sync (flutter#40394)"
  • Loading branch information
goderbauer authored Mar 28, 2023
1 parent b323406 commit 3d730c5
Show file tree
Hide file tree
Showing 75 changed files with 70 additions and 376 deletions.
28 changes: 16 additions & 12 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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-03-22, but with some modifications marked with
# "DIFFERENT FROM FLUTTER/FLUTTER" below.

analyzer:
Expand All @@ -23,7 +23,6 @@ linter:
- 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
Expand Down Expand Up @@ -52,8 +51,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 @@ -74,17 +71,19 @@ linter:
# - cascade_invocations # doesn't match the typical style of this repo
- cast_nullable_to_non_nullable
# - close_sinks # not reliable enough
- collection_methods_unrelated_type
- 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
# - 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 @@ -95,10 +94,12 @@ linter:
- flutter_style_todos
- hash_and_equals
- implementation_imports
- implicit_call_tearoffs
- invalid_case_patterns
- iterable_contains_unrelated_type
# - 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
Expand Down Expand Up @@ -137,7 +138,6 @@ 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
Expand All @@ -157,7 +157,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
# - 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 +168,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 @@ -185,12 +185,14 @@ linter:
# - unawaited_futures # too many false positives, especially with the way AnimationController works
- 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 +207,13 @@ linter:
- unnecessary_string_interpolations
- unnecessary_this
- unnecessary_to_list_in_spreads
# - unreachable_from_main # Do not enable this rule until it is un-marked as "experimental" and carefully re-evaluated.
- 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 +225,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 # DIFFERENT FROM FLUTTER/FLUTTER (needs to be evaluated, dart:ui does this frequently)
- 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
3 changes: 0 additions & 3 deletions ci/bin/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -968,13 +968,10 @@ Future<int> main(List<String> arguments) async {
switch (type) {
case MessageType.message:
stderr.writeln(message);
break;
case MessageType.error:
stderr.writeln('ERROR: $message');
break;
case MessageType.warning:
stderr.writeln('WARNING: $message');
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: 90df0faca032ae220230aef5e61ca020
Signature: 61adfda2905179c8e8b7d754d8660a7f

1 change: 0 additions & 1 deletion flutter_frontend_server/bin/starter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

library frontend_server;

import 'dart:io';

Expand Down
1 change: 0 additions & 1 deletion flutter_frontend_server/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// ignore_for_file: avoid_print

library flutter_frontend_server;

import 'dart:async';
import 'dart:io' hide FileSystemEntity;
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/channel_buffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ class ChannelBuffers {
}
index += 1;
resize(channelName, data.getUint32(index, Endian.host));
break;
case 'overflow':
if (bytes[index] != 0x0C) { // 12 = value code for list
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (arguments must be a two-element list, channel name and flag state)");
Expand All @@ -493,7 +492,6 @@ class ChannelBuffers {
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (second argument must be a boolean)");
}
allowOverflow(channelName, bytes[index] == 0x01);
break;
default:
throw Exception("Unrecognized method '$methodName' sent to $kControlChannelName");
}
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2831,10 +2831,8 @@ class Paragraph extends NativeFieldWrapperClass1 {
switch (position.affinity) {
case TextAffinity.upstream:
characterPosition = position.offset - 1;
break;
case TextAffinity.downstream:
characterPosition = position.offset;
break;
}
final List<int> boundary = _getWordBoundary(characterPosition);
return TextRange(start: boundary[0], end: boundary[1]);
Expand Down
2 changes: 0 additions & 2 deletions lib/web_ui/dev/test_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,9 @@ class BrowserManager {

case 'restart':
_onRestartController.add(null);
break;

case 'resume':
_pauseCompleter?.complete();
break;

default:
// Unreachable.
Expand Down
2 changes: 0 additions & 2 deletions lib/web_ui/lib/channel_buffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ class ChannelBuffers {
}
index += 1;
resize(channelName, data.getUint32(index, Endian.host));
break;
case 'overflow':
if (bytes[index] != 0x0C) {
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (arguments must be a two-element list, channel name and flag state)");
Expand All @@ -224,7 +223,6 @@ class ChannelBuffers {
throw Exception("Invalid arguments for 'overflow' method sent to $kControlChannelName (second argument must be a boolean)");
}
allowOverflow(channelName, bytes[index] == 0x01);
break;
default:
throw Exception("Unrecognized method '$methodName' sent to $kControlChannelName");
}
Expand Down
2 changes: 0 additions & 2 deletions lib/web_ui/lib/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,8 @@ Future<Codec> createBmp(
switch (format) {
case PixelFormat.bgra8888:
swapRedBlue = true;
break;
case PixelFormat.rgba8888:
swapRedBlue = false;
break;
}

// See https://en.wikipedia.org/wiki/BMP_file_format for format examples.
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// The code that performs the transformations lives in:
//
// - https://github.com/flutter/engine/blob/main/web_sdk/sdk_rewriter.dart

// ignore: unnecessary_library_directive
library engine;

export 'engine/alarm_clock.dart';
Expand Down
15 changes: 0 additions & 15 deletions lib/web_ui/lib/src/engine/canvas_pool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -592,23 +592,20 @@ class CanvasPool extends _SaveStackTracking {
ctx.arc(x, y, radius, 0, 2.0 * math.pi);
ctx.fill();
}
break;
case ui.PointMode.lines:
ctx.beginPath();
for (int i = 0; i < (len - 2); i += 4) {
ctx.moveTo(points[i] + offsetX, points[i + 1] + offsetY);
ctx.lineTo(points[i + 2] + offsetX, points[i + 3] + offsetY);
ctx.stroke();
}
break;
case ui.PointMode.polygon:
ctx.beginPath();
ctx.moveTo(points[0] + offsetX, points[1] + offsetY);
for (int i = 2; i < len; i += 2) {
ctx.lineTo(points[i] + offsetX, points[i + 1] + offsetY);
}
ctx.stroke();
break;
}
}

Expand All @@ -625,16 +622,12 @@ class CanvasPool extends _SaveStackTracking {
switch (verb) {
case SPath.kMoveVerb:
ctx.moveTo(p[0], p[1]);
break;
case SPath.kLineVerb:
ctx.lineTo(p[2], p[3]);
break;
case SPath.kCubicVerb:
ctx.bezierCurveTo(p[2], p[3], p[4], p[5], p[6], p[7]);
break;
case SPath.kQuadVerb:
ctx.quadraticCurveTo(p[2], p[3], p[4], p[5]);
break;
case SPath.kConicVerb:
final double w = iter.conicWeight;
final Conic conic = Conic(p[0], p[1], p[2], p[3], p[4], p[5], w);
Expand All @@ -647,10 +640,8 @@ class CanvasPool extends _SaveStackTracking {
final double p2y = points[i + 1].dy;
ctx.quadraticCurveTo(p1x, p1y, p2x, p2y);
}
break;
case SPath.kCloseVerb:
ctx.closePath();
break;
default:
throw UnimplementedError('Unknown path verb $verb');
}
Expand Down Expand Up @@ -683,18 +674,14 @@ class CanvasPool extends _SaveStackTracking {
switch (verb) {
case SPath.kMoveVerb:
ctx.moveTo(p[0] + offsetX, p[1] + offsetY);
break;
case SPath.kLineVerb:
ctx.lineTo(p[2] + offsetX, p[3] + offsetY);
break;
case SPath.kCubicVerb:
ctx.bezierCurveTo(p[2] + offsetX, p[3] + offsetY,
p[4] + offsetX, p[5] + offsetY, p[6] + offsetX, p[7] + offsetY);
break;
case SPath.kQuadVerb:
ctx.quadraticCurveTo(p[2] + offsetX, p[3] + offsetY,
p[4] + offsetX, p[5] + offsetY);
break;
case SPath.kConicVerb:
final double w = iter.conicWeight;
final Conic conic = Conic(p[0], p[1], p[2], p[3], p[4], p[5], w);
Expand All @@ -708,10 +695,8 @@ class CanvasPool extends _SaveStackTracking {
ctx.quadraticCurveTo(p1x + offsetX, p1y + offsetY,
p2x + offsetX, p2y + offsetY);
}
break;
case SPath.kCloseVerb:
ctx.closePath();
break;
default:
throw UnimplementedError('Unknown path verb $verb');
}
Expand Down
3 changes: 0 additions & 3 deletions lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ class HtmlViewEmbedder {
headTransform = mutator.matrix!.multiplied(headTransform);
head.style.transform =
float64ListToCssTransform(headTransform.storage);
break;
case MutatorType.clipRect:
case MutatorType.clipRRect:
case MutatorType.clipPath:
Expand Down Expand Up @@ -359,10 +358,8 @@ class HtmlViewEmbedder {
}
_resetAnchor(clipView);
head = clipView;
break;
case MutatorType.opacity:
embeddedOpacity *= mutator.alphaFloat;
break;
}
}

Expand Down
10 changes: 5 additions & 5 deletions lib/web_ui/lib/src/engine/canvaskit/image_web_codecs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// Uses the `ImageDecoder` class supplied by the browser.
///
/// See also:
///
/// * `image_wasm_codecs.dart`, which uses codecs supplied by the CanvasKit WASM bundle.
// Uses the `ImageDecoder` class supplied by the browser.
//
// See also:
//
// * `image_wasm_codecs.dart`, which uses codecs supplied by the CanvasKit WASM bundle.

import 'dart:async';
import 'dart:convert' show base64;
Expand Down
6 changes: 0 additions & 6 deletions lib/web_ui/lib/src/engine/canvaskit/layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,10 @@ class PrerollContext {
switch (m.type) {
case MutatorType.clipRect:
clipRect = m.rect!;
break;
case MutatorType.clipRRect:
clipRect = m.rrect!.outerRect;
break;
case MutatorType.clipPath:
clipRect = m.path!.getBounds();
break;
default:
continue;
}
Expand Down Expand Up @@ -527,14 +524,11 @@ class PhysicalShapeEngineLayer extends ContainerLayer
switch (_clipBehavior) {
case ui.Clip.hardEdge:
paintContext.internalNodesCanvas.clipPath(_path, false);
break;
case ui.Clip.antiAlias:
paintContext.internalNodesCanvas.clipPath(_path, true);
break;
case ui.Clip.antiAliasWithSaveLayer:
paintContext.internalNodesCanvas.clipPath(_path, true);
paintContext.internalNodesCanvas.saveLayer(paintBounds, null);
break;
case ui.Clip.none:
break;
}
Expand Down
Loading

0 comments on commit 3d730c5

Please sign in to comment.