Skip to content

Commit ac99928

Browse files
committed
Make all Finding.Message extensions file-private.
Now that our tests verify the actual text of the diagnostics, we don't need these helpers to be visible outside their file. This gets rid of some noise when you're writing `diagnose` calls in rules because you'll only see the ones that are relevant.
1 parent 0e5e7b9 commit ac99928

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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 7 additions & 7 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 4 deletions
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
}

0 commit comments

Comments
 (0)