File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
Sources/SwiftFormat/Rules
Tests/SwiftFormatTests/Rules Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -131,12 +131,13 @@ public final class ValidateDocumentationComments: SyntaxLintRule {
131
131
throwsDescription: Paragraph ? ,
132
132
node: DeclSyntax
133
133
) {
134
- // If a function is marked as `rethrows`, it doesn't have any errors of its
135
- // own that should be documented. So only require documentation for
136
- // functions marked `throws`.
134
+ // Documentation is required for functions marked as `throws`.
135
+ // For functions marked as `rethrows`, documentation is not enforced
136
+ // since they don’t introduce new errors of their own.
137
+ // However, it can still be included if needed.
137
138
let needsThrowsDesc = throwsOrRethrowsKeyword? . tokenKind == . keyword( . throws)
138
139
139
- if !needsThrowsDesc && throwsDescription != nil {
140
+ if throwsOrRethrowsKeyword == nil && throwsDescription != nil {
140
141
diagnose (
141
142
. removeThrowsComment( funcName: name) ,
142
143
on: throwsOrRethrowsKeyword ?? node. firstToken ( viewMode: . sourceAccurate)
Original file line number Diff line number Diff line change @@ -95,7 +95,6 @@ final class ValidateDocumentationCommentsTests: LintOrFormatRuleTestCase {
95
95
findings: [
96
96
FindingSpec ( " 1️⃣ " , message: " remove the 'Throws:' sections of 'doesNotThrow'; it does not throw any errors " ) ,
97
97
FindingSpec ( " 2️⃣ " , message: " add a 'Throws:' section to document the errors thrown by 'doesThrow' " ) ,
98
- FindingSpec ( " 3️⃣ " , message: " remove the 'Throws:' sections of 'doesRethrow'; it does not throw any errors " ) ,
99
98
]
100
99
)
101
100
}
You can’t perform that action at this time.
0 commit comments