diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cb1094a2..54172db5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: pull_request: branches: '*' env: - CI_XCODE_OLDEST: '/Applications/Xcode_12.5.1.app/Contents/Developer' + CI_XCODE_OLDEST: '/Applications/Xcode_13.1.app/Contents/Developer' CI_XCODE_13: '/Applications/Xcode_13.4.1.app/Contents/Developer' CI_XCODE_LATEST: '/Applications/Xcode_14.0.1.app/Contents/Developer' diff --git a/Sources/ParseSwift/API/API.swift b/Sources/ParseSwift/API/API.swift index 86bf352a7..f57aa32dd 100644 --- a/Sources/ParseSwift/API/API.swift +++ b/Sources/ParseSwift/API/API.swift @@ -254,3 +254,5 @@ public struct API { ParseConstants.sdk+ParseConstants.version } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/API/BatchUtils.swift b/Sources/ParseSwift/API/BatchUtils.swift index 231442d1f..bed71b6cd 100644 --- a/Sources/ParseSwift/API/BatchUtils.swift +++ b/Sources/ParseSwift/API/BatchUtils.swift @@ -19,7 +19,7 @@ typealias RESTBatchCommandNoBodyType = API.NonParseBodyCommand = BatchChildCommand where T: Encodable typealias ParseObjectBatchResponseEncodablePointer = [(Result)] -// swiftlint:disable line_length + typealias RESTBatchCommandTypeEncodablePointer = API.NonParseBodyCommand, ParseObjectBatchResponseEncodablePointer> where T: Encodable // swiftlint:enable line_length diff --git a/Sources/ParseSwift/API/ParseURLSessionDelegate.swift b/Sources/ParseSwift/API/ParseURLSessionDelegate.swift index 108b19237..c366aa77b 100644 --- a/Sources/ParseSwift/API/ParseURLSessionDelegate.swift +++ b/Sources/ParseSwift/API/ParseURLSessionDelegate.swift @@ -11,8 +11,7 @@ import Foundation import FoundationNetworking #endif -class ParseURLSessionDelegate: NSObject -{ +class ParseURLSessionDelegate: NSObject { var callbackQueue: DispatchQueue var authentication: ((URLAuthenticationChallenge, (URLSession.AuthChallengeDisposition, diff --git a/Sources/ParseSwift/Authentication/3rd Party/ParseApple/ParseApple.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseApple/ParseApple.swift index f79e1d161..af018f340 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseApple/ParseApple.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseApple/ParseApple.swift @@ -166,3 +166,5 @@ public extension ParseUser { Self.apple } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Authentication/3rd Party/ParseFacebook/ParseFacebook.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseFacebook/ParseFacebook.swift index 4c03525f1..32ca96a49 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseFacebook/ParseFacebook.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseFacebook/ParseFacebook.swift @@ -236,3 +236,5 @@ public extension ParseUser { Self.facebook } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Authentication/3rd Party/ParseGithub/ParseGitHub.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseGithub/ParseGitHub.swift index 57652b6e2..cd2c32e1d 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseGithub/ParseGitHub.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseGithub/ParseGitHub.swift @@ -157,3 +157,5 @@ public extension ParseUser { Self.github } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Authentication/3rd Party/ParseGoogle/ParseGoogle.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseGoogle/ParseGoogle.swift index 36dea317c..8cc7e3ab5 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseGoogle/ParseGoogle.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseGoogle/ParseGoogle.swift @@ -172,3 +172,5 @@ public extension ParseUser { Self.google } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Authentication/3rd Party/ParseInstagram/ParseInstagram.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseInstagram/ParseInstagram.swift index 6d375ca8e..17258fd3f 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseInstagram/ParseInstagram.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseInstagram/ParseInstagram.swift @@ -171,3 +171,5 @@ public extension ParseUser { Self.instagram } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Authentication/3rd Party/ParseLDAP/ParseLDAP.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseLDAP/ParseLDAP.swift index 4cf83313c..01e5c0dff 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseLDAP/ParseLDAP.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseLDAP/ParseLDAP.swift @@ -146,3 +146,5 @@ public extension ParseUser { Self.ldap } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Authentication/3rd Party/ParseLinkedIn/ParseLinkedIn.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseLinkedIn/ParseLinkedIn.swift index 84d762b74..85512f452 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseLinkedIn/ParseLinkedIn.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseLinkedIn/ParseLinkedIn.swift @@ -165,3 +165,5 @@ public extension ParseUser { Self.linkedin } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Authentication/3rd Party/ParseSpotify/ParseSpotify.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseSpotify/ParseSpotify.swift index 0f86fb5df..9f927c6a3 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseSpotify/ParseSpotify.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseSpotify/ParseSpotify.swift @@ -184,3 +184,5 @@ public extension ParseUser { Self.spotify } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Authentication/3rd Party/ParseTwitter/ParseTwitter.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseTwitter/ParseTwitter.swift index 8f065e6a4..4252e71a7 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseTwitter/ParseTwitter.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseTwitter/ParseTwitter.swift @@ -209,3 +209,6 @@ public extension ParseUser { Self.twitter } } + +// swiftlint:enable line_length +// swiftlint:enable function_parameter_count diff --git a/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift b/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift index 231ea49e6..45c57fb96 100644 --- a/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift +++ b/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift @@ -490,3 +490,5 @@ public extension ParseUser { } } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Coding/AnyDecodable.swift b/Sources/ParseSwift/Coding/AnyDecodable.swift index e7bb1f77e..7a6359169 100755 --- a/Sources/ParseSwift/Coding/AnyDecodable.swift +++ b/Sources/ParseSwift/Coding/AnyDecodable.swift @@ -35,6 +35,7 @@ struct AnyDecodable: Decodable { } } +// swiftlint:disable type_name protocol _AnyDecodable { var value: Any { get } init(_ value: T?) @@ -72,6 +73,7 @@ extension _AnyDecodable { } } } +// swiftlint:enable type_name extension AnyDecodable: Equatable { static func == (lhs: AnyDecodable, rhs: AnyDecodable) -> Bool { diff --git a/Sources/ParseSwift/Coding/AnyEncodable.swift b/Sources/ParseSwift/Coding/AnyEncodable.swift index f7738bee4..861ba6f02 100755 --- a/Sources/ParseSwift/Coding/AnyEncodable.swift +++ b/Sources/ParseSwift/Coding/AnyEncodable.swift @@ -37,6 +37,7 @@ struct AnyEncodable: Encodable { } } +// swiftlint:disable type_name @usableFromInline protocol _AnyEncodable { @@ -49,6 +50,7 @@ extension AnyEncodable: _AnyEncodable {} // MARK: - Encodable extension _AnyEncodable { + // swiftlint:enable type_name // swiftlint:disable:next cyclomatic_complexity function_body_length func encode(to encoder: Encoder) throws { diff --git a/Sources/ParseSwift/Coding/ParseEncoder.swift b/Sources/ParseSwift/Coding/ParseEncoder.swift index 75b92a2a6..7a4a26fee 100644 --- a/Sources/ParseSwift/Coding/ParseEncoder.swift +++ b/Sources/ParseSwift/Coding/ParseEncoder.swift @@ -18,6 +18,15 @@ // //===----------------------------------------------------------------------===// +// This rule does not allow types with underscores in their names. +// swiftlint:disable type_name +// swiftlint:disable colon +// swiftlint:disable line_length +// swiftlint:disable return_arrow_whitespace +// swiftlint:disable file_length +// swiftlint:disable redundant_discardable_let +// swiftlint:disable cyclomatic_complexity + import Foundation /// A marker protocol used to determine whether a value is a `String`-keyed `Dictionary` @@ -34,16 +43,6 @@ private protocol _JSONStringDictionaryEncodableMarker { } #endif extension Dictionary: _JSONStringDictionaryEncodableMarker where Key == String, Value: Encodable { } -// This rule does not allow types with underscores in their names. -// swiftlint:disable type_name -// swiftlint:disable colon -// swiftlint:disable force_cast -// swiftlint:disable line_length -// swiftlint:disable return_arrow_whitespace -// swiftlint:disable file_length -// swiftlint:disable redundant_discardable_let -// swiftlint:disable cyclomatic_complexity - // MARK: ParseEncoder /** An object that encodes Parse instances of a data type as JSON objects. - note: `JSONEncoder` facilitates the encoding of `Encodable` values into JSON. @@ -170,6 +169,7 @@ public struct ParseEncoder { objectsSavedBeforeThisOne: objectsSavedBeforeThisOne, filesSavedBeforeThisOne: filesSavedBeforeThisOne) } + // swiftlint:enable large_tuple // swiftlint:disable large_tuple internal func encode(_ value: ParseEncodable, @@ -197,6 +197,7 @@ public struct ParseEncoder { objectsSavedBeforeThisOne: objectsSavedBeforeThisOne, filesSavedBeforeThisOne: filesSavedBeforeThisOne) } + // swiftlint:enable large_tuple } // MARK: _ParseEncoder @@ -260,6 +261,7 @@ internal class _ParseEncoder: JSONEncoder, Encoder { message: "This method should not be used. Either use the JSONEncoder or if you are encoding a ParseObject use \"encodeObject\"") } + // swiftlint:disable large_tuple func encodeObject(_ value: Encodable, batching: Bool = false, collectChildren: Bool, @@ -294,6 +296,7 @@ internal class _ParseEncoder: JSONEncoder, Encoder { EncodingError.Context(codingPath: [], debugDescription: "Unable to encode the given top-level value to JSON.", underlyingError: error)) } } + // swiftlint:enable large_tuple func container(keyedBy type: Key.Type) -> KeyedEncodingContainer where Key: CodingKey { @@ -545,6 +548,7 @@ private struct _ParseEncoderKeyedEncodingContainer: KeyedEncodin existingContainer is NSMutableDictionary, "Attempt to re-encode into nested KeyedEncodingContainer<\(Key.self)> for key \"\(containerKey)\" is invalid: non-keyed container already encoded for this key" ) + // swiftlint:disable:next force_cast dictionary = existingContainer as! NSMutableDictionary } else { dictionary = NSMutableDictionary() @@ -567,6 +571,7 @@ private struct _ParseEncoderKeyedEncodingContainer: KeyedEncodin existingContainer is NSMutableArray, "Attempt to re-encode into nested UnkeyedEncodingContainer for key \"\(containerKey)\" is invalid: keyed container/single value already encoded for this key" ) + // swiftlint:disable:next force_cast array = existingContainer as! NSMutableArray } else { array = NSMutableArray() @@ -759,7 +764,6 @@ extension _ParseEncoder : SingleValueEncodingContainer { } // MARK: - Concrete Value Representations -// swiftlint:disable force_cast extension _ParseEncoder { /// Returns the given value boxed in a container appropriate for pushing onto the container stack. func box(_ value: Bool) -> NSObject { return NSNumber(value: value) } @@ -941,7 +945,6 @@ extension _ParseEncoder { return try self.box_(value) ?? NSDictionary() } - // swiftlint:disable:next line_length // This method is called "box_" instead of "box" to disambiguate it from the overloads. Because the return type here is different from all of the "box" overloads (and is more general), any "box" calls in here would call back into "box" recursively instead of calling the appropriate overload, which is not what we want. func box_(_ value: Encodable) throws -> NSObject? { // Disambiguation between variable and function is required due to @@ -949,6 +952,7 @@ extension _ParseEncoder { let type = Swift.type(of: value) if type == Date.self || type == NSDate.self { // Respect Date encoding strategy + // swiftlint:disable:next force_cast return try self.box((value as! Date)) } else if type == Data.self || type == NSData.self { // Respect Data encoding strategy @@ -992,6 +996,7 @@ extension _ParseEncoder { return self.storage.popContainer() } } +// swiftlint:enable line_length // MARK: - _ParseReferencingEncoder // swiftlint:disable line_length @@ -1173,7 +1178,6 @@ private struct _JSONKey : CodingKey { //===----------------------------------------------------------------------===// // Shared ISO8601 Date Formatter //===----------------------------------------------------------------------===// -// swiftlint:disable:next line_length // NOTE: This value is implicitly lazy and _must_ be lazy. We're compiled against the latest SDK (w/ ISO8601DateFormatter), but linked against whichever Foundation the user has. ISO8601DateFormatter might not exist, so we better not hit this code path on an older OS. @available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) private var _iso8601Formatter: ISO8601DateFormatter = { @@ -1181,3 +1185,11 @@ private var _iso8601Formatter: ISO8601DateFormatter = { formatter.formatOptions = .withInternetDateTime return formatter }() + +// swiftlint:enable type_name +// swiftlint:enable colon +// swiftlint:enable line_length +// swiftlint:enable return_arrow_whitespace +// swiftlint:enable file_length +// swiftlint:enable redundant_discardable_let +// swiftlint:enable cyclomatic_complexity diff --git a/Sources/ParseSwift/Extensions/URLSession.swift b/Sources/ParseSwift/Extensions/URLSession.swift index 60ff25e92..895b885f4 100644 --- a/Sources/ParseSwift/Extensions/URLSession.swift +++ b/Sources/ParseSwift/Extensions/URLSession.swift @@ -177,11 +177,13 @@ internal extension URLSession { dataTask(with: request) { (responseData, urlResponse, responseError) in guard let httpResponse = urlResponse as? HTTPURLResponse else { - completion(self.makeResult(request: request, - responseData: responseData, - urlResponse: urlResponse, - responseError: responseError, - mapper: mapper)) + callbackQueue.async { + completion(self.makeResult(request: request, + responseData: responseData, + urlResponse: urlResponse, + responseError: responseError, + mapper: mapper)) + } return } let statusCode = httpResponse.statusCode @@ -207,11 +209,13 @@ internal extension URLSession { } return } - completion(self.makeResult(request: request, - responseData: responseData, - urlResponse: urlResponse, - responseError: responseError, - mapper: mapper)) + callbackQueue.async { + completion(self.makeResult(request: request, + responseData: responseData, + urlResponse: urlResponse, + responseError: responseError, + mapper: mapper)) + } }.resume() } } diff --git a/Sources/ParseSwift/LiveQuery/Protocols/ParseLiveQueryDelegate.swift b/Sources/ParseSwift/LiveQuery/Protocols/ParseLiveQueryDelegate.swift index 1d3eaf1b5..508308343 100644 --- a/Sources/ParseSwift/LiveQuery/Protocols/ParseLiveQueryDelegate.swift +++ b/Sources/ParseSwift/LiveQuery/Protocols/ParseLiveQueryDelegate.swift @@ -79,3 +79,5 @@ public extension ParseLiveQueryDelegate { func closedSocket(_ code: URLSessionWebSocketTask.CloseCode?, reason: Data?) { } } #endif + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Objects/ParseInstallation.swift b/Sources/ParseSwift/Objects/ParseInstallation.swift index 694c890cf..0f8e2bc69 100644 --- a/Sources/ParseSwift/Objects/ParseInstallation.swift +++ b/Sources/ParseSwift/Objects/ParseInstallation.swift @@ -550,7 +550,9 @@ extension ParseInstallation { if case .success(let foundResult) = result { do { try Self.updateKeychainIfNeeded([foundResult]) - completion(.success(foundResult)) + callbackQueue.async { + completion(.success(foundResult)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -560,7 +562,9 @@ extension ParseInstallation { } } } else { - completion(result) + callbackQueue.async { + completion(result) + } } } } catch { @@ -700,7 +704,9 @@ extension ParseInstallation { ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -741,7 +747,9 @@ extension ParseInstallation { let object = try await command(method: method, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -782,7 +790,9 @@ extension ParseInstallation { let object = try await command(method: method, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -823,7 +833,9 @@ extension ParseInstallation { let object = try await command(method: method, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1012,7 +1024,9 @@ extension ParseInstallation { case .success: do { try Self.updateKeychainIfNeeded([self], deleting: true) - completion(.success(())) + callbackQueue.async { + completion(.success(())) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1022,7 +1036,9 @@ extension ParseInstallation { } } case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } } } } catch let error as ParseError { @@ -1207,7 +1223,9 @@ public extension Sequence where Element: ParseInstallation { ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1261,7 +1279,9 @@ public extension Sequence where Element: ParseInstallation { transaction: transaction, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1315,7 +1335,9 @@ public extension Sequence where Element: ParseInstallation { transaction: transaction, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1369,7 +1391,9 @@ public extension Sequence where Element: ParseInstallation { transaction: transaction, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1499,7 +1523,9 @@ public extension Sequence where Element: ParseInstallation { returnBatch.append(contentsOf: saved) if completed == (batches.count - 1) { try? Self.Element.updateKeychainIfNeeded(returnBatch.compactMap {try? $0.get()}) - completion(.success(returnBatch)) + callbackQueue.async { + completion(.success(returnBatch)) + } } completed += 1 case .failure(let error): @@ -1608,7 +1634,9 @@ public extension Sequence where Element: ParseInstallation { } } try? Self.Element.updateKeychainIfNeeded(fetchedObjects) - completion(.success(fetchedObjectsToReturn)) + callbackQueue.async { + completion(.success(fetchedObjectsToReturn)) + } case .failure(let error): callbackQueue.async { completion(.failure(error)) @@ -1724,11 +1752,15 @@ public extension Sequence where Element: ParseInstallation { if completed == (batches.count - 1) { try? Self.Element.updateKeychainIfNeeded(self.compactMap {$0}, deleting: true) - completion(.success(returnBatch)) + callbackQueue.async { + completion(.success(returnBatch)) + } } completed += 1 case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } return } } diff --git a/Sources/ParseSwift/Objects/ParseObject.swift b/Sources/ParseSwift/Objects/ParseObject.swift index 84db2f227..699348d81 100644 --- a/Sources/ParseSwift/Objects/ParseObject.swift +++ b/Sources/ParseSwift/Objects/ParseObject.swift @@ -415,7 +415,6 @@ transactions for this call. let group = DispatchGroup() group.enter() object.ensureDeepSave(options: options, - // swiftlint:disable:next line_length isShouldReturnIfChildObjectsFound: transaction) { (savedChildObjects, savedChildFiles, parseError) -> Void in // If an error occurs, everything should be skipped if parseError != nil { @@ -515,7 +514,9 @@ transactions for this call. ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -569,7 +570,9 @@ transactions for this call. transaction: transaction, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -622,7 +625,9 @@ transactions for this call. transaction: transaction, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -675,7 +680,9 @@ transactions for this call. transaction: transaction, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -720,7 +727,6 @@ transactions for this call. let group = DispatchGroup() group.enter() object.ensureDeepSave(options: options, - // swiftlint:disable:next line_length isShouldReturnIfChildObjectsFound: transaction) { (savedChildObjects, savedChildFiles, parseError) -> Void in // If an error occurs, everything should be skipped if let parseError = parseError { @@ -800,11 +806,15 @@ transactions for this call. case .success(let saved): returnBatch.append(contentsOf: saved) if completed == (batches.count - 1) { - completion(.success(returnBatch)) + callbackQueue.async { + completion(.success(returnBatch)) + } } completed += 1 case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } return } } @@ -851,7 +861,6 @@ transactions for this call. fetchedObjectsToReturn.append(.success(fetchedObject)) } else { fetchedObjectsToReturn.append(.failure(ParseError(code: .objectNotFound, - // swiftlint:disable:next line_length message: "objectId \"\(uniqueObjectId)\" was not found in className \"\(Self.Element.className)\""))) } } @@ -897,11 +906,12 @@ transactions for this call. fetchedObjectsToReturn.append(.success(fetchedObject)) } else { fetchedObjectsToReturn.append(.failure(ParseError(code: .objectNotFound, - // swiftlint:disable:next line_length message: "objectId \"\(uniqueObjectId)\" was not found in className \"\(Self.Element.className)\""))) } } - completion(.success(fetchedObjectsToReturn)) + callbackQueue.async { + completion(.success(fetchedObjectsToReturn)) + } case .failure(let error): callbackQueue.async { completion(.failure(error)) @@ -1011,11 +1021,15 @@ transactions for this call. case .success(let saved): returnBatch.append(contentsOf: saved) if completed == (batches.count - 1) { - completion(.success(returnBatch)) + callbackQueue.async { + completion(.success(returnBatch)) + } } completed += 1 case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } return } } @@ -1213,7 +1227,9 @@ extension ParseObject { ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1252,7 +1268,9 @@ extension ParseObject { let object = try await command(method: method, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1290,7 +1308,9 @@ extension ParseObject { let object = try await command(method: method, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1328,7 +1348,9 @@ extension ParseObject { let object = try await command(method: method, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1546,12 +1568,13 @@ extension ParseObject { do { try deleteCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - switch result { - - case .success: - completion(.success(())) - case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } } } } catch let error as ParseError { @@ -1569,3 +1592,5 @@ extension ParseObject { try API.NonParseBodyCommand.delete(self) } } // swiftlint:disable:this file_length + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Objects/ParseUser.swift b/Sources/ParseSwift/Objects/ParseUser.swift index 6d6c3e763..b6c8dfecd 100644 --- a/Sources/ParseSwift/Objects/ParseUser.swift +++ b/Sources/ParseSwift/Objects/ParseUser.swift @@ -334,10 +334,12 @@ extension ParseUser { try newUser.meCommand(sessionToken: sessionToken) .executeAsync(options: options, callbackQueue: callbackQueue) { result in - if case .success(let foundResult) = result { - completion(.success(foundResult)) - } else { - completion(result) + callbackQueue.async { + if case .success(let foundResult) = result { + completion(.success(foundResult)) + } else { + completion(result) + } } } } catch let error as ParseError { @@ -478,16 +480,17 @@ extension ParseUser { // Always let user logout locally, no matter the error. deleteCurrentKeychain() - switch result { - - case .success(let error): - if let error = error { + callbackQueue.async { + switch result { + case .success(let error): + if let error = error { + completion(.failure(error)) + } else { + completion(.success(())) + } + case .failure(let error): completion(.failure(error)) - } else { - completion(.success(())) } - case .failure(let error): - completion(.failure(error)) } } } @@ -541,16 +544,17 @@ extension ParseUser { options.insert(.cachePolicy(.reloadIgnoringLocalCacheData)) passwordResetCommand(email: email).executeAsync(options: options, callbackQueue: callbackQueue) { result in - switch result { - - case .success(let error): - if let error = error { + callbackQueue.async { + switch result { + case .success(let error): + if let error = error { + completion(.failure(error)) + } else { + completion(.success(())) + } + case .failure(let error): completion(.failure(error)) - } else { - completion(.success(())) } - case .failure(let error): - completion(.failure(error)) } } } @@ -670,8 +674,8 @@ extension ParseUser { options.insert(.cachePolicy(.reloadIgnoringLocalCacheData)) verificationEmailCommand(email: email) .executeAsync(options: options, callbackQueue: callbackQueue) { result in + callbackQueue.async { switch result { - case .success(let error): if let error = error { completion(.failure(error)) @@ -681,6 +685,7 @@ extension ParseUser { case .failure(let error): completion(.failure(error)) } + } } } @@ -965,6 +970,7 @@ extension ParseUser { try fetchCommand(include: includeKeys) .executeAsync(options: options, callbackQueue: callbackQueue) { result in + callbackQueue.async { if case .success(let foundResult) = result { do { try Self.updateKeychainIfNeeded([foundResult]) @@ -979,6 +985,7 @@ extension ParseUser { completion(result) } } + } } catch { callbackQueue.async { if let error = error as? ParseError { @@ -1115,7 +1122,9 @@ extension ParseUser { ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1154,7 +1163,9 @@ extension ParseUser { let object = try await command(method: method, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1193,7 +1204,9 @@ extension ParseUser { let object = try await command(method: method, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1232,7 +1245,9 @@ extension ParseUser { let object = try await command(method: method, options: options, callbackQueue: callbackQueue) - completion(.success(object)) + callbackQueue.async { + completion(.success(object)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1637,7 +1652,9 @@ public extension Sequence where Element: ParseUser { ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1691,7 +1708,9 @@ public extension Sequence where Element: ParseUser { transaction: transaction, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1745,7 +1764,9 @@ public extension Sequence where Element: ParseUser { transaction: transaction, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1799,7 +1820,9 @@ public extension Sequence where Element: ParseUser { transaction: transaction, options: options, callbackQueue: callbackQueue) - completion(.success(objects)) + callbackQueue.async { + completion(.success(objects)) + } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) @@ -1926,11 +1949,15 @@ public extension Sequence where Element: ParseUser { returnBatch.append(contentsOf: saved) if completed == (batches.count - 1) { try? Self.Element.updateKeychainIfNeeded(returnBatch.compactMap {try? $0.get()}) - completion(.success(returnBatch)) + callbackQueue.async { + completion(.success(returnBatch)) + } } completed += 1 case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } return } } @@ -2030,7 +2057,9 @@ public extension Sequence where Element: ParseUser { } } try? Self.Element.updateKeychainIfNeeded(fetchedObjects) - completion(.success(fetchedObjectsToReturn)) + callbackQueue.async { + completion(.success(fetchedObjectsToReturn)) + } case .failure(let error): callbackQueue.async { completion(.failure(error)) @@ -2145,11 +2174,15 @@ public extension Sequence where Element: ParseUser { if completed == (batches.count - 1) { try? Self.Element.updateKeychainIfNeeded(self.compactMap {$0}, deleting: true) - completion(.success(returnBatch)) + callbackQueue.async { + completion(.success(returnBatch)) + } } completed += 1 case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } return } } diff --git a/Sources/ParseSwift/Parse.swift b/Sources/ParseSwift/Parse.swift index cdf961312..9a492ecb9 100644 --- a/Sources/ParseSwift/Parse.swift +++ b/Sources/ParseSwift/Parse.swift @@ -531,3 +531,5 @@ public func deleteObjectiveCKeychain() throws { return true } #endif + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Protocols/ParseHookFunctionable.swift b/Sources/ParseSwift/Protocols/ParseHookFunctionable.swift index f815a70f2..fd9afcede 100644 --- a/Sources/ParseSwift/Protocols/ParseHookFunctionable.swift +++ b/Sources/ParseSwift/Protocols/ParseHookFunctionable.swift @@ -71,13 +71,17 @@ extension ParseHookFunctionable { do { try fetchCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - completion(result) + callbackQueue.async { + completion(result) + } } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) let parseError = error as? ParseError ?? defaultError - completion(.failure(parseError)) + callbackQueue.async { + completion(.failure(parseError)) + } } } @@ -158,13 +162,17 @@ extension ParseHookFunctionable { do { try createCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - completion(result) + callbackQueue.async { + completion(result) + } } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) let parseError = error as? ParseError ?? defaultError - completion(.failure(parseError)) + callbackQueue.async { + completion(.failure(parseError)) + } } } @@ -200,13 +208,17 @@ extension ParseHookFunctionable { do { try updateCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - completion(result) + callbackQueue.async { + completion(result) + } } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) let parseError = error as? ParseError ?? defaultError - completion(.failure(parseError)) + callbackQueue.async { + completion(.failure(parseError)) + } } } @@ -241,19 +253,22 @@ extension ParseHookFunctionable { do { try deleteCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - switch result { - - case .success: - completion(.success(())) - case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } } } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) let parseError = error as? ParseError ?? defaultError - completion(.failure(parseError)) + callbackQueue.async { + completion(.failure(parseError)) + } } } diff --git a/Sources/ParseSwift/Protocols/ParseHookRequestable.swift b/Sources/ParseSwift/Protocols/ParseHookRequestable.swift index 16f69b4ab..1f48ff4c8 100644 --- a/Sources/ParseSwift/Protocols/ParseHookRequestable.swift +++ b/Sources/ParseSwift/Protocols/ParseHookRequestable.swift @@ -78,7 +78,9 @@ extension ParseHookRequestable { guard let user = user else { let error = ParseError(code: .unknownError, message: "Resquest does not contain a user.") - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } return } let request = self @@ -87,12 +89,14 @@ extension ParseHookRequestable { options.forEach { updatedOptions.insert($0) } user.fetch(options: updatedOptions, callbackQueue: callbackQueue) { result in - switch result { - case .success(let fetchedUser): - let updatedRequest = request.applyUser(fetchedUser) - completion(.success(updatedRequest)) - case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + switch result { + case .success(let fetchedUser): + let updatedRequest = request.applyUser(fetchedUser) + completion(.success(updatedRequest)) + case .failure(let error): + completion(.failure(error)) + } } } } diff --git a/Sources/ParseSwift/Protocols/ParseHookTriggerable.swift b/Sources/ParseSwift/Protocols/ParseHookTriggerable.swift index 62d1caae1..8d16b3c1a 100644 --- a/Sources/ParseSwift/Protocols/ParseHookTriggerable.swift +++ b/Sources/ParseSwift/Protocols/ParseHookTriggerable.swift @@ -106,13 +106,17 @@ extension ParseHookTriggerable { do { try fetchCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - completion(result) + callbackQueue.async { + completion(result) + } } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) let parseError = error as? ParseError ?? defaultError - completion(.failure(parseError)) + callbackQueue.async { + completion(.failure(parseError)) + } } } @@ -195,13 +199,17 @@ extension ParseHookTriggerable { do { try createCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - completion(result) + callbackQueue.async { + completion(result) + } } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) let parseError = error as? ParseError ?? defaultError - completion(.failure(parseError)) + callbackQueue.async { + completion(.failure(parseError)) + } } } @@ -236,13 +244,17 @@ extension ParseHookTriggerable { do { try updateCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - completion(result) + callbackQueue.async { + completion(result) + } } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) let parseError = error as? ParseError ?? defaultError - completion(.failure(parseError)) + callbackQueue.async { + completion(.failure(parseError)) + } } } @@ -277,19 +289,22 @@ extension ParseHookTriggerable { do { try deleteCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - switch result { - - case .success: - completion(.success(())) - case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } } } } catch { let defaultError = ParseError(code: .unknownError, message: error.localizedDescription) let parseError = error as? ParseError ?? defaultError - completion(.failure(parseError)) + callbackQueue.async { + completion(.failure(parseError)) + } } } diff --git a/Sources/ParseSwift/Protocols/ParsePushApplePayloadable.swift b/Sources/ParseSwift/Protocols/ParsePushApplePayloadable.swift index 948c4bfef..3593fa048 100644 --- a/Sources/ParseSwift/Protocols/ParsePushApplePayloadable.swift +++ b/Sources/ParseSwift/Protocols/ParsePushApplePayloadable.swift @@ -83,3 +83,5 @@ public protocol ParsePushApplePayloadable: ParsePushPayloadable { */ var mdm: String? { get set } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Types/ParseACL.swift b/Sources/ParseSwift/Types/ParseACL.swift index 1fb34d44d..23dc0031f 100644 --- a/Sources/ParseSwift/Types/ParseACL.swift +++ b/Sources/ParseSwift/Types/ParseACL.swift @@ -416,6 +416,7 @@ extension ParseACL { // Encoding and decoding extension ParseACL { + // swiftlint:disable large_tuple public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: RawCodingKey.self) try container.allKeys.lazy.map { (scope) -> (String, KeyedDecodingContainer) in @@ -433,6 +434,7 @@ extension ParseACL { set($0, access: $1, value: $2) } } + // swiftlint:enable large_tuple public func encode(to encoder: Encoder) throws { guard let acl = acl else { return } // only encode if acl is present diff --git a/Sources/ParseSwift/Types/ParseAnalytics.swift b/Sources/ParseSwift/Types/ParseAnalytics.swift index 69098eb0e..9c929c8ca 100644 --- a/Sources/ParseSwift/Types/ParseAnalytics.swift +++ b/Sources/ParseSwift/Types/ParseAnalytics.swift @@ -128,11 +128,13 @@ public struct ParseAnalytics: ParseTypeable, Hashable { at: date) appOppened.saveCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - switch result { - case .success: - completion(.success(())) - case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } } } } @@ -164,11 +166,13 @@ public struct ParseAnalytics: ParseTypeable, Hashable { at: date) appOppened.saveCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - switch result { - case .success: - completion(.success(())) - case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } } } } @@ -190,11 +194,13 @@ public struct ParseAnalytics: ParseTypeable, Hashable { options.insert(.cachePolicy(.reloadIgnoringLocalCacheData)) self.saveCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - switch result { - case .success: - completion(.success(())) - case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } } } } @@ -224,11 +230,13 @@ public struct ParseAnalytics: ParseTypeable, Hashable { self.date = date self.saveCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - switch result { - case .success: - completion(.success(())) - case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } } } } diff --git a/Sources/ParseSwift/Types/ParseConfiguration.swift b/Sources/ParseSwift/Types/ParseConfiguration.swift index 1fdf8f92c..d856ec5b2 100644 --- a/Sources/ParseSwift/Types/ParseConfiguration.swift +++ b/Sources/ParseSwift/Types/ParseConfiguration.swift @@ -390,3 +390,5 @@ public struct ParseConfiguration { self.isMigratingFromObjcSDK = migratingFromObjcSDK } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Types/ParseFile.swift b/Sources/ParseSwift/Types/ParseFile.swift index e88cc6865..f720df7b2 100644 --- a/Sources/ParseSwift/Types/ParseFile.swift +++ b/Sources/ParseSwift/Types/ParseFile.swift @@ -266,11 +266,13 @@ extension ParseFile { options = options.union(self.options) deleteFileCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - switch result { - case .success: - completion(.success(())) - case .failure(let error): - completion(.failure(error)) + callbackQueue.async { + switch result { + case .success: + completion(.success(())) + case .failure(let error): + completion(.failure(error)) + } } } } diff --git a/Sources/ParseSwift/Types/ParsePush.swift b/Sources/ParseSwift/Types/ParsePush.swift index 4483afdf7..b045f9ad6 100644 --- a/Sources/ParseSwift/Types/ParsePush.swift +++ b/Sources/ParseSwift/Types/ParsePush.swift @@ -176,13 +176,17 @@ extension ParsePush { if expirationTime != nil && expirationInterval != nil { let error = ParseError(code: .unknownError, message: "expirationTime and expirationInterval cannot both be set.") - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } return } if `where` != nil && channels != nil { let error = ParseError(code: .unknownError, message: "query and channels cannot both be set.") - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } return } var options = options diff --git a/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushAppleAlert.swift b/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushAppleAlert.swift index 69f43a585..bd21d4a56 100644 --- a/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushAppleAlert.swift +++ b/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushAppleAlert.swift @@ -104,3 +104,5 @@ public struct ParsePushAppleAlert: ParseTypeable { case title, subtitle, body, action } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushAppleSound.swift b/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushAppleSound.swift index e4c424700..e75674760 100644 --- a/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushAppleSound.swift +++ b/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushAppleSound.swift @@ -32,3 +32,5 @@ public struct ParsePushAppleSound: ParseTypeable { */ var volume: Double? } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushPayloadApple.swift b/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushPayloadApple.swift index bbedeaf88..7b2f686e4 100644 --- a/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushPayloadApple.swift +++ b/Sources/ParseSwift/Types/ParsePushPayload/Apple/ParsePushPayloadApple.swift @@ -207,3 +207,5 @@ public struct ParsePushPayloadApple: ParsePushApplePayloadable { return mutablePayload } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Types/ParsePushPayload/Firebase/ParsePushFirebaseNotification.swift b/Sources/ParseSwift/Types/ParsePushPayload/Firebase/ParsePushFirebaseNotification.swift index b6175c836..82e54ef11 100644 --- a/Sources/ParseSwift/Types/ParsePushPayload/Firebase/ParsePushFirebaseNotification.swift +++ b/Sources/ParseSwift/Types/ParsePushPayload/Firebase/ParsePushFirebaseNotification.swift @@ -171,3 +171,5 @@ public struct ParsePushFirebaseNotification: ParseTypeable { self.image = image } } + +// swiftlint:enable line_length diff --git a/Sources/ParseSwift/Types/ParseSchema.swift b/Sources/ParseSwift/Types/ParseSchema.swift index 15531e532..131fab74f 100644 --- a/Sources/ParseSwift/Types/ParseSchema.swift +++ b/Sources/ParseSwift/Types/ParseSchema.swift @@ -387,7 +387,9 @@ extension ParseSchema { switch result { case .success: - completion(.success(())) + callbackQueue.async { + completion(.success(())) + } case .failure(let error): callbackQueue.async { completion(.failure(error)) @@ -425,7 +427,9 @@ extension ParseSchema { switch result { case .success: - completion(.success(())) + callbackQueue.async { + completion(.success(())) + } case .failure(let error): callbackQueue.async { completion(.failure(error)) diff --git a/Sources/ParseSwift/Types/Query.swift b/Sources/ParseSwift/Types/Query.swift index acb1e6c79..d8b1fe295 100644 --- a/Sources/ParseSwift/Types/Query.swift +++ b/Sources/ParseSwift/Types/Query.swift @@ -639,7 +639,9 @@ extension Query: Queryable { if order != nil || skip > 0 || self.limit != 100 { let error = ParseError(code: .unknownError, message: "Cannot iterate on a query with sort, skip, or limit.") - completion(.failure(error)) + callbackQueue.async { + completion(.failure(error)) + } return } let uuid = UUID() @@ -755,7 +757,9 @@ extension Query: Queryable { do { try firstCommand().executeAsync(options: options, callbackQueue: callbackQueue) { result in - completion(result) + callbackQueue.async { + completion(result) + } } } catch { let parseError = ParseError(code: .unknownError, diff --git a/TestHostTV/ViewController.swift b/TestHostTV/ViewController.swift index 4cfe09b36..a57acd7b7 100644 --- a/TestHostTV/ViewController.swift +++ b/TestHostTV/ViewController.swift @@ -8,6 +8,8 @@ import UIKit +// swiftlint:disable unneeded_override + class ViewController: UIViewController { override func viewDidLoad() { @@ -16,3 +18,5 @@ class ViewController: UIViewController { } } + +// swiftlint:enable unneeded_override diff --git a/Tests/ParseSwiftTests/BatchUtilsTests.swift b/Tests/ParseSwiftTests/BatchUtilsTests.swift index d41078a1c..9c4bf06bf 100644 --- a/Tests/ParseSwiftTests/BatchUtilsTests.swift +++ b/Tests/ParseSwiftTests/BatchUtilsTests.swift @@ -11,13 +11,6 @@ import XCTest @testable import ParseSwift class BatchUtilsTests: XCTestCase { - override func setUpWithError() throws { - try super.setUpWithError() - } - - override func tearDownWithError() throws { - try super.tearDownWithError() - } func testSplitArrayLessSegments() throws { let array = [1, 2] diff --git a/Tests/ParseSwiftTests/ParseKeychainAccessGroupTests.swift b/Tests/ParseSwiftTests/ParseKeychainAccessGroupTests.swift index 3d4117f44..a502a50df 100644 --- a/Tests/ParseSwiftTests/ParseKeychainAccessGroupTests.swift +++ b/Tests/ParseSwiftTests/ParseKeychainAccessGroupTests.swift @@ -261,6 +261,7 @@ class ParseKeychainAccessGroupTests: XCTestCase { XCTAssertEqual(acl, otherAcl) } + // swiftlint:disable unused_optional_binding func testRemoveOldObjectsFromKeychain() throws { try userLogin() Config.current = .init(welcomeMessage: "yolo", winningNumber: 1) @@ -326,6 +327,7 @@ class ParseKeychainAccessGroupTests: XCTestCase { return } } + // swiftlint:enable unused_optional_binding func testNoUserNoAccessGroupNoSync() throws { XCTAssertNil(KeychainStore.shared.data(forKey: ParseStorage.Keys.currentUser, diff --git a/Tests/ParseSwiftTests/ParseObjectBatchTests.swift b/Tests/ParseSwiftTests/ParseObjectBatchTests.swift index 1da900c4e..897055cc5 100644 --- a/Tests/ParseSwiftTests/ParseObjectBatchTests.swift +++ b/Tests/ParseSwiftTests/ParseObjectBatchTests.swift @@ -832,6 +832,8 @@ class ParseObjectBatchTests: XCTestCase { // swiftlint:disable:this type_body_le scoresOnServer: [GameScore], callbackQueue: DispatchQueue) { let expectation1 = XCTestExpectation(description: "Save object1") + let expectation2 = XCTestExpectation(description: "Save object2") + guard let scoreOnServer = scoresOnServer.first, let scoreOnServer2 = scoresOnServer.last else { XCTFail("Should unwrap") @@ -843,8 +845,8 @@ class ParseObjectBatchTests: XCTestCase { // swiftlint:disable:this type_body_le callbackQueue: callbackQueue) { result in switch result { - case .success(let saved): + XCTAssertEqual(saved.count, 2) guard let firstObject = saved.first, let secondObject = saved.last else { @@ -895,7 +897,6 @@ class ParseObjectBatchTests: XCTestCase { // swiftlint:disable:this type_body_le expectation1.fulfill() } - let expectation2 = XCTestExpectation(description: "Save object2") scores.saveAll(transaction: true, options: [.useMasterKey], callbackQueue: callbackQueue) { result in @@ -904,26 +905,26 @@ class ParseObjectBatchTests: XCTestCase { // swiftlint:disable:this type_body_le case .success(let saved): XCTAssertEqual(saved.count, 2) - guard let firstObject = saved.first, - let secondObject = saved.last else { - XCTFail("Should unwrap") - expectation2.fulfill() - return + let secondObject = saved.last else { + XCTFail("Should unwrap") + expectation2.fulfill() + return } switch firstObject { case .success(let first): guard let savedCreatedAt = first.createdAt, - let savedUpdatedAt = first.updatedAt else { - XCTFail("Should unwrap dates") - expectation2.fulfill() - return + let savedUpdatedAt = first.updatedAt else { + XCTFail("Should unwrap dates") + expectation2.fulfill() + return } XCTAssertEqual(savedCreatedAt, scoreOnServer.createdAt) XCTAssertEqual(savedUpdatedAt, scoreOnServer.createdAt) XCTAssertNil(first.ACL) + case .failure(let error): XCTFail(error.localizedDescription) } @@ -932,14 +933,15 @@ class ParseObjectBatchTests: XCTestCase { // swiftlint:disable:this type_body_le case .success(let second): guard let savedCreatedAt = second.createdAt, - let savedUpdatedAt = second.updatedAt else { - XCTFail("Should unwrap dates") - expectation2.fulfill() - return + let savedUpdatedAt = second.updatedAt else { + XCTFail("Should unwrap dates") + expectation2.fulfill() + return } XCTAssertEqual(savedCreatedAt, scoreOnServer2.createdAt) XCTAssertEqual(savedUpdatedAt, scoreOnServer2.createdAt) XCTAssertNil(second.ACL) + case .failure(let error): XCTFail(error.localizedDescription) } @@ -949,7 +951,7 @@ class ParseObjectBatchTests: XCTestCase { // swiftlint:disable:this type_body_le } expectation2.fulfill() } - wait(for: [expectation1, expectation2], timeout: 20.0) + wait(for: [expectation1, expectation2], timeout: 100.0) } func saveAllAsyncPointer(scores: [GameScore], // swiftlint:disable:this function_body_length cyclomatic_complexity diff --git a/Tests/ParseSwiftTests/ParsePushPayloadAnyTests.swift b/Tests/ParseSwiftTests/ParsePushPayloadAnyTests.swift index 82a9b1b2e..993395f8e 100644 --- a/Tests/ParseSwiftTests/ParsePushPayloadAnyTests.swift +++ b/Tests/ParseSwiftTests/ParsePushPayloadAnyTests.swift @@ -234,3 +234,5 @@ class ParsePushPayloadAnyTests: XCTestCase { #endif } } + +// swiftlint:enable line_length diff --git a/Tests/ParseSwiftTests/ParsePushPayloadAppleTests.swift b/Tests/ParseSwiftTests/ParsePushPayloadAppleTests.swift index adee90672..177ed6238 100644 --- a/Tests/ParseSwiftTests/ParsePushPayloadAppleTests.swift +++ b/Tests/ParseSwiftTests/ParsePushPayloadAppleTests.swift @@ -160,3 +160,5 @@ class ParsePushPayloadAppleTests: XCTestCase { XCTAssertEqual(decodedAlert, applePayload) } } + +// swiftlint:enable line_length diff --git a/Tests/ParseSwiftTests/ParsePushPayloadFirebaseTests.swift b/Tests/ParseSwiftTests/ParsePushPayloadFirebaseTests.swift index e9e567894..28cf24aee 100644 --- a/Tests/ParseSwiftTests/ParsePushPayloadFirebaseTests.swift +++ b/Tests/ParseSwiftTests/ParsePushPayloadFirebaseTests.swift @@ -77,3 +77,5 @@ class ParsePushPayloadFirebaseTests: XCTestCase { #endif } } + +// swiftlint:enable line_length diff --git a/Tests/ParseSwiftTests/ParseQueryCacheTests.swift b/Tests/ParseSwiftTests/ParseQueryCacheTests.swift index 8bc24a04b..b014799f6 100644 --- a/Tests/ParseSwiftTests/ParseQueryCacheTests.swift +++ b/Tests/ParseSwiftTests/ParseQueryCacheTests.swift @@ -771,3 +771,5 @@ class ParseQueryCacheTests: XCTestCase { // swiftlint:disable:this type_body_len } #endif } + +// swiftlint:enable line_length diff --git a/swiftlint.yml b/swiftlint.yml new file mode 100644 index 000000000..5b06724b3 --- /dev/null +++ b/swiftlint.yml @@ -0,0 +1 @@ +{"payload":{"allShortcutsEnabled":true,"fileTree":{"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"Parse.xcworkspace","path":"Parse.xcworkspace","contentType":"directory"},{"name":"ParseSwift-iOS","path":"ParseSwift-iOS","contentType":"directory"},{"name":"ParseSwift-macOS","path":"ParseSwift-macOS","contentType":"directory"},{"name":"ParseSwift-tvOS","path":"ParseSwift-tvOS","contentType":"directory"},{"name":"ParseSwift-watchOS","path":"ParseSwift-watchOS","contentType":"directory"},{"name":"ParseSwift.playground","path":"ParseSwift.playground","contentType":"directory"},{"name":"ParseSwift.xcodeproj","path":"ParseSwift.xcodeproj","contentType":"directory"},{"name":"ParseSwiftTestsmacOS","path":"ParseSwiftTestsmacOS","contentType":"directory"},{"name":"ParseSwiftTeststvOS","path":"ParseSwiftTeststvOS","contentType":"directory"},{"name":"Scripts","path":"Scripts","contentType":"directory"},{"name":"Sources","path":"Sources","contentType":"directory"},{"name":"TestHost","path":"TestHost","contentType":"directory"},{"name":"TestHostTV","path":"TestHostTV","contentType":"directory"},{"name":"Tests","path":"Tests","contentType":"directory"},{"name":".codecov.yml","path":".codecov.yml","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".spi.yml","path":".spi.yml","contentType":"file"},{"name":".swiftlint.yml","path":".swiftlint.yml","contentType":"file"},{"name":"CHANGELOG.md","path":"CHANGELOG.md","contentType":"file"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"MIGRATION.md","path":"MIGRATION.md","contentType":"file"},{"name":"Package.swift","path":"Package.swift","contentType":"file"},{"name":"Package@5.1.swift","path":"Package@5.1.swift","contentType":"file"},{"name":"ParseSwift.podtemplate","path":"ParseSwift.podtemplate","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"}],"totalCount":27}},"fileTreeProcessingTime":3.4804060000000003,"foldersToFetch":[],"repo":{"id":723682782,"defaultBranch":"main","name":"Parse-Swift","ownerLogin":"lsmilek1","currentUserCanPush":true,"isFork":true,"isEmpty":false,"createdAt":"2023-11-26T14:00:59.000+01:00","ownerAvatar":"https://avatars.githubusercontent.com/u/41491201?v=4","public":true,"private":false,"isOrgOwned":false},"symbolsExpanded":true,"treeExpanded":true,"refInfo":{"name":"main","listCacheKey":"v0:1701003660.815775","canEdit":true,"refType":"branch","currentOid":"8127eb020f4f5f521e7121acc0cb39091e01b218"},"path":".swiftlint.yml","currentUser":{"id":41491201,"login":"lsmilek1","userEmail":"Smilek.lukas@gmail.com"},"blob":{"rawLines":["disabled_rules:"," - file_length"," - cyclomatic_complexity"," - function_body_length"," - type_body_length"," - inclusive_language"," - comment_spacing"," - identifier_name","excluded: # paths to ignore during linting. Takes precedence over `included`."," - Tests/ParseSwiftTests/ParseEncoderTests"," - DerivedData"," - .build"," - .dependencies"],"stylingDirectives":[[{"start":0,"end":14,"cssClass":"pl-ent"}],[{"start":4,"end":15,"cssClass":"pl-s"}],[{"start":4,"end":25,"cssClass":"pl-s"}],[{"start":4,"end":24,"cssClass":"pl-s"}],[{"start":4,"end":20,"cssClass":"pl-s"}],[{"start":4,"end":22,"cssClass":"pl-s"}],[{"start":4,"end":19,"cssClass":"pl-s"}],[{"start":4,"end":19,"cssClass":"pl-s"}],[{"start":0,"end":8,"cssClass":"pl-ent"},{"start":10,"end":77,"cssClass":"pl-c"},{"start":10,"end":11,"cssClass":"pl-c"}],[{"start":4,"end":43,"cssClass":"pl-s"}],[{"start":4,"end":15,"cssClass":"pl-s"}],[{"start":4,"end":10,"cssClass":"pl-s"}],[{"start":4,"end":17,"cssClass":"pl-s"}]],"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":null,"configFilePath":null,"networkDependabotPath":"/lsmilek1/Parse-Swift/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":false,"repoAlertsPath":"/lsmilek1/Parse-Swift/security/dependabot","repoSecurityAndAnalysisPath":"/lsmilek1/Parse-Swift/settings/security_analysis","repoOwnerIsOrg":false,"currentUserCanAdminRepo":true},"displayName":".swiftlint.yml","displayUrl":"https://github.com/lsmilek1/Parse-Swift/blob/main/.swiftlint.yml?raw=true","headerInfo":{"blobSize":"334 Bytes","deleteInfo":{"deleteTooltip":"Delete this file"},"editInfo":{"editTooltip":"Edit this file"},"ghDesktopPath":"x-github-client://openRepo/https://github.com/lsmilek1/Parse-Swift?branch=main&filepath=.swiftlint.yml","gitLfsPath":null,"onBranch":true,"shortPath":"a198546","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Flsmilek1%2FParse-Swift%2Fblob%2Fmain%2F.swiftlint.yml","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"13","truncatedSloc":"13"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplateHelpUrl":"https://docs.github.com/articles/about-issue-and-pull-request-templates","issueTemplate":null,"discussionTemplate":null,"language":"YAML","languageID":407,"large":false,"loggedIn":true,"newDiscussionPath":"/lsmilek1/Parse-Swift/discussions/new","newIssuePath":"/lsmilek1/Parse-Swift/issues/new","planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/lsmilek1/Parse-Swift/blob/main/.swiftlint.yml","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/lsmilek1/Parse-Swift/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/lsmilek1/Parse-Swift/raw/main/.swiftlint.yml","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"repoOwner":"lsmilek1","repoName":"Parse-Swift","showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","showDependabotConfigurationBanner":null,"actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":true,"symbols":[]}},"copilotInfo":{"documentationUrl":"https://docs.github.com/copilot/overview-of-github-copilot/about-github-copilot-for-individuals","notices":{"codeViewPopover":{"dismissed":false,"dismissPath":"/settings/dismiss-notice/code_view_copilot_popover"}},"userAccess":{"accessAllowed":false,"hasSubscriptionEnded":false,"orgHasCFBAccess":false,"userHasCFIAccess":false,"userHasOrgs":false,"userIsOrgAdmin":false,"userIsOrgMember":false,"business":null,"featureRequestInfo":null}},"copilotAccessAllowed":false,"csrf_tokens":{"/lsmilek1/Parse-Swift/branches":{"post":"jbjEUQxBiXXWgHH-BxFM3V1unnApCQbvoHdZ__qWPR2GTsLNaLG7W2agoiH4C8VdQV1kL1IkiQY7SOvSusLY_Q"},"/repos/preferences":{"post":"9QhZ2t2bBrfEcn-4ixOmOUFzKiGCobfuQmRg0XHAl3HI0yVyrL9vziFiX0CdtqgKhyvziF4UnJt-FCJwP0SwaQ"}}},"title":"Parse-Swift/.swiftlint.yml at main ยท lsmilek1/Parse-Swift"} \ No newline at end of file