From bddcb7e0eb6f718811dadb3164e917093066aceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Smilek?= <41491201+lsmilek1@users.noreply.github.com> Date: Sun, 26 Nov 2023 14:10:39 +0100 Subject: [PATCH] Update ParseInstallation.swift adding callback queue on all methods --- .../ParseSwift/API/ParseURLSessionDelegate.swift | 3 +-- .../3rd Party/ParseTwitter/ParseTwitter.swift | 1 + Sources/ParseSwift/Coding/AnyCodable.swift | 2 -- Sources/ParseSwift/Coding/AnyEncodable.swift | 3 --- Sources/ParseSwift/Coding/ParseEncoder.swift | 14 +++----------- Sources/ParseSwift/Objects/ParseObject.swift | 4 ---- Sources/ParseSwift/Types/ParseACL.swift | 2 ++ TestHostTV/ViewController.swift | 4 ++++ Tests/ParseSwiftTests/BatchUtilsTests.swift | 7 ------- .../ParseKeychainAccessGroupTests.swift | 2 ++ swiftlint.yml | 1 + 11 files changed, 14 insertions(+), 29 deletions(-) create mode 100644 swiftlint.yml 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/ParseTwitter/ParseTwitter.swift b/Sources/ParseSwift/Authentication/3rd Party/ParseTwitter/ParseTwitter.swift index 12d51ae0f..4252e71a7 100644 --- a/Sources/ParseSwift/Authentication/3rd Party/ParseTwitter/ParseTwitter.swift +++ b/Sources/ParseSwift/Authentication/3rd Party/ParseTwitter/ParseTwitter.swift @@ -211,3 +211,4 @@ public extension ParseUser { } // swiftlint:enable line_length +// swiftlint:enable function_parameter_count diff --git a/Sources/ParseSwift/Coding/AnyCodable.swift b/Sources/ParseSwift/Coding/AnyCodable.swift index 0747bf2e4..2c0e3efc3 100755 --- a/Sources/ParseSwift/Coding/AnyCodable.swift +++ b/Sources/ParseSwift/Coding/AnyCodable.swift @@ -24,9 +24,7 @@ struct AnyCodable: Codable { } } -// swiftlint:disable type_name extension AnyCodable: _AnyEncodable, _AnyDecodable {} -// swiftlint:enable type_name extension AnyCodable: Equatable { static func == (lhs: AnyCodable, rhs: AnyCodable) -> Bool { // swiftlint:disable:this cyclomatic_complexity line_length diff --git a/Sources/ParseSwift/Coding/AnyEncodable.swift b/Sources/ParseSwift/Coding/AnyEncodable.swift index fe3f1f26a..861ba6f02 100755 --- a/Sources/ParseSwift/Coding/AnyEncodable.swift +++ b/Sources/ParseSwift/Coding/AnyEncodable.swift @@ -234,7 +234,6 @@ extension AnyEncodable: ExpressibleByStringInterpolation {} extension AnyEncodable: ExpressibleByArrayLiteral {} extension AnyEncodable: ExpressibleByDictionaryLiteral {} -// swiftlint:disable type_name extension _AnyEncodable { init(nilLiteral _: ()) { self.init(nil as Any?) @@ -267,5 +266,3 @@ extension _AnyEncodable { self.init([AnyHashable: Any](elements, uniquingKeysWith: { (first, _) in first })) } } - -// swiftlint:enable type_name diff --git a/Sources/ParseSwift/Coding/ParseEncoder.swift b/Sources/ParseSwift/Coding/ParseEncoder.swift index a7f7a437e..7a4a26fee 100644 --- a/Sources/ParseSwift/Coding/ParseEncoder.swift +++ b/Sources/ParseSwift/Coding/ParseEncoder.swift @@ -21,7 +21,6 @@ // 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 @@ -549,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() @@ -571,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() @@ -761,10 +762,8 @@ extension _ParseEncoder : SingleValueEncodingContainer { try self.storage.push(container: self.box(value)) } } -// swiftlint:enable force_cast // 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) } @@ -851,7 +850,6 @@ extension _ParseEncoder { } catch { // If the value pushed a container before throwing, pop it back off to restore state. if self.storage.count > depth { - // swiftlint:disable:next unused_optional_binding let _ = self.storage.popContainer() } @@ -881,7 +879,6 @@ extension _ParseEncoder { // If the value pushed a container before throwing, pop it back off to restore state. // This should not be possible for Data (which encodes as an array of bytes), but it cannot hurt to catch a failure. if self.storage.count > depth { - // swiftlint:disable:next unused_optional_binding let _ = self.storage.popContainer() } @@ -900,7 +897,6 @@ extension _ParseEncoder { } catch { // If the value pushed a container before throwing, pop it back off to restore state. if self.storage.count > depth { - // swiftlint:disable:next unused_optional_binding let _ = self.storage.popContainer() } @@ -931,7 +927,6 @@ extension _ParseEncoder { } catch { // If the value pushed a container before throwing, pop it back off to restore state. if self.storage.count > depth { - // swiftlint:disable:next unused_optional_binding let _ = self.storage.popContainer() } @@ -950,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 @@ -958,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 @@ -987,7 +982,6 @@ extension _ParseEncoder { } catch { // If the value pushed a container before throwing, pop it back off to restore state. if self.storage.count > depth { - // swiftlint:disable:next unused_optional_binding let _ = self.storage.popContainer() } @@ -1184,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 = { @@ -1195,7 +1188,6 @@ private var _iso8601Formatter: ISO8601DateFormatter = { // swiftlint:enable type_name // swiftlint:enable colon -// swiftlint:enable force_cast // swiftlint:enable line_length // swiftlint:enable return_arrow_whitespace // swiftlint:enable file_length diff --git a/Sources/ParseSwift/Objects/ParseObject.swift b/Sources/ParseSwift/Objects/ParseObject.swift index ac0b9c152..5cb4fff1f 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 { @@ -720,7 +719,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 { @@ -851,7 +849,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,7 +894,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)\""))) } } 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/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/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