Repository navigation
Fix lints - #625
Fix lints#625
Conversation
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
Signed-off-by: Thane Thomson <[email protected]>
| lint: | ||
| @echo "--> Running linter" | ||
| @go run github.com/golangci/golangci-lint/cmd/golangci-lint run | ||
| @go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run |
There was a problem hiding this comment.
By not specifying latest here, the version of golangci-lint used locally will be whichever version is currently installed in your ${GOPATH}/bin, meaning that each of us will potentially have a different version and therefore experience different results when linting locally.
Using latest here makes it consistent for all of us.
Signed-off-by: Thane Thomson <[email protected]>
| - uses: golangci/golangci-lint-action@v3 | ||
| with: | ||
| version: v1.51 | ||
| version: latest |
There was a problem hiding this comment.
I think we should keep up with the latest golangci-lint releases, especially if we're enforcing this check in the lint target of the Makefile, to ensure consistency.
|
|
||
| // deprecateSnakeCase is a util function for 0.34.1. Should be removed in 0.35 | ||
| func deprecateSnakeCase(cmd *cobra.Command, args []string) { | ||
| // TODO(thane): Remove this across all releases |
lasarojc
left a comment
There was a problem hiding this comment.
while I dislike some of the the practices pushed by the Lint, I all all for uniformity.
LGTM
| func MakeSwitch( | ||
| cfg *config.P2PConfig, | ||
| i int, | ||
| network, version string, |
| func (bapi *broadcastAPI) Ping(context.Context, *RequestPing) (*ResponsePing, error) { | ||
| // kvstore so we can check if the server is up | ||
| return &ResponsePing{}, nil | ||
| } | ||
|
|
||
| func (bapi *broadcastAPI) BroadcastTx(ctx context.Context, req *RequestBroadcastTx) (*ResponseBroadcastTx, error) { | ||
| func (bapi *broadcastAPI) BroadcastTx(_ context.Context, req *RequestBroadcastTx) (*ResponseBroadcastTx, error) { |
There was a problem hiding this comment.
We are setting the variable name to "_" in line 20, and removing the name altogether in line 15?
Can we treat the two cases the same way'
There was a problem hiding this comment.
The convention in Go is that, if all function parameters are unused, then you can have unnamed parameters. But the moment that one of your parameters is used, they all have to be named, in which case the unused ones must be called _.
sergio-mena
left a comment
There was a problem hiding this comment.
Thanks for this @thanethomson
I like it because there is zero risk of breaking something and the changes are sparse enough not to hinder git-blame significantly.
One thought: since this is strictly refactoring, is it worth your time backporting it to other branches?
If we don't, our local linter's going to fail when linting those branches, so I think I'll have to backport this. |
Signed-off-by: Thane Thomson <[email protected]>
This touches a large number of files, but I believe it's necessary as part of our tech debt cleanup. There are so many functions littering the codebase where: 1. We have unused parameters and they should have been refactored away, but they weren't 2. We have unused parameters and they should be named according to proper Go conventions (e.g. in interface implementations where a particular function signature is required, but the variable names should either be left out or `_` when unused) 3. We have redundant code (a whole bunch of redundant `if` statements and error checks, for example) 4. We use bad naming conventions for variables, like `copy` or `len` I'm also tired of having the linter fail locally. And if we don't do this, it will all just rot even more. This PR targets `main`, but should be applied across all the backport branches (which will, of course, require some conflict resolution, but I'm fine with doing that). I've left TODOs in some places where changes need to be made in follow-up PRs. Commits are organized by package so that it's hopefully easier to review. If you pick up on formatting changes, please see #604. --- #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments (cherry picked from commit 111d252) # Conflicts: # consensus/state.go # rpc/core/abci.go # rpc/core/blocks.go # rpc/core/consensus.go # rpc/core/evidence.go # rpc/core/health.go # rpc/core/mempool.go # rpc/core/net.go # rpc/core/status.go # rpc/core/tx.go
This touches a large number of files, but I believe it's necessary as part of our tech debt cleanup. There are so many functions littering the codebase where: 1. We have unused parameters and they should have been refactored away, but they weren't 2. We have unused parameters and they should be named according to proper Go conventions (e.g. in interface implementations where a particular function signature is required, but the variable names should either be left out or `_` when unused) 3. We have redundant code (a whole bunch of redundant `if` statements and error checks, for example) 4. We use bad naming conventions for variables, like `copy` or `len` I'm also tired of having the linter fail locally. And if we don't do this, it will all just rot even more. This PR targets `main`, but should be applied across all the backport branches (which will, of course, require some conflict resolution, but I'm fine with doing that). I've left TODOs in some places where changes need to be made in follow-up PRs. Commits are organized by package so that it's hopefully easier to review. If you pick up on formatting changes, please see #604. --- #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments (cherry picked from commit 111d252) # Conflicts: # abci/client/grpc_client.go # abci/client/grpc_client_test.go # abci/client/socket_client.go # abci/client/socket_client_test.go # abci/cmd/abci-cli/abci-cli.go # abci/example/kvstore/kvstore.go # abci/example/kvstore/kvstore_test.go # abci/server/grpc_server.go # abci/tests/server/client.go # abci/types/application.go # blocksync/reactor.go # cmd/cometbft/commands/inspect.go # consensus/reactor_test.go # consensus/replay_stubs.go # consensus/replay_test.go # consensus/state.go # consensus/state_test.go # consensus/types/height_vote_set_test.go # inspect/inspect.go # inspect/inspect_test.go # mempool/v0/clist_mempool_test.go # node/node.go # node/setup.go # p2p/base_reactor.go # p2p/mock/peer.go # p2p/mock/reactor.go # p2p/peer_set_test.go # rpc/client/local/local.go # rpc/client/mock/client.go # rpc/core/abci.go # rpc/core/blocks.go # rpc/core/consensus.go # rpc/core/dev.go # rpc/core/evidence.go # rpc/core/health.go # rpc/core/mempool.go # rpc/core/net.go # rpc/core/status.go # rpc/core/tx.go # state/indexer/block/kv/util.go # state/state_test.go # state/txindex/kv/utils.go # statesync/reactor.go # statesync/reactor_test.go # store/store_test.go # test/e2e/app/app.go # test/e2e/runner/evidence.go # types/event_bus.go # types/validator_set.go
This touches a large number of files, but I believe it's necessary as part of our tech debt cleanup. There are so many functions littering the codebase where: 1. We have unused parameters and they should have been refactored away, but they weren't 2. We have unused parameters and they should be named according to proper Go conventions (e.g. in interface implementations where a particular function signature is required, but the variable names should either be left out or `_` when unused) 3. We have redundant code (a whole bunch of redundant `if` statements and error checks, for example) 4. We use bad naming conventions for variables, like `copy` or `len` I'm also tired of having the linter fail locally. And if we don't do this, it will all just rot even more. This PR targets `main`, but should be applied across all the backport branches (which will, of course, require some conflict resolution, but I'm fine with doing that). I've left TODOs in some places where changes need to be made in follow-up PRs. Commits are organized by package so that it's hopefully easier to review. If you pick up on formatting changes, please see #604. --- #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments (cherry picked from commit 111d252) # Conflicts: # .github/workflows/lint.yml # abci/client/grpc_client.go # abci/client/grpc_client_test.go # abci/client/socket_client.go # abci/client/socket_client_test.go # abci/cmd/abci-cli/abci-cli.go # abci/example/kvstore/kvstore.go # abci/example/kvstore/kvstore_test.go # abci/server/grpc_server.go # abci/tests/server/client.go # abci/types/application.go # blockchain/v0/reactor.go # cmd/cometbft/commands/inspect.go # cmd/cometbft/commands/light.go # consensus/reactor_test.go # consensus/replay_stubs.go # consensus/replay_test.go # consensus/state.go # consensus/state_test.go # consensus/types/height_vote_set_test.go # consensus/wal_generator.go # inspect/inspect.go # inspect/inspect_test.go # internal/test/validator.go # mempool/v0/clist_mempool_test.go # node/node.go # node/setup.go # p2p/base_reactor.go # p2p/mock/peer.go # p2p/mock/reactor.go # p2p/peer_set_test.go # p2p/switch_test.go # rpc/client/local/local.go # rpc/client/mock/client.go # rpc/core/abci.go # rpc/core/blocks.go # rpc/core/consensus.go # rpc/core/dev.go # rpc/core/evidence.go # rpc/core/health.go # rpc/core/mempool.go # rpc/core/net.go # rpc/core/status.go # rpc/core/tx.go # scripts/metricsgen/metricsgen.go # state/indexer/block/kv/util.go # state/state_test.go # state/txindex/kv/kv_test.go # state/txindex/kv/utils.go # statesync/reactor.go # statesync/reactor_test.go # store/store_test.go # test/e2e/app/app.go # test/e2e/runner/evidence.go # types/event_bus.go # types/validator_set.go
* Fix lints (#625) This touches a large number of files, but I believe it's necessary as part of our tech debt cleanup. There are so many functions littering the codebase where: 1. We have unused parameters and they should have been refactored away, but they weren't 2. We have unused parameters and they should be named according to proper Go conventions (e.g. in interface implementations where a particular function signature is required, but the variable names should either be left out or `_` when unused) 3. We have redundant code (a whole bunch of redundant `if` statements and error checks, for example) 4. We use bad naming conventions for variables, like `copy` or `len` I'm also tired of having the linter fail locally. And if we don't do this, it will all just rot even more. This PR targets `main`, but should be applied across all the backport branches (which will, of course, require some conflict resolution, but I'm fine with doing that). I've left TODOs in some places where changes need to be made in follow-up PRs. Commits are organized by package so that it's hopefully easier to review. If you pick up on formatting changes, please see #604. --- #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments (cherry picked from commit 111d252) # Conflicts: # consensus/state.go # rpc/core/abci.go # rpc/core/blocks.go # rpc/core/consensus.go # rpc/core/evidence.go # rpc/core/health.go # rpc/core/mempool.go # rpc/core/net.go # rpc/core/status.go # rpc/core/tx.go * Fix conflicts Signed-off-by: Thane Thomson <[email protected]> --------- Signed-off-by: Thane Thomson <[email protected]> Co-authored-by: Thane Thomson <[email protected]>
This touches a large number of files, but I believe it's necessary as part of our tech debt cleanup. There are so many functions littering the codebase where: 1. We have unused parameters and they should have been refactored away, but they weren't 2. We have unused parameters and they should be named according to proper Go conventions (e.g. in interface implementations where a particular function signature is required, but the variable names should either be left out or `_` when unused) 3. We have redundant code (a whole bunch of redundant `if` statements and error checks, for example) 4. We use bad naming conventions for variables, like `copy` or `len` I'm also tired of having the linter fail locally. And if we don't do this, it will all just rot even more. This PR targets `main`, but should be applied across all the backport branches (which will, of course, require some conflict resolution, but I'm fine with doing that). I've left TODOs in some places where changes need to be made in follow-up PRs. Commits are organized by package so that it's hopefully easier to review. If you pick up on formatting changes, please see #604. --- #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments
This touches a large number of files, but I believe it's necessary as part of our tech debt cleanup. There are so many functions littering the codebase where:
_when unused)ifstatements and error checks, for example)copyorlenI'm also tired of having the linter fail locally. And if we don't do this, it will all just rot even more.
This PR targets
main, but should be applied across all the backport branches (which will, of course, require some conflict resolution, but I'm fine with doing that). I've left TODOs in some places where changes need to be made in follow-up PRs.Commits are organized by package so that it's hopefully easier to review.
If you pick up on formatting changes, please see #604.
PR checklist
.changelog(we use unclog to manage our changelog)docs/orspec/) and code comments