Skip to content

Commit 995f249

Browse files
committed
chore: Applied SwiftFormat.
Signed-off-by: Iva Horn <iva.horn@nextcloud.com>
1 parent c9f3980 commit 995f249

13 files changed

Lines changed: 81 additions & 80 deletions

Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import NextcloudKit
77
///
88
/// The `NSFileProviderEnumerator` implementation to enumerate file provider items and related change sets.
99
///
10-
final public class Enumerator: NSObject, NSFileProviderEnumerator, Sendable {
10+
public final class Enumerator: NSObject, NSFileProviderEnumerator, Sendable {
1111
let enumeratedItemIdentifier: NSFileProviderItemIdentifier
1212
private let enumeratedItemMetadata: SendableItemMetadata?
1313

@@ -111,8 +111,8 @@ final public class Enumerator: NSObject, NSFileProviderEnumerator, Sendable {
111111
return
112112
}
113113

114-
let domain = self.domain
115-
let enumeratedItemIdentifier = self.enumeratedItemIdentifier
114+
let domain = domain
115+
let enumeratedItemIdentifier = enumeratedItemIdentifier
116116

117117
let (_, trashedItems, _, trashReadError) = await remoteInterface.listingTrashAsync(
118118
filename: nil,
@@ -305,8 +305,8 @@ final public class Enumerator: NSObject, NSFileProviderEnumerator, Sendable {
305305
return
306306
}
307307

308-
let domain = self.domain
309-
let enumeratedItemIdentifier = self.enumeratedItemIdentifier
308+
let domain = domain
309+
let enumeratedItemIdentifier = enumeratedItemIdentifier
310310

311311
let (_, trashedItems, _, trashReadError) = await remoteInterface.listingTrashAsync(
312312
filename: nil,
@@ -371,14 +371,14 @@ final public class Enumerator: NSObject, NSFileProviderEnumerator, Sendable {
371371
}
372372

373373
guard readError == nil else {
374-
logger.error("Finished enumerating changes.", [.url: self.serverUrl, .error: readError])
374+
logger.error("Finished enumerating changes.", [.url: serverUrl, .error: readError])
375375

376-
let error = readError?.fileProviderError(handlingNoSuchItemErrorUsingItemIdentifier: self.enumeratedItemIdentifier) ?? NSFileProviderError(.cannotSynchronize)
376+
let error = readError?.fileProviderError(handlingNoSuchItemErrorUsingItemIdentifier: enumeratedItemIdentifier) ?? NSFileProviderError(.cannotSynchronize)
377377

378378
if readError!.isNotFoundError {
379-
logger.info("404 error means item no longer exists. Deleting metadata and reporting deletion without error.", [.url: self.serverUrl])
379+
logger.info("404 error means item no longer exists. Deleting metadata and reporting deletion without error.", [.url: serverUrl])
380380

381-
guard let itemMetadata = self.enumeratedItemMetadata else {
381+
guard let itemMetadata = enumeratedItemMetadata else {
382382
logger.error("Invalid enumeratedItemMetadata. Could not delete metadata nor report deletion.")
383383
observer.finishEnumeratingWithError(error)
384384
return
@@ -397,7 +397,7 @@ final public class Enumerator: NSObject, NSFileProviderEnumerator, Sendable {
397397
completeChangesObserver(
398398
observer,
399399
anchor: anchor,
400-
enumeratedItemIdentifier: self.enumeratedItemIdentifier,
400+
enumeratedItemIdentifier: enumeratedItemIdentifier,
401401
account: account,
402402
remoteInterface: remoteInterface,
403403
dbManager: dbManager,
@@ -416,12 +416,12 @@ final public class Enumerator: NSObject, NSFileProviderEnumerator, Sendable {
416416
return
417417
}
418418

419-
logger.info("Finished reading remote changes.", [.account: self.account.ncKitAccount, .url: self.serverUrl])
419+
logger.info("Finished reading remote changes.", [.account: account.ncKitAccount, .url: serverUrl])
420420

421421
completeChangesObserver(
422422
observer,
423423
anchor: anchor,
424-
enumeratedItemIdentifier: self.enumeratedItemIdentifier,
424+
enumeratedItemIdentifier: enumeratedItemIdentifier,
425425
account: account,
426426
remoteInterface: remoteInterface,
427427
dbManager: dbManager,

Sources/NextcloudFileProviderKit/Enumeration/RemoteChangeObserver.swift

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public final class RemoteChangeObserver: NSObject, @unchecked Sendable {
9191

9292
private func startPollingTimer() {
9393
guard !invalidated else {
94-
self.logger.error("Starting polling timer while the current one is not invalidated yet!")
94+
logger.error("Starting polling timer while the current one is not invalidated yet!")
9595
return
9696
}
9797

@@ -134,7 +134,7 @@ public final class RemoteChangeObserver: NSObject, @unchecked Sendable {
134134
startPollingTimer()
135135
return
136136
}
137-
137+
138138
Task { [weak self] in
139139
try await Task.sleep(nanoseconds: self?.webSocketReconfigureIntervalNanoseconds ?? 0)
140140
await self?.configureNotifyPush()
@@ -237,7 +237,7 @@ public final class RemoteChangeObserver: NSObject, @unchecked Sendable {
237237
webSocketPingTask.cancel()
238238
}
239239

240-
let account = self.accountId
240+
let account = accountId
241241

242242
webSocketPingTask = Task.detached(priority: .background) {
243243
do {
@@ -272,15 +272,15 @@ public final class RemoteChangeObserver: NSObject, @unchecked Sendable {
272272
return
273273
}
274274

275-
guard await self.invalidated == false else {
275+
guard await invalidated == false else {
276276
return
277277
}
278278

279279
guard error == nil else {
280-
self.logger.error("Websocket ping failed.", [.error: error])
281-
self.incrementWebSocketPingFailCount()
280+
logger.error("Websocket ping failed.", [.error: error])
281+
incrementWebSocketPingFailCount()
282282

283-
if self.webSocketPingFailCount > self.webSocketPingFailLimit {
283+
if webSocketPingFailCount > webSocketPingFailLimit {
284284
Task.detached(priority: .medium) {
285285
self.reconnectWebSocket()
286286
}
@@ -309,20 +309,20 @@ public final class RemoteChangeObserver: NSObject, @unchecked Sendable {
309309

310310
switch result {
311311
case .failure:
312-
let accountId = self.accountId
313-
self.logger.debug("Failed to read websocket.", [.account: accountId])
314-
// Do not reconnect here, delegate methods will handle reconnecting
312+
let accountId = accountId
313+
logger.debug("Failed to read websocket.", [.account: accountId])
314+
// Do not reconnect here, delegate methods will handle reconnecting
315315
case let .success(message):
316316
switch message {
317317
case let .data(data):
318-
self.processWebsocket(data: data)
318+
processWebsocket(data: data)
319319
case let .string(string):
320-
self.processWebsocket(string: string)
320+
processWebsocket(string: string)
321321
@unknown default:
322-
self.logger.error("Unknown case encountered while reading websocket!")
322+
logger.error("Unknown case encountered while reading websocket!")
323323
}
324324

325-
self.readWebSocket()
325+
readWebSocket()
326326
}
327327
}
328328
}
@@ -371,14 +371,14 @@ public final class RemoteChangeObserver: NSObject, @unchecked Sendable {
371371
}
372372

373373
func setWebSocketPingInterval(to nanoseconds: UInt64) {
374-
self.webSocketPingIntervalNanoseconds = nanoseconds
374+
webSocketPingIntervalNanoseconds = nanoseconds
375375
}
376376
}
377377

378378
// MARK: - URLSessionWebSocketDelegate
379379

380380
extension RemoteChangeObserver: URLSessionWebSocketDelegate {
381-
nonisolated public func urlSession(_: URLSession, webSocketTask _: URLSessionWebSocketTask, didOpenWithProtocol _: String?) {
381+
public nonisolated func urlSession(_: URLSession, webSocketTask _: URLSessionWebSocketTask, didOpenWithProtocol _: String?) {
382382
Task {
383383
guard invalidated == false else {
384384
return
@@ -389,7 +389,7 @@ extension RemoteChangeObserver: URLSessionWebSocketDelegate {
389389
}
390390
}
391391

392-
nonisolated public func urlSession(_: URLSession, webSocketTask: URLSessionWebSocketTask, didCloseWith _: URLSessionWebSocketTask.CloseCode, reason: Data?) {
392+
public nonisolated func urlSession(_: URLSession, webSocketTask: URLSessionWebSocketTask, didCloseWith _: URLSessionWebSocketTask.CloseCode, reason: Data?) {
393393
Task {
394394
guard invalidated == false else {
395395
return
@@ -407,13 +407,13 @@ extension RemoteChangeObserver: URLSessionWebSocketDelegate {
407407
}
408408
}
409409

410-
nonisolated public func urlSessionDidFinishEvents(forBackgroundURLSession _: URLSession) {}
410+
public nonisolated func urlSessionDidFinishEvents(forBackgroundURLSession _: URLSession) {}
411411
}
412412

413413
// MARK: - NextcloudKitDelegate methods
414414

415415
extension RemoteChangeObserver: NextcloudKitDelegate {
416-
nonisolated public func authenticationChallenge(_: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @Sendable @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
416+
public nonisolated func authenticationChallenge(_: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @Sendable @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
417417
Task { [weak self] in
418418
guard let self else {
419419
return
@@ -447,17 +447,17 @@ extension RemoteChangeObserver: NextcloudKitDelegate {
447447
}
448448
}
449449

450-
nonisolated public func networkReachabilityObserver(_ typeReachability: NKTypeReachability) {
450+
public nonisolated func networkReachabilityObserver(_ typeReachability: NKTypeReachability) {
451451
Task { [weak self] in
452452
guard let self else {
453453
return
454454
}
455455

456-
self.setNetworkReachability(typeReachability)
456+
setNetworkReachability(typeReachability)
457457
}
458458
}
459459

460-
nonisolated public func downloadProgress(
460+
public nonisolated func downloadProgress(
461461
_: Float,
462462
totalBytes _: Int64,
463463
totalBytesExpected _: Int64,
@@ -467,7 +467,7 @@ extension RemoteChangeObserver: NextcloudKitDelegate {
467467
task _: URLSessionTask
468468
) {}
469469

470-
nonisolated public func uploadProgress(
470+
public nonisolated func uploadProgress(
471471
_: Float,
472472
totalBytes _: Int64,
473473
totalBytesExpected _: Int64,
@@ -477,13 +477,13 @@ extension RemoteChangeObserver: NextcloudKitDelegate {
477477
task _: URLSessionTask
478478
) {}
479479

480-
nonisolated public func downloadingFinish(
480+
public nonisolated func downloadingFinish(
481481
_: URLSession,
482482
downloadTask _: URLSessionDownloadTask,
483483
didFinishDownloadingTo _: URL
484484
) {}
485485

486-
nonisolated public func downloadComplete(
486+
public nonisolated func downloadComplete(
487487
fileName _: String,
488488
serverUrl _: String,
489489
etag _: String?,
@@ -494,7 +494,7 @@ extension RemoteChangeObserver: NextcloudKitDelegate {
494494
error _: NKError
495495
) {}
496496

497-
nonisolated public func uploadComplete(
497+
public nonisolated func uploadComplete(
498498
fileName _: String,
499499
serverUrl _: String,
500500
ocId _: String?,
@@ -505,7 +505,7 @@ extension RemoteChangeObserver: NextcloudKitDelegate {
505505
error _: NKError
506506
) {}
507507

508-
nonisolated public func request(_: Alamofire.DataRequest, didParseResponse _: Alamofire.AFDataResponse<some Any>) {}
508+
public nonisolated func request(_: Alamofire.DataRequest, didParseResponse _: Alamofire.AFDataResponse<some Any>) {}
509509

510510
///
511511
/// Dispatches the asynchronous working set check.

Sources/NextcloudFileProviderKit/Item/Item.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import UniformTypeIdentifiers
88
///
99
/// Data model implementation for file provider items as defined by the file provider framework and `NSFileProviderItemProtocol`.
1010
///
11-
final public class Item: NSObject, NSFileProviderItem, Sendable {
11+
public final class Item: NSObject, NSFileProviderItem, Sendable {
1212
public enum FileProviderItemTransferError: Error {
1313
case downloadError
1414
case uploadError

Sources/NextcloudFileProviderKit/Metadata/RealmItemMetadata.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class RealmItemMetadata: Object, ItemMetadata {
6262
@Persisted var sessionTaskIdentifier: Int?
6363
@Persisted var storedShareType = List<Int>()
6464
var shareType: [Int] {
65-
get { storedShareType.map { $0 } }
65+
get { storedShareType.map(\.self) }
6666
set {
6767
storedShareType = List<Int>()
6868
storedShareType.append(objectsIn: newValue)
@@ -73,7 +73,7 @@ class RealmItemMetadata: Object, ItemMetadata {
7373
// TODO: Find a way to compare these two below in remote state check
7474
@Persisted var storedSharePermissionsCloudMesh = List<String>()
7575
var sharePermissionsCloudMesh: [String] {
76-
get { storedSharePermissionsCloudMesh.map { $0 } }
76+
get { storedSharePermissionsCloudMesh.map(\.self) }
7777
set {
7878
storedSharePermissionsCloudMesh = List<String>()
7979
storedSharePermissionsCloudMesh.append(objectsIn: newValue)
@@ -84,7 +84,7 @@ class RealmItemMetadata: Object, ItemMetadata {
8484
@Persisted var status: Int = 0
8585
@Persisted var storedTags = List<String>()
8686
var tags: [String] {
87-
get { storedTags.map { $0 } }
87+
get { storedTags.map(\.self) }
8888
set {
8989
storedTags = List<String>()
9090
storedTags.append(objectsIn: newValue)

Sources/NextcloudFileProviderKitMocks/TestableRemoteInterface.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ public struct TestableRemoteInterface: RemoteInterface, @unchecked Sendable {
8484
) async -> (account: String, data: Data?, error: NKError) { ("", nil, .invalidResponseError) }
8585

8686
public func downloadAsync(
87-
serverUrlFileName: Any,
88-
fileNameLocalPath: String,
89-
account: String,
90-
options: NKRequestOptions,
91-
requestHandler: @escaping (_ request: DownloadRequest) -> Void,
92-
taskHandler: @Sendable @escaping (_ task: URLSessionTask) -> Void,
93-
progressHandler: @escaping (_ progress: Progress) -> Void
87+
serverUrlFileName _: Any,
88+
fileNameLocalPath _: String,
89+
account _: String,
90+
options _: NKRequestOptions,
91+
requestHandler _: @escaping (_ request: DownloadRequest) -> Void,
92+
taskHandler _: @Sendable @escaping (_ task: URLSessionTask) -> Void,
93+
progressHandler _: @escaping (_ progress: Progress) -> Void
9494
) async -> (
9595
account: String,
9696
etag: String?,
@@ -130,11 +130,11 @@ public struct TestableRemoteInterface: RemoteInterface, @unchecked Sendable {
130130
}
131131

132132
public func listingTrashAsync(
133-
filename: String?,
134-
showHiddenFiles: Bool,
135-
account: String,
136-
options: NKRequestOptions,
137-
taskHandler: @Sendable @escaping (_ task: URLSessionTask) -> Void
133+
filename _: String?,
134+
showHiddenFiles _: Bool,
135+
account _: String,
136+
options _: NKRequestOptions,
137+
taskHandler _: @Sendable @escaping (_ task: URLSessionTask) -> Void
138138
) async -> (
139139
account: String,
140140
items: [NKTrash]?,
@@ -159,9 +159,9 @@ public struct TestableRemoteInterface: RemoteInterface, @unchecked Sendable {
159159
) async -> (account: String, data: Data?, error: NKError) { ("", nil, .invalidResponseError) }
160160

161161
public func getUserProfileAsync(
162-
account: String,
163-
options: NKRequestOptions,
164-
taskHandler: @Sendable @escaping (_ task: URLSessionTask) -> Void
162+
account _: String,
163+
options _: NKRequestOptions,
164+
taskHandler _: @Sendable @escaping (_ task: URLSessionTask) -> Void
165165
) async -> (
166166
account: String,
167167
userProfile: NKUserProfile?,

Tests/Interface/MockChangeNotificationInterface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import Foundation
55
import NextcloudFileProviderKit
66

7-
public final class MockChangeNotificationInterface: ChangeNotificationInterface {
7+
public final class MockChangeNotificationInterface: ChangeNotificationInterface {
88
public typealias ChangeHandler = @Sendable () -> Void
99

1010
let changeHandler: ChangeHandler?

0 commit comments

Comments
 (0)