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

Assign ctx, fs, sel to _ so no warnings about unused variables #3001

Closed
wants to merge 1 commit into from

Conversation

halkeye
Copy link
Contributor

@halkeye halkeye commented Apr 11, 2024

alternative to #2999

Found a few more while doing development, gopls/vscode was warning about more variables that are undefined.
Instead of having even more complex logic for making variables _, just assigned them to nothing so they would get used.

That only leaves one left in generate.go for me

image

I have:

  • Added tests covering the bug / feature (see testing)
  • Updated any relevant documentation (see docs)

@StevenACoffman
Copy link
Collaborator

I would much rather we don't do this. The point of the linter warning you is to detect possible bugs where an argument or a variable declaration are unused, and it identified we were being a bit lazy in our codegen conditionals.

When the arguments are changed from ctx to _ it is clear we only have the extraneous argument so the signature will match an interface.

When we assign var _ = ctx it obscures this intention.

@StevenACoffman
Copy link
Collaborator

Closing in favor of #2999

@halkeye halkeye deleted the use-unused-variables branch April 11, 2024 14:50
@halkeye
Copy link
Contributor Author

halkeye commented Apr 11, 2024

Yea. That's totally cool. One of the arguments was only used inside a loop behind a conditional and I couldn't figure out how to nicely figure that out in the args, so this was idea b

I'll see if I can't find a way. Thanks

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

Successfully merging this pull request may close these issues.

2 participants