Skip to content

Commit 18f7dc4

Browse files
committed
Improve a bunch of diagnostic messages.
In general, this PR attempts to make messages clearer, easier to read, and less terse. I've also tried to unify punctuation surrounding identifiers and other syntactic constructs mentioned in messages to use single quotes (instead of backticks or nothing).
1 parent 8337523 commit 18f7dc4

26 files changed

+88
-87
lines changed

Sources/SwiftFormatRules/AlwaysUseLowerCamelCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,6 @@ extension Finding.Message {
217217
public static func nameMustBeLowerCamelCase(
218218
_ name: String, description: String
219219
) -> Finding.Message {
220-
"rename \(description) '\(name)' using lower-camel-case"
220+
"rename the \(description) '\(name)' using lowerCamelCase"
221221
}
222222
}

Sources/SwiftFormatRules/AmbiguousTrailingClosureOverload.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public final class AmbiguousTrailingClosureOverload: SyntaxLintRule {
7474

7575
extension Finding.Message {
7676
public static func ambiguousTrailingClosureOverload(_ decl: String) -> Finding.Message {
77-
"rename '\(decl)' so it is no longer ambiguous with a trailing closure"
77+
"rename '\(decl)' so it is no longer ambiguous when called with a trailing closure"
7878
}
7979

8080
public static func otherAmbiguousOverloadHere(_ decl: String) -> Finding.Message {

Sources/SwiftFormatRules/DontRepeatTypeInStaticProperties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ public final class DontRepeatTypeInStaticProperties: SyntaxLintRule {
104104

105105
extension Finding.Message {
106106
public static func removeTypeFromName(name: String, type: Substring) -> Finding.Message {
107-
"remove '\(type)' from '\(name)'"
107+
"remove the suffix '\(type)' from the name of the variable '\(name)'"
108108
}
109109
}

Sources/SwiftFormatRules/FullyIndirectEnum.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ public final class FullyIndirectEnum: SyntaxFormatRule {
109109

110110
extension Finding.Message {
111111
public static func moveIndirectKeywordToEnumDecl(name: String) -> Finding.Message {
112-
"move 'indirect' to \(name) enum declaration when all cases are indirect"
112+
"move 'indirect' before the enum declaration '\(name)' when all cases are indirect"
113113
}
114114
}

Sources/SwiftFormatRules/NeverUseImplicitlyUnwrappedOptionals.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ public final class NeverUseImplicitlyUnwrappedOptionals: SyntaxLintRule {
6565

6666
extension Finding.Message {
6767
public static func doNotUseImplicitUnwrapping(identifier: String) -> Finding.Message {
68-
"use \(identifier) or \(identifier)? instead of \(identifier)!"
68+
"use '\(identifier)' or '\(identifier)?' instead of '\(identifier)!'"
6969
}
7070
}

Sources/SwiftFormatRules/NoAccessLevelOnExtensionDeclaration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ public final class NoAccessLevelOnExtensionDeclaration: SyntaxFormatRule {
102102

103103
extension Finding.Message {
104104
public static func removeRedundantAccessKeyword(name: String) -> Finding.Message {
105-
"remove redundant 'internal' access keyword from \(name)"
105+
"remove redundant 'internal' access keyword from '\(name)'"
106106
}
107107

108108
public static func moveAccessKeyword(keyword: String) -> Finding.Message {
109-
"specify \(keyword) access level for each member inside the extension"
109+
"move the '\(keyword)' access keyword to precede each member inside the extension"
110110
}
111111
}

Sources/SwiftFormatRules/NoAssignmentInExpressions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,5 @@ public final class NoAssignmentInExpressions: SyntaxFormatRule {
163163

164164
extension Finding.Message {
165165
public static let moveAssignmentToOwnStatement: Finding.Message =
166-
"move assignment expression into its own statement"
166+
"move this assignment expression into its own statement"
167167
}

Sources/SwiftFormatRules/NoBlockComments.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ public final class NoBlockComments: SyntaxLintRule {
3030

3131
extension Finding.Message {
3232
public static let avoidBlockComment: Finding.Message =
33-
"replace block comment with line comments"
33+
"replace this block comment with line comments"
3434
}

Sources/SwiftFormatRules/NoCasesWithOnlyFallthrough.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public final class NoCasesWithOnlyFallthrough: SyntaxFormatRule {
183183
// Diagnose the cases being collapsed. We do this for all but the last one in the array; the
184184
// last one isn't diagnosed because it will contain the body that applies to all the previous
185185
// cases.
186-
diagnose(.collapseCase(name: label.caseItems.with(\.leadingTrivia, []).with(\.trailingTrivia, []).description), on: label)
186+
diagnose(.collapseCase, on: label)
187187
}
188188
newCaseItems.append(contentsOf: labels.last!.caseItems)
189189

@@ -219,7 +219,7 @@ extension TriviaPiece {
219219
}
220220

221221
extension Finding.Message {
222-
public static func collapseCase(name: String) -> Finding.Message {
223-
"combine fallthrough-only case \(name) with a following case"
222+
public static var collapseCase: Finding.Message {
223+
"combine this fallthrough-only 'case' and the following 'case' into a single 'case'"
224224
}
225225
}

Sources/SwiftFormatRules/NoEmptyTrailingClosureParentheses.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public final class NoEmptyTrailingClosureParentheses: SyntaxFormatRule {
5353

5454
extension Finding.Message {
5555
public static func removeEmptyTrailingParentheses(name: String) -> Finding.Message {
56-
"remove '()' after \(name)"
56+
"remove the empty parentheses following '\(name)'"
5757
}
5858
}

0 commit comments

Comments
 (0)