diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16fc729..c112fe5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ it should raise analysis issues as you edit; alternatively validate from the Terminal: ``` -dartanalyzer lib test +dart analyze ``` All analysis warnings and errors must be fixed; hints should be considered. @@ -33,8 +33,7 @@ All analysis warnings and errors must be fixed; hints should be considered. ## Running tests ``` -pub get -pub run test +dart test ``` gRPC-web tests require [`envoy`]( @@ -69,4 +68,4 @@ early on. so. ## Updating protobuf definitions -Sometimes we might need to update the generated dart files from the protos included in `lib/src/protos`. To do this, run the script `tool/regenerate.sh` from the project root and it will update the generated dart files in `lib/src/geneerated`. \ No newline at end of file +Sometimes we might need to update the generated dart files from the protos included in `lib/src/protos`. To do this, run the script `tool/regenerate.sh` from the project root and it will update the generated dart files in `lib/src/generated`. diff --git a/README.md b/README.md index f85542b..eb6017f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ -The [Dart](https://www.dart.dev/) implementation of -[gRPC](https://grpc.io/): A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. - [![Dart](https://github.com/grpc/grpc-dart/actions/workflows/dart.yml/badge.svg)](https://github.com/grpc/grpc-dart/actions/workflows/dart.yml) [![pub package](https://img.shields.io/pub/v/grpc.svg)](https://pub.dev/packages/grpc) +The [Dart](https://www.dart.dev/) implementation of +[gRPC](https://grpc.io/): A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. ## Learn more diff --git a/analysis_options.yaml b/analysis_options.yaml index 5bcd150..18020d5 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,23 +1,22 @@ -# https://dart.dev/guides/language/analysis-options include: package:lints/recommended.yaml analyzer: errors: - # These should be fixed or ignored in the proto generator + # These should be fixed or ignored in the proto generator. implementation_imports: ignore no_leading_underscores_for_local_identifiers: ignore + unintended_html_in_doc_comment: ignore linter: rules: - #true - always_declare_return_types: true - cancel_subscriptions: true - close_sinks: true - directives_ordering: true - omit_local_variable_types: true - prefer_final_locals: true - prefer_single_quotes: true - test_types_in_equals: true - prefer_relative_imports: true - #false - unintended_html_in_doc_comment: false + - always_declare_return_types + - cancel_subscriptions + - close_sinks + - directives_ordering + - omit_local_variable_types + - prefer_final_locals + - prefer_relative_imports + - prefer_single_quotes + # Enable once 3.7 is stable. + # - strict_top_level_inference + - test_types_in_equals diff --git a/example/grpc-web/lib/app.dart b/example/grpc-web/lib/app.dart index fce83c5..c28c60e 100644 --- a/example/grpc-web/lib/app.dart +++ b/example/grpc-web/lib/app.dart @@ -14,6 +14,7 @@ // limitations under the License. import 'dart:async'; +// ignore: deprecated_member_use (#756) import 'dart:html'; import 'src/generated/echo.pbgrpc.dart'; diff --git a/example/grpc-web/web/main.dart b/example/grpc-web/web/main.dart index 24da3b6..bd740ff 100644 --- a/example/grpc-web/web/main.dart +++ b/example/grpc-web/web/main.dart @@ -12,6 +12,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + +// ignore: deprecated_member_use (#756) import 'dart:html'; import 'package:grpc/grpc_web.dart'; diff --git a/lib/grpc.dart b/lib/grpc.dart index 1c9593f..d2301a0 100644 --- a/lib/grpc.dart +++ b/lib/grpc.dart @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// ignore: dangling_library_doc_comments -/// Status detail types and error codes export 'package:grpc/src/generated/google/rpc/error_details.pb.dart'; export 'src/auth/auth.dart' show BaseAuthenticator; diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index 65f0de3..0cf773c 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -203,7 +203,7 @@ class ClientCall implements Response { } } - void onConnectionError(error) { + void onConnectionError(Object error) { _terminateWithError(GrpcError.unavailable('Error connecting: $error')); } @@ -398,7 +398,7 @@ class ClientCall implements Response { /// Handler for response errors. Forward the error to the [_responses] stream, /// wrapped if necessary. - void _onResponseError(error, StackTrace stackTrace) { + void _onResponseError(Object error, StackTrace stackTrace) { if (error is GrpcError) { _responseError(error, stackTrace); return; @@ -436,7 +436,7 @@ class ClientCall implements Response { /// Error handler for the requests stream. Something went wrong while trying /// to send the request to the server. Abort the request, and forward the /// error to the user code on the [_responses] stream. - void _onRequestError(error, StackTrace stackTrace) { + void _onRequestError(Object error, StackTrace stackTrace) { if (error is! GrpcError) { error = GrpcError.unknown(error.toString()); } diff --git a/lib/src/client/http2_connection.dart b/lib/src/client/http2_connection.dart index 4cce677..115f508 100644 --- a/lib/src/client/http2_connection.dart +++ b/lib/src/client/http2_connection.dart @@ -271,7 +271,7 @@ class Http2ClientConnection implements connection.ClientConnection { return _pendingCalls.isNotEmpty; } - void _handleConnectionFailure(error) { + void _handleConnectionFailure(Object error) { _disconnect(); if (_state == ConnectionState.shutdown || _state == ConnectionState.idle) { return; diff --git a/lib/src/client/transport/xhr_transport.dart b/lib/src/client/transport/xhr_transport.dart index 16b0dca..6798a77 100644 --- a/lib/src/client/transport/xhr_transport.dart +++ b/lib/src/client/transport/xhr_transport.dart @@ -14,6 +14,7 @@ // limitations under the License. import 'dart:async'; +// ignore: deprecated_member_use (#756) import 'dart:html'; import 'dart:typed_data'; diff --git a/lib/src/server/handler.dart b/lib/src/server/handler.dart index f28963c..e89557e 100644 --- a/lib/src/server/handler.dart +++ b/lib/src/server/handler.dart @@ -309,7 +309,7 @@ class ServerHandler extends ServiceCall { // -- Active state, outgoing response data -- - void _onResponse(response) { + void _onResponse(dynamic response) { try { final bytes = _descriptor.serialize(response); if (!_headersSent) { @@ -333,7 +333,7 @@ class ServerHandler extends ServiceCall { sendTrailers(); } - void _onResponseError(error, trace) { + void _onResponseError(Object error, StackTrace trace) { if (error is GrpcError) { _sendError(error, trace); } else { @@ -413,7 +413,7 @@ class ServerHandler extends ServiceCall { // -- All states, incoming error / stream closed -- - void _onError(error) { + void _onError(Object error) { // Exception from the incoming stream. Most likely a cancel request from the // client, so we treat it as such. _timeoutTimer?.cancel(); diff --git a/lib/src/shared/io_bits/io_bits_web.dart b/lib/src/shared/io_bits/io_bits_web.dart index e8dba5a..5290327 100644 --- a/lib/src/shared/io_bits/io_bits_web.dart +++ b/lib/src/shared/io_bits/io_bits_web.dart @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// ignore: deprecated_member_use (#756) export 'dart:html' show HttpStatus; /// Unavailable on the web diff --git a/pubspec.yaml b/pubspec.yaml index 26f9ab1..b441f10 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,9 +1,13 @@ name: grpc -description: Dart implementation of gRPC, a high performance, open-source universal RPC framework. version: 4.0.2-wip - +description: Dart implementation of gRPC, a high performance, open-source universal RPC framework. repository: https://github.com/grpc/grpc-dart +topics: + - grpc + - protocols + - rpc + environment: sdk: ^3.5.0 @@ -31,10 +35,5 @@ dev_dependencies: fake_async: ^1.3.1 false_secrets: - - interop/server1.key - - test/data/localhost.key - -topics: - - grpc - - rpc - - protocols + - interop/server1.key + - test/data/localhost.key diff --git a/test/client_tests/client_xhr_transport_test.dart b/test/client_tests/client_xhr_transport_test.dart index 1c58077..3034445 100644 --- a/test/client_tests/client_xhr_transport_test.dart +++ b/test/client_tests/client_xhr_transport_test.dart @@ -12,10 +12,12 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + @TestOn('browser') library; import 'dart:async'; +// ignore: deprecated_member_use (#756) import 'dart:html'; import 'package:async/async.dart'; diff --git a/test/server_handles_broken_connection_test.dart b/test/server_handles_broken_connection_test.dart index c59c9da..689b525 100644 --- a/test/server_handles_broken_connection_test.dart +++ b/test/server_handles_broken_connection_test.dart @@ -77,7 +77,7 @@ class ClientData { {required this.address, required this.port, required this.sendPort}); } -void client(clientData) async { +void client(ClientData clientData) async { final channel = grpc.ClientChannel( clientData.address, port: clientData.port, @@ -107,7 +107,7 @@ Future main() async { ]); await server.serve(address: address, port: 0); final receivePort = ReceivePort(); - Isolate.spawn( + Isolate.spawn( client, ClientData( address: address, diff --git a/test/timeline_test.dart b/test/timeline_test.dart index 1866ea5..b0e936d 100644 --- a/test/timeline_test.dart +++ b/test/timeline_test.dart @@ -137,7 +137,7 @@ void checkFinishEvent(List events) { expect(e.length, 2); } -void main([args = const []]) { +void main(List args) { test('Test gRPC timeline logging', () async { final vmService = await testee(); final timeline = await vmService.getVMTimeline();