Skip to content

update package:gcloud to a more recent set of lints #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions pkgs/gcloud/.status

This file was deleted.

5 changes: 3 additions & 2 deletions pkgs/gcloud/lib/datastore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class DatastoreError implements Exception {
}

class UnknownDatastoreError extends DatastoreError {
UnknownDatastoreError(error) : super('An unknown error occurred ($error).');
UnknownDatastoreError(Object error)
: super('An unknown error occurred ($error).');
}

class TransactionAbortedError extends DatastoreError {
Expand Down Expand Up @@ -89,7 +90,7 @@ class InternalError extends DatastoreError {
}

class QuotaExceededError extends DatastoreError {
QuotaExceededError(error) : super('Quota was exceeded ($error).');
QuotaExceededError(Object error) : super('Quota was exceeded ($error).');
}

/// A datastore Entity
Expand Down
2 changes: 0 additions & 2 deletions pkgs/gcloud/lib/db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library;

import 'dart:collection';
// dart:core is imported explicitly so it is available at top-level without
// the `core` prefix defined below.
Expand Down
7 changes: 3 additions & 4 deletions pkgs/gcloud/lib/service_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ Future fork(Future Function() func, {Function? onError}) {
return currentServiceScope._fork(func, onError: onError);
}

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

// We are running all on-scope-exit functions in reverse registration order.
// Even if one fails, we continue cleaning up and report then the list of
Expand All @@ -252,7 +251,7 @@ class _ServiceScope {
}
if (registeredEntry.scopeExitCallback != null) {
return Future.sync(registeredEntry.scopeExitCallback!)
.catchError((e, s) => errors.add(e));
.catchError((Object e, s) => errors.add(e));
} else {
return Future.value();
}
Expand Down
6 changes: 3 additions & 3 deletions pkgs/gcloud/lib/src/datastore_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class DatastoreImpl implements datastore.Datastore {
return true;
}

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

api.Value convertItem(i) =>
_convertDatastore2ApiPropertyValue(i, indexed, lists: false);
api.Value convertItem(Object? item) =>
_convertDatastore2ApiPropertyValue(item, indexed, lists: false);

return api.Value()
..arrayValue =
Expand Down
41 changes: 13 additions & 28 deletions pkgs/gcloud/lib/src/db/annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Kind {
/// annotation is placed.
final String? name;

/// The type, either [ID_TYPE_INTEGER] or [ID_TYPE_STRING].
/// The type, either [IdType.Integer] or [IdType.String].
final IdType idType;

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

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

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

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

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

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

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

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

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

// TODO: We want to support optional list properties as well.
// Get rid of "required: true" here.
const ListProperty(this.subProperty,
{String? propertyName, bool indexed = true})
: super(propertyName: propertyName, required: true, indexed: indexed);
const ListProperty(this.subProperty, {super.propertyName, super.indexed})
: super(required: true);

@override
bool validate(ModelDB db, Object? value) {
Expand Down
8 changes: 4 additions & 4 deletions pkgs/gcloud/lib/src/db/db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Transaction {
}
}

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

/// Build a query for [kind] models.
/// Build a query for kind models.
Query<T> query<T extends Model>({Partition? partition, Key? ancestorKey}) {
// TODO(#26): There is only one case where `partition` is not redundant
// Namely if `ancestorKey == null` and `partition != null`. We could
Expand All @@ -350,8 +350,8 @@ class DatastoreDB {
/// Any key that is not found in the datastore will have a corresponding
/// value of null in the list of model objects that is returned.
///
/// For transactions, please use [beginTransaction] and call the [lookup]
/// method on it's returned [Transaction] object.
/// For transactions, please use [ds.Datastore.beginTransaction] and call the
/// [lookup] method on it's returned [Transaction] object.
///
/// See also:
///
Expand Down
5 changes: 2 additions & 3 deletions pkgs/gcloud/lib/src/db/model_db_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class ModelDBImpl implements ModelDB {
return modelDescription.fieldNameToPropertyName(fieldName);
}

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

_ExpandoModelDescription(String kind, bool useIntegerId)
: super(kind, useIntegerId);
_ExpandoModelDescription(super.kind, super.useIntegerId);

@override
void initialize(ModelDBImpl db) {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/gcloud/lib/src/db/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ abstract class Model<T> {
///
/// The [ExpandoModel] class adds support for having dynamic properties. You can
/// set arbitrary fields on these models. The expanded values must be values
/// accepted by the [RawDatastore] implementation.
/// accepted by the [ds.Datastore] implementation.
abstract class ExpandoModel<T> extends Model<T> {
final Map<String, Object?> additionalProperties = {};

Expand Down
4 changes: 2 additions & 2 deletions pkgs/gcloud/lib/src/storage_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _StorageImpl implements Storage {

@override
Future<bool> bucketExists(String bucketName) {
bool notFoundError(e) {
bool notFoundError(Object e) {
return e is storage_api.DetailedApiRequestError && e.status == 404;
}

Expand Down Expand Up @@ -431,7 +431,7 @@ class _ObjectInfoImpl implements ObjectInfo {
}

class _BucketObjectEntry extends _ObjectInfoImpl implements BucketObjectEntry {
_BucketObjectEntry(storage_api.Object object) : super(object);
_BucketObjectEntry(super.object);

@override
bool get isDirectory => false;
Expand Down
4 changes: 2 additions & 2 deletions pkgs/gcloud/lib/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,8 @@ abstract class Bucket {
///
/// If [length] is provided, it must be greater than `0`.
///
/// If there is a problem accessing the file, a [DetailedApiRequestError] is
/// thrown.
/// If there is a problem accessing the file, a
/// [storage_api.DetailedApiRequestError] is thrown.
Stream<List<int>> read(String objectName, {int? offset, int? length});

/// Lookup object metadata.
Expand Down
4 changes: 2 additions & 2 deletions pkgs/gcloud/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ topics:
- gcp

environment:
sdk: '^3.0.0'
sdk: ^3.0.0

dependencies:
_discoveryapis_commons: ^1.0.0
Expand All @@ -20,7 +20,7 @@ dependencies:
retry: ^3.1.1

dev_dependencies:
dart_flutter_team_lints: ^1.0.0
dart_flutter_team_lints: ^3.0.0
googleapis_auth: ^1.1.0
http_parser: ^4.0.0
mime: ^1.0.0
Expand Down
2 changes: 1 addition & 1 deletion pkgs/gcloud/test/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class TraceClient extends http.BaseClient {
class RequestImpl extends http.BaseRequest {
final List<int> _body;

RequestImpl(String method, Uri url, this._body) : super(method, url);
RequestImpl(super.method, super.url, this._body);

@override
http.ByteStream finalize() {
Expand Down
8 changes: 8 additions & 0 deletions pkgs/gcloud/test/common_e2e.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ const projectEnv = 'GCLOUD_E2E_TEST_PROJECT';
// attempt to account for that.
const storageListDelay = Duration(seconds: 5);

String? shouldSkip() {
if (!Platform.environment.containsKey(projectEnv)) {
return '$projectEnv not set';
}

return null;
}

Future<T> withAuthClient<T>(
List<String> scopes,
Future<T> Function(String project, http.Client client) callback, {
Expand Down
5 changes: 3 additions & 2 deletions pkgs/gcloud/test/datastore/e2e/datastore_test_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void runTests(Datastore datastore, String? namespace) {
.then((result) => null);
}, xg: true);
} else {
return datastore.commit(deletes: keys).then((_) => _);
return datastore.commit(deletes: keys);
}
}

Expand Down Expand Up @@ -572,7 +572,8 @@ void runTests(Datastore datastore, String? namespace) {
group('conflicting_transaction', () {
Future testConflictingTransaction(List<Entity> entities,
{bool xg = false}) {
Future test(List<Entity?> entities, Transaction transaction, value) {
Future test(
List<Entity?> entities, Transaction transaction, int value) {
// Change entities:
var changedEntities = List<Entity?>.filled(entities.length, null);
for (var i = 0; i < entities.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions pkgs/gcloud/test/db/e2e/metamodel_test_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ List<Entity> buildEntitiesWithDifferentNamespaces() {
];
}

Future sleep(Duration duration) {
var completer = Completer();
Future<void> sleep(Duration duration) {
var completer = Completer<void>();
Timer(duration, completer.complete);
return completer.future;
}
Expand Down
3 changes: 2 additions & 1 deletion pkgs/gcloud/test/db/model_dbs/duplicate_fieldname.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore: unnecessary_library_directive
// This library name is used by tests.
// ignore: unnecessary_library_directive, unnecessary_library_name
library gcloud.db.model_test.duplicate_fieldname;

import 'package:gcloud/db.dart' as db;
Expand Down
Loading