Przeglądaj źródła

Apply SwiftFormat 0.51.0 (#3695)

### Goals :soccer:
This PR applies formatting from SwiftFormat 0.51.0.
Jon Shier 2 lat temu
rodzic
commit
81a29729e7

+ 37 - 37
.github/workflows/ci.yml

@@ -25,41 +25,45 @@ jobs:
     name: Test macOS, All Xcodes and Swifts
     runs-on: ${{ matrix.runsOn }}
     env:
-      DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}/Contents/Developer"
+      DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}.app/Contents/Developer"
     timeout-minutes: 10
     strategy:
       fail-fast: false
       matrix:
         include:
-          - xcode: "Xcode_14.2.app"
+          - xcode: "Xcode_14.3"
+            runsOn: firebreak
+            name: "macOS 13, Xcode 14.3, Swift 5.8.0"
+            testPlan: "macOS"
+          - xcode: "Xcode_14.2"
             runsOn: macOS-12
             name: "macOS 12, Xcode 14.2, Swift 5.7.2"
             testPlan: "macOS"
-          - xcode: "Xcode_14.1.app"
+          - xcode: "Xcode_14.1"
             runsOn: macOS-12
             name: "macOS 12, Xcode 14.1, Swift 5.7.1"
             testPlan: "macOS"
-          - xcode: "Xcode_14.0.1.app"
+          - xcode: "Xcode_14.0.1"
             runsOn: macOS-12
             name: "macOS 12, Xcode 14.0.1, Swift 5.7.0"
             testPlan: "macOS"
-          - xcode: "Xcode_13.4.1.app"
+          - xcode: "Xcode_13.4.1"
             runsOn: macOS-12
             name: "macOS 12, Xcode 13.4.1, Swift 5.6.1"
             testPlan: "macOS-NoTS"
-          - xcode: "Xcode_13.3.1.app"
+          - xcode: "Xcode_13.3.1"
             runsOn: macOS-12
             name: "macOS 12, Xcode 13.3.1, Swift 5.6.0"
             testPlan: "macOS-NoTS"
-          - xcode: "Xcode_13.2.1.app"
+          - xcode: "Xcode_13.2.1"
             runsOn: macOS-11
             name: "macOS 11, Xcode 13.2.1, Swift 5.5.2"
             testPlan: "macOS-NoTS"
-          - xcode: "Xcode_13.1.app"
+          - xcode: "Xcode_13.1"
             runsOn: macOS-11
             name: "macOS 11, Xcode 13.1, Swift 5.5.1"
             testPlan: "macOS-NoTS"
-          - xcode: "Xcode_13.0.app"
+          - xcode: "Xcode_13.0"
             runsOn: macOS-11
             name: "macOS 11, Xcode 13.0, Swift 5.5.0"
             testPlan: "macOS-NoTS"
@@ -122,12 +126,9 @@ jobs:
           - destination: "OS=14.5,name=iPhone 12 Pro"
             name: "iOS 14.5"
             testPlan: "iOS-NoTS"
-          - destination: "OS=13.7,name=iPhone 11 Pro"
-            name: "iOS 13.7"
-            testPlan: "iOS-NoTS"
-          - destination: "OS=12.4,name=iPhone Xs"
-            name: "iOS 12.4"
-            testPlan: "iOS-Old"
+          # - destination: "OS=13.7,name=iPhone 11 Pro"
+          #   name: "iOS 13.7"
+          #   testPlan: "iOS-NoTS"
     steps:
       - uses: actions/checkout@v3
       - name: Install Firewalk
@@ -150,12 +151,9 @@ jobs:
           - destination: "OS=14.5,name=Apple TV"
             name: "tvOS 14.5"
             testPlan: "tvOS-NoTS"
-          - destination: "OS=13.4,name=Apple TV"
-            name: "tvOS 13.4"
-            testPlan: "tvOS-NoTS"
-          - destination: "OS=12.4,name=Apple TV"
-            name: "tvOS 12.4"
-            testPlan: "tvOS-Old"
+          # - destination: "OS=13.4,name=Apple TV"
+          #   name: "tvOS 13.4"
+          #   testPlan: "tvOS-NoTS"
     steps:
       - uses: actions/checkout@v3
       - name: Install Firewalk
@@ -188,34 +186,37 @@ jobs:
     name: Test with SPM
     runs-on: ${{ matrix.runsOn }}
     env:
-      DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}/Contents/Developer"
+      DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}.app/Contents/Developer"
     timeout-minutes: 10
     strategy:
       fail-fast: false
       matrix:
         include:
-          - xcode: "Xcode_14.2.app"
+          - xcode: "Xcode_14.3"
+            runsOn: firebreak
+            name: "macOS 13, SPM 5.8.0 Test"
+          - xcode: "Xcode_14.2"
             runsOn: macOS-12
             name: "macOS 12, SPM 5.7.2 Test"
-          - xcode: "Xcode_14.1.app"
+          - xcode: "Xcode_14.1"
             runsOn: macOS-12
             name: "macOS 12, SPM 5.7.1 Test"
-          - xcode: "Xcode_14.0.1.app"
+          - xcode: "Xcode_14.0.1"
             runsOn: macOS-12
             name: "macOS 12, SPM 5.7.0 Test"
-          - xcode: "Xcode_13.4.1.app"
+          - xcode: "Xcode_13.4.1"
             runsOn: macOS-12
             name: "macOS 12, SPM 5.6.1 Test"
-          - xcode: "Xcode_13.3.1.app"
+          - xcode: "Xcode_13.3.1"
             runsOn: macOS-12
             name: "macOS 12, SPM 5.6.0 Test"
-          - xcode: "Xcode_13.2.1.app"
+          - xcode: "Xcode_13.2.1"
             runsOn: macOS-11
             name: "macOS 11, SPM 5.5.2 Test"
-          - xcode: "Xcode_13.1.app"
+          - xcode: "Xcode_13.1"
             runsOn: macOS-11
             name: "macOS 11, SPM 5.5.1 Test"
-          - xcode: "Xcode_13.0.app"
+          - xcode: "Xcode_13.0"
             runsOn: macOS-11
             name: "macOS 11, SPM 5.5.0 Test"
     steps:
@@ -231,16 +232,15 @@ jobs:
       fail-fast: false
       matrix:
         include:
-          - image: swift:5.7-bionic
-          - image: swift:5.7-focal
-          - image: swift:5.7-centos7
-          - image: swift:5.7-amazonlinux2
-          - image: swiftlang/swift:nightly-bionic
+          - image: swift:5.7.3-focal
+          - image: swift:5.7.3-centos7
+          - image: swift:5.7.3-amazonlinux2
           - image: swiftlang/swift:nightly-focal
           - image: swiftlang/swift:nightly-jammy
-          # - image: swiftlang/swift:nightly-centos7
-          - image: swiftlang/swift:nightly-centos8
           - image: swiftlang/swift:nightly-amazonlinux2
+          - image: swiftlang/swift:nightly-5.8-focal
+          - image: swiftlang/swift:nightly-5.8-jammy
+          - image: swiftlang/swift:nightly-5.8-amazonlinux2
     container:
       image: ${{ matrix.image }}
     timeout-minutes: 10

+ 15 - 17
Gemfile.lock

@@ -1,14 +1,13 @@
 GEM
   remote: https://rubygems.org/
   specs:
-    CFPropertyList (3.0.5)
+    CFPropertyList (3.0.6)
       rexml
-    activesupport (6.1.7.1)
+    activesupport (7.0.4.2)
       concurrent-ruby (~> 1.0, >= 1.0.2)
       i18n (>= 1.6, < 2)
       minitest (>= 5.1)
       tzinfo (~> 2.0)
-      zeitwerk (~> 2.3)
     addressable (2.8.1)
       public_suffix (>= 2.0.2, < 6.0)
     algoliasearch (1.27.5)
@@ -16,15 +15,15 @@ GEM
       json (>= 1.5.1)
     atomos (0.1.3)
     claide (1.1.0)
-    cocoapods (1.11.3)
+    cocoapods (1.12.0)
       addressable (~> 2.8)
       claide (>= 1.0.2, < 2.0)
-      cocoapods-core (= 1.11.3)
+      cocoapods-core (= 1.12.0)
       cocoapods-deintegrate (>= 1.0.3, < 2.0)
-      cocoapods-downloader (>= 1.4.0, < 2.0)
+      cocoapods-downloader (>= 1.6.0, < 2.0)
       cocoapods-plugins (>= 1.0.0, < 2.0)
       cocoapods-search (>= 1.0.0, < 2.0)
-      cocoapods-trunk (>= 1.4.0, < 2.0)
+      cocoapods-trunk (>= 1.6.0, < 2.0)
       cocoapods-try (>= 1.1.0, < 2.0)
       colored2 (~> 3.1)
       escape (~> 0.0.4)
@@ -32,10 +31,10 @@ GEM
       gh_inspector (~> 1.0)
       molinillo (~> 0.8.0)
       nap (~> 1.0)
-      ruby-macho (>= 1.0, < 3.0)
+      ruby-macho (>= 2.3.0, < 3.0)
       xcodeproj (>= 1.21.0, < 2.0)
-    cocoapods-core (1.11.3)
-      activesupport (>= 5.0, < 7)
+    cocoapods-core (1.12.0)
+      activesupport (>= 5.0, < 8)
       addressable (~> 2.8)
       algoliasearch (~> 1.0)
       concurrent-ruby (~> 1.1)
@@ -54,7 +53,7 @@ GEM
       netrc (~> 0.11)
     cocoapods-try (1.2.0)
     colored2 (3.1.2)
-    concurrent-ruby (1.1.10)
+    concurrent-ruby (1.2.2)
     escape (0.0.4)
     ethon (0.16.0)
       ffi (>= 1.15.0)
@@ -75,9 +74,9 @@ GEM
       sassc (~> 2.1)
       sqlite3 (~> 1.3)
       xcinvoke (~> 0.3.0)
-    json (2.6.2)
+    json (2.6.3)
     liferaft (0.0.6)
-    mini_portile2 (2.8.0)
+    mini_portile2 (2.8.1)
     minitest (5.17.0)
     molinillo (0.8.0)
     mustache (1.1.1)
@@ -86,17 +85,17 @@ GEM
     netrc (0.11.0)
     open4 (1.3.4)
     public_suffix (4.0.7)
-    redcarpet (3.5.1)
+    redcarpet (3.6.0)
     rexml (3.2.5)
     rouge (2.0.7)
     ruby-macho (2.5.1)
     sassc (2.4.0)
       ffi (~> 1.9)
-    sqlite3 (1.5.4)
+    sqlite3 (1.6.1)
       mini_portile2 (~> 2.8.0)
     typhoeus (1.4.0)
       ethon (>= 0.9.0)
-    tzinfo (2.0.5)
+    tzinfo (2.0.6)
       concurrent-ruby (~> 1.0)
     xcinvoke (0.3.0)
       liferaft (~> 0.0.6)
@@ -109,7 +108,6 @@ GEM
       rexml (~> 3.2.4)
     xcpretty (0.3.0)
       rouge (~> 2.0.7)
-    zeitwerk (2.6.6)
 
 PLATFORMS
   ruby

+ 8 - 8
Source/Concurrency.swift

@@ -120,7 +120,7 @@ public struct DataTask<Value> {
                 return await withTaskCancellationHandler {
                     await task.value
                 } onCancel: {
-                    self.cancel()
+                    cancel()
                 }
             } else {
                 return await task.value
@@ -313,7 +313,7 @@ public struct DownloadTask<Value> {
                 return await withTaskCancellationHandler {
                     await task.value
                 } onCancel: {
-                    self.cancel()
+                    cancel()
                 }
             } else {
                 return await task.value
@@ -533,7 +533,7 @@ public struct DataStreamTask {
     /// - Returns:                   The `Stream`.
     public func streamingData(automaticallyCancelling shouldAutomaticallyCancel: Bool = true, bufferingPolicy: Stream<Data, Never>.BufferingPolicy = .unbounded) -> Stream<Data, Never> {
         createStream(automaticallyCancelling: shouldAutomaticallyCancel, bufferingPolicy: bufferingPolicy) { onStream in
-            self.request.responseStream(on: .streamCompletionQueue(forRequestID: request.id), stream: onStream)
+            request.responseStream(on: .streamCompletionQueue(forRequestID: request.id), stream: onStream)
         }
     }
 
@@ -546,7 +546,7 @@ public struct DataStreamTask {
     /// - Returns:
     public func streamingStrings(automaticallyCancelling shouldAutomaticallyCancel: Bool = true, bufferingPolicy: Stream<String, Never>.BufferingPolicy = .unbounded) -> Stream<String, Never> {
         createStream(automaticallyCancelling: shouldAutomaticallyCancel, bufferingPolicy: bufferingPolicy) { onStream in
-            self.request.responseStreamString(on: .streamCompletionQueue(forRequestID: request.id), stream: onStream)
+            request.responseStreamString(on: .streamCompletionQueue(forRequestID: request.id), stream: onStream)
         }
     }
 
@@ -582,9 +582,9 @@ public struct DataStreamTask {
                                                                      bufferingPolicy: Stream<Serializer.SerializedObject, AFError>.BufferingPolicy = .unbounded)
         -> Stream<Serializer.SerializedObject, AFError> {
         createStream(automaticallyCancelling: shouldAutomaticallyCancel, bufferingPolicy: bufferingPolicy) { onStream in
-            self.request.responseStream(using: serializer,
-                                        on: .streamCompletionQueue(forRequestID: request.id),
-                                        stream: onStream)
+            request.responseStream(using: serializer,
+                                   on: .streamCompletionQueue(forRequestID: request.id),
+                                   stream: onStream)
         }
     }
 
@@ -670,7 +670,7 @@ public struct StreamOf<Element>: AsyncSequence {
 
         return Iterator(iterator: stream.makeAsyncIterator()) {
             continuation?.finish()
-            self.onTermination?()
+            onTermination?()
         }
     }
 

+ 20 - 20
Source/Request.swift

@@ -1166,17 +1166,17 @@ public class DataRequest: Request {
     @discardableResult
     public func validate(_ validation: @escaping Validation) -> Self {
         let validator: () -> Void = { [unowned self] in
-            guard self.error == nil, let response = self.response else { return }
+            guard error == nil, let response = response else { return }
 
-            let result = validation(self.request, response, self.data)
+            let result = validation(request, response, data)
 
             if case let .failure(error) = result { self.error = error.asAFError(or: .responseValidationFailed(reason: .customValidationFailed(error: error))) }
 
-            self.eventMonitor?.request(self,
-                                       didValidateRequest: self.request,
-                                       response: response,
-                                       data: self.data,
-                                       withResult: result)
+            eventMonitor?.request(self,
+                                  didValidateRequest: request,
+                                  response: response,
+                                  data: data,
+                                  withResult: result)
         }
 
         $validators.write { $0.append(validator) }
@@ -1337,18 +1337,18 @@ public final class DataStreamRequest: Request {
     @discardableResult
     public func validate(_ validation: @escaping Validation) -> Self {
         let validator: () -> Void = { [unowned self] in
-            guard self.error == nil, let response = self.response else { return }
+            guard error == nil, let response = response else { return }
 
-            let result = validation(self.request, response)
+            let result = validation(request, response)
 
             if case let .failure(error) = result {
                 self.error = error.asAFError(or: .responseValidationFailed(reason: .customValidationFailed(error: error)))
             }
 
-            self.eventMonitor?.request(self,
-                                       didValidateRequest: self.request,
-                                       response: response,
-                                       withResult: result)
+            eventMonitor?.request(self,
+                                  didValidateRequest: request,
+                                  response: response,
+                                  withResult: result)
         }
 
         $validators.write { $0.append(validator) }
@@ -1739,19 +1739,19 @@ public class DownloadRequest: Request {
     @discardableResult
     public func validate(_ validation: @escaping Validation) -> Self {
         let validator: () -> Void = { [unowned self] in
-            guard self.error == nil, let response = self.response else { return }
+            guard error == nil, let response = response else { return }
 
-            let result = validation(self.request, response, self.fileURL)
+            let result = validation(request, response, fileURL)
 
             if case let .failure(error) = result {
                 self.error = error.asAFError(or: .responseValidationFailed(reason: .customValidationFailed(error: error)))
             }
 
-            self.eventMonitor?.request(self,
-                                       didValidateRequest: self.request,
-                                       response: response,
-                                       fileURL: self.fileURL,
-                                       withResult: result)
+            eventMonitor?.request(self,
+                                  didValidateRequest: request,
+                                  response: response,
+                                  fileURL: fileURL,
+                                  withResult: result)
         }
 
         $validators.write { $0.append(validator) }

+ 2 - 2
Source/ResponseSerialization.swift

@@ -1172,7 +1172,7 @@ extension DataStreamRequest {
                                                                  on queue: DispatchQueue = .main,
                                                                  stream: @escaping Handler<Serializer.SerializedObject, AFError>) -> Self {
         let parser = { [unowned self] (data: Data) in
-            self.serializationQueue.async {
+            serializationQueue.async {
                 // Start work on serialization queue.
                 let result = Result { try serializer.serialize(data) }
                     .mapError { $0.asAFError(or: .responseSerializationFailed(reason: .customSerializationFailed(error: $0))) }
@@ -1212,7 +1212,7 @@ extension DataStreamRequest {
     public func responseStreamString(on queue: DispatchQueue = .main,
                                      stream: @escaping Handler<String, Never>) -> Self {
         let parser = { [unowned self] (data: Data) in
-            self.serializationQueue.async {
+            serializationQueue.async {
                 // Start work on serialization queue.
                 let string = String(decoding: data, as: UTF8.self)
                 // End work on serialization queue.

+ 3 - 3
Source/Validation.swift

@@ -185,7 +185,7 @@ extension DataRequest {
     @discardableResult
     public func validate() -> Self {
         let contentTypes: () -> [String] = { [unowned self] in
-            self.acceptableContentTypes
+            acceptableContentTypes
         }
         return validate(statusCode: acceptableStatusCodes).validate(contentType: contentTypes())
     }
@@ -233,7 +233,7 @@ extension DataStreamRequest {
     @discardableResult
     public func validate() -> Self {
         let contentTypes: () -> [String] = { [unowned self] in
-            self.acceptableContentTypes
+            acceptableContentTypes
         }
         return validate(statusCode: acceptableStatusCodes).validate(contentType: contentTypes())
     }
@@ -295,7 +295,7 @@ extension DownloadRequest {
     @discardableResult
     public func validate() -> Self {
         let contentTypes = { [unowned self] in
-            self.acceptableContentTypes
+            acceptableContentTypes
         }
         return validate(statusCode: acceptableStatusCodes).validate(contentType: contentTypes())
     }

+ 1 - 1
Tests/ConcurrencyTests.swift

@@ -498,7 +498,7 @@ final class ClosureAPIConcurrencyTests: BaseTestCase {
                      tasks: [URLSessionTask],
                      descriptions: [String],
                      response: AFDataResponse<TestResponse>)
-        #if swift(>=5.8)
+        #if swift(>=5.9)
         values = try! await (uploadProgress, downloadProgress, requests, tasks, descriptions, response)
         #else
         values = await (uploadProgress, downloadProgress, requests, tasks, descriptions, response)

+ 1 - 1
Tests/LeaksTests.swift

@@ -37,7 +37,7 @@ final class LeaksTests: XCTestCase {
             func leaksTo(_ file: String) -> Process {
                 let out = FileHandle(forWritingAtPath: file)!
                 defer {
-                    if #available(OSX 10.15, *) {
+                    if #available(macOS 10.15, *) {
                         try! out.close()
                     } else {
                         // Fallback on earlier versions

+ 1 - 1
Tests/TestHelpers.swift

@@ -243,7 +243,7 @@ extension Endpoint: URLRequestConvertible {
     var urlRequest: URLRequest { try! asURLRequest() }
 
     func asURLRequest() throws -> URLRequest {
-        var request = URLRequest(url: try asURL())
+        var request = try URLRequest(url: asURL())
         request.method = method
         request.headers = headers
         request.timeoutInterval = timeout

+ 0 - 2
Tests/ValidationTests.swift

@@ -800,8 +800,6 @@ extension DataRequest {
 extension DownloadRequest {
     func validateDataExists() -> Self {
         validate { [unowned self] _, _, _ in
-            let fileURL = self.fileURL
-
             guard let validFileURL = fileURL else { return .failure(ValidationError.missingFile) }
 
             do {

+ 1 - 1
watchOS Example/watchOS Example WatchKit Extension/ContentView.swift

@@ -30,7 +30,7 @@ struct ContentView: View {
 
     var body: some View {
         VStack {
-            Button(action: { self.networking.performRequest() },
+            Button(action: { networking.performRequest() },
                    label: { Text("Perform Request") })
             Text(networking.message)
         }