Skip to content
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

Fix Xcode 10.2 warnings #1826

Merged
merged 8 commits into from
Mar 30, 2019
4 changes: 2 additions & 2 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ end

# Run danger-prose to lint Chinese docs
added_and_modified_cn_docs = (git.added_files.grep(%r{docs_CN/*.md}) + git.modified_files.grep(%r{docs_CN/*.md}))
if added_and_modified_cn_docs.empty?
unless added_and_modified_cn_docs.empty?
prose.lint_files added_and_modified_cn_docs
end

# Run danger-prose to lint and check spelling English docs
added_and_modified_en_docs = (git.added_files.grep(%r{docs/*.md}) + git.modified_files.grep(%r{docs/*.md}))
if added_and_modified_en_docs.empty?
unless added_and_modified_en_docs.empty?
prose.lint_files added_and_modified_en_docs

prose.language = "en-us"
Expand Down
2 changes: 1 addition & 1 deletion Moya.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@
};
buildConfigurationList = CF2B188FD83B4489A8520824 /* Build configuration list for PBXProject "Moya" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down
9 changes: 6 additions & 3 deletions Sources/Moya/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@ extension Endpoint {

/// Required for using `Endpoint` as a key type in a `Dictionary`.
extension Endpoint: Equatable, Hashable {
public var hashValue: Int {
let request = try? urlRequest()
return request?.hashValue ?? url.hashValue
public func hash(into hasher: inout Hasher) {
guard let request = try? urlRequest() else {
hasher.combine(url)
return
}
hasher.combine(request)
}

/// Note: If both Endpoints fail to produce a URLRequest the comparison will
Expand Down
6 changes: 3 additions & 3 deletions Sources/Moya/MoyaProvider+Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

/// These functions are default mappings to `MoyaProvider`'s properties: endpoints, requests, manager, etc.
public extension MoyaProvider {
public final class func defaultEndpointMapping(for target: Target) -> Endpoint {
final class func defaultEndpointMapping(for target: Target) -> Endpoint {
return Endpoint(
url: URL(target: target).absoluteString,
sampleResponseClosure: { .networkResponse(200, target.sampleData) },
Expand All @@ -12,7 +12,7 @@ public extension MoyaProvider {
)
}

public final class func defaultRequestMapping(for endpoint: Endpoint, closure: RequestResultClosure) {
final class func defaultRequestMapping(for endpoint: Endpoint, closure: RequestResultClosure) {
do {
let urlRequest = try endpoint.urlRequest()
closure(.success(urlRequest))
Expand All @@ -25,7 +25,7 @@ public extension MoyaProvider {
}
}

public final class func defaultAlamofireManager() -> Manager {
final class func defaultAlamofireManager() -> Manager {
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = Manager.defaultHTTPHeaders

Expand Down
2 changes: 1 addition & 1 deletion Sources/Moya/MoyaProvider+Internal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public extension MoyaProvider {
}

/// Creates a function which, when called, executes the appropriate stubbing behavior for the given parameters.
public final func createStubFunction(_ token: CancellableToken, forTarget target: Target, withCompletion completion: @escaping Moya.Completion, endpoint: Endpoint, plugins: [PluginType], request: URLRequest) -> (() -> Void) { // swiftlint:disable:this function_parameter_count
final func createStubFunction(_ token: CancellableToken, forTarget target: Target, withCompletion completion: @escaping Moya.Completion, endpoint: Endpoint, plugins: [PluginType], request: URLRequest) -> (() -> Void) { // swiftlint:disable:this function_parameter_count
return {
if token.isCancelled {
self.cancelCompletion(completion, target: target)
Expand Down
6 changes: 3 additions & 3 deletions Sources/Moya/MoyaProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,17 @@ public extension MoyaProvider {
// at least add some class functions to allow easy access to common stubbing closures.

/// Do not stub.
public final class func neverStub(_: Target) -> Moya.StubBehavior {
final class func neverStub(_: Target) -> Moya.StubBehavior {
return .never
}

/// Return a response immediately.
public final class func immediatelyStub(_: Target) -> Moya.StubBehavior {
final class func immediatelyStub(_: Target) -> Moya.StubBehavior {
return .immediate
}

/// Return a response after a delay.
public final class func delayedStub(_ seconds: TimeInterval) -> (Target) -> Moya.StubBehavior {
final class func delayedStub(_ seconds: TimeInterval) -> (Target) -> Moya.StubBehavior {
return { _ in return .delayed(seconds: seconds) }
}
}
Expand Down
10 changes: 5 additions & 5 deletions Sources/Moya/Response.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public extension Response {
- statusCodes: The range of acceptable status codes.
- throws: `MoyaError.statusCode` when others are encountered.
*/
public func filter<R: RangeExpression>(statusCodes: R) throws -> Response where R.Bound == Int {
func filter<R: RangeExpression>(statusCodes: R) throws -> Response where R.Bound == Int {
guard statusCodes.contains(statusCode) else {
throw MoyaError.statusCode(self)
}
Expand All @@ -62,7 +62,7 @@ public extension Response {
- statusCode: The acceptable status code.
- throws: `MoyaError.statusCode` when others are encountered.
*/
public func filter(statusCode: Int) throws -> Response {
func filter(statusCode: Int) throws -> Response {
return try filter(statusCodes: statusCode...statusCode)
}

Expand All @@ -71,7 +71,7 @@ public extension Response {

- throws: `MoyaError.statusCode` when others are encountered.
*/
public func filterSuccessfulStatusCodes() throws -> Response {
func filterSuccessfulStatusCodes() throws -> Response {
return try filter(statusCodes: 200...299)
}

Expand All @@ -80,7 +80,7 @@ public extension Response {

- throws: `MoyaError.statusCode` when others are encountered.
*/
public func filterSuccessfulStatusAndRedirectCodes() throws -> Response {
func filterSuccessfulStatusAndRedirectCodes() throws -> Response {
return try filter(statusCodes: 200...399)
}

Expand Down Expand Up @@ -110,7 +110,7 @@ public extension Response {
/// Maps data received from the signal into a String.
///
/// - parameter atKeyPath: Optional key path at which to parse string.
public func mapString(atKeyPath keyPath: String? = nil) throws -> String {
func mapString(atKeyPath keyPath: String? = nil) throws -> String {
if let keyPath = keyPath {
// Key path was provided, try to parse string at key path
guard let jsonDictionary = try mapJSON() as? NSDictionary,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Moya/TargetType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public extension TargetType {
// MARK: - Deprecated

extension TargetType {
@available(*, deprecated: 11.0, message:
@available(*, deprecated, message:
"TargetType's validate property has been deprecated in 11.0. Please use validationType: ValidationType.")
var validate: Bool {
return false
Expand Down
4 changes: 2 additions & 2 deletions Sources/ReactiveMoya/MoyaProvider+Reactive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension MoyaProvider: ReactiveExtensionsProvider {}
public extension Reactive where Base: MoyaProviderType {

/// Designated request-making method.
public func request(_ token: Base.Target, callbackQueue: DispatchQueue? = nil) -> SignalProducer<Response, MoyaError> {
func request(_ token: Base.Target, callbackQueue: DispatchQueue? = nil) -> SignalProducer<Response, MoyaError> {
return SignalProducer { [weak base] observer, lifetime in
let cancellableToken = base?.request(token, callbackQueue: callbackQueue, progress: nil) { result in
switch result {
Expand All @@ -28,7 +28,7 @@ public extension Reactive where Base: MoyaProviderType {
}

/// Designated request-making method with progress.
public func requestWithProgress(_ token: Base.Target, callbackQueue: DispatchQueue? = nil) -> SignalProducer<ProgressResponse, MoyaError> {
func requestWithProgress(_ token: Base.Target, callbackQueue: DispatchQueue? = nil) -> SignalProducer<ProgressResponse, MoyaError> {
let progressBlock: (Signal<ProgressResponse, MoyaError>.Observer) -> (ProgressResponse) -> Void = { observer in
return { progress in
observer.send(value: progress)
Expand Down
4 changes: 2 additions & 2 deletions Sources/RxMoya/MoyaProvider+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public extension Reactive where Base: MoyaProviderType {
/// - token: Entity, which provides specifications necessary for a `MoyaProvider`.
/// - callbackQueue: Callback queue. If nil - queue from provider initializer will be used.
/// - Returns: Single response object.
public func request(_ token: Base.Target, callbackQueue: DispatchQueue? = nil) -> Single<Response> {
func request(_ token: Base.Target, callbackQueue: DispatchQueue? = nil) -> Single<Response> {
return Single.create { [weak base] single in
let cancellableToken = base?.request(token, callbackQueue: callbackQueue, progress: nil) { result in
switch result {
Expand All @@ -32,7 +32,7 @@ public extension Reactive where Base: MoyaProviderType {
}

/// Designated request-making method with progress.
public func requestWithProgress(_ token: Base.Target, callbackQueue: DispatchQueue? = nil) -> Observable<ProgressResponse> {
func requestWithProgress(_ token: Base.Target, callbackQueue: DispatchQueue? = nil) -> Observable<ProgressResponse> {
let progressBlock: (AnyObserver) -> (ProgressResponse) -> Void = { observer in
return { progress in
observer.onNext(progress)
Expand Down