-
Notifications
You must be signed in to change notification settings - Fork 420
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
Switch to swift-format #1655
Switch to swift-format #1655
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"fileScopedDeclarationPrivacy" : { | ||
"accessLevel" : "private" | ||
}, | ||
"indentation" : { | ||
"spaces" : 2 | ||
}, | ||
"indentConditionalCompilationBlocks" : false, | ||
"indentSwitchCaseLabels" : false, | ||
"lineBreakAroundMultilineExpressionChainComponents" : false, | ||
"lineBreakBeforeControlFlowKeywords" : false, | ||
"lineBreakBeforeEachArgument" : true, | ||
"lineBreakBeforeEachGenericRequirement" : false, | ||
"lineLength" : 100, | ||
"maximumBlankLines" : 1, | ||
"prioritizeKeepingFunctionOutputTogether" : true, | ||
"respectsExistingLineBreaks" : true, | ||
"rules" : { | ||
"AllPublicDeclarationsHaveDocumentation" : false, | ||
"AlwaysUseLowerCamelCase" : false, | ||
"AmbiguousTrailingClosureOverload" : true, | ||
"BeginDocumentationCommentWithOneLineSummary" : false, | ||
"DoNotUseSemicolons" : true, | ||
"DontRepeatTypeInStaticProperties" : true, | ||
"FileScopedDeclarationPrivacy" : true, | ||
"FullyIndirectEnum" : true, | ||
"GroupNumericLiterals" : true, | ||
"IdentifiersMustBeASCII" : true, | ||
"NeverForceUnwrap" : false, | ||
"NeverUseForceTry" : false, | ||
"NeverUseImplicitlyUnwrappedOptionals" : false, | ||
"NoAccessLevelOnExtensionDeclaration" : true, | ||
"NoAssignmentInExpressions" : true, | ||
"NoBlockComments" : false, | ||
"NoCasesWithOnlyFallthrough" : true, | ||
"NoEmptyTrailingClosureParentheses" : true, | ||
"NoLabelsInCasePatterns" : false, | ||
"NoLeadingUnderscores" : false, | ||
"NoParensAroundConditions" : true, | ||
"NoVoidReturnOnFunctionSignature" : true, | ||
"OneCasePerLine" : true, | ||
"OneVariableDeclarationPerLine" : true, | ||
"OnlyOneTrailingClosureArgument" : true, | ||
"OrderedImports" : true, | ||
"ReturnVoidInsteadOfEmptyTuple" : true, | ||
"UseEarlyExits" : false, | ||
"UseLetInEveryBoundCaseVariable" : false, | ||
"UseShorthandTypeNames" : true, | ||
"UseSingleLinePropertyGetter" : false, | ||
"UseSynthesizedInitializer" : false, | ||
"UseTripleSlashForDocumentationComments" : true, | ||
"UseWhereClausesInForLoops" : false, | ||
"ValidateDocumentationComments" : false | ||
}, | ||
"spacesAroundRangeFormationOperators" : true, | ||
"tabWidth" : 2, | ||
"version" : 1 | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import GRPC | |
import GRPCSampleData | ||
import NIOCore | ||
import NIOPosix | ||
|
||
#if canImport(NIOSSL) | ||
import NIOSSL | ||
#endif | ||
|
@@ -136,7 +137,7 @@ func startEchoServer(group: EventLoopGroup, port: Int, useTLS: Bool) async throw | |
print("starting secure server") | ||
#else | ||
fatalError("'useTLS: true' passed to \(#function) but NIOSSL is not available") | ||
#endif // canImport(NIOSSL) | ||
#endif // canImport(NIOSSL) | ||
} else { | ||
print("starting insecure server") | ||
builder = Server.insecure(group: group) | ||
|
@@ -180,7 +181,7 @@ func makeClient( | |
.withTLS(trustRoots: .certificates([caCert.certificate])) | ||
#else | ||
fatalError("'useTLS: true' passed to \(#function) but NIOSSL is not available") | ||
#endif // canImport(NIOSSL) | ||
#endif // canImport(NIOSSL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a bug in swift-format. There should only be one space. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure it is; it's quite common to include two spaces before an inline comment. |
||
} else { | ||
builder = ClientConnection.insecure(group: group) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,19 +232,23 @@ internal final class AsyncServerHandler< | |
internal private(set) var handlerStateMachine: ServerHandlerStateMachine | ||
/// A bag of components used by the user handler. | ||
@usableFromInline | ||
internal private(set) var handlerComponents: Optional<ServerHandlerComponents< | ||
Request, | ||
Response, | ||
GRPCAsyncWriterSinkDelegate<(Response, Compression)> | ||
>> | ||
internal private(set) var handlerComponents: | ||
Optional< | ||
ServerHandlerComponents< | ||
Request, | ||
Response, | ||
GRPCAsyncWriterSinkDelegate<(Response, Compression)> | ||
> | ||
> | ||
|
||
/// The user provided function to execute. | ||
@usableFromInline | ||
internal let userHandler: @Sendable ( | ||
GRPCAsyncRequestStream<Request>, | ||
GRPCAsyncResponseStreamWriter<Response>, | ||
GRPCAsyncServerCallContext | ||
) async throws -> Void | ||
internal let userHandler: | ||
@Sendable ( | ||
GRPCAsyncRequestStream<Request>, | ||
GRPCAsyncResponseStreamWriter<Response>, | ||
GRPCAsyncServerCallContext | ||
) async throws -> Void | ||
|
||
@usableFromInline | ||
internal typealias AsyncSequenceProducer = NIOThrowingAsyncSequenceProducer< | ||
|
@@ -415,7 +419,7 @@ internal final class AsyncServerHandler< | |
internal func receiveInterceptedMetadata(_ headers: HPACKHeaders) { | ||
switch self.interceptorStateMachine.interceptedRequestMetadata() { | ||
case .forward: | ||
() // continue | ||
() // continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems wrong too. |
||
case .cancel: | ||
return self.cancel(error: nil) | ||
case .drop: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file is slightly different than the one in
swift-certificates
. Can we align on one please.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aligning on formatting rules will be a significant amount of churn (52,000 lines) that I don't think is worth doing. The aim of this PR is to reduce churn by switching to a tool which produces more stable formatting; in that light the rules chosen follow the existing ones where possible to minimise the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. On the other hand we are planning to do some significant work in gRPC and that might be a good opportunity to do this one time churn. Having an aligned formatting file across our repos is IMO worth it in the long run. We could take this churn and just tell git to ignore this one commit in blames so it shouldn't even show up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced: we still need to work on and maintain v1 for quite some time so will still bear the cost of the significant churn. Formatters let users avoid having to do the manual work of sticking to style guidelines so the benefit of having a consistent style across projects is very low, IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure we have to maintain the v1 but this is a one time churn right? If we decide that
swift-format
is the future for our project then IMO we should take that one time churn once and then have everything aligned.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it's one time but it's a very large change. As I said above, I think the benefit of having consistent style across projects is low, especially as we have tools which enforce the style for you.
What we're effectively debating is which style to use. I would much prefer we stick to the style used in this PR because it minimises the changes made, so much so that they can be reviewed with relative ease.