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

Detect when copied and original variable is used #8

Closed
SuperSandro2000 opened this issue Mar 21, 2024 · 1 comment
Closed

Detect when copied and original variable is used #8

SuperSandro2000 opened this issue Mar 21, 2024 · 1 comment
Labels
question Further information is requested

Comments

@SuperSandro2000
Copy link

I have the following code which I extracted from a test:

		for _, req := range testRequests {
			failingReq := req // <----- here
			failingReq.ExpectBody = test.ErrorCode(keppel.ErrTooManyRequests)
			failingReq.ExpectStatus = http.StatusTooManyRequests
			failingReq.Check(t, h)

			s.Clock.StepBy(time.Second)
			req.Check(t, h)
		}

req gets copied and modified and both are used. I think the linter should ignore this or at least add an option to ignore it.

@karamaru-alpha
Copy link
Owner

karamaru-alpha commented Mar 22, 2024

@SuperSandro2000
I apologize for the delayed response.
This linter has ignore-alias option. Have you tried it?👀

cf. https://golangci-lint.run/usage/linters/#copyloopvar

linters:
  disable-all: true
  enable:
    - copyloopvar

linters-settings:
  copyloopvar:
    ignore-alias: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants