Skip to content

Commit 666e30d

Browse files
authoredAug 14, 2023
Update SwiftFormat version (#1639)
Motivation: Some changes cause the formatter to throw an error while formatting. This particular bug was fixed in 0.52.0. Modifications: - Update the formatter version to 0.52.0 - Update the rules applied to minimise the diff from updating - Run the formatter Results: - Formatter is up-to-date.
1 parent 735d88f commit 666e30d

21 files changed

+125
-106
lines changed
 

‎.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- name: "Formatting and License Headers check"
1616
run: |
17-
SWIFTFORMAT_VERSION=0.49.4
17+
SWIFTFORMAT_VERSION=0.52.0
1818
git clone --depth 1 --branch "$SWIFTFORMAT_VERSION" "https://github.com/nicklockwood/SwiftFormat" "$HOME/SwiftFormat"
1919
swift build -c release --package-path "$HOME/SwiftFormat" --product swiftformat
2020
export PATH=$PATH:"$(swift build -c release --package-path "$HOME/SwiftFormat" --show-bin-path)"

‎.swiftformat

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,20 @@
4141

4242
# Put ACLs on declarations within an extension rather than the extension itself.
4343
--extensionacl on-declarations
44+
45+
# Don't remove internal ACLs
46+
--disable redundantInternal
47+
48+
# Don't remove redundant parenstheses, because no all of them are redundant.
49+
--disable redundantParens
50+
51+
# Don't remove static Self
52+
--disable redundantStaticSelf
53+
54+
# Hoisting try and await causes a bunch of issues (and churn) in 0.52.0. Disable
55+
# them for the time being.
56+
--disable hoistTry
57+
--disable hoistAwait
58+
59+
# Disabled as enabling causes a lot of churn.
60+
--disable wrapSingleLineComments

‎Examples/Google/SpeechToText/Sources/Launch/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import UIKit
1818

19-
@UIApplicationMain
19+
@main
2020
class AppDelegate: UIResponder, UIApplicationDelegate {
2121
func application(
2222
_ application: UIApplication,

‎Examples/Google/SpeechToText/Sources/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class ViewController: UIViewController {
2727
button.backgroundColor = .darkGray
2828
button.layer.cornerRadius = 15
2929
button.clipsToBounds = true
30-
button.addTarget(self, action: #selector(recordTapped), for: .touchUpInside)
30+
button.addTarget(self, action: #selector(self.recordTapped), for: .touchUpInside)
3131
return button
3232
}()
3333

@@ -110,7 +110,7 @@ final class ViewController: UIViewController {
110110
self.textView.snp.makeConstraints { make in
111111
make.top.equalTo(view.safeAreaLayoutGuide.snp.topMargin)
112112
make.left.right.equalToSuperview()
113-
make.bottom.equalTo(recordButton.snp.top)
113+
make.bottom.equalTo(self.recordButton.snp.top)
114114
}
115115

116116
self.recordButton.snp.makeConstraints { make in

‎Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
import PackageDescription
1818
// swiftformat puts the next import before the tools version.
19-
// swiftformat:disable:next sortedImports
19+
// swiftformat:disable:next sortImports
2020
import class Foundation.ProcessInfo
2121

2222
let grpcPackageName = "grpc-swift"

‎Performance/QPSBenchmark/Sources/QPSBenchmark/Runtime/Async/AsyncPingPongRequestMaker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ final class AsyncPingPongRequestMaker: AsyncRequestMaker, @unchecked Sendable {
6868
while !self.stopRequested.load(ordering: .relaxed),
6969
self.messagesPerStream == 0 || messagesSent < self.messagesPerStream {
7070
try await streamingCall.requestStream.send(self.requestMessage)
71-
let _ = try await responseStream.next()
71+
_ = try await responseStream.next()
7272
let endTime = grpcTimeNow()
7373
self.stats.add(latency: endTime - startTime)
7474
messagesSent += 1

‎Sources/GRPC/ServerCallContexts/StreamingResponseCallContext.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ internal final class _StreamingResponseCallContext<Request, Response>:
237237
/// Concrete implementation of `StreamingResponseCallContext` used for testing.
238238
///
239239
/// Simply records all sent messages.
240-
open class StreamingResponseCallContextTestStub<ResponsePayload>: StreamingResponseCallContext<ResponsePayload> {
240+
open class StreamingResponseCallContextTestStub<ResponsePayload>: StreamingResponseCallContext<
241+
ResponsePayload
242+
> {
241243
open var recordedResponses: [ResponsePayload] = []
242244

243245
override open func sendResponse(

‎Sources/GRPCPerformanceTests/Benchmarks/UnaryThroughput.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Unary: ServerProvidingBenchmark {
7979
let upperBound = min(lowerBound + batchSize, self.requestCount)
8080

8181
let requests = (lowerBound ..< upperBound).map { _ in
82-
client.get(Echo_EchoRequest.with { $0.text = self.requestText }).response
82+
self.client.get(Echo_EchoRequest.with { $0.text = self.requestText }).response
8383
}
8484

8585
messages += requests.count

‎Tests/GRPCTests/ClientInterceptorPipelineTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ClientInterceptorPipelineTests: GRPCTestCase {
159159
assertThat(cancelled, .is(false))
160160
cancelled = true
161161
// We don't expect a promise: this cancellation is fired by the pipeline.
162-
assertThat(promise, .is(.nil()))
162+
assertThat(promise, .is(.none()))
163163
},
164164
onRequestPart: { _, _ in
165165
XCTFail("Unexpected request part")
@@ -202,14 +202,14 @@ class ClientInterceptorPipelineTests: GRPCTestCase {
202202
assertThat(cancellations, .is(0))
203203
cancellations += 1
204204
// We don't expect a promise: this cancellation is fired by the pipeline.
205-
assertThat(promise, .is(.nil()))
205+
assertThat(promise, .is(.none()))
206206
},
207207
onRequestPart: { _, _ in
208208
XCTFail("Unexpected request part")
209209
},
210210
onResponsePart: { part in
211211
// We only expect the end.
212-
assertThat(part.end, .is(.notNil()))
212+
assertThat(part.end, .is(.some()))
213213
}
214214
)
215215

‎Tests/GRPCTests/ConnectionPool/GRPCChannelPoolTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ final class GRPCChannelPoolTests: GRPCTestCase {
303303

304304
// If we express no event loop preference then we should not get the loaded loop.
305305
let indifferentLoopRPCs = (1 ... 10).map {
306-
_ in echo.get(.with { $0.text = "" })
306+
_ in self.echo.get(.with { $0.text = "" })
307307
}
308308

309309
XCTAssert(indifferentLoopRPCs.map { $0.eventLoop }.allSatisfy { $0 !== loop })

‎Tests/GRPCTests/GRPCAsyncClientCallTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ class GRPCAsyncClientCallTests: GRPCTestCase {
160160
var responseStreamIterator = update.responseStream.makeAsyncIterator()
161161
for word in ["boyle", "jeffers", "holt"] {
162162
try await update.requestStream.send(.with { $0.text = word })
163-
await assertThat(try await responseStreamIterator.next(), .is(.notNil()))
163+
await assertThat(try await responseStreamIterator.next(), .is(.some()))
164164
}
165165

166166
update.requestStream.finish()
167167

168-
await assertThat(try await responseStreamIterator.next(), .is(.nil()))
168+
await assertThat(try await responseStreamIterator.next(), .is(.none()))
169169

170170
await assertThat(try await update.trailingMetadata, .is(.equalTo(Self.OKTrailingMetadata)))
171171
await assertThat(await update.status, .hasCode(.ok))

‎Tests/GRPCTests/GRPCPingHandlerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ extension PingHandler.Action: Equatable {
387387
extension GRPCPingHandlerTests {
388388
func testSingleAckIsEmittedOnPing() throws {
389389
let client = EmbeddedChannel()
390-
let _ = try client.configureHTTP2Pipeline(mode: .client) { _ in
390+
_ = try client.configureHTTP2Pipeline(mode: .client) { _ in
391391
fatalError("Unexpected inbound stream")
392392
}.wait()
393393

‎Tests/GRPCTests/GRPCWebToHTTP2ServerCodecTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class GRPCWebToHTTP2ServerCodecTests: GRPCTestCase {
4747
)
4848
assertThat(try channel.writeInbound(HTTPServerRequestPart.head(head)), .doesNotThrow())
4949
let headersPayload = try channel.readInbound(as: HTTP2Frame.FramePayload.self)
50-
assertThat(headersPayload, .notNil(.headers(.contains(":path", [path]))))
50+
assertThat(headersPayload, .some(.headers(.contains(":path", [path]))))
5151
}
5252

5353
private func receiveBytes(
@@ -59,22 +59,22 @@ class GRPCWebToHTTP2ServerCodecTests: GRPCTestCase {
5959

6060
if let expectedBytes = expectedBytes {
6161
let dataPayload = try channel.readInbound(as: HTTP2Frame.FramePayload.self)
62-
assertThat(dataPayload, .notNil(.data(buffer: ByteBuffer(bytes: expectedBytes))))
62+
assertThat(dataPayload, .some(.data(buffer: ByteBuffer(bytes: expectedBytes))))
6363
}
6464
}
6565

6666
private func receiveEnd(on channel: EmbeddedChannel) throws {
6767
assertThat(try channel.writeInbound(HTTPServerRequestPart.end(nil)), .doesNotThrow())
6868
let dataEndPayload = try channel.readInbound(as: HTTP2Frame.FramePayload.self)
69-
assertThat(dataEndPayload, .notNil(.data(buffer: ByteBuffer(), endStream: true)))
69+
assertThat(dataEndPayload, .some(.data(buffer: ByteBuffer(), endStream: true)))
7070
}
7171

7272
private func sendResponseHeaders(on channel: EmbeddedChannel) throws {
7373
let responseHeaders: HPACKHeaders = [":status": "200"]
7474
let headerPayload: HTTP2Frame.FramePayload = .headers(.init(headers: responseHeaders))
7575
assertThat(try channel.writeOutbound(headerPayload), .doesNotThrow())
7676
let responseHead = try channel.readOutbound(as: HTTPServerResponsePart.self)
77-
assertThat(responseHead, .notNil(.head(status: .ok)))
77+
assertThat(responseHead, .some(.head(status: .ok)))
7878
}
7979

8080
private func sendTrailersOnlyResponse(on channel: EmbeddedChannel) throws {
@@ -83,9 +83,9 @@ class GRPCWebToHTTP2ServerCodecTests: GRPCTestCase {
8383

8484
assertThat(try channel.writeOutbound(headerPayload), .doesNotThrow())
8585
let responseHead = try channel.readOutbound(as: HTTPServerResponsePart.self)
86-
assertThat(responseHead, .notNil(.head(status: .ok)))
86+
assertThat(responseHead, .some(.head(status: .ok)))
8787
let end = try channel.readOutbound(as: HTTPServerResponsePart.self)
88-
assertThat(end, .notNil(.end()))
88+
assertThat(end, .some(.end()))
8989
}
9090

9191
private func sendBytes(
@@ -99,9 +99,9 @@ class GRPCWebToHTTP2ServerCodecTests: GRPCTestCase {
9999

100100
if let expectedBytes = expectedBytes {
101101
let expectedBuffer = ByteBuffer(bytes: expectedBytes)
102-
assertThat(try channel.readOutbound(), .notNil(.body(.is(expectedBuffer))))
102+
assertThat(try channel.readOutbound(), .some(.body(.is(expectedBuffer))))
103103
} else {
104-
assertThat(try channel.readOutbound(as: HTTPServerResponsePart.self), .doesNotThrow(.nil()))
104+
assertThat(try channel.readOutbound(as: HTTPServerResponsePart.self), .doesNotThrow(.none()))
105105
}
106106
}
107107

@@ -115,10 +115,10 @@ class GRPCWebToHTTP2ServerCodecTests: GRPCTestCase {
115115
assertThat(try channel.writeOutbound(headersPayload), .doesNotThrow())
116116

117117
if let expectedBytes = expectedBytes {
118-
assertThat(try channel.readOutbound(), .notNil(.body(.is(expectedBytes))))
118+
assertThat(try channel.readOutbound(), .some(.body(.is(expectedBytes))))
119119
}
120120

121-
assertThat(try channel.readOutbound(), .notNil(.end()))
121+
assertThat(try channel.readOutbound(), .some(.end()))
122122
}
123123

124124
func testWebBinaryHappyPath() throws {

‎Tests/GRPCTests/ServerInterceptorPipelineTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ServerInterceptorPipelineTests: GRPCTestCase {
6060
onRequestPart: { requestParts.append($0) },
6161
onResponsePart: { part, promise in
6262
responseParts.append(part)
63-
assertThat(promise, .is(.nil()))
63+
assertThat(promise, .is(.none()))
6464
}
6565
)
6666

@@ -80,7 +80,7 @@ class ServerInterceptorPipelineTests: GRPCTestCase {
8080
assertThat(responseParts, .hasCount(3))
8181
assertThat(responseParts[0].metadata, .is([:]))
8282
assertThat(responseParts[1].message, .is("bar"))
83-
assertThat(responseParts[2].end, .is(.notNil()))
83+
assertThat(responseParts[2].end, .is(.some()))
8484

8585
// Pipelines should now be closed. We can't send or receive.
8686
let p = self.embeddedEventLoop.makePromise(of: Void.self)
@@ -110,15 +110,15 @@ class ServerInterceptorPipelineTests: GRPCTestCase {
110110

111111
// Check the request parts are there.
112112
assertThat(recorder.requestParts, .hasCount(3))
113-
assertThat(recorder.requestParts[0].metadata, .is(.notNil()))
114-
assertThat(recorder.requestParts[1].message, .is(.notNil()))
113+
assertThat(recorder.requestParts[0].metadata, .is(.some()))
114+
assertThat(recorder.requestParts[1].message, .is(.some()))
115115
assertThat(recorder.requestParts[2].isEnd, .is(true))
116116

117117
// Check the response parts are there.
118118
assertThat(recorder.responseParts, .hasCount(3))
119-
assertThat(recorder.responseParts[0].metadata, .is(.notNil()))
120-
assertThat(recorder.responseParts[1].message, .is(.notNil()))
121-
assertThat(recorder.responseParts[2].end, .is(.notNil()))
119+
assertThat(recorder.responseParts[0].metadata, .is(.some()))
120+
assertThat(recorder.responseParts[1].message, .is(.some()))
121+
assertThat(recorder.responseParts[2].end, .is(.some()))
122122
}
123123
}
124124

‎Tests/GRPCTests/ServerInterceptorTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ class ServerInterceptorTests: GRPCTestCase {
9898
handler.receiveEnd()
9999

100100
// Expect responses.
101-
assertThat(self.recorder.metadata, .is(.notNil()))
101+
assertThat(self.recorder.metadata, .is(.some()))
102102
assertThat(self.recorder.messages.count, .is(1))
103-
assertThat(self.recorder.status, .is(.notNil()))
103+
assertThat(self.recorder.status, .is(.some()))
104104

105105
// We expect 2 request parts: the provider responds before it sees end, that's fine.
106106
assertThat(recordingInterceptor.requestParts, .hasCount(2))
@@ -123,9 +123,9 @@ class ServerInterceptorTests: GRPCTestCase {
123123
handler.receiveEnd()
124124

125125
// Get the responses.
126-
assertThat(self.recorder.metadata, .is(.notNil()))
126+
assertThat(self.recorder.metadata, .is(.some()))
127127
assertThat(self.recorder.messages.count, .is(1))
128-
assertThat(self.recorder.status, .is(.notNil()))
128+
assertThat(self.recorder.status, .is(.some()))
129129
}
130130

131131
func testClientStreamingFromInterceptor() throws {
@@ -140,9 +140,9 @@ class ServerInterceptorTests: GRPCTestCase {
140140
handler.receiveEnd()
141141

142142
// Get the responses.
143-
assertThat(self.recorder.metadata, .is(.notNil()))
143+
assertThat(self.recorder.metadata, .is(.some()))
144144
assertThat(self.recorder.messages.count, .is(1))
145-
assertThat(self.recorder.status, .is(.notNil()))
145+
assertThat(self.recorder.status, .is(.some()))
146146
}
147147

148148
func testServerStreamingFromInterceptor() throws {
@@ -155,9 +155,9 @@ class ServerInterceptorTests: GRPCTestCase {
155155
handler.receiveEnd()
156156

157157
// Get the responses.
158-
assertThat(self.recorder.metadata, .is(.notNil()))
158+
assertThat(self.recorder.metadata, .is(.some()))
159159
assertThat(self.recorder.messages.count, .is(3))
160-
assertThat(self.recorder.status, .is(.notNil()))
160+
assertThat(self.recorder.status, .is(.some()))
161161
}
162162

163163
func testBidirectionalStreamingFromInterceptor() throws {
@@ -172,9 +172,9 @@ class ServerInterceptorTests: GRPCTestCase {
172172
handler.receiveEnd()
173173

174174
// Get the responses.
175-
assertThat(self.recorder.metadata, .is(.notNil()))
175+
assertThat(self.recorder.metadata, .is(.some()))
176176
assertThat(self.recorder.messages.count, .is(3))
177-
assertThat(self.recorder.status, .is(.notNil()))
177+
assertThat(self.recorder.status, .is(.some()))
178178
}
179179
}
180180

‎Tests/GRPCTests/ServerThrowingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class ServerThrowingTests: EchoTestCaseBase {
150150
}
151151
}
152152
XCTAssertThrowsError(try call.response.wait()) {
153-
XCTAssertEqual(expectedError, $0 as? GRPCStatus)
153+
XCTAssertEqual(self.expectedError, $0 as? GRPCStatus)
154154
}
155155
}
156156

@@ -170,7 +170,7 @@ class ServerThrowingTests: EchoTestCaseBase {
170170
// With `ErrorReturningEchoProvider` we actually _return_ a response, which means that the `response` future
171171
// will _not_ fail, so in that case this test doesn't apply.
172172
XCTAssertThrowsError(try call.response.wait()) {
173-
XCTAssertEqual(expectedError, $0 as? GRPCStatus)
173+
XCTAssertEqual(self.expectedError, $0 as? GRPCStatus)
174174
}
175175
}
176176
}

‎Tests/GRPCTests/ServerWebTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ extension ServerWebTests {
157157
var expectedData = Data()
158158
var index = 0
159159
message.split(separator: " ").forEach { component in
160-
expectedData.append(gRPCEncodedEchoRequest("Swift echo expand (\(index)): \(component)"))
160+
expectedData.append(self.gRPCEncodedEchoRequest("Swift echo expand (\(index)): \(component)"))
161161
index += 1
162162
}
163163
expectedData.append(self.gRPCWebTrailers())

0 commit comments

Comments
 (0)
Please sign in to comment.