From 3eac873f0e76cdb5d82de068d9afc5bbbcc19db7 Mon Sep 17 00:00:00 2001 From: DAVID Amaury Date: Fri, 16 Aug 2019 12:04:38 +0200 Subject: [PATCH] Fixed some swiftlint warnings. --- Examples/_shared/GitHubAPI.swift | 4 ++-- .../Moya/Plugins/NetworkLoggerPlugin.swift | 24 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Examples/_shared/GitHubAPI.swift b/Examples/_shared/GitHubAPI.swift index 4f253dcab..bcc69a6c9 100644 --- a/Examples/_shared/GitHubAPI.swift +++ b/Examples/_shared/GitHubAPI.swift @@ -8,8 +8,8 @@ import Moya private func JSONResponseDataFormatter(_ data: Data) -> String { do { let dataAsJSON = try JSONSerialization.jsonObject(with: data) - let prettyData = try JSONSerialization.data(withJSONObject: dataAsJSON, options: .prettyPrinted) - return String(data:prettyData, encoding: .utf8) ?? String() + let prettyData = try JSONSerialization.data(withJSONObject: dataAsJSON, options: .prettyPrinted) + return String(data: prettyData, encoding: .utf8) ?? String() } catch { return String() } diff --git a/Sources/Moya/Plugins/NetworkLoggerPlugin.swift b/Sources/Moya/Plugins/NetworkLoggerPlugin.swift index f9e8ced7f..c3df12fa2 100644 --- a/Sources/Moya/Plugins/NetworkLoggerPlugin.swift +++ b/Sources/Moya/Plugins/NetworkLoggerPlugin.swift @@ -11,7 +11,7 @@ public final class NetworkLoggerPlugin { } } -//MARK: - PluginType +// MARK: - PluginType extension NetworkLoggerPlugin: PluginType { public func willSend(_ request: RequestType, target: TargetType) { configuration.output(target, logNetworkRequest(request, target: target)) @@ -27,7 +27,7 @@ extension NetworkLoggerPlugin: PluginType { } } -//MARK: - Logging +// MARK: - Logging private extension NetworkLoggerPlugin { func newEntry(identifier: String, message: String) -> String { @@ -35,7 +35,6 @@ private extension NetworkLoggerPlugin { return "\(configuration.loggerId): [\(date)] \(identifier): \(message)" } - func logNetworkRequest(_ request: RequestType, target: TargetType) -> [String] { //cURL formatting @@ -103,7 +102,6 @@ private extension NetworkLoggerPlugin { return output } - func logNetworkError(_ error: MoyaError, target: TargetType) -> [String] { //Some errors will still have a response, like errors due to Alamofire's HTTP code validation. if let moyaResponse = error.response { @@ -115,7 +113,7 @@ private extension NetworkLoggerPlugin { } } -//MARK: - Configuration +// MARK: - Configuration public extension NetworkLoggerPlugin { struct Configuration { @@ -174,24 +172,24 @@ public extension NetworkLoggerPlugin.Configuration { public let rawValue: Int public init(rawValue: Int) { self.rawValue = rawValue } - public static let method: RequestLogOptions = RequestLogOptions(rawValue: 1 << 0) - public static let body: RequestLogOptions = RequestLogOptions(rawValue: 1 << 1) - public static let headers: RequestLogOptions = RequestLogOptions(rawValue: 1 << 2) + public static let method: RequestLogOptions = RequestLogOptions(rawValue: 1 << 0) + public static let body: RequestLogOptions = RequestLogOptions(rawValue: 1 << 1) + public static let headers: RequestLogOptions = RequestLogOptions(rawValue: 1 << 2) public static let formatAscURL: RequestLogOptions = RequestLogOptions(rawValue: 1 << 3) //Aggregate options - public static let `default`: RequestLogOptions = [method, headers] - public static let verbose: RequestLogOptions = [method, headers, body] + public static let `default`: RequestLogOptions = [method, headers] + public static let verbose: RequestLogOptions = [method, headers, body] } struct ResponseLogOptions: OptionSet { public let rawValue: Int public init(rawValue: Int) { self.rawValue = rawValue } - public static let body: ResponseLogOptions = ResponseLogOptions(rawValue: 1 << 0) + public static let body: ResponseLogOptions = ResponseLogOptions(rawValue: 1 << 0) //Aggregate options - public static let `default`: ResponseLogOptions = [] - public static let verbose: ResponseLogOptions = [body] + public static let `default`: ResponseLogOptions = [] + public static let verbose: ResponseLogOptions = [body] } }