From 0a66d8a7a41677271e3b2b9f21852c34147d987e Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Fri, 22 Nov 2019 20:33:47 +0100 Subject: [PATCH] implicit-casts:false in fuchsia_remote_debug_protocol (#45239) --- .../analysis_options.yaml | 12 +++++++++++ .../lib/src/dart/dart_vm.dart | 16 +++++++-------- .../lib/src/runners/ssh_command_runner.dart | 2 +- .../src/runners/ssh_command_runner_test.dart | 20 +++++++++---------- 4 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 packages/fuchsia_remote_debug_protocol/analysis_options.yaml diff --git a/packages/fuchsia_remote_debug_protocol/analysis_options.yaml b/packages/fuchsia_remote_debug_protocol/analysis_options.yaml new file mode 100644 index 0000000000..2344f5ab1f --- /dev/null +++ b/packages/fuchsia_remote_debug_protocol/analysis_options.yaml @@ -0,0 +1,12 @@ +# Override the parent analysis_options until all the repo has implicit-casts: false + +include: ../analysis_options.yaml + +analyzer: + strong-mode: + implicit-casts: false + implicit-dynamic: false + +linter: + rules: + avoid_as: false diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart index 5a3595c0b9..594a9e4c62 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart @@ -171,7 +171,7 @@ class DartVm { await invokeRpc('getVM', timeout: timeout); final List result = []; for (Map jsonIsolate in jsonVmRef['isolates']) { - final String name = jsonIsolate['name']; + final String name = jsonIsolate['name'] as String; if (pattern.matchAsPrefix(name) != null) { _log.fine('Found Isolate matching "$pattern": "$name"'); result.add(IsolateRef._fromJson(jsonIsolate, this)); @@ -197,7 +197,7 @@ class DartVm { 'Peer connection timed out during RPC call', timeout, ); - }); + }) as Map; return result; } @@ -243,11 +243,11 @@ class FlutterView { /// All other cases return a [FlutterView] instance. The name of the /// view may be null, but the id will always be set. factory FlutterView._fromJson(Map json) { - final Map isolate = json['isolate']; - final String id = json['id']; + final Map isolate = json['isolate'] as Map; + final String id = json['id'] as String; String name; if (isolate != null) { - name = isolate['name']; + name = isolate['name'] as String; if (name == null) { throw RpcFormatError('Unable to find name for isolate "$isolate"'); } @@ -286,9 +286,9 @@ class IsolateRef { IsolateRef._(this.name, this.number, this.dartVm); factory IsolateRef._fromJson(Map json, DartVm dartVm) { - final String number = json['number']; - final String name = json['name']; - final String type = json['type']; + final String number = json['number'] as String; + final String name = json['name'] as String; + final String type = json['type'] as String; if (type == null) { throw RpcFormatError('Unable to find type within JSON "$json"'); } diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/runners/ssh_command_runner.dart b/packages/fuchsia_remote_debug_protocol/lib/src/runners/ssh_command_runner.dart index fddcd954e3..3bb483303a 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/runners/ssh_command_runner.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/runners/ssh_command_runner.dart @@ -99,6 +99,6 @@ class SshCommandRunner { 'Command failed: $command\nstdout: ${result.stdout}\nstderr: ${result.stderr}'); } _log.fine('SSH command stdout in brackets:[${result.stdout}]'); - return result.stdout.split('\n'); + return (result.stdout as String).split('\n'); } } diff --git a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart index 8e61cf5620..4a72468779 100644 --- a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart @@ -53,11 +53,11 @@ void main() { interface: interface, sshConfigPath: '/whatever', ); - when(mockProcessResult.stdout).thenReturn('somestuff'); + when(mockProcessResult.stdout).thenReturn('somestuff'); when(mockProcessResult.exitCode).thenReturn(0); await runner.run('ls /whatever'); final List passedCommand = - verify(mockProcessManager.run(captureAny)).captured.single; + verify(mockProcessManager.run(captureAny)).captured.single as List; expect(passedCommand, contains('$ipV6Addr%$interface')); }); @@ -67,11 +67,11 @@ void main() { mockProcessManager, address: ipV6Addr, ); - when(mockProcessResult.stdout).thenReturn('somestuff'); + when(mockProcessResult.stdout).thenReturn('somestuff'); when(mockProcessResult.exitCode).thenReturn(0); await runner.run('ls /whatever'); final List passedCommand = - verify(mockProcessManager.run(captureAny)).captured.single; + verify(mockProcessManager.run(captureAny)).captured.single as List; expect(passedCommand, contains(ipV6Addr)); }); @@ -79,7 +79,7 @@ void main() { const String addr = '192.168.1.1'; runner = SshCommandRunner.withProcessManager(mockProcessManager, address: addr); - when(mockProcessResult.stdout).thenReturn('''this + when(mockProcessResult.stdout).thenReturn('''this has four lines'''); @@ -92,7 +92,7 @@ void main() { const String addr = '192.168.1.1'; runner = SshCommandRunner.withProcessManager(mockProcessManager, address: addr); - when(mockProcessResult.stdout).thenReturn('whatever'); + when(mockProcessResult.stdout).thenReturn('whatever'); when(mockProcessResult.exitCode).thenReturn(1); Future failingFunction() async { await runner.run('oihaw'); @@ -109,11 +109,11 @@ void main() { address: addr, sshConfigPath: config, ); - when(mockProcessResult.stdout).thenReturn('somestuff'); + when(mockProcessResult.stdout).thenReturn('somestuff'); when(mockProcessResult.exitCode).thenReturn(0); await runner.run('ls /whatever'); final List passedCommand = - verify(mockProcessManager.run(captureAny)).captured.single; + verify(mockProcessManager.run(captureAny)).captured.single as List; expect(passedCommand, contains('-F')); final int indexOfFlag = passedCommand.indexOf('-F'); final String passedConfig = passedCommand[indexOfFlag + 1]; @@ -126,11 +126,11 @@ void main() { mockProcessManager, address: addr, ); - when(mockProcessResult.stdout).thenReturn('somestuff'); + when(mockProcessResult.stdout).thenReturn('somestuff'); when(mockProcessResult.exitCode).thenReturn(0); await runner.run('ls /whatever'); final List passedCommand = - verify(mockProcessManager.run(captureAny)).captured.single; + verify(mockProcessManager.run(captureAny)).captured.single as List; final int indexOfFlag = passedCommand.indexOf('-F'); expect(indexOfFlag, equals(-1)); });