-
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: remove unused local variables #22340
Conversation
📝 WalkthroughWalkthroughThe pull request introduces modifications across several files in a Go project. Key changes include an update to the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
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 using PR comments)
Other keywords and placeholders
Documentation and Community
|
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: 2
🧹 Outside diff range and nitpick comments (3)
.golangci.yml (1)
123-123
: Add newline at end of fileAdd a newline character at the end of the file to follow POSIX standards and common best practices.
unused: local-variables-are-used: false +
🧰 Tools
🪛 yamllint
[error] 123-123: no new line character at the end of file
(new-line-at-end-of-file)
types/mempool/priority_nonce_test.go (2)
Line range hint
598-609
: Correct grammatical errors in function commentsThe comments within the
validateOrder
function contain grammatical errors that affect readability:
- "Then if t2.sender have the same sender" should be "Then if
t1
andt2
have the same sender".- "t3.n < t2.n" should likely be "t3.n < t2.n or t3.n <= t2.n" for consistency.
- The sentence structures can be improved for clarity.
Consider revising the comments as follows:
// Given two transactions t1 and t2, where t2.p > t1.p but t2.i < t1.i, - // Then if t2.sender have the same sender then t2.nonce > t1.nonce - // or - // If t1 and t2 have different senders then there must be some t3 with - // t3.sender == t2.sender and t3.n < t2.n and t3.p <= t1.p + // then if t1 and t2 have the same sender, t2.nonce should be greater than t1.nonce. + // If t1 and t2 have different senders, then there must be some transaction t3 with + // t3.sender == t2.sender, t3.n < t2.n, and t3.p <= t1.p.
Line range hint
93-185
: Refactor duplicated test code inTestPriorityNonceTxOrderWithAdapter
andTestPriorityNonceTxOrder
The test functions
TestPriorityNonceTxOrderWithAdapter
andTestPriorityNonceTxOrder
have significant duplication in their setup and execution logic. Refactoring shared code into helper functions or methods will reduce redundancy, enhance readability, and make future maintenance easier.Also applies to: 186-274
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (6)
- .golangci.yml (1 hunks)
- schema/indexer/start.go (1 hunks)
- simapp/export.go (0 hunks)
- store/cachekv/store_test.go (0 hunks)
- types/mempool/priority_nonce_test.go (1 hunks)
- x/staking/keeper/query_utils.go (0 hunks)
💤 Files with no reviewable changes (3)
- simapp/export.go
- store/cachekv/store_test.go
- x/staking/keeper/query_utils.go
🧰 Additional context used
📓 Path-based instructions (2)
schema/indexer/start.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.types/mempool/priority_nonce_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"
🪛 yamllint
.golangci.yml
[error] 123-123: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (1)
schema/indexer/start.go (1)
123-123
: LGTM! Improved error wrapping.The change from
%v
to%w
verb infmt.Errorf
is a good improvement as it properly wraps the original error, allowing better error handling and stack trace preservation up the call chain. This follows Go's error handling best practices.
unused: | ||
local-variables-are-used: false |
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.
Reconsider disabling unused local variable checks
This change appears to contradict the PR's objective of removing unused local variables. Setting local-variables-are-used: false
will prevent the linter from detecting unused variables, which could lead to code quality issues and dead code accumulation in the future.
Consider removing these lines to maintain strict checking for unused variables:
- unused:
- local-variables-are-used: false
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
unused: | |
local-variables-are-used: false |
🧰 Tools
🪛 yamllint
[error] 123-123: no new line character at the end of file
(new-line-at-end-of-file)
types/mempool/priority_nonce_test.go
Outdated
@@ -588,6 +588,7 @@ func validateOrder(mtxs []sdk.Tx) error { | |||
} | |||
} | |||
} | |||
_ = iterations |
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.
Unused variable 'iterations' should be removed
The variable iterations
in the validateOrder
function is declared but never used in a meaningful way. Assigning _ = iterations
is unnecessary and only suppresses the compiler warning. Considering the PR's objective to remove unused local variables, it's better to remove the variable entirely to clean up the code.
Apply the following diff to eliminate the unused variable:
func validateOrder(mtxs []sdk.Tx) error {
- iterations := 0
var itxs []txSpec
for i, mtx := range mtxs {
- iterations++
tx := mtx.(testTx)
itxs = append(itxs, txSpec{p: int(tx.priority), n: int(tx.nonce), a: tx.address, i: i})
}
// Existing logic...
- _ = iterations
// fmt.Printf("validation in iterations: %d\n", iterations)
return nil
}
Committable suggestion was skipped due to low confidence.
@Mergifyio backport release/v0.52.x |
✅ Backports have been created
|
(cherry picked from commit 1515856) # Conflicts: # store/cachekv/store_test.go
Co-authored-by: zakir <[email protected]> Co-authored-by: Julien Robert <[email protected]>
* main: (157 commits) feat(core): add ConfigMap type (#22361) test: migrate e2e/genutil to systemtest (#22325) feat(accounts): re-introduce bundler (#21562) feat(log): add slog-backed Logger type (#22347) fix(x/tx): add feePayer as signer (#22311) test: migrate e2e/baseapp to integration tests (#22357) test: add x/circuit system tests (#22331) test: migrate e2e/tx tests to systemtest (#22152) refactor(simdv2): allow non-comet server components (#22351) build(deps): Bump rtCamp/action-slack-notify from 2.3.1 to 2.3.2 (#22352) fix(server/v2): respect context cancellation in start command (#22346) chore(simdv2): allow overriding the --home flag (#22348) feat(server/v2): add SimulateWithState to AppManager (#22335) docs(x/accounts): improve comments (#22339) chore: remove unused local variables (#22340) test: x/accounts systemtests (#22320) chore(client): use command's configured output (#22334) perf(log): use sonic json lib (#22233) build(deps): bump x/tx (#22327) fix(x/accounts/lockup): fix proto path (#22319) ...
Description
Closes: #XXXX
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
New Features
Bug Fixes
Tests
CacheKVStore
and priority nonce mempool.Documentation