Skip to content

Commit 0a66d8a

Browse files
authored
implicit-casts:false in fuchsia_remote_debug_protocol (flutter#45239)
1 parent e2cf2f0 commit 0a66d8a

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Override the parent analysis_options until all the repo has implicit-casts: false
2+
3+
include: ../analysis_options.yaml
4+
5+
analyzer:
6+
strong-mode:
7+
implicit-casts: false
8+
implicit-dynamic: false
9+
10+
linter:
11+
rules:
12+
avoid_as: false

packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class DartVm {
171171
await invokeRpc('getVM', timeout: timeout);
172172
final List<IsolateRef> result = <IsolateRef>[];
173173
for (Map<String, dynamic> jsonIsolate in jsonVmRef['isolates']) {
174-
final String name = jsonIsolate['name'];
174+
final String name = jsonIsolate['name'] as String;
175175
if (pattern.matchAsPrefix(name) != null) {
176176
_log.fine('Found Isolate matching "$pattern": "$name"');
177177
result.add(IsolateRef._fromJson(jsonIsolate, this));
@@ -197,7 +197,7 @@ class DartVm {
197197
'Peer connection timed out during RPC call',
198198
timeout,
199199
);
200-
});
200+
}) as Map<String, dynamic>;
201201
return result;
202202
}
203203

@@ -243,11 +243,11 @@ class FlutterView {
243243
/// All other cases return a [FlutterView] instance. The name of the
244244
/// view may be null, but the id will always be set.
245245
factory FlutterView._fromJson(Map<String, dynamic> json) {
246-
final Map<String, dynamic> isolate = json['isolate'];
247-
final String id = json['id'];
246+
final Map<String, dynamic> isolate = json['isolate'] as Map<String, dynamic>;
247+
final String id = json['id'] as String;
248248
String name;
249249
if (isolate != null) {
250-
name = isolate['name'];
250+
name = isolate['name'] as String;
251251
if (name == null) {
252252
throw RpcFormatError('Unable to find name for isolate "$isolate"');
253253
}
@@ -286,9 +286,9 @@ class IsolateRef {
286286
IsolateRef._(this.name, this.number, this.dartVm);
287287

288288
factory IsolateRef._fromJson(Map<String, dynamic> json, DartVm dartVm) {
289-
final String number = json['number'];
290-
final String name = json['name'];
291-
final String type = json['type'];
289+
final String number = json['number'] as String;
290+
final String name = json['name'] as String;
291+
final String type = json['type'] as String;
292292
if (type == null) {
293293
throw RpcFormatError('Unable to find type within JSON "$json"');
294294
}

packages/fuchsia_remote_debug_protocol/lib/src/runners/ssh_command_runner.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,6 @@ class SshCommandRunner {
9999
'Command failed: $command\nstdout: ${result.stdout}\nstderr: ${result.stderr}');
100100
}
101101
_log.fine('SSH command stdout in brackets:[${result.stdout}]');
102-
return result.stdout.split('\n');
102+
return (result.stdout as String).split('\n');
103103
}
104104
}

packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ void main() {
5353
interface: interface,
5454
sshConfigPath: '/whatever',
5555
);
56-
when<String>(mockProcessResult.stdout).thenReturn('somestuff');
56+
when<dynamic>(mockProcessResult.stdout).thenReturn('somestuff');
5757
when(mockProcessResult.exitCode).thenReturn(0);
5858
await runner.run('ls /whatever');
5959
final List<String> passedCommand =
60-
verify(mockProcessManager.run(captureAny)).captured.single;
60+
verify(mockProcessManager.run(captureAny)).captured.single as List<String>;
6161
expect(passedCommand, contains('$ipV6Addr%$interface'));
6262
});
6363

@@ -67,19 +67,19 @@ void main() {
6767
mockProcessManager,
6868
address: ipV6Addr,
6969
);
70-
when<String>(mockProcessResult.stdout).thenReturn('somestuff');
70+
when<dynamic>(mockProcessResult.stdout).thenReturn('somestuff');
7171
when(mockProcessResult.exitCode).thenReturn(0);
7272
await runner.run('ls /whatever');
7373
final List<String> passedCommand =
74-
verify(mockProcessManager.run(captureAny)).captured.single;
74+
verify(mockProcessManager.run(captureAny)).captured.single as List<String>;
7575
expect(passedCommand, contains(ipV6Addr));
7676
});
7777

7878
test('verify commands are split into multiple lines', () async {
7979
const String addr = '192.168.1.1';
8080
runner = SshCommandRunner.withProcessManager(mockProcessManager,
8181
address: addr);
82-
when<String>(mockProcessResult.stdout).thenReturn('''this
82+
when<dynamic>(mockProcessResult.stdout).thenReturn('''this
8383
has
8484
four
8585
lines''');
@@ -92,7 +92,7 @@ void main() {
9292
const String addr = '192.168.1.1';
9393
runner = SshCommandRunner.withProcessManager(mockProcessManager,
9494
address: addr);
95-
when<String>(mockProcessResult.stdout).thenReturn('whatever');
95+
when<dynamic>(mockProcessResult.stdout).thenReturn('whatever');
9696
when(mockProcessResult.exitCode).thenReturn(1);
9797
Future<void> failingFunction() async {
9898
await runner.run('oihaw');
@@ -109,11 +109,11 @@ void main() {
109109
address: addr,
110110
sshConfigPath: config,
111111
);
112-
when<String>(mockProcessResult.stdout).thenReturn('somestuff');
112+
when<dynamic>(mockProcessResult.stdout).thenReturn('somestuff');
113113
when(mockProcessResult.exitCode).thenReturn(0);
114114
await runner.run('ls /whatever');
115115
final List<String> passedCommand =
116-
verify(mockProcessManager.run(captureAny)).captured.single;
116+
verify(mockProcessManager.run(captureAny)).captured.single as List<String>;
117117
expect(passedCommand, contains('-F'));
118118
final int indexOfFlag = passedCommand.indexOf('-F');
119119
final String passedConfig = passedCommand[indexOfFlag + 1];
@@ -126,11 +126,11 @@ void main() {
126126
mockProcessManager,
127127
address: addr,
128128
);
129-
when<String>(mockProcessResult.stdout).thenReturn('somestuff');
129+
when<dynamic>(mockProcessResult.stdout).thenReturn('somestuff');
130130
when(mockProcessResult.exitCode).thenReturn(0);
131131
await runner.run('ls /whatever');
132132
final List<String> passedCommand =
133-
verify(mockProcessManager.run(captureAny)).captured.single;
133+
verify(mockProcessManager.run(captureAny)).captured.single as List<String>;
134134
final int indexOfFlag = passedCommand.indexOf('-F');
135135
expect(indexOfFlag, equals(-1));
136136
});

0 commit comments

Comments
 (0)