@@ -20,7 +20,8 @@ public extension FormatRule {
20
20
}
21
21
22
22
formatter. forEach ( . keyword) { keywordIndex, keyword in
23
- guard [ " func " , " init " , " subscript " ] . contains ( keyword. string) ,
23
+ guard case let . keyword( keyword) = keyword,
24
+ [ " func " , " init " , " subscript " ] . contains ( keyword) ,
24
25
let functionDecl = formatter. parseFunctionDeclaration ( keywordIndex: keywordIndex) ,
25
26
functionDecl. effects. contains ( where: { $0. hasPrefix ( " async " ) } ) ,
26
27
let bodyRange = functionDecl. bodyRange
@@ -33,14 +34,9 @@ public extension FormatRule {
33
34
34
35
if formatter. options. redundantAsync == . testsOnly {
35
36
// Only process test functions
36
- guard let testFramework, functionDecl. returnType == nil else { return }
37
-
38
- switch testFramework {
39
- case . xcTest:
40
- guard functionDecl. name? . starts ( with: " test " ) == true else { return }
41
- case . swiftTesting:
42
- guard formatter. modifiersForDeclaration ( at: keywordIndex, contains: " @Test " ) else { return }
43
- }
37
+ guard keyword == " func " , let testFramework,
38
+ formatter. isTestFunction ( at: keywordIndex, in: functionDecl, for: testFramework)
39
+ else { return }
44
40
}
45
41
46
42
// Check if the function body contains any await keywords
0 commit comments