Skip to content

Fix Swift Lint Warnings #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/ParseSwift/Objects Protocols/ObjectType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)!
Expand Down Expand Up @@ -175,8 +175,8 @@ public extension ObjectType {
public func fetch(options: API.Option, callback: @escaping ((Result<Self>) -> Void)) -> Cancellable? {
do {
return try fetchCommand().execute(options: options, callback)
} catch let e {
callback(.error(e))
} catch let error {
callback(.error(error))
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/ParseSwift/REST/RESTBatchCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ struct SaveOrUpdateResponse: Decodable {
}
}

public class RESTBatchCommand<T>: RESTBatchCommandType<T> where T: ObjectType {
class RESTBatchCommand<T>: RESTBatchCommandType<T> where T: ObjectType {
typealias ParseObjectCommand = RESTCommand<T, T>
typealias ParseObjectBatchCommand = BatchCommand<T, T>

init(commands: [ParseObjectCommand]) {
let commands = commands.flatMap { (command) -> RESTCommand<T, T>? in
let commands = commands.compactMap { (command) -> RESTCommand<T, T>? in
let path = ParseConfiguration.mountPath + command.path.urlComponent
guard let body = command.body else {
return nil
}
return RESTCommand<T, T>(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
Expand Down
12 changes: 6 additions & 6 deletions Sources/ParseSwift/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public enum Result<T> {
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)
Expand All @@ -34,8 +34,8 @@ public enum Result<T> {
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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Sources/ParseSwift/Synchronous.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ typealias ResultCapturing<T> = (Result<T>) -> Void
// Mark it private for now
private func await<T>(block: (@escaping ResultCapturing<T>) -> Void) throws -> T {
let sema = DispatchSemaphore(value: 0)
var r: Result<T>!
var result: Result<T>!
block({
r = $0
result = $0
sema.signal()
})
sema.wait()
switch r! {
switch result! {
case .success(let value):
return value
case .error(let error):
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Types/ACL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseSwift/Types/Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
Expand Down