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

Prefer declaration over initialization in grpc query handlers #3376

Closed
1 of 3 tasks
DimitrisJim opened this issue Mar 30, 2023 · 0 comments · Fixed by #3436
Closed
1 of 3 tasks

Prefer declaration over initialization in grpc query handlers #3376

DimitrisJim opened this issue Mar 30, 2023 · 0 comments · Fixed by #3436
Labels
good first issue Good for newcomers type: code hygiene Clean up code but without changing functionality or interfaces

Comments

@DimitrisJim
Copy link
Contributor

DimitrisJim commented Mar 30, 2023

Summary

Taken from #3346 (comment), there's a preference for declaring and not initializing variables in the code base.

Problem Definition

Be consistent with the use of declarations where applicable, prefer declarations over declaration + initialization in the code base. This appears to exist in most of the grpc handlers, some examples (non exhaustive):

  • In the client handler for getting the consensus state.
  • In the connection handler for getting the connections.
  • In the channel handler for getting the channels.

Changing these usually also requires the tests be changed in order to expect the nil slice in the cases where nothing is returned.

Proposal

Change occurrences of initialization into declaration in the query handlers (and the tests that depend on the response).


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned
@crodriguezvega crodriguezvega added good first issue Good for newcomers type: code hygiene Clean up code but without changing functionality or interfaces labels Mar 30, 2023
@mergify mergify bot closed this as completed in #3436 Apr 19, 2023
mergify bot pushed a commit that referenced this issue Apr 19, 2023
## Description



closes: #3376


### Commit Message / Changelog Entry

```bash
nit: Replace initialization with declaration in grpc query handlers
```

see the [guidelines](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#commit-messages) for commit messages. (view raw markdown for examples)




---

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

- [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#pull-request-targeting)).
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules/11-structure.md) and [Go style guide](../docs/dev/go-style-guide.md).
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/main/testing/README.md#ibc-testing-package).
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`).
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [ ] Provide a [commit message](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#commit-messages) to be used for the changelog entry in the PR description for review.
- [ ] Re-reviewed `Files changed` in the Github PR explorer.
- [ ] Review `Codecov Report` in the comment section below once CI passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: code hygiene Clean up code but without changing functionality or interfaces
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants