Skip to content

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

Description

@myshkin5

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
		}
	}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions