Skip to content

Commit 1ff6e9c

Browse files
authored
update package:appengine to use a recent lint set (#228)
1 parent cda0362 commit 1ff6e9c

File tree

12 files changed

+87
-57
lines changed

12 files changed

+87
-57
lines changed

pkgs/appengine/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,6 @@ in the output of `gcloud app deploy` (as well as via the
170170
## Regenerating protobuf
171171

172172
You need to have protoc in `$PATH`.
173-
Run the `tool/fetch_protos_and_regenerate_dart.sh` script. It will fetch the latest protos and compile them for dart using the protoc_plugin in `dev_dependencies`.
173+
Run the `tool/fetch_protos_and_regenerate_dart.sh` script. It will fetch the
174+
latest protos and compile them for dart using the protoc_plugin in
175+
`dev_dependencies`.

pkgs/appengine/analysis_options.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
include: package:lints/core.yaml
2+
13
analyzer:
24
errors:
3-
# This is triggered in generated code.
4-
unnecessary_import: ignore
5+
# TODO: We need to update the grpc generator to escape html entities in
6+
# proto comments.
7+
unintended_html_in_doc_comment: ignore
58

69
exclude:
710
- tmp/**

pkgs/appengine/example/pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: hello_world
22
publish_to: none
3+
34
environment:
4-
sdk: '>=2.12.0 <3.0.0'
5+
sdk: ^3.0.0
56

67
dependencies:
78
appengine: ^0.13.0
8-
logging:
9+
logging: ^1.3.0

pkgs/appengine/lib/appengine.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'src/appengine_internal.dart' as appengine_internal;
1313
import 'src/client_context.dart';
1414

1515
export 'package:gcloud/http.dart';
16+
1617
export 'src/appengine_context.dart';
1718
export 'src/client_context.dart';
1819
export 'src/errors.dart';
@@ -62,7 +63,7 @@ Future runAppEngine(
6263
bool shared = false,
6364
void onAcceptingConnections(InternetAddress address, int port)?,
6465
}) {
65-
var errorHandler;
66+
void Function(Object, StackTrace)? errorHandler;
6667
if (onError != null) {
6768
if (onError is ZoneUnaryCallback) {
6869
errorHandler = (error, stack) => onError(error);

pkgs/appengine/lib/src/grpc_api_impl/datastore_impl.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ class _Codec {
506506
final keyElements = List<raw.KeyElement?>.filled(pb.path.length, null);
507507
for (int i = 0; i < pb.path.length; i++) {
508508
final part = pb.path[i];
509-
var id;
509+
Object id;
510510
if (part.hasName()) {
511511
id = part.name;
512512
} else if (part.hasId()) {
@@ -516,7 +516,7 @@ class _Codec {
516516
}
517517
keyElements[i] = raw.KeyElement(part.kind, id);
518518
}
519-
var partition;
519+
raw.Partition? partition;
520520
if (pb.hasPartitionId()) {
521521
final partitionId = pb.partitionId;
522522
if (partitionId.hasNamespaceId()) {

pkgs/appengine/lib/src/grpc_api_impl/logging_impl.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ library grpc_logging;
66

77
import 'dart:async';
88
import 'dart:io';
9+
910
import 'package:grpc/grpc.dart' as grpc;
1011
import 'package:stack_trace/stack_trace.dart' show Trace;
1112

pkgs/appengine/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ topics:
1111
- gcp
1212

1313
environment:
14-
sdk: '>=2.19.0 <3.0.0'
14+
sdk: ^3.0.0
1515

1616
dependencies:
1717
fixnum: ^1.0.0
@@ -25,5 +25,6 @@ dependencies:
2525
stack_trace: ^1.10.0
2626

2727
dev_dependencies:
28+
lints: ^5.0.0
2829
protoc_plugin: ^21.1.2
2930
test: ^1.17.5

pkgs/appengine/test/integration/db/db_tests.dart

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ class Person extends db.Model {
6161
@db.ModelKeyProperty(propertyName: 'mangledWife')
6262
db.Key? wife;
6363

64-
operator ==(Object other) => sameAs(other);
64+
@override
65+
bool operator ==(Object other) => sameAs(other);
6566

66-
sameAs(Object other) {
67+
bool sameAs(Object other) {
6768
return other is Person &&
6869
id == other.id &&
6970
parentKey == other.parentKey &&
@@ -72,6 +73,9 @@ class Person extends db.Model {
7273
wife == other.wife;
7374
}
7475

76+
@override
77+
int get hashCode => Object.hash(name, age, wife);
78+
7579
String toString() => 'Person(id: $id, name: $name, age: $age)';
7680
}
7781

@@ -126,7 +130,8 @@ class ExpandoPerson extends db.ExpandoModel {
126130
@db.StringProperty(propertyName: 'NN')
127131
String? nickname;
128132

129-
operator ==(Object other) {
133+
@override
134+
bool operator ==(Object other) {
130135
if (other is ExpandoPerson && id == other.id && name == other.name) {
131136
if (additionalProperties.length != other.additionalProperties.length) {
132137
return false;
@@ -140,6 +145,9 @@ class ExpandoPerson extends db.ExpandoModel {
140145
}
141146
return false;
142147
}
148+
149+
@override
150+
int get hashCode => Object.hash(name, nickname);
143151
}
144152

145153
Future sleep(Duration duration) => Future.delayed(duration);
@@ -310,7 +318,9 @@ runTests(db.DatastoreDB store, String namespace) {
310318
persons[0].parentKey = users[0].key;
311319
users[1].parentKey = persons[1].key;
312320

313-
return testInsertLookupDelete([]..addAll(users)..addAll(persons));
321+
return testInsertLookupDelete([]
322+
..addAll(users)
323+
..addAll(persons));
314324
});
315325

316326
test('auto_ids', () {
@@ -420,7 +430,7 @@ runTests(db.DatastoreDB store, String namespace) {
420430
expandoPersons.add(expandoPerson);
421431
}
422432

423-
var LOWER_BOUND = 'user2';
433+
const LOWER_BOUND = 'user2';
424434

425435
var usersSortedNameDescNicknameAsc = List<User>.from(users);
426436
usersSortedNameDescNicknameAsc.sort((User a, User b) {
@@ -454,7 +464,9 @@ runTests(db.DatastoreDB store, String namespace) {
454464
.where((User u) => u.wife == root.append(User, id: 42 + 3))
455465
.toList();
456466

457-
var allInserts = <db.Model>[]..addAll(users)..addAll(expandoPersons);
467+
var allInserts = <db.Model>[]
468+
..addAll(users)
469+
..addAll(expandoPersons);
458470
var allKeys = allInserts.map((model) => model.key).toList();
459471
List<db.Key> userKeys = users.map((model) => model.key).toList();
460472
List<db.Key> expandoPersonsKeys =

pkgs/appengine/test/integration/db/metamodel_tests.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'dart:async';
99
import 'package:test/test.dart';
1010

1111
import 'package:gcloud/datastore.dart';
12-
import 'package:gcloud/datastore.dart' show Key, Partition;
1312
import 'package:gcloud/db.dart' as db;
1413
import 'package:gcloud/db/metamodel.dart';
1514

pkgs/appengine/test/integration/grpc_datastore_test.dart

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,53 @@ import 'package:test/test.dart' as test;
1111
import 'db/db_tests.dart' as db_tests;
1212
import 'db/metamodel_tests.dart' as metamodel_tests;
1313

14-
import 'common_e2e.dart' show onBot, withAuthenticator;
14+
import 'common_e2e.dart' show onBot, withAuthenticator, PROJECT_ENV;
1515
import 'raw_datastore_test_impl.dart' as datastore_tests;
1616

17-
main() async {
18-
final endpoint = 'datastore.googleapis.com';
19-
20-
final String nsPrefix = Platform.operatingSystem;
21-
22-
// Early exit if trying to run this integration test on the bot.
23-
17+
String? shouldSkip() {
2418
if (onBot()) {
25-
return;
19+
return 'Skipping e2e tests on bot';
2620
}
2721

28-
await withAuthenticator(OAuth2Scopes,
29-
(String project, grpc.HttpBasedAuthenticator authenticator) async {
30-
test.group('grpc datastore', () {
31-
final clientChannel = grpc.ClientChannel(endpoint);
32-
final datastore =
33-
GrpcDatastoreImpl(clientChannel, authenticator, project);
34-
// ignore: unused_local_variable
35-
final dbService = db.DatastoreDB(datastore);
36-
37-
// Once all tests are done we'll close the resources.
38-
test.tearDownAll(() async {
39-
await clientChannel.shutdown();
40-
});
22+
if (!Platform.environment.containsKey(PROJECT_ENV)) {
23+
return '$PROJECT_ENV not set';
24+
}
25+
26+
return null;
27+
}
4128

42-
// Run low-level datastore tests.
43-
datastore_tests.runTests(
44-
datastore, '${nsPrefix}${DateTime.now().millisecondsSinceEpoch}');
29+
void main() async {
30+
final endpoint = 'datastore.googleapis.com';
4531

46-
// Run high-level db tests.
47-
db_tests.runTests(
48-
dbService, '${nsPrefix}${DateTime.now().millisecondsSinceEpoch}');
32+
final String nsPrefix = Platform.operatingSystem;
4933

50-
// Run metamodel tests.
51-
metamodel_tests.runTests(datastore, dbService,
52-
'${nsPrefix}${DateTime.now().millisecondsSinceEpoch}');
53-
}, skip: onBot());
54-
});
34+
test.group('grpc', () {
35+
test.test('datastore', () async {
36+
await withAuthenticator(OAuth2Scopes,
37+
(String project, grpc.HttpBasedAuthenticator authenticator) async {
38+
final clientChannel = grpc.ClientChannel(endpoint);
39+
final datastore =
40+
GrpcDatastoreImpl(clientChannel, authenticator, project);
41+
// ignore: unused_local_variable
42+
final dbService = db.DatastoreDB(datastore);
43+
44+
// Once all tests are done we'll close the resources.
45+
test.tearDownAll(() async {
46+
await clientChannel.shutdown();
47+
});
48+
49+
// Run low-level datastore tests.
50+
datastore_tests.runTests(
51+
datastore, '${nsPrefix}${DateTime.now().millisecondsSinceEpoch}');
52+
53+
// Run high-level db tests.
54+
db_tests.runTests(
55+
dbService, '${nsPrefix}${DateTime.now().millisecondsSinceEpoch}');
56+
57+
// Run metamodel tests.
58+
metamodel_tests.runTests(datastore, dbService,
59+
'${nsPrefix}${DateTime.now().millisecondsSinceEpoch}');
60+
});
61+
});
62+
}, skip: shouldSkip());
5563
}

0 commit comments

Comments
 (0)