Przeglądaj źródła

Update formatting. (#3285)

Jon Shier 5 lat temu
rodzic
commit
5c34603e05

+ 1 - 0
.swiftformat

@@ -6,6 +6,7 @@
 # rules
 --enable isEmpty
 --disable andOperator
+--disable wrapMultilineStatementBraces
 
 # format options
 

+ 17 - 17
Source/RetryPolicy.swift

@@ -64,7 +64,7 @@ open class RetryPolicy: RequestInterceptor {
         // process.
         //   - [Enabled] The other process could release the background session.
         .backgroundSessionInUseByAnotherProcess,
-                                                                           
+
         // [System] The shared container identifier of the URL session configuration is needed but has not been set.
         //   - [Disabled] Cannot change at runtime.
         // .backgroundSessionRequiresSharedContainer,
@@ -72,11 +72,11 @@ open class RetryPolicy: RequestInterceptor {
         // [System] The app is suspended or exits while a background data task is processing.
         //   - [Enabled] App can be foregrounded or launched to recover.
         .backgroundSessionWasDisconnected,
-                                                                           
+
         // [Network] The URL Loading system received bad data from the server.
         //   - [Enabled] Server could return valid data when retrying.
         .badServerResponse,
-                                                                           
+
         // [Resource] A malformed URL prevented a URL request from being initiated.
         //   - [Disabled] URL was most likely constructed incorrectly.
         // .badURL,
@@ -85,7 +85,7 @@ open class RetryPolicy: RequestInterceptor {
         // simultaneous phone and data communication (EDGE or GPRS).
         //   - [Enabled] Phone call could be ended to allow request to recover.
         .callIsActive,
-                                                                           
+
         // [Client] An asynchronous load has been canceled.
         //   - [Disabled] Request was cancelled by the client.
         // .cancelled,
@@ -97,7 +97,7 @@ open class RetryPolicy: RequestInterceptor {
         // [Network] An attempt to connect to a host failed.
         //   - [Enabled] Server or DNS lookup could recover during retry.
         .cannotConnectToHost,
-                                                                           
+
         // [File System] A download task couldn’t create the downloaded file on disk because of an I/O failure.
         //   - [Disabled] File system error is unlikely to recover with retry.
         // .cannotCreateFile,
@@ -113,11 +113,11 @@ open class RetryPolicy: RequestInterceptor {
         // [Network] The host name for a URL could not be resolved.
         //   - [Enabled] Server or DNS lookup could recover during retry.
         .cannotFindHost,
-                                                                           
+
         // [Network] A request to load an item only from the cache could not be satisfied.
         //   - [Enabled] Cache could be populated during a retry.
         .cannotLoadFromNetwork,
-                                                                           
+
         // [File System] A download task was unable to move a downloaded file on disk.
         //   - [Disabled] File system error is unlikely to recover with retry.
         // .cannotMoveFile,
@@ -153,19 +153,19 @@ open class RetryPolicy: RequestInterceptor {
         // [System] The cellular network disallowed a connection.
         //   - [Enabled] WiFi connection could be established during retry.
         .dataNotAllowed,
-                                                                           
+
         // [Network] The host address could not be found via DNS lookup.
         //   - [Enabled] DNS lookup could succeed during retry.
         .dnsLookupFailed,
-                                                                           
+
         // [Data] A download task failed to decode an encoded file during the download.
         //   - [Enabled] Server could correct the decoding issue with retry.
         .downloadDecodingFailedMidStream,
-                                                                           
+
         // [Data] A download task failed to decode an encoded file after downloading.
         //   - [Enabled] Server could correct the decoding issue with retry.
         .downloadDecodingFailedToComplete,
-                                                                           
+
         // [File System] A file does not exist.
         //   - [Disabled] File system error is unlikely to recover with retry.
         // .fileDoesNotExist,
@@ -184,11 +184,11 @@ open class RetryPolicy: RequestInterceptor {
         // is disabled.
         //   - [Enabled] WiFi connection could be established during retry.
         .internationalRoamingOff,
-                                                                           
+
         // [Connectivity] A client or server connection was severed in the middle of an in-progress load.
         //   - [Enabled] A network connection could be established during retry.
         .networkConnectionLost,
-                                                                           
+
         // [File System] A resource couldn’t be read because of insufficient permissions.
         //   - [Disabled] Permissions are unlikely to be granted during retry.
         // .noPermissionsToReadFile,
@@ -197,7 +197,7 @@ open class RetryPolicy: RequestInterceptor {
         // cannot be established automatically.
         //   - [Enabled] A network connection could be established during retry.
         .notConnectedToInternet,
-                                                                           
+
         // [Resource] A redirect was specified by way of server response code, but the server did not accompany this
         // code with a redirect URL.
         //   - [Disabled] The redirect URL is unlikely to be supplied during a retry.
@@ -216,11 +216,11 @@ open class RetryPolicy: RequestInterceptor {
         //   - [Enabled] The secure connection could be established during a retry given the lack of specificity
         //     provided by the error.
         .secureConnectionFailed,
-                                                                           
+
         // [Security] A server certificate had a date which indicates it has expired, or is not yet valid.
         //   - [Enabled] The server certificate could become valid within the retry window.
         .serverCertificateHasBadDate,
-                                                                           
+
         // [Security] A server certificate was not signed by any root server.
         //   - [Disabled] The server certificate is unlikely to change during the retry window.
         // .serverCertificateHasUnknownRoot,
@@ -228,7 +228,7 @@ open class RetryPolicy: RequestInterceptor {
         // [Security] A server certificate is not yet valid.
         //   - [Enabled] The server certificate could become valid within the retry window.
         .serverCertificateNotYetValid,
-                                                                           
+
         // [Security] A server certificate was signed by a root server that isn’t trusted.
         //   - [Disabled] The server certificate is unlikely to become trusted within the retry window.
         // .serverCertificateUntrusted,

+ 4 - 4
Source/Validation.swift

@@ -83,7 +83,7 @@ extension Request {
         -> ValidationResult
         where S.Iterator.Element == Int {
         if acceptableStatusCodes.contains(response.statusCode) {
-            return .success(Void())
+            return .success(())
         } else {
             let reason: ErrorReason = .unacceptableStatusCode(code: response.statusCode)
             return .failure(AFError.responseValidationFailed(reason: reason))
@@ -97,7 +97,7 @@ extension Request {
                                            data: Data?)
         -> ValidationResult
         where S.Iterator.Element == String {
-        guard let data = data, !data.isEmpty else { return .success(Void()) }
+        guard let data = data, !data.isEmpty else { return .success(()) }
 
         return validate(contentType: acceptableContentTypes, response: response)
     }
@@ -112,7 +112,7 @@ extension Request {
         else {
             for contentType in acceptableContentTypes {
                 if let mimeType = MIMEType(contentType), mimeType.isWildcard {
-                    return .success(Void())
+                    return .success(())
                 }
             }
 
@@ -126,7 +126,7 @@ extension Request {
 
         for contentType in acceptableContentTypes {
             if let acceptableMIMEType = MIMEType(contentType), acceptableMIMEType.matches(responseMIMEType) {
-                return .success(Void())
+                return .success(())
             }
         }
 

+ 2 - 2
Tests/CombineTests.swift

@@ -356,7 +356,7 @@ final class DataRequestCombineTests: CombineTestCase {
         if #available(macOS 11, iOS 14, watchOS 7, tvOS 14, *) {
             throw XCTSkip("Skip on 2020 OS versions, as Combine cancellation no longer emits a value.")
         }
-        
+
         // Given
         let responseReceived = expectation(description: "response should be received")
         let completionReceived = expectation(description: "stream should complete")
@@ -870,7 +870,7 @@ final class DataStreamRequestCombineTests: CombineTestCase {
         if #available(macOS 11, iOS 14, watchOS 7, tvOS 14, *) {
             throw XCTSkip("Skip on 2020 OS versions, as Combine cancellation no longer emits a value.")
         }
-        
+
         // Given
         let responseReceived = expectation(description: "response should be received")
         let completionReceived = expectation(description: "stream should complete")

+ 11 - 11
Tests/ParameterEncodingTests.swift

@@ -291,19 +291,19 @@ class URLParameterEncodingTestCase: ParameterEncodingTestCase {
             let encoding = URLEncoding(boolEncoding: .literal)
             let parameters: [String: Any] = [// Must still encode to numbers
                 "a": 1,
-                                             "b": 0,
-                                             "c": 1.0,
-                                             "d": 0.0,
-                                             "e": NSNumber(value: 1),
-                                             "f": NSNumber(value: 0),
-                                             "g": NSNumber(value: 1.0),
-                                             "h": NSNumber(value: 0.0),
-                                             
+                "b": 0,
+                "c": 1.0,
+                "d": 0.0,
+                "e": NSNumber(value: 1),
+                "f": NSNumber(value: 0),
+                "g": NSNumber(value: 1.0),
+                "h": NSNumber(value: 0.0),
+
                 // Must encode to literals
                 "i": true,
-                                             "j": false,
-                                             "k": NSNumber(value: true),
-                                             "l": NSNumber(value: false)]
+                "j": false,
+                "k": NSNumber(value: true),
+                "l": NSNumber(value: false)]
 
             // When
             let urlRequest = try encoding.encode(self.urlRequest, with: parameters)

+ 4 - 4
Tests/ValidationTests.swift

@@ -723,7 +723,7 @@ extension DataRequest {
     func validateDataExists() -> Self {
         validate { _, _, data in
             guard data != nil else { return .failure(ValidationError.missingData) }
-            return .success(Void())
+            return .success(())
         }
     }
 
@@ -741,7 +741,7 @@ extension DownloadRequest {
 
             do {
                 _ = try Data(contentsOf: validFileURL)
-                return .success(Void())
+                return .success(())
             } catch {
                 return .failure(ValidationError.fileReadFailed)
             }
@@ -770,7 +770,7 @@ final class CustomValidationTestCase: BaseTestCase {
         AF.request(urlString)
             .validate { _, _, data in
                 guard data != nil else { return .failure(ValidationError.missingData) }
-                return .success(Void())
+                return .success(())
             }
             .response { resp in
                 requestError = resp.error
@@ -783,7 +783,7 @@ final class CustomValidationTestCase: BaseTestCase {
 
                 do {
                     _ = try Data(contentsOf: fileURL)
-                    return .success(Void())
+                    return .success(())
                 } catch {
                     return .failure(ValidationError.fileReadFailed)
                 }