Skip to content

Commit e502246

Browse files
authored
Update swiftformat to 0.48.8 (#491)
### Motivation Our current swiftformat version does not support async/await. Since we want to add support for async/await we must update swiftformat or disable it. I tried my very best to keep the number of changes as small as possible. I assume we want to stick with the new 0.48.8 for some time. ### Changes - Update swiftformat to 0.48.8 ### Result We can land async/await code.
1 parent 4fd1150 commit e502246

13 files changed

+66
-61
lines changed

.swiftformat

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
# file options
22

3-
--swiftversion 5.0
3+
--swiftversion 5.2
44
--exclude .build
55

66
# format options
77

88
--self insert
99
--patternlet inline
10-
--stripunusedargs unnamed-only
1110
--ranges nospace
12-
--disable typeSugar, andOperator # typeSugar: https://github.com/nicklockwood/SwiftFormat/issues/636
11+
--stripunusedargs unnamed-only
12+
--ifdef indent
13+
--extensionacl on-declarations
14+
--disable typeSugar # https://github.com/nicklockwood/SwiftFormat/issues/636
15+
--disable andOperator
16+
--disable wrapMultilineStatementBraces
17+
--disable enumNamespaces
18+
--disable redundantExtensionACL
19+
--disable redundantReturn
20+
--disable preferKeyPath
21+
--disable sortedSwitchCases
1322

1423
# rules

Sources/AsyncHTTPClient/ConnectionPool/HTTP2/HTTP2Connection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ final class HTTP2Connection {
9797
targetWindowSize: 8 * 1024 * 1024, // 8mb
9898
outboundBufferSizeHighWatermark: 8196,
9999
outboundBufferSizeLowWatermark: 4092,
100-
inboundStreamInitializer: { (channel) -> EventLoopFuture<Void> in
100+
inboundStreamInitializer: { channel -> EventLoopFuture<Void> in
101101
channel.eventLoop.makeFailedFuture(HTTP2PushNotSupportedError())
102102
}
103103
)

Sources/AsyncHTTPClient/ConnectionPool/HTTPConnectionPool+Factory.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ extension HTTPConnectionPool.ConnectionFactory {
115115
deadline: deadline,
116116
eventLoop: eventLoop,
117117
logger: logger
118-
).flatMapThrowing { (negotiated) -> Channel in
118+
).flatMapThrowing { negotiated -> Channel in
119119

120120
guard case .http1_1(let channel) = negotiated else {
121121
preconditionFailure("Expected to create http/1.1 connections only for now")
@@ -453,7 +453,7 @@ extension HTTPConnectionPool.ConnectionFactory {
453453
let bootstrap = ClientBootstrap(group: eventLoop)
454454
.connectTimeout(deadline - NIODeadline.now())
455455
.channelInitializer { channel in
456-
sslContextFuture.flatMap { (sslContext) -> EventLoopFuture<Void> in
456+
sslContextFuture.flatMap { sslContext -> EventLoopFuture<Void> in
457457
do {
458458
let sync = channel.pipeline.syncOperations
459459
let sslHandler = try NIOSSLClientHandler(
@@ -497,8 +497,8 @@ extension ConnectionPool.Key.Scheme {
497497
}
498498
}
499499

500-
private extension String {
501-
var isIPAddress: Bool {
500+
extension String {
501+
fileprivate var isIPAddress: Bool {
502502
var ipv4Addr = in_addr()
503503
var ipv6Addr = in6_addr()
504504

Sources/AsyncHTTPClient/ConnectionPool/HTTPRequestStateMachine.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ struct HTTPRequestStateMachine {
191191

192192
mutating func errorHappened(_ error: Error) -> Action {
193193
if let error = error as? NIOSSLError,
194-
error == .uncleanShutdown,
195-
let action = self.handleNIOSSLUncleanShutdownError() {
194+
error == .uncleanShutdown,
195+
let action = self.handleNIOSSLUncleanShutdownError() {
196196
return action
197197
}
198198
switch self.state {
@@ -435,7 +435,7 @@ struct HTTPRequestStateMachine {
435435
case .running(let requestState, .receivingBody(let head, var streamState)):
436436
// This should never happen. But we don't want to precondition this behavior. Let's just
437437
// pass the read event on
438-
return self.avoidingStateMachineCoW { (state) -> Action in
438+
return self.avoidingStateMachineCoW { state -> Action in
439439
let action = streamState.read()
440440
state = .running(requestState, .receivingBody(head, streamState))
441441
return action.toRequestAction()
@@ -470,7 +470,7 @@ struct HTTPRequestStateMachine {
470470
case .running(let requestState, .receivingBody(let head, var streamState)):
471471
// This should never happen. But we don't want to precondition this behavior. Let's just
472472
// pass the read event on
473-
return self.avoidingStateMachineCoW { (state) -> Action in
473+
return self.avoidingStateMachineCoW { state -> Action in
474474
let buffer = streamState.channelReadComplete()
475475
state = .running(requestState, .receivingBody(head, streamState))
476476
if let buffer = buffer {
@@ -542,7 +542,7 @@ struct HTTPRequestStateMachine {
542542
preconditionFailure("How can we receive a response body, if we haven't received a head. Invalid state: \(self.state)")
543543

544544
case .running(let requestState, .receivingBody(let head, var responseStreamState)):
545-
return self.avoidingStateMachineCoW { (state) -> Action in
545+
return self.avoidingStateMachineCoW { state -> Action in
546546
responseStreamState.receivedBodyPart(body)
547547
state = .running(requestState, .receivingBody(head, responseStreamState))
548548
return .wait

Sources/AsyncHTTPClient/ConnectionPool/State Machine/HTTPConnectionPool+HTTP1Connections.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ extension HTTPConnectionPool {
610610
uniquingKeysWith: +
611611
)
612612
var connectionToCreate = requiredEventLoopOfPendingRequests
613-
.flatMap { (eventLoop, requestCount) -> [(Connection.ID, EventLoop)] in
613+
.flatMap { eventLoop, requestCount -> [(Connection.ID, EventLoop)] in
614614
// We need a connection for each queued request with a required event loop.
615615
// Therefore, we look how many request we have queued for a given `eventLoop` and
616616
// how many connections we are already starting on the given `eventLoop`.

Sources/AsyncHTTPClient/ConnectionPool/State Machine/HTTPConnectionPool+StateMachine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extension HTTPConnectionPool {
2626
self.connection = connection
2727
}
2828

29-
static let none: Action = Action(request: .none, connection: .none)
29+
static let none = Action(request: .none, connection: .none)
3030
}
3131

3232
enum ConnectionAction {

Sources/AsyncHTTPClient/FileDownloadDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public final class FileDownloadDelegate: HTTPClientResponseDelegate {
6767
self.reportHead?(head)
6868

6969
if let totalBytesString = head.headers.first(name: "Content-Length"),
70-
let totalBytes = Int(totalBytesString) {
70+
let totalBytes = Int(totalBytesString) {
7171
self.progress.totalBytes = totalBytes
7272
}
7373

Sources/AsyncHTTPClient/HTTPClient+HTTPCookie.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ extension HTTPClient {
153153
}
154154
}
155155

156-
private extension String {
157-
func omittingQuotes() -> String {
156+
extension String {
157+
fileprivate func omittingQuotes() -> String {
158158
let dquote = "\""
159159
if !hasPrefix(dquote) || !hasSuffix(dquote) {
160160
return self

Sources/AsyncHTTPClient/RequestValidation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ extension HTTPHeaders {
4545
}
4646

4747
private func validateFieldNames() throws {
48-
let invalidFieldNames = self.compactMap { (name, _) -> String? in
49-
let satisfy = name.utf8.allSatisfy { (char) -> Bool in
48+
let invalidFieldNames = self.compactMap { name, _ -> String? in
49+
let satisfy = name.utf8.allSatisfy { char -> Bool in
5050
switch char {
5151
case UInt8(ascii: "a")...UInt8(ascii: "z"),
5252
UInt8(ascii: "A")...UInt8(ascii: "Z"),

Tests/AsyncHTTPClientTests/HTTP2ConnectionTests.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ extension TestConnectionCreator: HTTPConnectionRequester {
342342
}
343343

344344
func http1ConnectionCreated(_ connection: HTTP1Connection) {
345-
let wrapper = self.lock.withLock {
346-
() -> (EitherPromiseWrapper<HTTP1Connection, HTTP2Connection>) in
345+
let wrapper = self.lock.withLock { () -> (EitherPromiseWrapper<HTTP1Connection, HTTP2Connection>) in
347346

348347
switch self.state {
349348
case .waitingForHTTP1Connection(let promise):
@@ -360,8 +359,7 @@ extension TestConnectionCreator: HTTPConnectionRequester {
360359
}
361360

362361
func http2ConnectionCreated(_ connection: HTTP2Connection, maximumStreams: Int) {
363-
let wrapper = self.lock.withLock {
364-
() -> (EitherPromiseWrapper<HTTP2Connection, HTTP1Connection>) in
362+
let wrapper = self.lock.withLock { () -> (EitherPromiseWrapper<HTTP2Connection, HTTP1Connection>) in
365363

366364
switch self.state {
367365
case .waitingForHTTP1Connection(let promise):
@@ -392,8 +390,7 @@ extension TestConnectionCreator: HTTPConnectionRequester {
392390
}
393391

394392
func failedToCreateHTTPConnection(_: HTTPConnectionPool.Connection.ID, error: Swift.Error) {
395-
let wrapper = self.lock.withLock {
396-
() -> (FailPromiseWrapper<HTTP1Connection, HTTP2Connection>) in
393+
let wrapper = self.lock.withLock { () -> (FailPromiseWrapper<HTTP1Connection, HTTP2Connection>) in
397394

398395
switch self.state {
399396
case .waitingForHTTP1Connection(let promise):

Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func isTestingNIOTS() -> Bool {
4040
func getDefaultEventLoopGroup(numberOfThreads: Int) -> EventLoopGroup {
4141
#if canImport(Network)
4242
if #available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *),
43-
isTestingNIOTS() {
43+
isTestingNIOTS() {
4444
return NIOTSEventLoopGroup(loopCount: numberOfThreads, defaultQoS: .default)
4545
}
4646
#endif
@@ -601,7 +601,7 @@ final class HTTPProxySimulator: ChannelInboundHandler, RemovableChannelHandler {
601601

602602
if let expectedAuhorization = self.expectedAuhorization {
603603
guard let authorization = head.headers["proxy-authorization"].first,
604-
expectedAuhorization == authorization else {
604+
expectedAuhorization == authorization else {
605605
self.head.status = .proxyAuthenticationRequired
606606
return
607607
}

0 commit comments

Comments
 (0)