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

chore: enable errcheck linter #16406

Merged
merged 49 commits into from
Jul 12, 2023
Merged

Conversation

ruthishvitwit
Copy link
Contributor

Description

The aim of this pr is to solve and fix all the errors after enabling Errcheck.I have made some of changes in a way i could understand the issue.Please suggest any changes or pointout any errors

Closes: #16293


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@ruthishvitwit ruthishvitwit requested a review from a team as a code owner June 2, 2023 10:14
@github-prbot github-prbot requested review from a team, julienrbrt and samricotta and removed request for a team June 2, 2023 10:15
@ruthishvitwit ruthishvitwit changed the title Fix: Errcheck enabled Chore: Errcheck enabled Jun 2, 2023
@julienrbrt julienrbrt changed the title Chore: Errcheck enabled chore: enabled errcheck linter Jun 2, 2023
@julienrbrt julienrbrt changed the title chore: enabled errcheck linter chore: enable errcheck linter Jun 2, 2023
baseapp/utils_test.go Outdated Show resolved Hide resolved
crypto/keys/secp256k1/internal/secp256k1/secp256_test.go Outdated Show resolved Hide resolved
x/auth/client/cli/tx_sign.go Outdated Show resolved Hide resolved
x/distribution/keeper/msg_server.go Outdated Show resolved Hide resolved
x/staking/testutil/helpers.go Outdated Show resolved Hide resolved
Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like omitting the errors at many places and also pending @julienrbrt 's comments.

crypto/keys/secp256k1/internal/secp256k1/secp256_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments as julien and atheesh
Can you also resolve the conflicts?

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thank you @ruthishvitwit!

@faddat
Copy link
Contributor

faddat commented Jul 5, 2023

Hey thanks @ruthishvitwit this is one of the linters that helps me sleep at night

Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly lgtm, a few nits.

baseapp/utils_test.go Outdated Show resolved Hide resolved
baseapp/utils_test.go Outdated Show resolved Hide resolved
baseapp/utils_test.go Outdated Show resolved Hide resolved
testutil/network/network.go Show resolved Hide resolved
x/feegrant/keeper/keeper.go Show resolved Hide resolved
x/nft/simulation/operations_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than atheesh's comments and few nits, mostly looks good.
There are also some failing tests. Can you please take a look at them ?

baseapp/abci_test.go Outdated Show resolved Hide resolved
client/v2/autocli/common_test.go Outdated Show resolved Hide resolved
@julienrbrt
Copy link
Member

@ruthishvitwit, could you fix the conflict and implement the last comments from Atheesh, so we can merge?

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two tests are failing, could you have a look?

suite.govKeeper.SetProposal(suite.ctx, proposal)
err = suite.govKeeper.SetProposal(suite.ctx, proposal)
suite.Require().NoError(err)
err = suite.govKeeper.SetProposal(suite.ctx, proposal)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this duplicated?

err = suite.govKeeper.SetProposal(suite.ctx, proposal)
suite.Require().NoError(err)

err = suite.govKeeper.SetProposal(suite.ctx, proposal)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@ruthishvitwit
Copy link
Contributor Author

@julienrbrt I am not able to solve the errors in the tests which are failing . Will u be able to take a look at it once??

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the first test failing it is fine to do not check the error.
For the second TestRollback, we should ensure there are validators, so you need to update the genesis (app.DefaultGenesis) and add some validators (e.g.

genesisState, err = simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)
)

@@ -153,4 +153,5 @@ func (s *E2ETestSuite) TestBlockResults() {

return nil
}, 10)
require.NoError(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ok to ignore, as it may fail as the first few blocks, and this is why we retry for 10 blocks.
This will "fix" the test issue you have.

@ruthishvitwit ruthishvitwit requested a review from julienrbrt July 11, 2023 09:56
@julienrbrt
Copy link
Member

Can you fix the conflicts and let's merge!

@julienrbrt julienrbrt enabled auto-merge July 12, 2023 08:57
@julienrbrt julienrbrt added this pull request to the merge queue Jul 12, 2023
Merged via the queue into cosmos:main with commit fd7e549 Jul 12, 2023
mergify bot pushed a commit that referenced this pull request Jul 12, 2023
(cherry picked from commit fd7e549)

# Conflicts:
#	.golangci.yml
#	simapp/internal/testnet/cometrpc_test.go
#	simapp/internal/testnet/cometstarter_test.go
#	simapp/internal/testnet/example_basic_test.go
#	tests/integration/distribution/keeper/msg_server_test.go
#	tests/integration/gov/keeper/keeper_test.go
#	tests/integration/slashing/keeper/keeper_test.go
#	x/distribution/simulation/operations_test.go
#	x/slashing/keeper/genesis_test.go
#	x/slashing/keeper/keeper_test.go
#	x/slashing/simulation/operations_test.go
@julienrbrt julienrbrt removed the backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release label Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable errcheck linter
8 participants