Skip to content

Update swiftformat to 0.48.8 #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# file options

--swiftversion 5.0
--swiftversion 5.2
--exclude .build

# format options

--self insert
--patternlet inline
--stripunusedargs unnamed-only
--ranges nospace
--disable typeSugar, andOperator # typeSugar: https://github.com/nicklockwood/SwiftFormat/issues/636
--stripunusedargs unnamed-only
--ifdef indent
--extensionacl on-declarations
--disable typeSugar # https://github.com/nicklockwood/SwiftFormat/issues/636
--disable andOperator
--disable wrapMultilineStatementBraces
--disable enumNamespaces
--disable redundantExtensionACL
--disable redundantReturn
--disable preferKeyPath
--disable sortedSwitchCases

# rules
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ final class HTTP2Connection {
targetWindowSize: 8 * 1024 * 1024, // 8mb
outboundBufferSizeHighWatermark: 8196,
outboundBufferSizeLowWatermark: 4092,
inboundStreamInitializer: { (channel) -> EventLoopFuture<Void> in
inboundStreamInitializer: { channel -> EventLoopFuture<Void> in
channel.eventLoop.makeFailedFuture(HTTP2PushNotSupportedError())
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ extension HTTPConnectionPool.ConnectionFactory {
deadline: deadline,
eventLoop: eventLoop,
logger: logger
).flatMapThrowing { (negotiated) -> Channel in
).flatMapThrowing { negotiated -> Channel in

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

private extension String {
var isIPAddress: Bool {
extension String {
fileprivate var isIPAddress: Bool {
var ipv4Addr = in_addr()
var ipv6Addr = in6_addr()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ struct HTTPRequestStateMachine {

mutating func errorHappened(_ error: Error) -> Action {
if let error = error as? NIOSSLError,
error == .uncleanShutdown,
let action = self.handleNIOSSLUncleanShutdownError() {
error == .uncleanShutdown,
let action = self.handleNIOSSLUncleanShutdownError() {
return action
}
switch self.state {
Expand Down Expand Up @@ -435,7 +435,7 @@ struct HTTPRequestStateMachine {
case .running(let requestState, .receivingBody(let head, var streamState)):
// This should never happen. But we don't want to precondition this behavior. Let's just
// pass the read event on
return self.avoidingStateMachineCoW { (state) -> Action in
return self.avoidingStateMachineCoW { state -> Action in
let action = streamState.read()
state = .running(requestState, .receivingBody(head, streamState))
return action.toRequestAction()
Expand Down Expand Up @@ -470,7 +470,7 @@ struct HTTPRequestStateMachine {
case .running(let requestState, .receivingBody(let head, var streamState)):
// This should never happen. But we don't want to precondition this behavior. Let's just
// pass the read event on
return self.avoidingStateMachineCoW { (state) -> Action in
return self.avoidingStateMachineCoW { state -> Action in
let buffer = streamState.channelReadComplete()
state = .running(requestState, .receivingBody(head, streamState))
if let buffer = buffer {
Expand Down Expand Up @@ -542,7 +542,7 @@ struct HTTPRequestStateMachine {
preconditionFailure("How can we receive a response body, if we haven't received a head. Invalid state: \(self.state)")

case .running(let requestState, .receivingBody(let head, var responseStreamState)):
return self.avoidingStateMachineCoW { (state) -> Action in
return self.avoidingStateMachineCoW { state -> Action in
responseStreamState.receivedBodyPart(body)
state = .running(requestState, .receivingBody(head, responseStreamState))
return .wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ extension HTTPConnectionPool {
uniquingKeysWith: +
)
var connectionToCreate = requiredEventLoopOfPendingRequests
.flatMap { (eventLoop, requestCount) -> [(Connection.ID, EventLoop)] in
.flatMap { eventLoop, requestCount -> [(Connection.ID, EventLoop)] in
// We need a connection for each queued request with a required event loop.
// Therefore, we look how many request we have queued for a given `eventLoop` and
// how many connections we are already starting on the given `eventLoop`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension HTTPConnectionPool {
self.connection = connection
}

static let none: Action = Action(request: .none, connection: .none)
static let none = Action(request: .none, connection: .none)
}

enum ConnectionAction {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AsyncHTTPClient/FileDownloadDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public final class FileDownloadDelegate: HTTPClientResponseDelegate {
self.reportHead?(head)

if let totalBytesString = head.headers.first(name: "Content-Length"),
let totalBytes = Int(totalBytesString) {
let totalBytes = Int(totalBytesString) {
self.progress.totalBytes = totalBytes
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/AsyncHTTPClient/HTTPClient+HTTPCookie.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ extension HTTPClient {
}
}

private extension String {
func omittingQuotes() -> String {
extension String {
fileprivate func omittingQuotes() -> String {
let dquote = "\""
if !hasPrefix(dquote) || !hasSuffix(dquote) {
return self
Expand Down
4 changes: 2 additions & 2 deletions Sources/AsyncHTTPClient/RequestValidation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ extension HTTPHeaders {
}

private func validateFieldNames() throws {
let invalidFieldNames = self.compactMap { (name, _) -> String? in
let satisfy = name.utf8.allSatisfy { (char) -> Bool in
let invalidFieldNames = self.compactMap { name, _ -> String? in
let satisfy = name.utf8.allSatisfy { char -> Bool in
switch char {
case UInt8(ascii: "a")...UInt8(ascii: "z"),
UInt8(ascii: "A")...UInt8(ascii: "Z"),
Expand Down
9 changes: 3 additions & 6 deletions Tests/AsyncHTTPClientTests/HTTP2ConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ extension TestConnectionCreator: HTTPConnectionRequester {
}

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

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

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

switch self.state {
case .waitingForHTTP1Connection(let promise):
Expand Down Expand Up @@ -392,8 +390,7 @@ extension TestConnectionCreator: HTTPConnectionRequester {
}

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

switch self.state {
case .waitingForHTTP1Connection(let promise):
Expand Down
4 changes: 2 additions & 2 deletions Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func isTestingNIOTS() -> Bool {
func getDefaultEventLoopGroup(numberOfThreads: Int) -> EventLoopGroup {
#if canImport(Network)
if #available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *),
isTestingNIOTS() {
isTestingNIOTS() {
return NIOTSEventLoopGroup(loopCount: numberOfThreads, defaultQoS: .default)
}
#endif
Expand Down Expand Up @@ -601,7 +601,7 @@ final class HTTPProxySimulator: ChannelInboundHandler, RemovableChannelHandler {

if let expectedAuhorization = self.expectedAuhorization {
guard let authorization = head.headers["proxy-authorization"].first,
expectedAuhorization == authorization else {
expectedAuhorization == authorization else {
self.head.status = .proxyAuthenticationRequired
return
}
Expand Down
Loading