Skip to content

Commit 666e30d

Browse files
authored
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

File tree

21 files changed

+125
-106
lines changed

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 })

0 commit comments

Comments
 (0)