Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ public final class ValidateDocumentationComments: SyntaxLintRule {
throwsDescription: Paragraph?,
node: DeclSyntax
) {
// If a function is marked as `rethrows`, it doesn't have any errors of its
// own that should be documented. So only require documentation for
// functions marked `throws`.
// Documentation is required for functions marked as `throws`.
// For functions marked as `rethrows`, documentation is not enforced
// since they don’t introduce new errors of their own.
// However, it can still be included if needed.
let needsThrowsDesc = throwsOrRethrowsKeyword?.tokenKind == .keyword(.throws)

if !needsThrowsDesc && throwsDescription != nil {
if throwsOrRethrowsKeyword == nil && throwsDescription != nil {
diagnose(
.removeThrowsComment(funcName: name),
on: throwsOrRethrowsKeyword ?? node.firstToken(viewMode: .sourceAccurate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ final class ValidateDocumentationCommentsTests: LintOrFormatRuleTestCase {
findings: [
FindingSpec("1️⃣", message: "remove the 'Throws:' sections of 'doesNotThrow'; it does not throw any errors"),
FindingSpec("2️⃣", message: "add a 'Throws:' section to document the errors thrown by 'doesThrow'"),
FindingSpec("3️⃣", message: "remove the 'Throws:' sections of 'doesRethrow'; it does not throw any errors"),
]
)
}
Expand Down