Skip to content

Commit cda0362

Browse files
authored
update package:gcloud to a more recent set of lints (#229)
1 parent 0435f3c commit cda0362

27 files changed

+573
-599
lines changed

pkgs/gcloud/.status

Lines changed: 0 additions & 39 deletions
This file was deleted.

pkgs/gcloud/lib/datastore.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class DatastoreError implements Exception {
6161
}
6262

6363
class UnknownDatastoreError extends DatastoreError {
64-
UnknownDatastoreError(error) : super('An unknown error occurred ($error).');
64+
UnknownDatastoreError(Object error)
65+
: super('An unknown error occurred ($error).');
6566
}
6667

6768
class TransactionAbortedError extends DatastoreError {
@@ -89,7 +90,7 @@ class InternalError extends DatastoreError {
8990
}
9091

9192
class QuotaExceededError extends DatastoreError {
92-
QuotaExceededError(error) : super('Quota was exceeded ($error).');
93+
QuotaExceededError(Object error) : super('Quota was exceeded ($error).');
9394
}
9495

9596
/// A datastore Entity

pkgs/gcloud/lib/db.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library;
6-
75
import 'dart:collection';
86
// dart:core is imported explicitly so it is available at top-level without
97
// the `core` prefix defined below.

pkgs/gcloud/lib/service_scope.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ Future fork(Future Function() func, {Function? onError}) {
102102
return currentServiceScope._fork(func, onError: onError);
103103
}
104104

105-
/// Register a new [object] into the current service scope using the given
106-
/// [key].
105+
/// Register [value] into the current service scope using the given [key].
107106
///
108107
/// If [onScopeExit] is provided, it will be called when the service scope ends.
109108
///
@@ -240,7 +239,7 @@ class _ServiceScope {
240239
/// Runs all on-scope-exit functions in [_ServiceScope].
241240
Future _runScopeExitHandlers() {
242241
_cleaningUp = true;
243-
var errors = [];
242+
var errors = <Object>[];
244243

245244
// We are running all on-scope-exit functions in reverse registration order.
246245
// Even if one fails, we continue cleaning up and report then the list of
@@ -252,7 +251,7 @@ class _ServiceScope {
252251
}
253252
if (registeredEntry.scopeExitCallback != null) {
254253
return Future.sync(registeredEntry.scopeExitCallback!)
255-
.catchError((e, s) => errors.add(e));
254+
.catchError((Object e, s) => errors.add(e));
256255
} else {
257256
return Future.value();
258257
}

pkgs/gcloud/lib/src/datastore_impl.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class DatastoreImpl implements datastore.Datastore {
106106
return true;
107107
}
108108

109-
api.Value _convertDatastore2ApiPropertyValue(value, bool indexed,
109+
api.Value _convertDatastore2ApiPropertyValue(Object? value, bool indexed,
110110
{bool lists = true}) {
111111
var apiValue = api.Value()..excludeFromIndexes = !indexed;
112112
if (value == null) {
@@ -132,8 +132,8 @@ class DatastoreImpl implements datastore.Datastore {
132132
throw Exception('List values are not allowed.');
133133
}
134134

135-
api.Value convertItem(i) =>
136-
_convertDatastore2ApiPropertyValue(i, indexed, lists: false);
135+
api.Value convertItem(Object? item) =>
136+
_convertDatastore2ApiPropertyValue(item, indexed, lists: false);
137137

138138
return api.Value()
139139
..arrayValue =

pkgs/gcloud/lib/src/db/annotations.dart

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Kind {
3535
/// annotation is placed.
3636
final String? name;
3737

38-
/// The type, either [ID_TYPE_INTEGER] or [ID_TYPE_STRING].
38+
/// The type, either [IdType.Integer] or [IdType.String].
3939
final IdType idType;
4040

4141
/// Annotation specifying the name of this kind and whether to use integer or
@@ -102,9 +102,7 @@ abstract class Property {
102102
/// An abstract base class for primitive properties which can e.g. be used
103103
/// within a composed `ListProperty`.
104104
abstract class PrimitiveProperty extends Property {
105-
const PrimitiveProperty(
106-
{String? propertyName, bool required = false, bool indexed = true})
107-
: super(propertyName: propertyName, required: required, indexed: indexed);
105+
const PrimitiveProperty({super.propertyName, super.required, super.indexed});
108106

109107
@override
110108
Object? encodeValue(ModelDB db, Object? value,
@@ -120,9 +118,7 @@ abstract class PrimitiveProperty extends Property {
120118
/// It will validate that values are booleans before writing them to the
121119
/// datastore and when reading them back.
122120
class BoolProperty extends PrimitiveProperty {
123-
const BoolProperty(
124-
{String? propertyName, bool required = false, bool indexed = true})
125-
: super(propertyName: propertyName, required: required, indexed: indexed);
121+
const BoolProperty({super.propertyName, super.required, super.indexed});
126122

127123
@override
128124
bool validate(ModelDB db, Object? value) =>
@@ -134,9 +130,7 @@ class BoolProperty extends PrimitiveProperty {
134130
/// It will validate that values are integers before writing them to the
135131
/// datastore and when reading them back.
136132
class IntProperty extends PrimitiveProperty {
137-
const IntProperty(
138-
{String? propertyName, bool required = false, bool indexed = true})
139-
: super(propertyName: propertyName, required: required, indexed: indexed);
133+
const IntProperty({super.propertyName, super.required, super.indexed});
140134

141135
@override
142136
bool validate(ModelDB db, Object? value) =>
@@ -148,9 +142,7 @@ class IntProperty extends PrimitiveProperty {
148142
/// It will validate that values are doubles before writing them to the
149143
/// datastore and when reading them back.
150144
class DoubleProperty extends PrimitiveProperty {
151-
const DoubleProperty(
152-
{String? propertyName, bool required = false, bool indexed = true})
153-
: super(propertyName: propertyName, required: required, indexed: indexed);
145+
const DoubleProperty({super.propertyName, super.required, super.indexed});
154146

155147
@override
156148
bool validate(ModelDB db, Object? value) =>
@@ -162,9 +154,7 @@ class DoubleProperty extends PrimitiveProperty {
162154
/// It will validate that values are strings before writing them to the
163155
/// datastore and when reading them back.
164156
class StringProperty extends PrimitiveProperty {
165-
const StringProperty(
166-
{String? propertyName, bool required = false, bool indexed = true})
167-
: super(propertyName: propertyName, required: required, indexed: indexed);
157+
const StringProperty({super.propertyName, super.required, super.indexed});
168158

169159
@override
170160
bool validate(ModelDB db, Object? value) =>
@@ -176,9 +166,7 @@ class StringProperty extends PrimitiveProperty {
176166
/// It will validate that values are keys before writing them to the
177167
/// datastore and when reading them back.
178168
class ModelKeyProperty extends PrimitiveProperty {
179-
const ModelKeyProperty(
180-
{String? propertyName, bool required = false, bool indexed = true})
181-
: super(propertyName: propertyName, required: required, indexed: indexed);
169+
const ModelKeyProperty({super.propertyName, super.required, super.indexed});
182170

183171
@override
184172
bool validate(ModelDB db, Object? value) =>
@@ -201,10 +189,10 @@ class ModelKeyProperty extends PrimitiveProperty {
201189
///
202190
/// It will validate that values are blobs before writing them to the
203191
/// datastore and when reading them back. Blob values will be represented by
204-
/// List<int>.
192+
/// `List<int>`.
205193
class BlobProperty extends PrimitiveProperty {
206-
const BlobProperty({String? propertyName, bool required = false})
207-
: super(propertyName: propertyName, required: required, indexed: false);
194+
const BlobProperty({super.propertyName, super.required})
195+
: super(indexed: false);
208196

209197
// NOTE: We don't validate that the entries of the list are really integers
210198
// of the range 0..255!
@@ -233,9 +221,7 @@ class BlobProperty extends PrimitiveProperty {
233221
/// It will validate that values are DateTime objects before writing them to the
234222
/// datastore and when reading them back.
235223
class DateTimeProperty extends PrimitiveProperty {
236-
const DateTimeProperty(
237-
{String? propertyName, bool required = false, bool indexed = true})
238-
: super(propertyName: propertyName, required: required, indexed: indexed);
224+
const DateTimeProperty({super.propertyName, super.required, super.indexed});
239225

240226
@override
241227
bool validate(ModelDB db, Object? value) =>
@@ -260,9 +246,8 @@ class ListProperty extends Property {
260246

261247
// TODO: We want to support optional list properties as well.
262248
// Get rid of "required: true" here.
263-
const ListProperty(this.subProperty,
264-
{String? propertyName, bool indexed = true})
265-
: super(propertyName: propertyName, required: true, indexed: indexed);
249+
const ListProperty(this.subProperty, {super.propertyName, super.indexed})
250+
: super(required: true);
266251

267252
@override
268253
bool validate(ModelDB db, Object? value) {

pkgs/gcloud/lib/src/db/db.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Transaction {
8585
}
8686
}
8787

88-
/// Query for [kind] models with [ancestorKey].
88+
/// Query for kind models with [ancestorKey].
8989
///
9090
/// Note that [ancestorKey] is required, since a transaction is not allowed to
9191
/// touch/look at an arbitrary number of rows.
@@ -325,7 +325,7 @@ class DatastoreDB {
325325
});
326326
}
327327

328-
/// Build a query for [kind] models.
328+
/// Build a query for kind models.
329329
Query<T> query<T extends Model>({Partition? partition, Key? ancestorKey}) {
330330
// TODO(#26): There is only one case where `partition` is not redundant
331331
// Namely if `ancestorKey == null` and `partition != null`. We could
@@ -350,8 +350,8 @@ class DatastoreDB {
350350
/// Any key that is not found in the datastore will have a corresponding
351351
/// value of null in the list of model objects that is returned.
352352
///
353-
/// For transactions, please use [beginTransaction] and call the [lookup]
354-
/// method on it's returned [Transaction] object.
353+
/// For transactions, please use [ds.Datastore.beginTransaction] and call the
354+
/// [lookup] method on it's returned [Transaction] object.
355355
///
356356
/// See also:
357357
///

pkgs/gcloud/lib/src/db/model_db_impl.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class ModelDBImpl implements ModelDB {
168168
return modelDescription.fieldNameToPropertyName(fieldName);
169169
}
170170

171-
/// Converts [value] according to the [Property] named [name] in [type].
171+
/// Converts [value] according to the given [kind].
172172
@override
173173
Object? toDatastoreValue(String kind, String fieldName, Object? value,
174174
{bool forComparison = false}) {
@@ -528,8 +528,7 @@ class _ExpandoModelDescription extends _ModelDescription<ExpandoModel> {
528528
late Set<String> realPropertyNames;
529529
late Set<String> usedNames;
530530

531-
_ExpandoModelDescription(String kind, bool useIntegerId)
532-
: super(kind, useIntegerId);
531+
_ExpandoModelDescription(super.kind, super.useIntegerId);
533532

534533
@override
535534
void initialize(ModelDBImpl db) {

pkgs/gcloud/lib/src/db/models.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ abstract class Model<T> {
111111
///
112112
/// The [ExpandoModel] class adds support for having dynamic properties. You can
113113
/// set arbitrary fields on these models. The expanded values must be values
114-
/// accepted by the [RawDatastore] implementation.
114+
/// accepted by the [ds.Datastore] implementation.
115115
abstract class ExpandoModel<T> extends Model<T> {
116116
final Map<String, Object?> additionalProperties = {};
117117

pkgs/gcloud/lib/src/storage_impl.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class _StorageImpl implements Storage {
7171

7272
@override
7373
Future<bool> bucketExists(String bucketName) {
74-
bool notFoundError(e) {
74+
bool notFoundError(Object e) {
7575
return e is storage_api.DetailedApiRequestError && e.status == 404;
7676
}
7777

@@ -431,7 +431,7 @@ class _ObjectInfoImpl implements ObjectInfo {
431431
}
432432

433433
class _BucketObjectEntry extends _ObjectInfoImpl implements BucketObjectEntry {
434-
_BucketObjectEntry(storage_api.Object object) : super(object);
434+
_BucketObjectEntry(super.object);
435435

436436
@override
437437
bool get isDirectory => false;

0 commit comments

Comments
 (0)