-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: fix all lint issue since golangci-lint bump #21326
Conversation
Warning Rate limit exceeded@julienrbrt has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 36 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughWalkthroughThe recent changes primarily focus on enhancing error handling and type safety in various components of the codebase. This includes modifications to error reporting methods, the introduction of new types for context keys, and updates to the linting process to include Makefiles. These adjustments aim to improve code clarity, maintainability, and overall functionality without altering existing logic significantly. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant System
participant Logger
participant Keyring
User->>System: Trigger action
System->>Keyring: Retrieve keyring context
Keyring-->>System: Return keyring context
System->>Logger: Log event
Logger-->>System: Confirm log
System-->>User: Response
This diagram illustrates the primary interactions between the user, system, logger, and keyring components during an action. The flow remains intact while showcasing the enhanced clarity in error handling and context management introduced in the recent changes. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (20)
- .github/workflows/lint.yml (1 hunks)
- client/v2/autocli/keyring/keyring.go (1 hunks)
- log/CHANGELOG.md (1 hunks)
- log/logger.go (1 hunks)
- simapp/simd/cmd/root_di.go (1 hunks)
- tests/integration/slashing/slashing_test.go (1 hunks)
- tests/systemtests/system.go (1 hunks)
- tools/cosmovisor/cmd/cosmovisor/version_test.go (1 hunks)
- x/auth/keeper/grpc_query.go (4 hunks)
- x/authz/keeper/grpc_query.go (4 hunks)
- x/distribution/keeper/grpc_query.go (2 hunks)
- x/distribution/keeper/msg_server.go (1 hunks)
- x/evidence/keeper/grpc_query.go (1 hunks)
- x/feegrant/keeper/grpc_query.go (2 hunks)
- x/gov/keeper/msg_server.go (1 hunks)
- x/gov/keeper/proposal.go (1 hunks)
- x/group/client/cli/tx.go (1 hunks)
- x/group/keeper/keeper.go (1 hunks)
- x/slashing/keeper/signing_info.go (1 hunks)
- x/upgrade/keeper/abci_test.go (2 hunks)
Files skipped from review due to trivial changes (8)
- .github/workflows/lint.yml
- log/CHANGELOG.md
- simapp/simd/cmd/root_di.go
- tools/cosmovisor/cmd/cosmovisor/version_test.go
- x/auth/keeper/grpc_query.go
- x/distribution/keeper/grpc_query.go
- x/gov/keeper/msg_server.go
- x/slashing/keeper/signing_info.go
Additional context used
Path-based instructions (12)
client/v2/autocli/keyring/keyring.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/evidence/keeper/grpc_query.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/feegrant/keeper/grpc_query.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.tests/integration/slashing/slashing_test.go (3)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/authz/keeper/grpc_query.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.log/logger.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/distribution/keeper/msg_server.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/gov/keeper/proposal.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/group/client/cli/tx.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/group/keeper/keeper.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/upgrade/keeper/abci_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"tests/systemtests/system.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (13)
client/v2/autocli/keyring/keyring.go (1)
13-15
: Enhanced Type Safety withkeyringContextKey
.The introduction of
keyringContextKey
improves type safety by using a specific type for context keys, reducing the risk of key collisions. This is a good practice for context usage in Go.x/evidence/keeper/grpc_query.go (1)
56-56
: Simplified Error Handling.The change from
status.Errorf
tostatus.Error
simplifies error handling by removing unnecessary formatting, enhancing readability without affecting functionality.x/feegrant/keeper/grpc_query.go (1)
38-38
: Simplified Error Handling.The change from
status.Errorf
tostatus.Error
simplifies error handling by removing unnecessary formatting, enhancing readability without affecting functionality.Also applies to: 48-48
tests/integration/slashing/slashing_test.go (1)
117-117
: Correct usage oferrors.Is
.The change in the parameter order of
errors.Is
aligns with its intended usage, enhancing error handling accuracy.x/authz/keeper/grpc_query.go (1)
51-51
: Simplified error handling withstatus.Error
.Switching from
status.Errorf
tostatus.Error
simplifies error handling by eliminating unnecessary formatting, which is appropriate here.Also applies to: 73-73, 114-114, 169-169
log/logger.go (1)
33-35
: Enhanced type safety withcontextKey
.Introducing a distinct
contextKey
type forContextKey
improves type safety and helps prevent key collisions in context usage.x/distribution/keeper/msg_server.go (1)
192-192
: Consider usingWrapf
for more informative error messages.The change from
errors.Wrapf
toerrors.Wrap
simplifies the error message but removes the ability to include the validator address in the error context. Consider whether this context is necessary for debugging or logging purposes.Verification successful
Consider Using
Wrapf
for Dynamic Error MessagesThe current use of
errors.Wrap
is consistent across the codebase, but switching toerrors.Wrapf
could enhance error messages by including dynamic data like the validator address, which can aid in debugging and logging.
- File:
x/distribution/keeper/msg_server.go
- Line: 192
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if `errors.Wrap` is used consistently for error wrapping in the codebase. # Test: Search for `errors.Wrap` usage. Expect: Consistent usage across the codebase. rg --type go 'errors\.Wrap\('Length of output: 10934
x/gov/keeper/proposal.go (1)
86-88
: Consider usingWrapf
for more informative error messages.The change from
errorsmod.Wrapf
toerrorsmod.Wrap
simplifies the error message but removes the ability to include the signer address in the error context. Consider whether this context is necessary for debugging or logging purposes.x/group/client/cli/tx.go (1)
501-501
: Ensureprop.Proposers
is always initialized.The simplification assumes
prop.Proposers
is nevernil
. Ensure that this assumption holds throughout the codebase to prevent potentialnil
pointer dereference errors.x/group/keeper/keeper.go (1)
458-458
: Consider the implications of usingWrap
instead ofWrapf
.The change from
Wrapf
toWrap
in theassertMetadataLength
function simplifies error handling by removing formatting capabilities. Ensure that this change does not reduce the context needed for debugging. If additional context is required, consider usingWrapf
with a formatted message.x/upgrade/keeper/abci_test.go (2)
151-151
: Correct use oferrors.Is
function.The change in argument order for
errors.Is
correctly aligns with its intended use, enhancing the clarity and accuracy of error checking.
226-226
: Correct use oferrors.Is
function.The change in argument order for
errors.Is
correctly aligns with its intended use, enhancing the clarity and accuracy of error checking.tests/systemtests/system.go (1)
250-250
: Use oft.Fatal
instead oft.Fatalf
.The change from
t.Fatalf
tot.Fatal
in theAwaitUpgradeInfo
method allows deferred functions to execute after a test failure. Ensure that this behavior aligns with the intended test cleanup process.Verification successful
No impact on test cleanup from changing
t.Fatalf
tot.Fatal
.The change from
t.Fatalf
tot.Fatal
in theAwaitUpgradeInfo
method does not affect test cleanup in its current usage context, as there are no deferred functions in the relevant test file. Thus, the behavior aligns with the intended test process.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if `AwaitUpgradeInfo` is invoked in tests and if the change from `t.Fatalf` to `t.Fatal` impacts test cleanup. # Test: Search for the function usage. Expect: Occurrences where the function is invoked. rg --type go -A 5 $'AwaitUpgradeInfo'Length of output: 926
Script:
#!/bin/bash # Check for deferred functions in the `upgrade_test.go` file where `AwaitUpgradeInfo` is used. rg --type go 'defer' tests/systemtests/upgrade_test.goLength of output: 54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (20)
- .github/workflows/lint.yml (1 hunks)
- client/v2/autocli/keyring/keyring.go (1 hunks)
- log/CHANGELOG.md (1 hunks)
- log/logger.go (1 hunks)
- simapp/simd/cmd/root_di.go (1 hunks)
- tests/integration/slashing/slashing_test.go (1 hunks)
- tests/systemtests/system.go (1 hunks)
- tools/cosmovisor/cmd/cosmovisor/version_test.go (1 hunks)
- x/auth/keeper/grpc_query.go (4 hunks)
- x/authz/keeper/grpc_query.go (4 hunks)
- x/distribution/keeper/grpc_query.go (2 hunks)
- x/distribution/keeper/msg_server.go (1 hunks)
- x/evidence/keeper/grpc_query.go (1 hunks)
- x/feegrant/keeper/grpc_query.go (2 hunks)
- x/gov/keeper/msg_server.go (1 hunks)
- x/gov/keeper/proposal.go (1 hunks)
- x/group/client/cli/tx.go (1 hunks)
- x/group/keeper/keeper.go (1 hunks)
- x/slashing/keeper/signing_info.go (1 hunks)
- x/upgrade/keeper/abci_test.go (2 hunks)
Files skipped from review due to trivial changes (7)
- log/CHANGELOG.md
- simapp/simd/cmd/root_di.go
- tools/cosmovisor/cmd/cosmovisor/version_test.go
- x/auth/keeper/grpc_query.go
- x/authz/keeper/grpc_query.go
- x/distribution/keeper/grpc_query.go
- x/slashing/keeper/signing_info.go
Additional context used
Path-based instructions (12)
client/v2/autocli/keyring/keyring.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/evidence/keeper/grpc_query.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/feegrant/keeper/grpc_query.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.tests/integration/slashing/slashing_test.go (3)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"log/logger.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/distribution/keeper/msg_server.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/gov/keeper/proposal.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/group/client/cli/tx.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/group/keeper/keeper.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/gov/keeper/msg_server.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/upgrade/keeper/abci_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"tests/systemtests/system.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (14)
client/v2/autocli/keyring/keyring.go (1)
13-15
: Improved type safety withkeyringContextKey
.The change from an empty struct to a distinct type enhances type safety and clarity in the code. This is a good practice to avoid potential key collisions in the context.
Ensure that all usages of
KeyringContextKey
in the codebase are updated to accommodate this change.Verification successful
All usages of
KeyringContextKey
are consistent with the new type definition.The codebase correctly uses
KeyringContextKey
as a context key with the new typekeyringContextKey
, ensuring improved type safety and avoiding potential key collisions.
client/v2/autocli/keyring/keyring.go
: Used incontext.WithValue
.client/v2/autocli/flag/address.go
: Retrieved usingdctx.Value
.No further changes are needed.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all usages of `KeyringContextKey` in the codebase. # Test: Search for the usage of `KeyringContextKey`. Expect: Consistent usage with the new type. rg --type go -A 5 $'KeyringContextKey'Length of output: 1284
.github/workflows/lint.yml (1)
27-27
: Expanded linting coverage to include.mk
files.Adding
**/*.mk
to the linting patterns ensures that all Makefile-related files are checked, improving consistency and maintainability.x/evidence/keeper/grpc_query.go (1)
56-56
: Simplified error handling withstatus.Error
.Using
status.Error
instead ofstatus.Errorf
removes unnecessary formatting, which simplifies the code and can enhance performance.x/feegrant/keeper/grpc_query.go (1)
38-38
: Consistent error handling withstatus.Error
.The change from
status.Errorf
tostatus.Error
improves consistency in error handling. This is a good practice as it simplifies error message formatting.Also applies to: 48-48
tests/integration/slashing/slashing_test.go (1)
117-117
: Improved error assertion logic.The correction in the error assertion logic enhances readability and correctness, aligning with Go's best practices for error handling.
log/logger.go (1)
33-35
: Enhanced type safety withcontextKey
.The introduction of
contextKey
as a distinct type forContextKey
improves type safety and maintainability by preventing potential type collisions.x/distribution/keeper/msg_server.go (1)
192-192
: Simplified error wrapping is acceptable.The change from
errors.Wrapf
toerrors.Wrap
simplifies the error message. Ensure that the error message remains clear and informative without the formatted context.x/gov/keeper/proposal.go (1)
86-88
: Simplified error wrapping is acceptable.The change from
errorsmod.Wrapf
toerrorsmod.Wrap
simplifies the error message. Ensure that the error message remains clear and informative without the formatted context.x/group/client/cli/tx.go (1)
501-501
: Verify assumption aboutprop.Proposers
.The removal of the nil check assumes that
prop.Proposers
will not be nil. Ensure this assumption is valid to prevent potential runtime errors.x/group/keeper/keeper.go (1)
458-458
: Simplify error wrapping by removing formatting.The change from
Wrapf
toWrap
simplifies the error message handling by removing unnecessary formatting. This enhances consistency and clarity in error reporting.x/gov/keeper/msg_server.go (1)
386-386
: Simplify error wrapping by removing formatting.The change from
Wrapf
toWrap
in theSudoExec
function simplifies error handling by removing unnecessary formatting. This improves the consistency and clarity of error messages.x/upgrade/keeper/abci_test.go (2)
151-151
: Enhance readability in error checking.Reversing the order of parameters in
errors.Is
improves readability and aligns with typical usage patterns, ensuring that the error variable is the first argument.
226-226
: Enhance readability in error checking.Reversing the order of parameters in
errors.Is
improves readability and aligns with typical usage patterns, ensuring that the error variable is the first argument.tests/systemtests/system.go (1)
250-250
: Simplified error handling is appropriate.The change from
t.Fatalf(err.Error())
tot.Fatal(err.Error())
simplifies the error handling without affecting functionality, as no formatting is required.
(cherry picked from commit 6276b01) # Conflicts: # log/CHANGELOG.md # log/logger.go # tools/cosmovisor/cmd/cosmovisor/version_test.go
* main: (76 commits) docs: more app v2 renaming (#21336) chore: update link in disclaimer (#21339) refactor(x/distribution): audit QA (#21316) docs: rename app v2 to app di when talking about runtime v0 (#21329) feat(schema): specify JSON mapping (#21243) fix(x/authz): bring back msg response in `DispatchActions` (#21044) chore: fix all lint issue since golangci-lint bump (#21326) refactor(x/mint): v0.52 audit x/mint (#21301) chore: fix spelling errors (#21327) feat: export genesis in simapp v2 (#21199) fix(baseapp)!: Halt at height now does not produce the halt height block (#21256) refactor(scripts): remove unused variable (#21320) chore(schema/testing): upgrade to go 1.23 iterators (#21282) chore: readmes + upgrading docs (#21271) feat(client): add auto cli for node service (#21074) ci: fix github workflow vulnerable to script injection (#21304) build(deps): Bump github.com/prometheus/client_golang from 1.19.1 to 1.20.0 (#21307) build(deps): use Go 1.23 instead of Go 1.22 (#21280) refactor(x/auth): audit x/auth changes (#21146) chore: remove todo: "abstract out staking message back to staking" (#21266) ...
Description
With the bump to golangci-lint v1.60.1, some lint issue have happened: which blocks other PR with unrelated required changes: https://github.com/cosmos/cosmos-sdk/actions/runs/10418897604/job/28855908251?pr=21281
We had a job to run golangci-lint in the whole codebase at version bump, but due to the split of the makefile this hasn't happened.
This PR fixes all errors returned by
make lint-fix
and updates the job to re-run linting on the whole codebase if a*.mk
file it touched.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...
!
in the type prefix if API or client breaking changeCHANGELOG.md
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.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
.mk
files for better validation of Makefiles.