Skip to content

Commit

Permalink
Update ParseInstallation.swift
Browse files Browse the repository at this point in the history
adding callback queue on all methods
  • Loading branch information
lsmilek1 committed Feb 11, 2024
1 parent 8127eb0 commit bddcb7e
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 29 deletions.
3 changes: 1 addition & 2 deletions Sources/ParseSwift/API/ParseURLSessionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import Foundation
import FoundationNetworking
#endif

class ParseURLSessionDelegate: NSObject
{
class ParseURLSessionDelegate: NSObject {
var callbackQueue: DispatchQueue
var authentication: ((URLAuthenticationChallenge,
(URLSession.AuthChallengeDisposition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,4 @@ public extension ParseUser {
}

// swiftlint:enable line_length
// swiftlint:enable function_parameter_count
2 changes: 0 additions & 2 deletions Sources/ParseSwift/Coding/AnyCodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions Sources/ParseSwift/Coding/AnyEncodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand Down Expand Up @@ -267,5 +266,3 @@ extension _AnyEncodable {
self.init([AnyHashable: Any](elements, uniquingKeysWith: { (first, _) in first }))
}
}

// swiftlint:enable type_name
14 changes: 3 additions & 11 deletions Sources/ParseSwift/Coding/ParseEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -549,6 +548,7 @@ private struct _ParseEncoderKeyedEncodingContainer<Key: CodingKey>: 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()
Expand All @@ -571,6 +571,7 @@ private struct _ParseEncoderKeyedEncodingContainer<Key: CodingKey>: 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

Check warning on line 574 in Sources/ParseSwift/Coding/ParseEncoder.swift

View check run for this annotation

Codecov / codecov/patch

Sources/ParseSwift/Coding/ParseEncoder.swift#L574

Added line #L574 was not covered by tests
array = existingContainer as! NSMutableArray
} else {
array = NSMutableArray()
Expand Down Expand Up @@ -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) }
Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -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()
}

Expand All @@ -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()
}

Expand Down Expand Up @@ -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()
}

Expand All @@ -950,14 +945,14 @@ 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
// issue tracked at: https://bugs.swift.org/browse/SR-1846
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
Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -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 = {
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Sources/ParseSwift/Objects/ParseObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)\"")))
}
}
Expand Down Expand Up @@ -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)\"")))
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/ParseSwift/Types/ParseACL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<ParseACL.Access>) in
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions TestHostTV/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import UIKit

// swiftlint:disable unneeded_override

class ViewController: UIViewController {

override func viewDidLoad() {
Expand All @@ -16,3 +18,5 @@ class ViewController: UIViewController {
}

}

// swiftlint:enable unneeded_override
7 changes: 0 additions & 7 deletions Tests/ParseSwiftTests/BatchUtilsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions Tests/ParseSwiftTests/ParseKeychainAccessGroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -326,6 +327,7 @@ class ParseKeychainAccessGroupTests: XCTestCase {
return
}
}
// swiftlint:enable unused_optional_binding

func testNoUserNoAccessGroupNoSync() throws {
XCTAssertNil(KeychainStore.shared.data(forKey: ParseStorage.Keys.currentUser,
Expand Down
1 change: 1 addition & 0 deletions swiftlint.yml
Original file line number Diff line number Diff line change
@@ -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":"[email protected]","path":"[email protected]","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":"[email protected]"},"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"}

0 comments on commit bddcb7e

Please sign in to comment.