File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Tests/SwiftFormatRulesTests Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,12 @@ public final class ValidateDocumentationComments: SyntaxLintRule {
9696 ) {
9797 if returnClause == nil && returnDesc != nil {
9898 diagnose ( . removeReturnComment( funcName: name) , on: node)
99- } else if returnClause != nil && returnDesc == nil {
99+ } else if let returnClause = returnClause, returnDesc == nil {
100+ if let returnTypeIdentifier = returnClause. returnType. as ( SimpleTypeIdentifierSyntax . self) ,
101+ returnTypeIdentifier. name. text == " Never "
102+ {
103+ return
104+ }
100105 diagnose ( . documentReturnValue( funcName: name) , on: returnClause)
101106 }
102107 }
Original file line number Diff line number Diff line change @@ -117,10 +117,29 @@ final class ValidateDocumentationCommentsTests: LintOrFormatRuleTestCase {
117117 /// - p2: Parameter 2.
118118 /// - p3: Parameter 3.
119119 func foo(p1: Int, p2: Int, p3: Int) -> Int {}
120+
121+ /// One sentence summary.
122+ ///
123+ /// - Parameters:
124+ /// - p1: Parameter 1.
125+ /// - p2: Parameter 2.
126+ /// - p3: Parameter 3.
127+ func neverReturns(p1: Int, p2: Int, p3: Int) -> Never {}
128+
129+ /// One sentence summary.
130+ ///
131+ /// - Parameters:
132+ /// - p1: Parameter 1.
133+ /// - p2: Parameter 2.
134+ /// - p3: Parameter 3.
135+ /// - Returns: Never returns.
136+ func documentedNeverReturns(p1: Int, p2: Int, p3: Int) -> Never {}
120137 """
121138 performLint ( ValidateDocumentationComments . self, input: input)
122139 XCTAssertDiagnosed ( . removeReturnComment( funcName: " noReturn " ) , line: 8 , column: 1 )
123140 XCTAssertDiagnosed ( . documentReturnValue( funcName: " foo " ) , line: 16 , column: 37 )
141+ XCTAssertNotDiagnosed ( . documentReturnValue( funcName: " neverReturns " ) )
142+ XCTAssertNotDiagnosed ( . removeReturnComment( funcName: " documentedNeverReturns " ) )
124143 }
125144
126145 func testValidDocumentation( ) {
You can’t perform that action at this time.
0 commit comments