diff --git a/Sources/ParseSwift/Objects Protocols/ObjectType.swift b/Sources/ParseSwift/Objects Protocols/ObjectType.swift index 227be2c64..614177f71 100644 --- a/Sources/ParseSwift/Objects Protocols/ObjectType.swift +++ b/Sources/ParseSwift/Objects Protocols/ObjectType.swift @@ -51,8 +51,8 @@ internal extension ObjectType { extension ObjectType { // Parse ClassName inference public static var className: String { - let t = "\(type(of: self))" - return t.components(separatedBy: ".").first! // strip .Type + let classType = "\(type(of: self))" + return classType.components(separatedBy: ".").first! // strip .Type } public var className: String { return Self.className @@ -120,7 +120,7 @@ let dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .custom({ (dec) -> let container = try dec.singleValueContainer() let decodedString = try container.decode(String.self) return dateFormatter.date(from: decodedString)! - } catch let e { + } catch let error { let container = try dec.container(keyedBy: DateEncodingKeys.self) if let decoded = try container.decodeIfPresent(String.self, forKey: .iso) { return dateFormatter.date(from: decoded)! @@ -175,8 +175,8 @@ public extension ObjectType { public func fetch(options: API.Option, callback: @escaping ((Result) -> Void)) -> Cancellable? { do { return try fetchCommand().execute(options: options, callback) - } catch let e { - callback(.error(e)) + } catch let error { + callback(.error(error)) } return nil } diff --git a/Sources/ParseSwift/REST/RESTBatchCommand.swift b/Sources/ParseSwift/REST/RESTBatchCommand.swift index 1d2ce69f9..9fe5d4e7e 100644 --- a/Sources/ParseSwift/REST/RESTBatchCommand.swift +++ b/Sources/ParseSwift/REST/RESTBatchCommand.swift @@ -55,12 +55,12 @@ struct SaveOrUpdateResponse: Decodable { } } -public class RESTBatchCommand: RESTBatchCommandType where T: ObjectType { +class RESTBatchCommand: RESTBatchCommandType where T: ObjectType { typealias ParseObjectCommand = RESTCommand typealias ParseObjectBatchCommand = BatchCommand init(commands: [ParseObjectCommand]) { - let commands = commands.flatMap { (command) -> RESTCommand? in + let commands = commands.compactMap { (command) -> RESTCommand? in let path = ParseConfiguration.mountPath + command.path.urlComponent guard let body = command.body else { return nil @@ -68,7 +68,7 @@ public class RESTBatchCommand: RESTBatchCommandType where T: ObjectType { return RESTCommand(method: command.method, path: .any(path), body: body, mapper: command.mapper) } - let bodies = commands.flatMap { (command) -> T? in + let bodies = commands.compactMap { (command) -> T? in return command.body } let mapper = { (data: Data) -> [(T, ParseError?)] in diff --git a/Sources/ParseSwift/Result.swift b/Sources/ParseSwift/Result.swift index 876924198..3eca100d4 100644 --- a/Sources/ParseSwift/Result.swift +++ b/Sources/ParseSwift/Result.swift @@ -20,8 +20,8 @@ public enum Result { case .success(let success): do { return .success(try transform(success)) - } catch let e { - return .error(e) + } catch let error { + return .error(error) } case .error(let error): return .error(error) @@ -34,8 +34,8 @@ public enum Result { case .success(let success): do { return try transform(success) - } catch let e { - return .error(e) + } catch let error { + return .error(error) } case .error(let error): return .error(error) @@ -56,11 +56,11 @@ extension Result where T == Data { case .success(let data): do { return .success(try mapper(data)) - } catch let e { + } catch let error { do { // try default error mapper :) return .error(try getDecoder().decode(ParseError.self, from: data)) } catch {} - return .error(e) + return .error(error) } case .error(let error): return .error(error) diff --git a/Sources/ParseSwift/Synchronous.swift b/Sources/ParseSwift/Synchronous.swift index b1b0eddb7..7b70bc46c 100644 --- a/Sources/ParseSwift/Synchronous.swift +++ b/Sources/ParseSwift/Synchronous.swift @@ -12,13 +12,13 @@ typealias ResultCapturing = (Result) -> Void // Mark it private for now private func await(block: (@escaping ResultCapturing) -> Void) throws -> T { let sema = DispatchSemaphore(value: 0) - var r: Result! + var result: Result! block({ - r = $0 + result = $0 sema.signal() }) sema.wait() - switch r! { + switch result! { case .success(let value): return value case .error(let error): diff --git a/Sources/ParseSwift/Types/ACL.swift b/Sources/ParseSwift/Types/ACL.swift index 901b5c85a..dccb525b8 100644 --- a/Sources/ParseSwift/Types/ACL.swift +++ b/Sources/ParseSwift/Types/ACL.swift @@ -114,7 +114,7 @@ extension ACL { try container.nestedContainer(keyedBy: Access.self, forKey: scope)) }.flatMap { pair -> [(String, Access, Bool)] in let (scope, accessValues) = pair - return try accessValues.allKeys.flatMap { (access) -> (String, Access, Bool)? in + return try accessValues.allKeys.compactMap { (access) -> (String, Access, Bool)? in // swiftlint:disable line_length guard let value = try accessValues.decodeIfPresent(Bool.self, forKey: access) else { // swiftlint:enable line_length diff --git a/Sources/ParseSwift/Types/Query.swift b/Sources/ParseSwift/Types/Query.swift index c0281c927..30ea34871 100644 --- a/Sources/ParseSwift/Types/Query.swift +++ b/Sources/ParseSwift/Types/Query.swift @@ -112,10 +112,10 @@ internal struct QueryWhere: Encodable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: RawCodingKey.self) try _constraints.forEach { (key, value) in - var c = container.nestedContainer(keyedBy: QueryConstraint.Comparator.self, + var nestedContainer = container.nestedContainer(keyedBy: QueryConstraint.Comparator.self, forKey: .key(key)) try value.forEach { (constraint) in - try constraint.encode(to: c.superEncoder(forKey: constraint.comparator)) + try constraint.encode(to: nestedContainer.superEncoder(forKey: constraint.comparator)) } } }