blob: 88ab134c5dff3ec0322002f6a8981bc67d701665 [file] [log] [blame]
Jessie Liu207cf1a2023-11-13 18:37:15 +00001# Copyright (c) HashiCorp, Inc.
2# SPDX-License-Identifier: MPL-2.0
3
4rules:
5 - id: loopclosure
6 patterns:
7 - pattern-inside: |
8 for $A, $B := range $C {
9 ...
10 }
11 - pattern-inside: |
12 go func() {
13 ...
14 }()
15 - pattern-not-inside: |
16 go func(..., $B, ...) {
17 ...
18 }(..., $B, ...)
19 - pattern-not-inside: |
20 go func() {
21 ...
22 for ... {
23 ...
24 }
25 ...
26 }()
27 - pattern: $B
28 message: Loop variable $B used inside goroutine
29 languages:
30 - go
31 severity: WARNING