Skip to content

Commit

Permalink
Fix for
Browse files Browse the repository at this point in the history
  • Loading branch information
jkolarik-paylocity committed Nov 26, 2024
1 parent d3dbee6 commit 8f13b30
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,19 @@ private extension AsyncWithoutAwaitRule {
pendingAsync = nil
}

override func visitPost(_ node: ForStmtSyntax) {
if node.awaitKeyword != nil {
functionScopes.modifyLast {
$0.containsAwait = true
}
}
}

private func checkViolation() {
guard let info = functionScopes.pop(),
let asyncToken = info.asyncToken,
!info.containsAwait
guard
let info = functionScopes.pop(),
let asyncToken = info.asyncToken,
!info.containsAwait
else {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,28 @@ internal struct AsyncWithoutAwaitRuleExamples {
typealias Bar = () async -> Void
let baz = { qux() }
"""),
Example("""
func test() async {
for await foo in bar {}
}
"""),
Example("""
func test() async {
while let foo = await bar() {}
}
"""),
Example("""
func test() async {
async let foo = bar()
let baz = await foo
}
"""),
Example("""
func test() async {
async let foo = bar()
await foo
}
"""),
]

static let triggeringExamples = [
Expand Down Expand Up @@ -189,6 +211,21 @@ internal struct AsyncWithoutAwaitRuleExamples {
}
}
"""),
Example("""
func test() ↓async {
for foo in bar {}
}
"""),
Example("""
func test() ↓async {
while let foo = bar() {}
}
"""),
Example("""
func test() ↓async {
async let foo = bar()
}
"""),
]

static let corrections = [
Expand Down

0 comments on commit 8f13b30

Please sign in to comment.