Skip to content

Commit

Permalink
various analysis updates (#755)
Browse files Browse the repository at this point in the history
* various analysis updates

* misc updates

* remove unintentional dartdoc comment

* Update CONTRIBUTING.md

Co-authored-by: Moritz <[email protected]>

* add ignore comments for use of deprecated apis

---------

Co-authored-by: Moritz <[email protected]>
  • Loading branch information
devoncarew and mosuem authored Jan 30, 2025
1 parent 9a9c017 commit 7f9042f
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 42 deletions.
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ 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.

## Running tests

```
pub get
pub run test
dart test
```

gRPC-web tests require [`envoy`](
Expand Down Expand Up @@ -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`.
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`.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
27 changes: 13 additions & 14 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions example/grpc-web/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions example/grpc-web/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 0 additions & 2 deletions lib/grpc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/client/call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class ClientCall<Q, R> implements Response {
}
}

void onConnectionError(error) {
void onConnectionError(Object error) {
_terminateWithError(GrpcError.unavailable('Error connecting: $error'));
}

Expand Down Expand Up @@ -398,7 +398,7 @@ class ClientCall<Q, R> 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;
Expand Down Expand Up @@ -436,7 +436,7 @@ class ClientCall<Q, R> 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());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/client/http2_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/src/client/transport/xhr_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.

import 'dart:async';
// ignore: deprecated_member_use (#756)
import 'dart:html';
import 'dart:typed_data';

Expand Down
6 changes: 3 additions & 3 deletions lib/src/server/handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions lib/src/shared/io_bits/io_bits_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/client_tests/client_xhr_transport_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions test/server_handles_broken_connection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -107,7 +107,7 @@ Future<void> main() async {
]);
await server.serve(address: address, port: 0);
final receivePort = ReceivePort();
Isolate.spawn(
Isolate.spawn<ClientData>(
client,
ClientData(
address: address,
Expand Down
2 changes: 1 addition & 1 deletion test/timeline_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void checkFinishEvent(List<Map> events) {
expect(e.length, 2);
}

void main([args = const <String>[]]) {
void main(List<String> args) {
test('Test gRPC timeline logging', () async {
final vmService = await testee();
final timeline = await vmService.getVMTimeline();
Expand Down

0 comments on commit 7f9042f

Please sign in to comment.