From 938f2171f27e1a9210c73f2e2f98c4f05db7befb Mon Sep 17 00:00:00 2001 From: Yegor Jbanov Date: Fri, 27 Mar 2020 09:37:13 -0700 Subject: [PATCH 1/2] Reland "add limited analysis options (#17332)" This time I'm starting without Cirrus. Will add Cirrus serpartely from code changes. This reverts commit 6d33ee1a2ca7d404ebd5cb434d8ab859bf8ac0b7. --- .cirrus.yml | 10 +++ lib/web_ui/analysis_options.yaml | 88 ++++++++++++++++++- lib/web_ui/dev/browser.dart | 2 +- lib/web_ui/dev/firefox_installer_test.dart | 2 +- lib/web_ui/dev/test_platform.dart | 2 +- .../lib/src/engine/compositor/vertices.dart | 2 +- .../lib/src/engine/surface/path_metrics.dart | 1 - lib/web_ui/lib/src/engine/window.dart | 2 - lib/web_ui/lib/src/ui/painting.dart | 2 - lib/web_ui/lib/src/ui/text.dart | 8 -- .../engine/image/html_image_codec_test.dart | 2 +- .../engine/canvas_context_test.dart | 1 - .../engine/path_metrics_test.dart | 11 --- .../engine/text_style_golden_test.dart | 1 - lib/web_ui/test/text/measurement_test.dart | 1 + 15 files changed, 103 insertions(+), 32 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 77d8b81ca4a6f..7b954671a7aeb 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -126,6 +126,16 @@ task: - name: web_tests-7_last-linux # last Web shard must end with _last << : *WEB_SHARD_TEMPLATE + - name: web_engine_analysis + compile_host_script: | + cd $ENGINE_PATH/src + ./flutter/tools/gn --unoptimized --full-dart-sdk + ninja -C out/host_debug_unopt + script: + - cd $ENGINE_PATH/src/flutter/lib/web_ui + - $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/pub get + - $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/dartanalyzer --fatal-warnings --fatal-hints dev/ lib/ test/ tool/ + - name: web_engine_integration_test_linux compile_host_script: | cd $ENGINE_PATH/src diff --git a/lib/web_ui/analysis_options.yaml b/lib/web_ui/analysis_options.yaml index 6892f49dc726b..7c46e201fff84 100644 --- a/lib/web_ui/analysis_options.yaml +++ b/lib/web_ui/analysis_options.yaml @@ -1 +1,87 @@ -# Intentionally kept empty. \ No newline at end of file +# This is copy of the root analysis_options.yaml. As we clean up the Web code, +# we'll be uncommenting rules and gradually fix the code. When all rules are +# uncommented, we'll delete this file and simply inherit the root options. + +analyzer: + # TODO(uncomment) strong-mode: + # TODO(uncomment) implicit-casts: false + # TODO(uncomment) implicit-dynamic: false + errors: + missing_required_param: warning + missing_return: warning + native_function_body_in_non_sdk_code: ignore + todo: ignore + +linter: + rules: + - always_declare_return_types + # TODO(uncomment) - always_put_control_body_on_new_line + # TODO(uncomment) - always_specify_types + # TODO(uncomment) - annotate_overrides + # TODO(uncomment) - avoid_classes_with_only_static_members + # TODO(uncomment) - avoid_empty_else + # TODO(uncomment) - avoid_function_literals_in_foreach_calls + # TODO(uncomment) - avoid_init_to_null + # TODO(uncomment) - avoid_null_checks_in_equality_operators + # TODO(uncomment) - avoid_relative_lib_imports + # TODO(uncomment) - avoid_renaming_method_parameters + # TODO(uncomment) - avoid_return_types_on_setters + # TODO(uncomment) - avoid_slow_async_io + # TODO(uncomment) - await_only_futures + # TODO(uncomment) - camel_case_types + # TODO(uncomment) - cancel_subscriptions + # TODO(uncomment) - control_flow_in_finally + # TODO(uncomment) - directives_ordering + # TODO(uncomment) - empty_catches + # TODO(uncomment) - empty_constructor_bodies + # TODO(uncomment) - empty_statements + # TODO(uncomment) - hash_and_equals + # TODO(uncomment) - implementation_imports + # TODO(uncomment) - iterable_contains_unrelated_type + # TODO(uncomment) - library_names + # TODO(uncomment) - library_prefixes + # TODO(uncomment) - list_remove_unrelated_type + # TODO(uncomment) - no_adjacent_strings_in_list + # TODO(uncomment) - no_duplicate_case_values + # TODO(uncomment) - non_constant_identifier_names + # TODO(uncomment) - overridden_fields + # TODO(uncomment) - package_api_docs + # TODO(uncomment) - package_names + # TODO(uncomment) - package_prefixed_library_names + # TODO(uncomment) - prefer_adjacent_string_concatenation + # TODO(uncomment) - prefer_asserts_in_initializer_lists + # TODO(uncomment) - prefer_collection_literals + # TODO(uncomment) - prefer_conditional_assignment + # TODO(uncomment) - prefer_const_constructors + # TODO(uncomment) - prefer_const_constructors_in_immutables + # TODO(uncomment) - prefer_const_declarations + # TODO(uncomment) - prefer_const_literals_to_create_immutables + # TODO(uncomment) - prefer_contains + # TODO(uncomment) - prefer_equal_for_default_values + # TODO(uncomment) - prefer_final_locals + # TODO(uncomment) - prefer_foreach + # TODO(uncomment) - prefer_generic_function_type_aliases + # TODO(uncomment) - prefer_initializing_formals + # TODO(uncomment) - prefer_is_empty + # TODO(uncomment) - prefer_is_not_empty + # TODO(uncomment) - prefer_single_quotes + # TODO(uncomment) - prefer_typing_uninitialized_variables + # TODO(uncomment) - public_member_api_docs + # TODO(uncomment) - recursive_getters + # TODO(uncomment) - slash_for_doc_comments + # TODO(uncomment) - sort_unnamed_constructors_first + # TODO(uncomment) - test_types_in_equals + # TODO(uncomment) - throw_in_finally + # TODO(uncomment) - type_init_formals + # TODO(uncomment) - unnecessary_brace_in_string_interps + # TODO(uncomment) - unnecessary_const + # TODO(uncomment) - unnecessary_getters_setters + # TODO(uncomment) - unnecessary_new + # TODO(uncomment) - unnecessary_null_aware_assignments + # TODO(uncomment) - unnecessary_null_in_if_null_operators + # TODO(uncomment) - unnecessary_overrides + # TODO(uncomment) - unnecessary_parenthesis + # TODO(uncomment) - unnecessary_this + # TODO(uncomment) - unrelated_type_equality_checks + # TODO(uncomment) - use_rethrow_when_possible + # TODO(uncomment) - valid_regexps diff --git a/lib/web_ui/dev/browser.dart b/lib/web_ui/dev/browser.dart index 8c4c736e99aab..989609cd8a5bf 100644 --- a/lib/web_ui/dev/browser.dart +++ b/lib/web_ui/dev/browser.dart @@ -72,7 +72,7 @@ abstract class Browser { _processCompleter.complete(process); var output = Uint8Buffer(); - drainOutput(Stream> stream) { + void drainOutput(Stream> stream) { try { _ioSubscriptions .add(stream.listen(output.addAll, cancelOnError: true)); diff --git a/lib/web_ui/dev/firefox_installer_test.dart b/lib/web_ui/dev/firefox_installer_test.dart index 2d687d7be1c6b..fc18277f53b14 100644 --- a/lib/web_ui/dev/firefox_installer_test.dart +++ b/lib/web_ui/dev/firefox_installer_test.dart @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// @dart = 2.6 @TestOn('vm && linux') -// @dart = 2.6 import 'dart:io' as io; import 'package:path/path.dart' as path; diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart index 6b4663d5d4a91..1e5aa3c79b7b8 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -744,7 +744,7 @@ class BrowserManager { var suiteID = _suiteID++; RunnerSuiteController controller; - closeIframe() { + void closeIframe() { if (_closed) return; _controllers.remove(controller); _channel.sink.add({'command': 'closeSuite', 'id': suiteID}); diff --git a/lib/web_ui/lib/src/engine/compositor/vertices.dart b/lib/web_ui/lib/src/engine/compositor/vertices.dart index 67164c498411c..b9d43ba6d262b 100644 --- a/lib/web_ui/lib/src/engine/compositor/vertices.dart +++ b/lib/web_ui/lib/src/engine/compositor/vertices.dart @@ -116,7 +116,7 @@ class SkVertices implements ui.Vertices { } } - static _encodePoints(List points) { + static js.JsArray> _encodePoints(List points) { if (points == null) return null; js.JsArray> encodedPoints = diff --git a/lib/web_ui/lib/src/engine/surface/path_metrics.dart b/lib/web_ui/lib/src/engine/surface/path_metrics.dart index 98a95622d3c48..7ad30fd725dc3 100644 --- a/lib/web_ui/lib/src/engine/surface/path_metrics.dart +++ b/lib/web_ui/lib/src/engine/surface/path_metrics.dart @@ -616,7 +616,6 @@ class SurfacePathMetricIterator implements Iterator { SurfacePathMetric _pathMetric; _SurfacePathMeasure _pathMeasure; - bool _firstTime = true; @override SurfacePathMetric get current => _pathMetric; diff --git a/lib/web_ui/lib/src/engine/window.dart b/lib/web_ui/lib/src/engine/window.dart index 03695abc096b3..a3da6d2dbcc00 100644 --- a/lib/web_ui/lib/src/engine/window.dart +++ b/lib/web_ui/lib/src/engine/window.dart @@ -555,9 +555,7 @@ class EngineWindow extends ui.Window { bool _handleWebTestEnd2EndMessage(MethodCodec codec, ByteData data) { final MethodCall decoded = codec.decodeMethodCall(data); - final Map message = decoded.arguments; double ratio = double.parse(decoded.arguments); - bool result = false; switch(decoded.method) { case 'setDevicePixelRatio': window.debugOverrideDevicePixelRatio(ratio); diff --git a/lib/web_ui/lib/src/ui/painting.dart b/lib/web_ui/lib/src/ui/painting.dart index 9cef2faefb636..b08ef9dafab40 100644 --- a/lib/web_ui/lib/src/ui/painting.dart +++ b/lib/web_ui/lib/src/ui/painting.dart @@ -1069,8 +1069,6 @@ abstract class Shader { /// There are several types of gradients, represented by the various /// constructors on this class. abstract class Gradient extends Shader { - Gradient._() : super._(); - /// Creates a linear gradient from `from` to `to`. /// /// If `colorStops` is provided, `colorStops[i]` is a number from 0.0 to 1.0 diff --git a/lib/web_ui/lib/src/ui/text.dart b/lib/web_ui/lib/src/ui/text.dart index 8a1ae89fab5a6..a55779537e150 100644 --- a/lib/web_ui/lib/src/ui/text.dart +++ b/lib/web_ui/lib/src/ui/text.dart @@ -866,14 +866,6 @@ class TextBox { this.direction, ); - TextBox._( - this.left, - this.top, - this.right, - this.bottom, - int directionIndex, - ) : direction = TextDirection.values[directionIndex]; - /// The left edge of the text box, irrespective of direction. /// /// To get the leading edge (which may depend on the [direction]), consider [start]. diff --git a/lib/web_ui/test/engine/image/html_image_codec_test.dart b/lib/web_ui/test/engine/image/html_image_codec_test.dart index 3c1f347162d1d..38cd5602d32f4 100644 --- a/lib/web_ui/test/engine/image/html_image_codec_test.dart +++ b/lib/web_ui/test/engine/image/html_image_codec_test.dart @@ -22,7 +22,7 @@ Future main() async { chunkCallback: (int loaded, int total) { buffer.write('$loaded/$total,'); }); - final ui.FrameInfo frameInfo = await codec.getNextFrame(); + await codec.getNextFrame(); expect(buffer.toString(), '0/100,100/100,'); }); }); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_context_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_context_test.dart index d6e3ee13e9711..f0d2f15a08a77 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_context_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_context_test.dart @@ -4,7 +4,6 @@ // @dart = 2.6 import 'dart:html' as html; -import 'dart:js_util' as js_util; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart' as engine; diff --git a/lib/web_ui/test/golden_tests/engine/path_metrics_test.dart b/lib/web_ui/test/golden_tests/engine/path_metrics_test.dart index dcabb01fdbde1..38379087867e2 100644 --- a/lib/web_ui/test/golden_tests/engine/path_metrics_test.dart +++ b/lib/web_ui/test/golden_tests/engine/path_metrics_test.dart @@ -4,7 +4,6 @@ // @dart = 2.6 import 'dart:html' as html; -import 'dart:typed_data'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; @@ -63,8 +62,6 @@ void main() async { test('Should calculate tangent on cubic curve', () async { final Path path = Path(); - double p0x = 150; - double p0y = 20; double p1x = 240; double p1y = 120; double p2x = 320; @@ -112,8 +109,6 @@ void main() async { final Path path = Path(); path.moveTo(50, 130); path.lineTo(150, 20); - double p0x = 150; - double p0y = 20; double p1x = 240; double p1y = 120; double p2x = 320; @@ -122,8 +117,6 @@ void main() async { rc.drawPath(path, paint); - final Float32List buffer = Float32List(6); - List points = [p0x, p0y, p1x, p1y, p2x, p2y]; double t0 = 0.2; double t1 = 0.7; @@ -168,8 +161,6 @@ void main() async { final Path path = Path(); path.moveTo(50, 130); path.lineTo(150, 20); - double p0x = 150; - double p0y = 20; double p1x = 40; double p1y = 120; double p2x = 300; @@ -180,8 +171,6 @@ void main() async { rc.drawPath(path, paint); - final Float32List buffer = Float32List(6); - List points = [p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y]; double t0 = 0.2; double t1 = 0.7; diff --git a/lib/web_ui/test/golden_tests/engine/text_style_golden_test.dart b/lib/web_ui/test/golden_tests/engine/text_style_golden_test.dart index e46d8c258c277..c8ec261e8b72a 100644 --- a/lib/web_ui/test/golden_tests/engine/text_style_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/text_style_golden_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. // @dart = 2.6 -import 'package:test/test.dart'; import 'package:ui/ui.dart'; import 'package:ui/src/engine.dart'; diff --git a/lib/web_ui/test/text/measurement_test.dart b/lib/web_ui/test/text/measurement_test.dart index 919e5fc97ae61..cf96ab0ef25b9 100644 --- a/lib/web_ui/test/text/measurement_test.dart +++ b/lib/web_ui/test/text/measurement_test.dart @@ -1154,5 +1154,6 @@ EngineLineMetrics line( width: width, lineNumber: lineNumber, left: left, + endIndexWithoutNewlines: -1, ); } From ccdb426dfa97f66e2689c4e0c0708eef572b8db2 Mon Sep 17 00:00:00 2001 From: Yegor Jbanov Date: Fri, 27 Mar 2020 09:40:29 -0700 Subject: [PATCH 2/2] disable Cirrus analysis check --- .cirrus.yml | 18 +++++++++--------- lib/web_ui/test/engine/profiler_test.dart | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 7b954671a7aeb..cfd659e488540 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -126,15 +126,15 @@ task: - name: web_tests-7_last-linux # last Web shard must end with _last << : *WEB_SHARD_TEMPLATE - - name: web_engine_analysis - compile_host_script: | - cd $ENGINE_PATH/src - ./flutter/tools/gn --unoptimized --full-dart-sdk - ninja -C out/host_debug_unopt - script: - - cd $ENGINE_PATH/src/flutter/lib/web_ui - - $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/pub get - - $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/dartanalyzer --fatal-warnings --fatal-hints dev/ lib/ test/ tool/ + # - name: web_engine_analysis + # compile_host_script: | + # cd $ENGINE_PATH/src + # ./flutter/tools/gn --unoptimized --full-dart-sdk + # ninja -C out/host_debug_unopt + # script: + # - cd $ENGINE_PATH/src/flutter/lib/web_ui + # - $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/pub get + # - $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/dartanalyzer --fatal-warnings --fatal-hints dev/ lib/ test/ tool/ - name: web_engine_integration_test_linux compile_host_script: | diff --git a/lib/web_ui/test/engine/profiler_test.dart b/lib/web_ui/test/engine/profiler_test.dart index 58f12d17cf758..04d580d2fa969 100644 --- a/lib/web_ui/test/engine/profiler_test.dart +++ b/lib/web_ui/test/engine/profiler_test.dart @@ -78,7 +78,7 @@ class BenchmarkDatapoint { int get hashCode => hashValues(name, value); @override - operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) { return true; }