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

Revert "Post 3.0 lint sync" #40687

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 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 2023-03-22, but with some modifications marked with
# as of 2022-07-27, but with some modifications marked with
# "DIFFERENT FROM FLUTTER/FLUTTER" below.

analyzer:
Expand All @@ -23,6 +23,7 @@ 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 @@ -51,6 +52,8 @@ 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 @@ -71,19 +74,17 @@ 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 # too many false positives, similar to unawaited_futures
# - discarded_futures # not yet tested
# - 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 @@ -94,12 +95,10 @@ 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 @@ -138,6 +137,7 @@ 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
# - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
# - 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 # 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
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
- secure_pubspec_urls
- sized_box_for_whitespace
- sized_box_shrink_expand
# - sized_box_shrink_expand # not yet tested
- slash_for_doc_comments
- sort_child_properties_last
- sort_constructors_first
Expand All @@ -185,14 +185,12 @@ 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 @@ -207,13 +205,12 @@ 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
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
- use_enums
# - use_colored_box # not yet tested
# - use_decorated_box # not yet tested
# - use_enums # not yet tested
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
- use_if_null_to_convert_nulls_to_bools
Expand All @@ -225,7 +222,6 @@ 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: 3 additions & 0 deletions ci/bin/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -968,10 +968,13 @@ 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: 61adfda2905179c8e8b7d754d8660a7f
Signature: 90df0faca032ae220230aef5e61ca020

1 change: 1 addition & 0 deletions flutter_frontend_server/bin/starter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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: 1 addition & 0 deletions flutter_frontend_server/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// ignore_for_file: avoid_print

library flutter_frontend_server;

import 'dart:async';
import 'dart:io' hide FileSystemEntity;
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/channel_buffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ 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 @@ -492,6 +493,7 @@ 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: 2 additions & 0 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2831,8 +2831,10 @@ 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: 2 additions & 0 deletions lib/web_ui/dev/test_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1006,9 +1006,11 @@ class BrowserManager {

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

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

default:
// Unreachable.
Expand Down
2 changes: 2 additions & 0 deletions lib/web_ui/lib/channel_buffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ 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 @@ -223,6 +224,7 @@ 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: 2 additions & 0 deletions lib/web_ui/lib/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,10 @@ 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: 15 additions & 0 deletions lib/web_ui/lib/src/engine/canvas_pool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -592,20 +592,23 @@ 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 @@ -622,12 +625,16 @@ 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 @@ -640,8 +647,10 @@ 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 @@ -674,14 +683,18 @@ 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 @@ -695,8 +708,10 @@ 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: 3 additions & 0 deletions lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ 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 @@ -358,8 +359,10 @@ 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: 6 additions & 0 deletions lib/web_ui/lib/src/engine/canvaskit/layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ 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 @@ -524,11 +527,14 @@ 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