Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code triggers gosec G601 "Implicit memory aliasing in for loop." #75

Open
myshkin5 opened this issue Dec 2, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@myshkin5
Copy link
Collaborator

myshkin5 commented Dec 2, 2022

Code is iterating, grabbing the wanted value, then breaking:

	for n, res := range r.Moq.ResultsByParams_XXX {
		if res.AnyParams == r.AnyParams {
			results = &res
			break
		}
		if res.AnyCount > anyCount {
			insertAt = n
		}
	}

Could use the index to avoid the linter issue:

	for n, res := range r.Moq.ResultsByParams_XXX {
		if res.AnyParams == r.AnyParams {
			results = &r.Moq.ResultsByParams_XXX[n]
			break
		}
		if res.AnyCount > anyCount {
			insertAt = n
		}
	}
@myshkin5 myshkin5 added the bug Something isn't working label Dec 2, 2022
@myshkin5
Copy link
Collaborator Author

myshkin5 commented Dec 2, 2022

Also triggers exportloopref linter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant