File tree 2 files changed +25
-1
lines changed
Tests/SwiftFormatRulesTests
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 {
96
96
) {
97
97
if returnClause == nil && returnDesc != nil {
98
98
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
+ }
100
105
diagnose ( . documentReturnValue( funcName: name) , on: returnClause)
101
106
}
102
107
}
Original file line number Diff line number Diff line change @@ -117,10 +117,29 @@ final class ValidateDocumentationCommentsTests: LintOrFormatRuleTestCase {
117
117
/// - p2: Parameter 2.
118
118
/// - p3: Parameter 3.
119
119
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 {}
120
137
"""
121
138
performLint ( ValidateDocumentationComments . self, input: input)
122
139
XCTAssertDiagnosed ( . removeReturnComment( funcName: " noReturn " ) , line: 8 , column: 1 )
123
140
XCTAssertDiagnosed ( . documentReturnValue( funcName: " foo " ) , line: 16 , column: 37 )
141
+ XCTAssertNotDiagnosed ( . documentReturnValue( funcName: " neverReturns " ) )
142
+ XCTAssertNotDiagnosed ( . removeReturnComment( funcName: " documentedNeverReturns " ) )
124
143
}
125
144
126
145
func testValidDocumentation( ) {
You can’t perform that action at this time.
0 commit comments