Skip to content

Commit 9394c97

Browse files
authored
Analysis cleanup of web tests (flutter#27670)
1 parent 91476a8 commit 9394c97

File tree

91 files changed

+196
-72
lines changed

Some content is hidden

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

91 files changed

+196
-72
lines changed

lib/web_ui/analysis_options.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ analyzer:
1313

1414
linter:
1515
rules:
16-
annotate_overrides: false
1716
avoid_classes_with_only_static_members: false
18-
avoid_empty_else: false
1917
avoid_function_literals_in_foreach_calls: false
20-
avoid_init_to_null: false
2118
avoid_null_checks_in_equality_operators: false
2219
avoid_relative_lib_imports: false
2320
avoid_renaming_method_parameters: false
@@ -86,6 +83,6 @@ linter:
8683
unnecessary_string_interpolations: false
8784
cast_nullable_to_non_nullable: false
8885
flutter_style_todos: false
89-
avoid_void_async: false
86+
9087
# We have some legitimate use-cases for this (preserve tear-off identity)
91-
prefer_function_declarations_over_variables: false
88+
prefer_function_declarations_over_variables: false

lib/web_ui/dev/chrome.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ Future<Uri> getRemoteDebuggerUrl(Uri base) async {
209209
/// This manager can be used for both macOS and Linux.
210210
// TODO: https://github.com/flutter/flutter/issues/65673
211211
class ChromeScreenshotManager extends ScreenshotManager {
212+
@override
212213
String get filenameSuffix => '';
213214

214215
/// Capture a screenshot of the web content.
@@ -218,6 +219,7 @@ class ChromeScreenshotManager extends ScreenshotManager {
218219
/// [region] is used to decide which part of the web content will be used in
219220
/// test image. It includes starting coordinate x,y as well as height and
220221
/// width of the area to capture.
222+
@override
221223
Future<Image> capture(math.Rectangle<num>? region) async {
222224
final wip.ChromeConnection chromeConnection =
223225
wip.ChromeConnection('localhost', kDevtoolsPort);
@@ -230,7 +232,7 @@ class ChromeScreenshotManager extends ScreenshotManager {
230232
}
231233
final wip.WipConnection wipConnection = await chromeTab.connect();
232234

233-
Map<String, dynamic>? captureScreenshotParameters = null;
235+
Map<String, dynamic>? captureScreenshotParameters;
234236
if (region != null) {
235237
captureScreenshotParameters = <String, dynamic>{
236238
'format': 'png',

lib/web_ui/dev/common.dart

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class _MacBinding implements PlatformBinding {
140140
String getChromeDownloadUrl(String version) =>
141141
'$_kBaseDownloadUrl/Mac%2F$version%2Fchrome-mac.zip?alt=media';
142142

143+
@override
143144
String getChromeExecutablePath(io.Directory versionDir) => path.join(
144145
versionDir.path,
145146
'chrome-mac',

lib/web_ui/dev/felt.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ CommandRunner<bool> runner = CommandRunner<bool>(
2424
..addCommand(TestCommand())
2525
..addCommand(BuildCommand());
2626

27-
void main(List<String> rawArgs) async {
27+
Future<void> main(List<String> rawArgs) async {
2828
// Remove --clean from the list as that's processed by the wrapper script.
2929
final List<String> args = rawArgs.where((String arg) => arg != '--clean').toList();
3030

@@ -69,7 +69,7 @@ void main(List<String> rawArgs) async {
6969
io.exit(io.exitCode);
7070
}
7171

72-
void _listenToShutdownSignals() async {
72+
Future<void> _listenToShutdownSignals() async {
7373
io.ProcessSignal.sigint.watch().listen((_) async {
7474
print('Received SIGINT. Shutting down.');
7575
await cleanup();

lib/web_ui/dev/safari_installation.dart

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class IosSafariArgParser extends BrowserArgParser {
6565
/// The [IosSafariArgParser] singleton.
6666
static IosSafariArgParser get instance => _singletonInstance;
6767

68+
@override
6869
String get version => 'iOS ${iosMajorVersion}.${iosMinorVersion}';
6970

7071
final int _pinnedIosMajorVersion;

lib/web_ui/dev/safari_ios.dart

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class SafariIos extends Browser {
7979
///
8080
/// This manager will only be created/used for macOS.
8181
class SafariIosScreenshotManager extends ScreenshotManager {
82+
@override
8283
String get filenameSuffix => '.iOS_Safari';
8384

8485
SafariIosScreenshotManager() {
@@ -154,6 +155,7 @@ class SafariIosScreenshotManager extends ScreenshotManager {
154155
/// width of the area to capture.
155156
///
156157
/// Uses simulator tool `xcrun simctl`'s 'screenshot' command.
158+
@override
157159
Future<Image> capture(math.Rectangle<num>? region) async {
158160
final String filename = 'screenshot${_fileNameCounter}.png';
159161
_fileNameCounter++;

lib/web_ui/dev/test_platform.dart

+8
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ class BrowserPlatform extends PlatformPlugin {
371371
return suite;
372372
}
373373

374+
@override
374375
StreamChannel<dynamic> loadChannel(String path, SuitePlatform platform) =>
375376
throw UnimplementedError();
376377

@@ -413,6 +414,7 @@ class BrowserPlatform extends PlatformPlugin {
413414
///
414415
/// Note that this doesn't close the server itself. Browser tests can still be
415416
/// loaded, they'll just spawn new browsers.
417+
@override
416418
Future<void> closeEphemeral() async {
417419
if (_browserManager != null) {
418420
final BrowserManager? result = await _browserManager!;
@@ -424,6 +426,7 @@ class BrowserPlatform extends PlatformPlugin {
424426
///
425427
/// Returns a [Future] that completes once the server is closed and its
426428
/// resources have been fully released.
429+
@override
427430
Future<void> close() {
428431
return _closeMemo.runOnce(() async {
429432
final List<Future<void>> futures = <Future<void>>[];
@@ -780,17 +783,22 @@ class BrowserManager {
780783
class _BrowserEnvironment implements Environment {
781784
final BrowserManager _manager;
782785

786+
@override
783787
final bool supportsDebugging = true;
784788

789+
@override
785790
final Uri? observatoryUrl;
786791

792+
@override
787793
final Uri? remoteDebuggerUrl;
788794

795+
@override
789796
final Stream<dynamic> onRestart;
790797

791798
_BrowserEnvironment(this._manager, this.observatoryUrl,
792799
this.remoteDebuggerUrl, this.onRestart);
793800

801+
@override
794802
CancelableOperation<void> displayPause() => _manager._displayPause();
795803
}
796804

lib/web_ui/dev/watcher.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class PipelineWatcher {
226226
});
227227
}
228228

229-
void _runPipeline() async {
229+
Future<void> _runPipeline() async {
230230
if (pipeline.status == PipelineStatus.stopping) {
231231
// We are already trying to stop the pipeline. No need to do anything.
232232
return;

lib/web_ui/lib/src/engine/canvas_pool.dart

+3
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ class CanvasPool extends _SaveStackTracking {
476476
}
477477
}
478478

479+
@override
479480
void clipRect(ui.Rect rect) {
480481
super.clipRect(rect);
481482
if (_canvas != null) {
@@ -489,6 +490,7 @@ class CanvasPool extends _SaveStackTracking {
489490
ctx.clip();
490491
}
491492

493+
@override
492494
void clipRRect(ui.RRect rrect) {
493495
super.clipRRect(rrect);
494496
if (_canvas != null) {
@@ -502,6 +504,7 @@ class CanvasPool extends _SaveStackTracking {
502504
ctx.clip();
503505
}
504506

507+
@override
505508
void clipPath(ui.Path path) {
506509
super.clipPath(path);
507510
if (_canvas != null) {

lib/web_ui/lib/src/engine/canvaskit/color_filter.dart

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ abstract class CkColorFilter
7373
/// filter is used as a [ColorFilter].
7474
SkColorFilter _initRawColorFilter();
7575

76+
@override
7677
ManagedSkiaObject<SkImageFilter> get imageFilter =>
7778
CkColorFilterImageFilter(colorFilter: this);
7879
}

lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart

+6
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ class EmbeddedViewParams {
536536
final ui.Size size;
537537
final MutatorsStack mutators;
538538

539+
@override
539540
bool operator ==(Object other) {
540541
if (identical(this, other)) {
541542
return true;
@@ -546,6 +547,7 @@ class EmbeddedViewParams {
546547
other.mutators == mutators;
547548
}
548549

550+
@override
549551
int get hashCode => ui.hashValues(offset, size, mutators);
550552
}
551553

@@ -593,6 +595,7 @@ class Mutator {
593595

594596
double get alphaFloat => alpha! / 255.0;
595597

598+
@override
596599
bool operator ==(Object other) {
597600
if (identical(this, other)) {
598601
return true;
@@ -622,6 +625,7 @@ class Mutator {
622625
}
623626
}
624627

628+
@override
625629
int get hashCode => ui.hashValues(type, rect, rrect, path, matrix, alpha);
626630
}
627631

@@ -658,6 +662,7 @@ class MutatorsStack extends Iterable<Mutator> {
658662
_mutators.removeLast();
659663
}
660664

665+
@override
661666
bool operator ==(Object other) {
662667
if (identical(other, this)) {
663668
return true;
@@ -666,6 +671,7 @@ class MutatorsStack extends Iterable<Mutator> {
666671
listEquals<Mutator>(other._mutators, _mutators);
667672
}
668673

674+
@override
669675
int get hashCode => ui.hashList(_mutators);
670676

671677
@override

lib/web_ui/lib/src/engine/canvaskit/image_filter.dart

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class _CkMatrixImageFilter extends CkImageFilter {
141141
final Float64List matrix;
142142
final ui.FilterQuality filterQuality;
143143

144+
@override
144145
SkImageFilter _initSkiaObject() {
145146
return canvasKit.ImageFilter.MakeMatrixTransform(
146147
toSkMatrixFromFloat64(matrix),

lib/web_ui/lib/src/engine/canvaskit/layer.dart

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ abstract class Layer implements ui.EngineLayer {
4141

4242
// TODO(dnfield): Implement ui.EngineLayer.dispose for CanvasKit.
4343
// https://github.com/flutter/flutter/issues/82878
44+
@override
4445
void dispose() {}
4546
}
4647

lib/web_ui/lib/src/engine/canvaskit/layer_scene_builder.dart

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class LayerSceneBuilder implements ui.SceneBuilder {
146146
return pushLayer<ColorFilterEngineLayer>(ColorFilterEngineLayer(filter));
147147
}
148148

149+
@override
149150
ImageFilterEngineLayer pushImageFilter(
150151
ui.ImageFilter filter, {
151152
ui.ImageFilterEngineLayer? oldLayer,

lib/web_ui/lib/src/engine/html/bitmap_canvas.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class BitmapCanvas extends EngineCanvas {
6868

6969
/// The last CSS font string is cached to optimize the case where the font
7070
/// styles hasn't changed.
71-
String? _cachedLastCssFont = null;
71+
String? _cachedLastCssFont;
7272

7373
/// List of extra sibling elements created for paragraphs and clipping.
7474
final List<html.Element> _children = <html.Element>[];

lib/web_ui/lib/src/engine/html/path/path_metrics.dart

+3
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ class SurfacePathMetric implements ui.PathMetric {
551551
/// have been implied when using methods like [Path.addRect]) or if
552552
/// `forceClosed` was specified as true in the call to [Path.computeMetrics].
553553
/// Returns false otherwise.
554+
@override
554555
final bool isClosed;
555556

556557
/// The zero-based index of the contour.
@@ -565,6 +566,7 @@ class SurfacePathMetric implements ui.PathMetric {
565566
/// the contours of the path at the time the path's metrics were computed. If
566567
/// additional contours were added or existing contours updated, this metric
567568
/// will be invalid for the current state of the path.
569+
@override
568570
final int contourIndex;
569571

570572
final _SurfacePathMeasure _measure;
@@ -588,6 +590,7 @@ class SurfacePathMetric implements ui.PathMetric {
588590
///
589591
/// `start` and `end` are pinned to legal values (0..[length])
590592
/// Begin the segment with a moveTo if `startWithMoveTo` is true.
593+
@override
591594
ui.Path extractPath(double start, double end, {bool startWithMoveTo = true}) {
592595
return _measure.extractPath(contourIndex, start, end,
593596
startWithMoveTo: startWithMoveTo);

lib/web_ui/lib/src/engine/html/path/path_ref.dart

+1
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class PathRef {
301301
bottomLeft: radii[_Corner.kLowerLeft]);
302302
}
303303

304+
@override
304305
bool operator ==(Object other) {
305306
if (identical(this, other)) {
306307
return true;

lib/web_ui/lib/src/engine/html/render_vertices.dart

+2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ class _WebGlRenderer implements GlRenderer {
302302
///
303303
/// Browsers that support OffscreenCanvas and the transferToImageBitmap api
304304
/// will return ImageBitmap, otherwise will return CanvasElement.
305+
@override
305306
Object? drawRect(ui.Rect targetRect, GlContext gl, GlProgram glProgram,
306307
NormalizedGradient gradient, int widthInPixels, int heightInPixels) {
307308
drawRectToGl(
@@ -314,6 +315,7 @@ class _WebGlRenderer implements GlRenderer {
314315

315316
/// Renders a rectangle using given program into an image resource and returns
316317
/// url.
318+
@override
317319
String drawRectToImageUrl(
318320
ui.Rect targetRect,
319321
GlContext gl,

lib/web_ui/lib/src/engine/html/scene.dart

+2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ class SurfaceScene implements ui.Scene {
2020

2121
/// Creates a raster image representation of the current state of the scene.
2222
/// This is a slow operation that is performed on a background thread.
23+
@override
2324
Future<ui.Image> toImage(int width, int height) {
2425
throw UnsupportedError('toImage is not supported on the Web');
2526
}
2627

2728
/// Releases the resources used by this scene.
2829
///
2930
/// After calling this function, the scene is cannot be used further.
31+
@override
3032
void dispose() {}
3133
}
3234

lib/web_ui/lib/src/engine/html/shaders/shader.dart

+2
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ class _BlurEngineImageFilter extends EngineImageFilter {
698698
final ui.TileMode tileMode;
699699

700700
// TODO(flutter_web): implement TileMode.
701+
@override
701702
String get filterAttribute => blurSigmasToCssString(sigmaX, sigmaY);
702703

703704
@override
@@ -728,6 +729,7 @@ class _MatrixEngineImageFilter extends EngineImageFilter {
728729
final ui.FilterQuality filterQuality;
729730

730731
// TODO(flutter_web): implement FilterQuality.
732+
@override
731733
String get transformAttribute => float64ListToCssTransform(webMatrix);
732734

733735
@override

0 commit comments

Comments
 (0)