From 0f8c9a057d22520e4605be1238ead5f1cdf49592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Coye=20de=20Brune=CC=81lis?= Date: Tue, 6 Feb 2024 12:21:18 +0100 Subject: [PATCH] chore: SonarCloud feedback --- kDriveCore/Services/BackgroundTasksService.swift | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/kDriveCore/Services/BackgroundTasksService.swift b/kDriveCore/Services/BackgroundTasksService.swift index 534610d88..528c0818d 100644 --- a/kDriveCore/Services/BackgroundTasksService.swift +++ b/kDriveCore/Services/BackgroundTasksService.swift @@ -44,6 +44,8 @@ public protocol BackgroundTasksServiceable { } struct BackgroundTasksService: BackgroundTasksServiceable { + private static let activityShouldTerminateMessage = "Notified activity should terminate" + @LazyInjectService private var scheduler: BGTaskScheduler @LazyInjectService private var accountManager: AccountManageable @LazyInjectService private var uploadQueue: UploadQueue @@ -92,7 +94,7 @@ struct BackgroundTasksService: BackgroundTasksServiceable { Log.backgroundTaskScheduling("handleBackgroundRefresh") // User installed the app but never logged in if expiringActivity.shouldTerminate || accountManager.accounts.isEmpty { - Log.backgroundTaskScheduling("Notified activity should terminate", level: .error) + Log.backgroundTaskScheduling(Self.activityShouldTerminateMessage, level: .error) completion(false) expiringActivity.endAll() return @@ -101,8 +103,8 @@ struct BackgroundTasksService: BackgroundTasksServiceable { Log.backgroundTaskScheduling("Enqueue new pictures") photoUploader.scheduleNewPicturesForUpload() - guard expiringActivity.shouldTerminate == false else { - Log.backgroundTaskScheduling("Notified activity should terminate", level: .error) + guard !expiringActivity.shouldTerminate else { + Log.backgroundTaskScheduling(Self.activityShouldTerminateMessage, level: .error) completion(false) expiringActivity.endAll() return @@ -111,8 +113,8 @@ struct BackgroundTasksService: BackgroundTasksServiceable { Log.backgroundTaskScheduling("Clean errors for all uploads") uploadQueue.cleanNetworkAndLocalErrorsForAllOperations() - guard expiringActivity.shouldTerminate == false else { - Log.backgroundTaskScheduling("Notified activity should terminate", level: .error) + guard !expiringActivity.shouldTerminate else { + Log.backgroundTaskScheduling(Self.activityShouldTerminateMessage, level: .error) completion(false) expiringActivity.endAll() return @@ -121,8 +123,8 @@ struct BackgroundTasksService: BackgroundTasksServiceable { Log.backgroundTaskScheduling("Reload operations in queue") uploadQueue.rebuildUploadQueueFromObjectsInRealm() - guard expiringActivity.shouldTerminate == false else { - Log.backgroundTaskScheduling("Notified activity should terminate", level: .error) + guard !expiringActivity.shouldTerminate else { + Log.backgroundTaskScheduling(Self.activityShouldTerminateMessage, level: .error) completion(false) expiringActivity.endAll() return