2023-03-15 16:00:52 +00:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-09-15 14:13:51 +00:00
|
|
|
rules:
|
|
|
|
- id: loopclosure
|
|
|
|
patterns:
|
|
|
|
- pattern-inside: |
|
|
|
|
for $A, $B := range $C {
|
|
|
|
...
|
|
|
|
}
|
|
|
|
- pattern-inside: |
|
|
|
|
go func() {
|
|
|
|
...
|
|
|
|
}()
|
|
|
|
- pattern-not-inside: |
|
|
|
|
go func(..., $B, ...) {
|
|
|
|
...
|
|
|
|
}(..., $B, ...)
|
|
|
|
- pattern-not-inside: |
|
|
|
|
go func() {
|
|
|
|
...
|
|
|
|
for ... {
|
|
|
|
...
|
|
|
|
}
|
|
|
|
...
|
|
|
|
}()
|
|
|
|
- pattern: $B
|
|
|
|
message: Loop variable $B used inside goroutine
|
|
|
|
languages:
|
|
|
|
- go
|
|
|
|
severity: WARNING
|