Skip to content

Commit 175d363

Browse files
committed
.swift-format: Specify an exhaustive configuration
Not specifying a rule disables checking for that rule rather than assumes the default value, which was not the expected effect. This applies the default configuration, keeping current settings and disabling 2 default-enabled rules: `DoNotUseSemicolons` and `NoAccessLevelOnExtensionDeclaration`.
1 parent a703b24 commit 175d363

File tree

81 files changed

+233
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+233
-175
lines changed

.swift-format

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,78 @@
11
{
2+
"fileScopedDeclarationPrivacy": {
3+
"accessLevel": "private"
4+
},
25
"indentConditionalCompilationBlocks": false,
6+
"indentSwitchCaseLabels": false,
37
"indentation": {
48
"spaces": 2
59
},
10+
"lineBreakAroundMultilineExpressionChainComponents": false,
11+
"lineBreakBeforeControlFlowKeywords": false,
612
"lineBreakBeforeEachArgument": true,
13+
"lineBreakBeforeEachGenericRequirement": false,
14+
"lineBreakBetweenDeclarationAttributes": false,
715
"lineLength": 120,
16+
"maximumBlankLines": 1,
17+
"multiElementCollectionTrailingCommas": true,
18+
"noAssignmentInExpressions": {
19+
"allowedFunctions": [
20+
"XCTAssertNoThrow"
21+
]
22+
},
823
"prioritizeKeepingFunctionOutputTogether": true,
24+
"reflowMultilineStringLiterals": {
25+
"never": {
26+
27+
}
28+
},
29+
"respectsExistingLineBreaks": true,
930
"rules": {
31+
"AllPublicDeclarationsHaveDocumentation": false,
32+
"AlwaysUseLiteralForEmptyCollectionInit": false,
1033
"AlwaysUseLowerCamelCase": false,
1134
"AmbiguousTrailingClosureOverload": false,
35+
"AvoidRetroactiveConformances": true,
36+
"BeginDocumentationCommentWithOneLineSummary": false,
37+
"DoNotUseSemicolons": false,
38+
"DontRepeatTypeInStaticProperties": true,
39+
"FileScopedDeclarationPrivacy": true,
40+
"FullyIndirectEnum": true,
41+
"GroupNumericLiterals": true,
42+
"IdentifiersMustBeASCII": true,
43+
"NeverForceUnwrap": false,
44+
"NeverUseForceTry": false,
45+
"NeverUseImplicitlyUnwrappedOptionals": false,
46+
"NoAccessLevelOnExtensionDeclaration": false,
47+
"NoAssignmentInExpressions": true,
1248
"NoBlockComments": false,
49+
"NoCasesWithOnlyFallthrough": true,
50+
"NoEmptyLinesOpeningClosingBraces": false,
51+
"NoEmptyTrailingClosureParentheses": true,
52+
"NoLabelsInCasePatterns": true,
53+
"NoLeadingUnderscores": false,
54+
"NoParensAroundConditions": true,
55+
"NoPlaygroundLiterals": true,
1356
"NoVoidReturnOnFunctionSignature": true,
57+
"OmitExplicitReturns": false,
58+
"OneCasePerLine": true,
59+
"OneVariableDeclarationPerLine": true,
60+
"OnlyOneTrailingClosureArgument": true,
1461
"OrderedImports": true,
62+
"ReplaceForEachWithForLoop": true,
1563
"ReturnVoidInsteadOfEmptyTuple": true,
64+
"TypeNamesShouldBeCapitalized": true,
65+
"UseEarlyExits": false,
66+
"UseExplicitNilCheckInConditions": true,
1667
"UseLetInEveryBoundCaseVariable": false,
68+
"UseShorthandTypeNames": true,
69+
"UseSingleLinePropertyGetter": true,
1770
"UseSynthesizedInitializer": false,
71+
"UseTripleSlashForDocumentationComments": true,
72+
"UseWhereClausesInForLoops": false,
73+
"ValidateDocumentationComments": false
1874
},
75+
"spacesAroundRangeFormationOperators": false,
76+
"spacesBeforeEndOfLineComments": 2,
1977
"version": 1,
2078
}

CodeGeneration/Sources/SyntaxSupport/Child.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ public class Child: NodeChoiceConvertible {
129129

130130
public var syntaxNodeKind: SyntaxNodeKind {
131131
switch kind {
132-
case .node(kind: let kind):
132+
case .node(let kind):
133133
return kind
134134
case .nodeChoices:
135135
return .syntax
136-
case .collection(kind: let kind, _, _, _, _):
136+
case .collection(let kind, _, _, _, _):
137137
return kind
138138
case .token:
139139
return .token
@@ -284,7 +284,7 @@ public class Child: NodeChoiceConvertible {
284284
return choices.isEmpty
285285
case .node(let kind):
286286
return kind.isBase
287-
case .collection(kind: let kind, _, _, _, _):
287+
case .collection(let kind, _, _, _, _):
288288
return kind.isBase
289289
case .token:
290290
return false

CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct GrammarGenerator {
4141
case .nodeChoices(let choices, _):
4242
let choicesDescriptions = choices.map { grammar(for: $0) }
4343
return "(\(choicesDescriptions.joined(separator: " | ")))\(optionality)"
44-
case .collection(kind: let kind, _, _, _, _):
44+
case .collection(let kind, _, _, _, _):
4545
return "\(kind.doccLink)\(optionality)"
4646
case .token(let choices, _, _):
4747
if choices.count == 1 {

CodeGeneration/Sources/SyntaxSupport/Node.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public struct LayoutNode {
284284
/// This includes unexpected children
285285
public var children: [Child] {
286286
switch node.data {
287-
case .layout(children: let children, childHistory: _, traits: _):
287+
case .layout(let children, childHistory: _, traits: _):
288288
return children
289289
case .collection:
290290
preconditionFailure("NodeLayoutView must wrap a Node with data `.layout`")
@@ -299,7 +299,7 @@ public struct LayoutNode {
299299
/// The history of the layout node's children.
300300
public var childHistory: Child.History {
301301
switch node.data {
302-
case .layout(children: _, childHistory: let childHistory, traits: _):
302+
case .layout(children: _, let childHistory, traits: _):
303303
return childHistory
304304
case .collection:
305305
preconditionFailure("NodeLayoutView must wrap a Node with data `.layout`")
@@ -309,7 +309,7 @@ public struct LayoutNode {
309309
/// Traits that the node conforms to.
310310
public var traits: [String] {
311311
switch node.data {
312-
case .layout(children: _, childHistory: _, traits: let traits):
312+
case .layout(children: _, childHistory: _, let traits):
313313
return traits
314314
case .collection:
315315
preconditionFailure("NodeLayoutView must wrap a Node with data `.layout`")
@@ -361,7 +361,7 @@ public struct CollectionNode {
361361
switch node.data {
362362
case .layout:
363363
preconditionFailure("NodeLayoutView must wrap a Node with data `.collection`")
364-
case .collection(choices: let choices):
364+
case .collection(let choices):
365365
return choices
366366
}
367367
}
@@ -391,15 +391,15 @@ fileprivate extension Child {
391391
return [kind]
392392
case .nodeChoices(let choices, _):
393393
return choices.flatMap(\.kinds)
394-
case .collection(kind: let kind, _, _, _, _):
394+
case .collection(let kind, _, _, _, _):
395395
return [kind]
396396
case .token:
397397
return [.token]
398398
}
399399
}
400400
}
401401

402-
fileprivate func interleaveUnexpectedChildren(_ children: [Child]) -> [Child] {
402+
private func interleaveUnexpectedChildren(_ children: [Child]) -> [Child] {
403403
let liftedChildren = children.lazy.map(Optional.some)
404404
let pairedChildren = zip([nil] + liftedChildren, liftedChildren + [nil])
405405

CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ extension Child {
2929
public var buildableType: SyntaxBuildableType {
3030
let buildableKind: SyntaxOrTokenNodeKind
3131
switch kind {
32-
case .node(kind: let kind):
32+
case .node(let kind):
3333
buildableKind = .node(kind: kind)
3434
case .nodeChoices:
3535
buildableKind = .node(kind: .syntax)
36-
case .collection(kind: let kind, _, _, _, _):
36+
case .collection(let kind, _, _, _, _):
3737
buildableKind = .node(kind: kind)
3838
case .token:
3939
buildableKind = .token(self.tokenKind!)

CodeGeneration/Sources/Utils/SyntaxBuildableType.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public struct SyntaxBuildableType: Hashable {
122122
/// without any question marks attached.
123123
public var syntaxBaseName: TypeSyntax {
124124
switch kind {
125-
case .node(kind: let kind):
125+
case .node(let kind):
126126
return kind.syntaxType
127127
case .token:
128128
return "TokenSyntax"
@@ -150,7 +150,7 @@ public struct SyntaxBuildableType: Hashable {
150150
/// that can be used to build the collection.
151151
public var resultBuilderType: TypeSyntax {
152152
switch kind {
153-
case .node(kind: let kind):
153+
case .node(let kind):
154154
return TypeSyntax("\(raw: kind.uppercasedFirstWordRawValue)Builder")
155155
case .token:
156156
preconditionFailure("Tokens cannot be constructed using result builders")

CodeGeneration/Sources/generate-swift-syntax/GenerateSwiftSyntax.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ struct GenerateSwiftSyntax: AsyncParsableCommand {
226226

227227
}
228228

229-
fileprivate func generateFile(
229+
private func generateFile(
230230
contents: @autoclosure () -> String,
231231
destination: URL,
232232
verbose: Bool

CodeGeneration/Sources/generate-swift-syntax/InitSignature+Extensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ extension InitSignature {
191191
}
192192
}
193193

194-
fileprivate func convertFromSyntaxProtocolToSyntaxType(
194+
private func convertFromSyntaxProtocolToSyntaxType(
195195
child: Child
196196
) -> ExprSyntax {
197197
let childName = child.identifier
@@ -350,7 +350,7 @@ extension InitParameterMapping {
350350
func makeArgumentExpr() -> LabeledExprSyntax {
351351
let argValue =
352352
switch argument {
353-
case .decl(olderChild: let olderChild):
353+
case .decl(let olderChild):
354354
ExprSyntax(DeclReferenceExprSyntax(baseName: olderChild.baseCallName))
355355

356356
case .nestedInit(let initArgs):

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/RawSyntaxValidationFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ let rawSyntaxValidationFile = try! SourceFileSyntax(leadingTrivia: copyrightHead
209209
}
210210

211211
ExprSyntax("assertAnyHasNoError(kind, \(raw: index), \(verifiedChoices))")
212-
case .token(choices: let choices, requiresLeadingSpace: _, requiresTrailingSpace: _):
212+
case .token(let choices, requiresLeadingSpace: _, requiresTrailingSpace: _):
213213
let choices = ArrayExprSyntax {
214214
for choice in choices {
215215
switch choice {

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/TriviaPiecesFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ let triviaPiecesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
268268
try! generateIsHelpers(for: "RawTriviaPiece")
269269
}
270270

271-
fileprivate func generateIsHelpers(for pieceName: TokenSyntax) throws -> ExtensionDeclSyntax {
271+
private func generateIsHelpers(for pieceName: TokenSyntax) throws -> ExtensionDeclSyntax {
272272
func generateHelper(_ header: SyntaxNodeString, trait: TriviaTraits) throws -> VariableDeclSyntax {
273273
try VariableDeclSyntax(header) {
274274
try SwitchExprSyntax("switch self") {

0 commit comments

Comments
 (0)