You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package pkg
func fn() {
var ch chan int
for range ch {
defer println()
break
}
for range ch {
defer println()
return
}
}
But they do get flagged:
/tmp/foo.go:6:3: defers in this range loop won't run unless the channel gets closed (SA9001)
/tmp/foo.go:11:3: defers in this range loop won't run unless the channel gets closed (SA9001)
The text was updated successfully, but these errors were encountered:
As noted in the PR: dominikh#488,
let's check if there is either a `return` statement or a `break` control
flow when looping over channels. This would reduce false positives.
Add a test for the same as noted in the issue!
Signed-off-by: Karthik Nayak <[email protected]>
As noted in issue gh-488, let's check if there is either a 'return' or a
'break' statement when looping over channels.
Add a test for the same as noted in the issue!
Signed-off-by: Karthik Nayak <[email protected]>
Closes: gh-1298 [via git-merge-pr]
Closes: gh-488
(cherry picked from commit bfa1dc5)
Neither of these defers should get flagged:
But they do get flagged:
The text was updated successfully, but these errors were encountered: