fix: mobile unawaited_futures lint (#21661)

* chore: add unawaited_futures lint as warning

# Conflicts:
#	mobile/analysis_options.yaml

* remove unused dcm lints

They will be added back later on a case by case basis

* fix warning

# Conflicts:
#	mobile/lib/presentation/pages/drift_remote_album.page.dart

* auto gen file

* review changes

* conflict resolution

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong
2025-10-27 20:02:52 +05:30
committed by GitHub
parent 664a8fa499
commit ac0d646401
88 changed files with 491 additions and 538 deletions

View File

@@ -53,7 +53,7 @@ void main() {
});
tearDown(() async {
sut.dispose();
unawaited(sut.dispose());
await controller.close();
});
@@ -129,7 +129,7 @@ void main() {
final stream = sut.watch(StoreKey.accessToken);
final events = <String?>[_kAccessToken, _kAccessToken.toUpperCase(), null, _kAccessToken.toLowerCase()];
expectLater(stream, emitsInOrder(events));
unawaited(expectLater(stream, emitsInOrder(events)));
for (final event in events) {
valueController.add(event);

View File

@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/domain/models/user.model.dart';
@@ -99,7 +101,7 @@ void main() {
final count = await db.storeValues.count();
expect(count, isNot(isZero));
await sut.deleteAll();
expectLater(await db.storeValues.count(), isZero);
unawaited(expectLater(await db.storeValues.count(), isZero));
});
});
@@ -124,29 +126,31 @@ void main() {
test('watch()', () async {
final stream = sut.watch(StoreKey.version);
expectLater(stream, emitsInOrder([_kTestVersion, _kTestVersion + 10]));
unawaited(expectLater(stream, emitsInOrder([_kTestVersion, _kTestVersion + 10])));
await pumpEventQueue();
await sut.upsert(StoreKey.version, _kTestVersion + 10);
});
test('watchAll()', () async {
final stream = sut.watchAll();
expectLater(
stream,
emitsInOrder([
[
const StoreDto<Object>(StoreKey.version, _kTestVersion),
StoreDto<Object>(StoreKey.backupFailedSince, _kTestBackupFailed),
const StoreDto<Object>(StoreKey.accessToken, _kTestAccessToken),
const StoreDto<Object>(StoreKey.colorfulInterface, _kTestColorfulInterface),
],
[
const StoreDto<Object>(StoreKey.version, _kTestVersion + 10),
StoreDto<Object>(StoreKey.backupFailedSince, _kTestBackupFailed),
const StoreDto<Object>(StoreKey.accessToken, _kTestAccessToken),
const StoreDto<Object>(StoreKey.colorfulInterface, _kTestColorfulInterface),
],
]),
unawaited(
expectLater(
stream,
emitsInOrder([
[
const StoreDto<Object>(StoreKey.version, _kTestVersion),
StoreDto<Object>(StoreKey.backupFailedSince, _kTestBackupFailed),
const StoreDto<Object>(StoreKey.accessToken, _kTestAccessToken),
const StoreDto<Object>(StoreKey.colorfulInterface, _kTestColorfulInterface),
],
[
const StoreDto<Object>(StoreKey.version, _kTestVersion + 10),
StoreDto<Object>(StoreKey.backupFailedSince, _kTestBackupFailed),
const StoreDto<Object>(StoreKey.accessToken, _kTestAccessToken),
const StoreDto<Object>(StoreKey.colorfulInterface, _kTestColorfulInterface),
],
]),
),
);
await sut.upsert(StoreKey.version, _kTestVersion + 10);
});

View File

@@ -64,9 +64,9 @@ void main() {
TestUtils.init();
db = await TestUtils.initIsar();
await StoreService.init(storeRepository: IsarStoreRepository(db));
Store.put(StoreKey.currentUser, UserStub.admin);
Store.put(StoreKey.serverEndpoint, '');
Store.put(StoreKey.accessToken, '');
await Store.put(StoreKey.currentUser, UserStub.admin);
await Store.put(StoreKey.serverEndpoint, '');
await Store.put(StoreKey.accessToken, '');
});
setUp(() async {

View File

@@ -35,8 +35,8 @@ void main() {
TestUtils.init();
db = await TestUtils.initIsar();
await StoreService.init(storeRepository: IsarStoreRepository(db));
Store.put(StoreKey.currentUser, UserStub.admin);
Store.put(StoreKey.serverEndpoint, '');
await Store.put(StoreKey.currentUser, UserStub.admin);
await Store.put(StoreKey.serverEndpoint, '');
});
setUp(() {

View File

@@ -31,9 +31,9 @@ void main() {
db = await TestUtils.initIsar();
// For UserCircleAvatar
await StoreService.init(storeRepository: IsarStoreRepository(db));
Store.put(StoreKey.currentUser, UserStub.admin);
Store.put(StoreKey.serverEndpoint, '');
Store.put(StoreKey.accessToken, '');
await Store.put(StoreKey.currentUser, UserStub.admin);
await Store.put(StoreKey.serverEndpoint, '');
await Store.put(StoreKey.accessToken, '');
});
setUp(() {

View File

@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
import 'package:immich_mobile/utils/async_mutex.dart';
@@ -7,11 +9,11 @@ void main() {
AsyncMutex lock = AsyncMutex();
List<int> events = [];
expect(0, lock.enqueued);
lock.run(() => Future.delayed(const Duration(milliseconds: 10), () => events.add(1)));
unawaited(lock.run(() => Future.delayed(const Duration(milliseconds: 10), () => events.add(1))));
expect(1, lock.enqueued);
lock.run(() => Future.delayed(const Duration(milliseconds: 3), () => events.add(2)));
unawaited(lock.run(() => Future.delayed(const Duration(milliseconds: 3), () => events.add(2))));
expect(2, lock.enqueued);
lock.run(() => Future.delayed(const Duration(milliseconds: 1), () => events.add(3)));
unawaited(lock.run(() => Future.delayed(const Duration(milliseconds: 1), () => events.add(3))));
expect(3, lock.enqueued);
await lock.run(() => Future.delayed(const Duration(milliseconds: 10), () => events.add(4)));
expect(0, lock.enqueued);