Skip to content

Commit eb53639

Browse files
committed
Don't apply noForceTryInTests if function has a return type
1 parent 4c84a2e commit eb53639

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Sources/Rules/NoForceTryInTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public extension FormatRule {
1313
}
1414

1515
formatter.forEach(.keyword("func")) { funcKeywordIndex, _ in
16-
guard let functionDecl = formatter.parseFunctionDeclaration(keywordIndex: funcKeywordIndex)
16+
guard let functionDecl = formatter.parseFunctionDeclaration(keywordIndex: funcKeywordIndex),
17+
functionDecl.returnType == nil
1718
else { return }
1819

1920
switch testFramework {

Tests/Rules/NoForceTryInTestsTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ final class NoForceTryInTestsTests: XCTestCase {
6969
func something() {
7070
try! somethingThatThrows()
7171
}
72+
73+
func testHelper() -> String {
74+
try! generateString()
75+
}
7276
}
7377
"""
7478
testFormatting(for: input, rule: .noForceTryInTests)

0 commit comments

Comments
 (0)