Skip to content

Commit f04d941

Browse files
authored
[web] enable always_specify_types lint (#27406)
1 parent 3649200 commit f04d941

File tree

100 files changed

+638
-612
lines changed

Some content is hidden

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

100 files changed

+638
-612
lines changed

lib/web_ui/analysis_options.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ analyzer:
1313

1414
linter:
1515
rules:
16-
always_specify_types: false
1716
annotate_overrides: false
1817
avoid_classes_with_only_static_members: false
1918
avoid_empty_else: false

lib/web_ui/dev/browser.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,20 @@ abstract class Browser {
7676
///
7777
/// This will fire once the process has started successfully.
7878
Future<Process> get _process => _processCompleter.future;
79-
final _processCompleter = Completer<Process>();
79+
final Completer<Process> _processCompleter = Completer<Process>();
8080

8181
/// Whether [close] has been called.
82-
var _closed = false;
82+
bool _closed = false;
8383

8484
/// A future that completes when the browser exits.
8585
///
8686
/// If there's a problem starting or running the browser, this will complete
8787
/// with an error.
8888
Future<void> get onExit => _onExitCompleter.future;
89-
final _onExitCompleter = Completer<void>();
89+
final Completer<void> _onExitCompleter = Completer<void>();
9090

9191
/// Standard IO streams for the underlying browser process.
92-
final _ioSubscriptions = <StreamSubscription>[];
92+
final List<StreamSubscription<void>> _ioSubscriptions = <StreamSubscription<void>>[];
9393

9494
/// Creates a new browser.
9595
///
@@ -102,10 +102,10 @@ abstract class Browser {
102102
// for the process to actually start. They should just wait for the HTTP
103103
// request instead.
104104
runZonedGuarded(() async {
105-
var process = await startBrowser();
105+
Process process = await startBrowser();
106106
_processCompleter.complete(process);
107107

108-
var output = Uint8Buffer();
108+
Uint8Buffer output = Uint8Buffer();
109109
void drainOutput(Stream<List<int>> stream) {
110110
try {
111111
_ioSubscriptions
@@ -117,7 +117,7 @@ abstract class Browser {
117117
drainOutput(process.stdout);
118118
drainOutput(process.stderr);
119119

120-
var exitCode = await process.exitCode;
120+
int exitCode = await process.exitCode;
121121

122122
// This hack dodges an otherwise intractable race condition. When the user
123123
// presses Control-C, the signal is sent to the browser and the test
@@ -134,8 +134,8 @@ abstract class Browser {
134134
}
135135

136136
if (!_closed && exitCode != 0) {
137-
var outputString = utf8.decode(output);
138-
var message = '$name failed with exit code $exitCode.';
137+
String outputString = utf8.decode(output);
138+
String message = '$name failed with exit code $exitCode.';
139139
if (outputString.isNotEmpty) {
140140
message += '\nStandard output:\n$outputString';
141141
}
@@ -151,7 +151,7 @@ abstract class Browser {
151151
}
152152

153153
// Make sure the process dies even if the error wasn't fatal.
154-
_process.then((process) => process.kill());
154+
_process.then((Process process) => process.kill());
155155

156156
if (stackTrace == null) {
157157
stackTrace = Trace.current();
@@ -170,13 +170,13 @@ abstract class Browser {
170170
///
171171
/// Returns the same [Future] as [onExit], except that it won't emit
172172
/// exceptions.
173-
Future close() async {
173+
Future<void> close() async {
174174
_closed = true;
175175

176176
// If we don't manually close the stream the test runner can hang.
177177
// For example this happens with Chrome Headless.
178178
// See SDK issue: https://github.com/dart-lang/sdk/issues/31264
179-
for (var stream in _ioSubscriptions) {
179+
for (StreamSubscription<void> stream in _ioSubscriptions) {
180180
unawaited(stream.cancel());
181181
}
182182

@@ -192,7 +192,7 @@ abstract class ScreenshotManager {
192192
/// Capture a screenshot.
193193
///
194194
/// Please read the details for the implementing classes.
195-
Future<Image> capture(math.Rectangle region);
195+
Future<Image> capture(math.Rectangle<num> region);
196196

197197
/// Suffix to be added to the end of the filename.
198198
///

lib/web_ui/dev/build.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import 'dart:async';
77

88
import 'package:args/command_runner.dart';
99
import 'package:path/path.dart' as path;
10+
import 'package:watcher/src/watch_event.dart';
1011

1112
import 'environment.dart';
1213
import 'utils.dart';
1314
import 'watcher.dart';
1415

15-
class BuildCommand extends Command<bool> with ArgUtils {
16+
class BuildCommand extends Command<bool> with ArgUtils<bool> {
1617
BuildCommand() {
1718
argParser
1819
..addFlag(
@@ -48,7 +49,7 @@ class BuildCommand extends Command<bool> with ArgUtils {
4849
dir: libPath.absolute,
4950
pipeline: buildPipeline,
5051
// Ignore font files that are copied whenever tests run.
51-
ignore: (event) => event.path.endsWith('.ttf'),
52+
ignore: (WatchEvent event) => event.path.endsWith('.ttf'),
5253
).start();
5354
}
5455
return true;

lib/web_ui/dev/chrome.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ChromeEnvironment implements BrowserEnvironment {
5151
/// Any errors starting or running the process are reported through [onExit].
5252
class Chrome extends Browser {
5353
@override
54-
final name = 'Chrome';
54+
final String name = 'Chrome';
5555

5656
@override
5757
final Future<Uri> remoteDebuggerUrl;
@@ -60,7 +60,7 @@ class Chrome extends Browser {
6060
/// [Uri] or a [String].
6161
factory Chrome(Uri url, {bool debug = false}) {
6262
String version = ChromeArgParser.instance.version;
63-
var remoteDebuggerCompleter = Completer<Uri>.sync();
63+
Completer<Uri> remoteDebuggerCompleter = Completer<Uri>.sync();
6464
return Chrome._(() async {
6565
final BrowserInstallation installation = await getOrInstallChrome(
6666
version,
@@ -80,7 +80,7 @@ class Chrome extends Browser {
8080
final bool isChromeNoSandbox =
8181
Platform.environment['CHROME_NO_SANDBOX'] == 'true';
8282
final String dir = environment.webUiDartToolDir.createTempSync('test_chrome_user_data_').resolveSymbolicLinksSync();
83-
var args = [
83+
List<String> args = <String>[
8484
'--user-data-dir=$dir',
8585
url.toString(),
8686
if (!debug)
@@ -218,7 +218,7 @@ class ChromeScreenshotManager extends ScreenshotManager {
218218
/// [region] is used to decide which part of the web content will be used in
219219
/// test image. It includes starting coordinate x,y as well as height and
220220
/// width of the area to capture.
221-
Future<Image> capture(math.Rectangle? region) async {
221+
Future<Image> capture(math.Rectangle<num>? region) async {
222222
final wip.ChromeConnection chromeConnection =
223223
wip.ChromeConnection('localhost', kDevtoolsPort);
224224
final wip.ChromeTab? chromeTab = await chromeConnection.getTab(

lib/web_ui/dev/chrome_installer.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'dart:async';
66
import 'dart:io' as io;
7+
import 'dart:typed_data';
78

89
import 'package:archive/archive.dart';
910
import 'package:archive/archive_io.dart';
@@ -220,15 +221,15 @@ class ChromeInstaller {
220221
final Stopwatch stopwatch = Stopwatch()..start();
221222

222223
// Read the Zip file from disk.
223-
final bytes = downloadedFile.readAsBytesSync();
224+
final Uint8List bytes = downloadedFile.readAsBytesSync();
224225

225226
final Archive archive = ZipDecoder().decodeBytes(bytes);
226227

227228
// Extract the contents of the Zip archive to disk.
228229
for (final ArchiveFile file in archive) {
229230
final String filename = file.name;
230231
if (file.isFile) {
231-
final data = file.content as List<int>;
232+
final List<int> data = file.content as List<int>;
232233
io.File(path.join(versionDir.path, filename))
233234
..createSync(recursive: true)
234235
..writeAsBytesSync(data);

lib/web_ui/dev/clean.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:path/path.dart' as path;
1111
import 'environment.dart';
1212
import 'utils.dart';
1313

14-
class CleanCommand extends Command<bool> with ArgUtils {
14+
class CleanCommand extends Command<bool> with ArgUtils<bool> {
1515
CleanCommand() {
1616
argParser
1717
..addFlag(

lib/web_ui/dev/common.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class DevNull implements StringSink {
221221
void write(Object? obj) {}
222222

223223
@override
224-
void writeAll(Iterable objects, [String separator = ""]) {}
224+
void writeAll(Iterable<dynamic> objects, [String separator = ""]) {}
225225

226226
@override
227227
void writeCharCode(int charCode) {}

lib/web_ui/dev/create_simulator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:simulators/simulator_manager.dart';
1010
import 'safari_installation.dart';
1111
import 'utils.dart';
1212

13-
class CreateSimulatorCommand extends Command<bool> with ArgUtils {
13+
class CreateSimulatorCommand extends Command<bool> with ArgUtils<bool> {
1414
CreateSimulatorCommand() {
1515
IosSafariArgParser.instance.populateOptions(argParser);
1616
argParser

lib/web_ui/dev/edge.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class EdgeEnvironment implements BrowserEnvironment {
4242
/// Any errors starting or running the process are reported through [onExit].
4343
class Edge extends Browser {
4444
@override
45-
final name = 'Edge';
45+
final String name = 'Edge';
4646

4747
/// Starts a new instance of Safari open to the given [url], which may be a
4848
/// [Uri] or a [String].
@@ -63,8 +63,10 @@ class Edge extends Browser {
6363
pathToOpen = pathToOpen.substring(0, index-1);
6464
}
6565

66-
var process =
67-
await Process.start(installation.executable, ['$pathToOpen','-k']);
66+
Process process = await Process.start(
67+
installation.executable,
68+
<String>['$pathToOpen','-k'],
69+
);
6870

6971
return process;
7072
});

lib/web_ui/dev/felt.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import 'exceptions.dart';
1414
import 'test_runner.dart';
1515
import 'utils.dart';
1616

17-
CommandRunner runner = CommandRunner<bool>(
17+
CommandRunner<bool> runner = CommandRunner<bool>(
1818
'felt',
1919
'Command-line utility for building and testing Flutter web engine.',
2020
)
@@ -26,7 +26,7 @@ CommandRunner runner = CommandRunner<bool>(
2626

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

3131
if (args.isEmpty) {
3232
// The felt tool was invoked with no arguments. Print usage.

0 commit comments

Comments
 (0)