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

Add linter to prevent accidental variable shadowing #1604

Open
javierhonduco opened this issue May 4, 2023 · 4 comments
Open

Add linter to prevent accidental variable shadowing #1604

javierhonduco opened this issue May 4, 2023 · 4 comments
Labels
area/build-pipeline Something to do with CI and build pipeline

Comments

@javierhonduco
Copy link
Contributor

          We need linter to prevent this [accidental variable shadowing].

Originally posted by @kakkoyun in #1507 (comment)

@javierhonduco
Copy link
Contributor Author

https://github.com/gordonklaus/ineffassign looks like could work

@maxbrunet
Copy link
Member

gordonklaus/ineffassign looks like could work

This is enable by default in golangci-lint

govet seems to have stricter settings in regards to shadowing that we could enable: https://golangci-lint.run/usage/linters/#govet

@javierhonduco
Copy link
Contributor Author

So odd it wasn't caught by it! Thanks for checking that and for the safer alternative. I'm happy to help cleaning up our codebase if there's many instances 😄

@kakkoyun
Copy link
Member

kakkoyun commented May 4, 2023

There's an option to pass golangci-lint https://golangci-lint.run/usage/linters/#govet

It's a bit strict though, but I'm happy to have that strictness.

@kakkoyun kakkoyun added the area/build-pipeline Something to do with CI and build pipeline label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build-pipeline Something to do with CI and build pipeline
Projects
None yet
Development

No branches or pull requests

3 participants