Skip to content

Commit f25ccd9

Browse files
VirrageSccojocar
authored andcommittedMar 4, 2024··
Ignore 'implicit memory aliasing' rule for Go 1.22+
Signed-off-by: Janusz Marcinkiewicz <januszm@nvidia.com>
1 parent 582e91a commit f25ccd9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ directory you can supply `./...` as the input argument.
159159
- G503: Import blocklist: crypto/rc4
160160
- G504: Import blocklist: net/http/cgi
161161
- G505: Import blocklist: crypto/sha1
162-
- G601: Implicit memory aliasing of items from a range statement
162+
- G601: Implicit memory aliasing of items from a range statement (only for Go 1.21 or lower)
163163
- G602: Slice access out of bounds
164164

165165
### Retired rules

‎rules/implicit_aliasing.go

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ func doGetIdentExpr(expr ast.Expr, hasSelector bool) (*ast.Ident, bool) {
4747
}
4848

4949
func (r *implicitAliasing) Match(n ast.Node, c *gosec.Context) (*issue.Issue, error) {
50+
// This rule does not apply for Go 1.22, see https://tip.golang.org/doc/go1.22#language.
51+
major, minor, _ := gosec.GoVersion()
52+
if major >= 1 && minor >= 22 {
53+
return nil, nil
54+
}
55+
5056
switch node := n.(type) {
5157
case *ast.RangeStmt:
5258
// When presented with a range statement, get the underlying Object bound to

0 commit comments

Comments
 (0)
Please sign in to comment.