Skip to content

Commit 99c09a4

Browse files
authored
Merge pull request #636 from allevato/private-diags
Make all `Finding.Message` extensions file-private.
2 parents 0e5e7b9 + ac99928 commit 99c09a4

Some content is hidden

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

42 files changed

+71
-124
lines changed

Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -790,12 +790,12 @@ public class PrettyPrinter {
790790
}
791791

792792
extension Finding.Message {
793-
public static let moveEndOfLineComment: Finding.Message =
793+
fileprivate static let moveEndOfLineComment: Finding.Message =
794794
"move end-of-line comment that exceeds the line length"
795795

796-
public static let addTrailingComma: Finding.Message =
796+
fileprivate static let addTrailingComma: Finding.Message =
797797
"add trailing comma to the last element in multiline collection literal"
798798

799-
public static let removeTrailingComma: Finding.Message =
799+
fileprivate static let removeTrailingComma: Finding.Message =
800800
"remove trailing comma from the last element in single line collection literal"
801801
}

Sources/SwiftFormat/PrettyPrint/WhitespaceLinter.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ extension WhitespaceIndentation {
432432
}
433433

434434
extension Finding.Message {
435-
public static let trailingWhitespaceError: Finding.Message = "remove trailing whitespace"
435+
fileprivate static let trailingWhitespaceError: Finding.Message = "remove trailing whitespace"
436436

437-
public static func indentationError(
437+
fileprivate static func indentationError(
438438
expected expectedIndentation: WhitespaceIndentation,
439439
actual actualIndentation: WhitespaceIndentation
440440
) -> Finding.Message {
@@ -470,20 +470,20 @@ extension Finding.Message {
470470
}
471471
}
472472

473-
public static func spacingError(_ spaces: Int) -> Finding.Message {
473+
fileprivate static func spacingError(_ spaces: Int) -> Finding.Message {
474474
let verb = spaces > 0 ? "add" : "remove"
475475
let noun = abs(spaces) == 1 ? "space" : "spaces"
476476
return "\(verb) \(abs(spaces)) \(noun)"
477477
}
478478

479-
public static let spacingCharError: Finding.Message = "use spaces for spacing"
479+
fileprivate static let spacingCharError: Finding.Message = "use spaces for spacing"
480480

481-
public static let removeLineError: Finding.Message = "remove line break"
481+
fileprivate static let removeLineError: Finding.Message = "remove line break"
482482

483-
public static func addLinesError(_ lines: Int) -> Finding.Message {
483+
fileprivate static func addLinesError(_ lines: Int) -> Finding.Message {
484484
let noun = lines == 1 ? "break" : "breaks"
485485
return "add \(lines) line \(noun)"
486486
}
487487

488-
public static let lineLengthError: Finding.Message = "line is too long"
488+
fileprivate static let lineLengthError: Finding.Message = "line is too long"
489489
}

Sources/SwiftFormat/Rules/AllPublicDeclarationsHaveDocumentation.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ public final class AllPublicDeclarationsHaveDocumentation: SyntaxLintRule {
8787
}
8888

8989
extension Finding.Message {
90-
@_spi(Rules)
91-
public static func declRequiresComment(_ name: String) -> Finding.Message {
90+
fileprivate static func declRequiresComment(_ name: String) -> Finding.Message {
9291
"add a documentation comment for '\(name)'"
9392
}
9493
}

Sources/SwiftFormat/Rules/AlwaysUseLiteralForEmptyCollectionInit.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ public final class AlwaysUseLiteralForEmptyCollectionInit : SyntaxFormatRule {
201201
}
202202

203203
extension Finding.Message {
204-
public static func refactorIntoEmptyLiteral(replace: String, with: String) -> Finding.Message {
204+
fileprivate static func refactorIntoEmptyLiteral(replace: String, with: String)
205+
-> Finding.Message
206+
{
205207
"replace '\(replace)' with '\(with)'"
206208
}
207209
}

Sources/SwiftFormat/Rules/AlwaysUseLowerCamelCase.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ extension ReturnClauseSyntax {
214214
}
215215

216216
extension Finding.Message {
217-
@_spi(Rules)
218-
public static func nameMustBeLowerCamelCase(
217+
fileprivate static func nameMustBeLowerCamelCase(
219218
_ name: String, description: String
220219
) -> Finding.Message {
221220
"rename the \(description) '\(name)' using lowerCamelCase"

Sources/SwiftFormat/Rules/AmbiguousTrailingClosureOverload.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ public final class AmbiguousTrailingClosureOverload: SyntaxLintRule {
7373
}
7474

7575
extension Finding.Message {
76-
@_spi(Rules)
77-
public static func ambiguousTrailingClosureOverload(_ decl: String) -> Finding.Message {
76+
fileprivate static func ambiguousTrailingClosureOverload(_ decl: String) -> Finding.Message {
7877
"rename '\(decl)' so it is no longer ambiguous when called with a trailing closure"
7978
}
8079

81-
@_spi(Rules)
82-
public static func otherAmbiguousOverloadHere(_ decl: String) -> Finding.Message {
80+
fileprivate static func otherAmbiguousOverloadHere(_ decl: String) -> Finding.Message {
8381
"ambiguous overload '\(decl)' is here"
8482
}
8583
}

Sources/SwiftFormat/Rules/BeginDocumentationCommentWithOneLineSummary.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,13 @@ public final class BeginDocumentationCommentWithOneLineSummary: SyntaxLintRule {
195195
}
196196

197197
extension Finding.Message {
198-
@_spi(Rules)
199-
public static func terminateSentenceWithPeriod<Sentence: StringProtocol>(_ text: Sentence)
198+
fileprivate static func terminateSentenceWithPeriod<Sentence: StringProtocol>(_ text: Sentence)
200199
-> Finding.Message
201200
{
202201
"terminate this sentence with a period: \"\(text)\""
203202
}
204203

205-
@_spi(Rules)
206-
public static func addBlankLineAfterFirstSentence<Sentence: StringProtocol>(_ text: Sentence)
204+
fileprivate static func addBlankLineAfterFirstSentence<Sentence: StringProtocol>(_ text: Sentence)
207205
-> Finding.Message
208206
{
209207
"add a blank comment line after this sentence: \"\(text)\""

Sources/SwiftFormat/Rules/DoNotUseSemicolons.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,8 @@ public final class DoNotUseSemicolons: SyntaxFormatRule {
111111
}
112112

113113
extension Finding.Message {
114-
@_spi(Rules)
115-
public static let removeSemicolon: Finding.Message = "remove ';'"
114+
fileprivate static let removeSemicolon: Finding.Message = "remove ';'"
116115

117-
@_spi(Rules)
118-
public static let removeSemicolonAndMove: Finding.Message =
116+
fileprivate static let removeSemicolonAndMove: Finding.Message =
119117
"remove ';' and move the next statement to a new line"
120118
}

Sources/SwiftFormat/Rules/DontRepeatTypeInStaticProperties.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ public final class DontRepeatTypeInStaticProperties: SyntaxLintRule {
106106
}
107107

108108
extension Finding.Message {
109-
@_spi(Rules)
110-
public static func removeTypeFromName(name: String, type: Substring) -> Finding.Message {
109+
fileprivate static func removeTypeFromName(name: String, type: Substring) -> Finding.Message {
111110
"remove the suffix '\(type)' from the name of the variable '\(name)'"
112111
}
113112
}

Sources/SwiftFormat/Rules/FileScopedDeclarationPrivacy.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,9 @@ public final class FileScopedDeclarationPrivacy: SyntaxFormatRule {
160160
}
161161

162162
extension Finding.Message {
163-
@_spi(Rules)
164-
public static let replacePrivateWithFileprivate: Finding.Message =
163+
fileprivate static let replacePrivateWithFileprivate: Finding.Message =
165164
"replace 'private' with 'fileprivate' on file-scoped declarations"
166165

167-
@_spi(Rules)
168-
public static let replaceFileprivateWithPrivate: Finding.Message =
166+
fileprivate static let replaceFileprivateWithPrivate: Finding.Message =
169167
"replace 'fileprivate' with 'private' on file-scoped declarations"
170168
}

Sources/SwiftFormat/Rules/FullyIndirectEnum.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ public final class FullyIndirectEnum: SyntaxFormatRule {
123123
}
124124

125125
extension Finding.Message {
126-
@_spi(Rules)
127-
public static func moveIndirectKeywordToEnumDecl(name: String) -> Finding.Message {
126+
fileprivate static func moveIndirectKeywordToEnumDecl(name: String) -> Finding.Message {
128127
"declare enum '\(name)' itself as indirect when all cases are indirect"
129128
}
130129

131-
public static let removeIndirect: Finding.Message = "remove 'indirect' here"
130+
fileprivate static let removeIndirect: Finding.Message = "remove 'indirect' here"
132131
}

Sources/SwiftFormat/Rules/GroupNumericLiterals.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ public final class GroupNumericLiterals: SyntaxFormatRule {
8080
}
8181

8282
extension Finding.Message {
83-
@_spi(Rules)
84-
public static func groupNumericLiteral(every stride: Int, base: String) -> Finding.Message {
83+
fileprivate static func groupNumericLiteral(every stride: Int, base: String) -> Finding.Message {
8584
return "group every \(stride) digits in this \(base) literal using a '_' separator"
8685
}
8786
}

Sources/SwiftFormat/Rules/IdentifiersMustBeASCII.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public final class IdentifiersMustBeASCII: SyntaxLintRule {
3131
}
3232

3333
extension Finding.Message {
34-
@_spi(Rules)
35-
public static func nonASCIICharsNotAllowed(
34+
fileprivate static func nonASCIICharsNotAllowed(
3635
_ invalidCharacters: [String], _ identifierName: String
3736
) -> Finding.Message {
3837
"""

Sources/SwiftFormat/Rules/NeverForceUnwrap.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ public final class NeverForceUnwrap: SyntaxLintRule {
5050
}
5151

5252
extension Finding.Message {
53-
@_spi(Rules)
54-
public static func doNotForceUnwrap(name: String) -> Finding.Message {
53+
fileprivate static func doNotForceUnwrap(name: String) -> Finding.Message {
5554
"do not force unwrap '\(name)'"
5655
}
5756

58-
@_spi(Rules)
59-
public static func doNotForceCast(name: String) -> Finding.Message {
57+
fileprivate static func doNotForceCast(name: String) -> Finding.Message {
6058
"do not force cast to '\(name)'"
6159
}
6260
}

Sources/SwiftFormat/Rules/NeverUseForceTry.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,5 @@ public final class NeverUseForceTry: SyntaxLintRule {
4444
}
4545

4646
extension Finding.Message {
47-
@_spi(Rules)
48-
public static let doNotForceTry: Finding.Message = "do not use force try"
47+
fileprivate static let doNotForceTry: Finding.Message = "do not use force try"
4948
}

Sources/SwiftFormat/Rules/NeverUseImplicitlyUnwrappedOptionals.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public final class NeverUseImplicitlyUnwrappedOptionals: SyntaxLintRule {
6161
}
6262

6363
extension Finding.Message {
64-
@_spi(Rules)
65-
public static func doNotUseImplicitUnwrapping(identifier: String) -> Finding.Message {
64+
fileprivate static func doNotUseImplicitUnwrapping(identifier: String) -> Finding.Message {
6665
"use '\(identifier)' or '\(identifier)?' instead of '\(identifier)!'"
6766
}
6867
}

Sources/SwiftFormat/Rules/NoAccessLevelOnExtensionDeclaration.swift

+4-8
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,18 @@ public final class NoAccessLevelOnExtensionDeclaration: SyntaxFormatRule {
105105
}
106106

107107
extension Finding.Message {
108-
@_spi(Rules)
109-
public static let removeRedundantAccessKeyword: Finding.Message =
108+
fileprivate static let removeRedundantAccessKeyword: Finding.Message =
110109
"remove this redundant 'internal' access modifier from this extension"
111110

112-
@_spi(Rules)
113-
public static func moveAccessKeyword(keyword: String) -> Finding.Message {
111+
fileprivate static func moveAccessKeyword(keyword: String) -> Finding.Message {
114112
"move this '\(keyword)' access modifier to precede each member inside this extension"
115113
}
116114

117-
@_spi(Rules)
118-
public static func moveAccessKeywordAndMakeFileprivate(keyword: String) -> Finding.Message {
115+
fileprivate static func moveAccessKeywordAndMakeFileprivate(keyword: String) -> Finding.Message {
119116
"remove this '\(keyword)' access modifier and declare each member inside this extension as 'fileprivate'"
120117
}
121118

122-
@_spi(Rules)
123-
public static func addModifierToExtensionMember(keyword: String) -> Finding.Message {
119+
fileprivate static func addModifierToExtensionMember(keyword: String) -> Finding.Message {
124120
"add '\(keyword)' access modifier to this declaration"
125121
}
126122
}

Sources/SwiftFormat/Rules/NoAssignmentInExpressions.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ public final class NoAssignmentInExpressions: SyntaxFormatRule {
157157
}
158158

159159
extension Finding.Message {
160-
@_spi(Rules)
161-
public static let moveAssignmentToOwnStatement: Finding.Message =
160+
fileprivate static let moveAssignmentToOwnStatement: Finding.Message =
162161
"move this assignment expression into its own statement"
163162
}

Sources/SwiftFormat/Rules/NoBlockComments.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public final class NoBlockComments: SyntaxLintRule {
2929
}
3030

3131
extension Finding.Message {
32-
@_spi(Rules)
33-
public static let avoidBlockComment: Finding.Message =
32+
fileprivate static let avoidBlockComment: Finding.Message =
3433
"replace this block comment with line comments"
3534
}

Sources/SwiftFormat/Rules/NoCasesWithOnlyFallthrough.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ extension TriviaPiece {
224224
}
225225

226226
extension Finding.Message {
227-
@_spi(Rules)
228-
public static var collapseCase: Finding.Message {
227+
fileprivate static var collapseCase: Finding.Message {
229228
"combine this fallthrough-only 'case' and the following 'case' into a single 'case'"
230229
}
231230
}

Sources/SwiftFormat/Rules/NoEmptyTrailingClosureParentheses.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public final class NoEmptyTrailingClosureParentheses: SyntaxFormatRule {
5454
}
5555

5656
extension Finding.Message {
57-
@_spi(Rules)
58-
public static func removeEmptyTrailingParentheses(name: String) -> Finding.Message {
57+
fileprivate static func removeEmptyTrailingParentheses(name: String) -> Finding.Message {
5958
"remove the empty parentheses following '\(name)'"
6059
}
6160
}

Sources/SwiftFormat/Rules/NoLabelsInCasePatterns.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ public final class NoLabelsInCasePatterns: SyntaxFormatRule {
7575
}
7676

7777
extension Finding.Message {
78-
@_spi(Rules)
79-
public static func removeRedundantLabel(name: String) -> Finding.Message {
78+
fileprivate static func removeRedundantLabel(name: String) -> Finding.Message {
8079
"remove the label '\(name)' from this 'case' pattern"
8180
}
8281
}

Sources/SwiftFormat/Rules/NoLeadingUnderscores.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ public final class NoLeadingUnderscores: SyntaxLintRule {
125125
}
126126

127127
extension Finding.Message {
128-
@_spi(Rules)
129-
public static func doNotStartWithUnderscore(identifier: String) -> Finding.Message {
128+
fileprivate static func doNotStartWithUnderscore(identifier: String) -> Finding.Message {
130129
"remove the leading '_' from the name '\(identifier)'"
131130
}
132131
}

Sources/SwiftFormat/Rules/NoParensAroundConditions.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ public final class NoParensAroundConditions: SyntaxFormatRule {
121121
}
122122

123123
extension Finding.Message {
124-
@_spi(Rules)
125-
public static let removeParensAroundExpression: Finding.Message =
124+
fileprivate static let removeParensAroundExpression: Finding.Message =
126125
"remove the parentheses around this expression"
127126
}

Sources/SwiftFormat/Rules/NoVoidReturnOnFunctionSignature.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ public final class NoVoidReturnOnFunctionSignature: SyntaxFormatRule {
5252
}
5353

5454
extension Finding.Message {
55-
@_spi(Rules)
56-
public static func removeRedundantReturn(_ type: String) -> Finding.Message {
55+
fileprivate static func removeRedundantReturn(_ type: String) -> Finding.Message {
5756
"remove the explicit return type '\(type)' from this function"
5857
}
5958
}

Sources/SwiftFormat/Rules/OmitExplicitReturns.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,6 @@ public final class OmitExplicitReturns: SyntaxFormatRule {
144144
}
145145

146146
extension Finding.Message {
147-
public static let omitReturnStatement: Finding.Message =
147+
fileprivate static let omitReturnStatement: Finding.Message =
148148
"'return' can be omitted because body consists of a single expression"
149149
}

Sources/SwiftFormat/Rules/OneCasePerLine.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ public final class OneCasePerLine: SyntaxFormatRule {
137137
}
138138

139139
extension Finding.Message {
140-
@_spi(Rules)
141-
public static func moveAssociatedOrRawValueCase(name: String) -> Finding.Message {
140+
fileprivate static func moveAssociatedOrRawValueCase(name: String) -> Finding.Message {
142141
"move '\(name)' to its own 'case' declaration"
143142
}
144143
}

Sources/SwiftFormat/Rules/OneVariableDeclarationPerLine.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public final class OneVariableDeclarationPerLine: SyntaxFormatRule {
7474
}
7575

7676
extension Finding.Message {
77-
@_spi(Rules)
78-
public static func onlyOneVariableDeclaration(specifier: String) -> Finding.Message {
77+
fileprivate static func onlyOneVariableDeclaration(specifier: String) -> Finding.Message {
7978
"split this variable declaration to introduce only one variable per '\(specifier)'"
8079
}
8180
}

Sources/SwiftFormat/Rules/OnlyOneTrailingClosureArgument.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public final class OnlyOneTrailingClosureArgument: SyntaxLintRule {
3030
}
3131

3232
extension Finding.Message {
33-
@_spi(Rules)
34-
public static let removeTrailingClosure: Finding.Message =
33+
fileprivate static let removeTrailingClosure: Finding.Message =
3534
"revise this function call to avoid using both closure arguments and a trailing closure"
3635
}

Sources/SwiftFormat/Rules/OrderedImports.swift

+4-8
Original file line numberDiff line numberDiff line change
@@ -569,17 +569,13 @@ extension Line: CustomDebugStringConvertible {
569569
}
570570

571571
extension Finding.Message {
572-
@_spi(Rules)
573-
public static let placeAtTopOfFile: Finding.Message = "place imports at the top of the file"
572+
fileprivate static let placeAtTopOfFile: Finding.Message = "place imports at the top of the file"
574573

575-
@_spi(Rules)
576-
public static func groupImports(before: LineType, after: LineType) -> Finding.Message {
574+
fileprivate static func groupImports(before: LineType, after: LineType) -> Finding.Message {
577575
"place \(before) imports before \(after) imports"
578576
}
579577

580-
@_spi(Rules)
581-
public static let removeDuplicateImport: Finding.Message = "remove this duplicate import"
578+
fileprivate static let removeDuplicateImport: Finding.Message = "remove this duplicate import"
582579

583-
@_spi(Rules)
584-
public static let sortImports: Finding.Message = "sort import statements lexicographically"
580+
fileprivate static let sortImports: Finding.Message = "sort import statements lexicographically"
585581
}

Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public final class ReplaceForEachWithForLoop : SyntaxLintRule {
4747
}
4848

4949
extension Finding.Message {
50-
public static func replaceForEachWithLoop() -> Finding.Message {
50+
fileprivate static func replaceForEachWithLoop() -> Finding.Message {
5151
"replace use of '.forEach { ... }' with for-in loop"
5252
}
5353
}

0 commit comments

Comments
 (0)