Skip to content

chore: quick cleanup - #2239

Merged
tac0turtle merged 4 commits into
mainfrom
marko/cleanup
May 2, 2025
Merged

chore: quick cleanup#2239
tac0turtle merged 4 commits into
mainfrom
marko/cleanup

Conversation

@tac0turtle

@tac0turtletac0turtle commented May 2, 2025

Copy link
Copy Markdown
Contributor

Overview

Summary by CodeRabbit

  • Refactor
    • Updated various tests and internal methods to use more idiomatic Go syntax, including replacing explicit context creation with test-provided contexts and updating loop constructs to range-based forms.
    • Replaced usage of interface{} with any in method signatures and variable declarations for improved clarity and modern Go style.
    • Simplified logic for certain value assignments using concise standard library functions.
  • Style
    • Improved code readability and consistency by adopting current Go best practices in type declarations and loop structures.
  • Bug Fixes
    • Corrected loop logic in transaction generation to ensure proper iteration and data population.

@coderabbitai

coderabbitaiBot commented May 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This set of changes primarily focuses on code modernization and cleanup across multiple packages. The main updates include replacing the use of interface{} with the Go 1.18+ alias any in function signatures, variable declarations, and method parameters. Additionally, many test files now use the testing framework's t.Context() instead of explicitly creating and canceling contexts. Several for-loops have been updated from index-based to range-based syntax for improved readability. No changes are made to the core logic, exported entity signatures (except for the any alias), or control flow, except for a potential bug introduced in types/utils.go by incorrectly using range over an integer.

Changes

File(s)Change Summary
block/publish_block_test.go, block/reaper_test.go, pkg/store/prefix_test.go, pkg/store/store_test.go, pkg/p2p/client_test.goReplaced explicit context creation/cancellation with t.Context() from the testing framework in all relevant test functions and mock calls. Removed unnecessary context imports.
block/submitter.goRefactored gas price adjustment logic to use max(gasPrice, initialGasPrice) instead of a conditional check after division.
node/full_node_integration_test.go, pkg/cache/cache_test.go, pkg/p2p/utils_test.go, types/utils.go, types/utils_test.go, test/e2e/sut_helper.goUpdated for-loop syntax from index-based (for i := 0; i < N; i++) to range-based (for i := range N or similar) in various places for improved readability.
node/helpers.go, pkg/os/os.go, pkg/os/os_test.go, test/e2e/sut_helper.goChanged variadic parameter type from ...interface{} to ...any in logger and helper function signatures.
pkg/cmd/run_node_test.go, pkg/genesis/io_test.go, pkg/config/config_test.goUpdated struct fields, variable declarations, and function parameters from interface{} to any for modern Go style.
pkg/p2p/utils_test.goChanged IP slice copying to use make and copy for deep copying instead of append.
pkg/config/config_test.goChanged the expectedValue parameter in assertFlagValue from interface{} to any.
pkg/os/os.go, pkg/os/os_test.goUpdated the logger interface and its mock implementation to use any instead of interface{} for variadic parameters.
types/utils.goChanged loop over integer to range-based, which may introduce a bug since range over an integer is not valid Go syntax.

Sequence Diagram(s)

sequenceDiagram
participant Tester
participant TestFunction
participant MockComponent
Tester->>TestFunction: Call test with t.Context()
TestFunction->>MockComponent: Use t.Context() in mock expectations
TestFunction->>TestFunction: Run test logic (unchanged)
TestFunction->>MockComponent: Call method with t.Context()
MockComponent-->>TestFunction: Return expected result
TestFunction-->>Tester: Assert results
Loading

Suggested labels

T:testing, T:code-hygiene

Suggested reviewers

  • tzdybal
  • tuxcanfly
  • Manav-Aggarwal
  • yarikbratashchuk

Poem

In fields of code, a rabbit hops,
Swapping interface{} for any—it never stops!
Loops now range with graceful flair,
Contexts from tests float through the air.
Cleaner, lighter, modern Go,
This bunny’s work is all aglow.
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions

github-actionsBot commented May 2, 2025

Copy link
Copy Markdown
Contributor

The latest Buf updates on your PR. Results from workflow CI and Release / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedMay 2, 2025, 9:29 AM

Comment threadpkg/config/yaml.go Outdated
@codecov

codecovBot commented May 2, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 55.02%. Comparing base (fbe8b10) to head (aaf0a3f).
Report is 1 commits behind head on main.

Files with missing linesPatch %Lines
node/helpers.go0.00%2 Missing ⚠️
block/submitter.go0.00%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #2239 +/- ##
==========================================
+ Coverage 55.01% 55.02% +0.01% 
==========================================
Files 52 52 Lines 4508 4507 -1 ==========================================
Hits 2480 2480 + Misses 1762 1761 -1 
Partials 266 266 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR performs a quick cleanup to update context-usage and parameter types from interface{} to any, while also replacing traditional for-loops with the “for range” construct throughout several test and helper files.

  • Update of context propagation to use t.Context() instead of manually creating a context
  • Replacement of “for i := 0; i < X; i++” loops with “for range X” loops across multiple test files
  • Substitution of interface{} with any in several function signatures to reflect updated coding style

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 10 comments.

Show a summary per file
FileDescription
types/serialization_test.goChanged loop syntax by replacing index-based loop with “for range 8”.
test/e2e/sut_helper.goUpdated context usage and replaced traditional loop with “for range 5”.
pkg/store/store_test.goSwitched context and loop syntax in tests using constant “n”.
pkg/store/prefix_test.goRevised loops to use “for range len(keys)” instead of index-based loops.
pkg/signer/file/file_signer_test.goUpdated loops to use “for range” on integer variables numGoRoutines and messageCount.
pkg/p2p/utils_test.goModified loop syntax to use “for range” on integer n.
pkg/cache/cache_test.goChanged loops to use “for range” on integer values goroutines and operations.
node/full_node_integration_test.goConverted several index-based loops to “for range” style.
...Additional similar adjustments in remaining files.

Comment threadtypes/serialization_test.go Outdated
// create random hashes
h := []Hash{}
for i := 0; i < 8; i++ {
for range 8 {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

Using 'for range' directly on an integer constant is not valid in Go as integers are not iterable. Consider using 'for i := 0; i < 8; i++' or 'for range make([]struct{}, 8)' if an index is not needed.

Suggested change
forrange8 {
forrangemake([]struct{}, 8) {

Copilot uses AI. Check for mistakes.
}()
})
for i := 0; i < 5; i++ {
for range 5 {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

Using 'for range' on an integer literal is not valid in Go; use a conventional loop like 'for i := 0; i < 5; i++' or iterate over a slice of length 5 instead.

Suggested change
forrange5 {
fori:=0; i<5; i++ {

Copilot uses AI. Check for mistakes.
Comment threadpkg/store/store_test.go Outdated
Comment on lines +174 to +178
for i := range n {
require.NoError(s.SetMetadata(t.Context(), getKey(i), getValue(i)))
}

for i := 0; i < n; i++ {
value, err := s.GetMetadata(ctx, getKey(i))
for i := range n {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

The 'for range' construct cannot be used directly on an integer (n); use a loop like 'for i := 0; i < n; i++' or range over a slice of length n.

Copilot uses AI. Check for mistakes.
Comment threadpkg/store/prefix_test.go Outdated

for i := 0; i < len(keys); i++ {
err := prefixbatchkv1.Put(ctx, keys[i], values[i])
for i := range len(keys) {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

Ranging over the result of 'len(keys)' is invalid because len(keys) returns an integer. Consider using 'for i := 0; i < len(keys); i++' or 'for i := range keys' instead.

Suggested change
fori:=rangelen(keys) {
fori:=0; i<len(keys); i++ {

Copilot uses AI. Check for mistakes.
Comment threadpkg/signer/file/file_signer_test.go Outdated
Comment on lines +394 to +396
for i := range numGoRoutines {
go func(routineNum int) {
for j := 0; j < messageCount; j++ {
for j := range messageCount {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

The expression 'numGoRoutines' is an integer; using 'for range' on an integer is invalid. Use 'for i := 0; i < numGoRoutines; i++' instead.

Copilot uses AI. Check for mistakes.
Comment threadpkg/signer/file/file_signer_test.go Outdated
Comment on lines +394 to +396
for i := range numGoRoutines {
go func(routineNum int) {
for j := 0; j < messageCount; j++ {
for j := range messageCount {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

Using 'for range' on 'messageCount', which is an integer, is not allowed. Replace with a conventional loop such as 'for j := 0; j < messageCount; j++'.

Copilot uses AI. Check for mistakes.
Comment threadpkg/cache/cache_test.go Outdated
Comment on lines +102 to +105
for i := range goroutines {
go func(id int) {
defer wg.Done()
for j := 0; j < operations; j++ {
for j := range operations {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

The variable 'goroutines' is an integer and cannot be directly iterated over using 'for range'. Consider replacing with 'for i := 0; i < goroutines; i++'.

Copilot uses AI. Check for mistakes.
Comment threadpkg/cache/cache_test.go Outdated
Comment on lines +102 to +105
for i := range goroutines {
go func(id int) {
defer wg.Done()
for j := 0; j < operations; j++ {
for j := range operations {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

Since 'operations' is an integer, iterating over it with 'for range' is invalid. Use a traditional loop syntax like 'for j := 0; j < operations; j++' instead.

Copilot uses AI. Check for mistakes.
Comment threadpkg/p2p/utils_test.go Outdated

mnet := mocknet.New()
for i := 0; i < n; i++ {
for i := range n {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

The identifier 'n' is an integer and cannot be used with 'for range' directly. Replace with a loop such as 'for i := 0; i < n; i++' or range over a constructed slice.

Suggested change
fori:=rangen {
fori:=0; i<n; i++ {

Copilot uses AI. Check for mistakes.
Comment threadblock/retriever.go Outdated
var err error
m.logger.Debug("trying to retrieve block from DA", "daHeight", daHeight)
for r := 0; r < dAFetcherRetries; r++ {
for range dAFetcherRetries {

CopilotAIMay 2, 2025

Copy link

Choose a reason for hiding this comment

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

Using 'for range' on 'dAFetcherRetries' (an integer) is not valid. Consider using 'for r := 0; r < dAFetcherRetries; r++' instead.

Suggested change
forrangedAFetcherRetries {
forr:=0; r<dAFetcherRetries; r++ {

Copilot uses AI. Check for mistakes.
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 11

♻️ Duplicate comments (1)
pkg/store/prefix_test.go (1)

100-104: ⚠️ Potential issue

Same scalar-range issue in verification loop

Repeat of the previous compile error; apply the same correction.

-	for i := range len(keys) {+	for i := range keys {
🧹 Nitpick comments (1)
block/publish_block_test.go (1)

309-309: Consider cleanup of unused cancel function

Your change to use t.Context() means the cancel function returned from setupManagerForPublishBlockTest is no longer used. Consider a follow-up PR to update the test setup function to no longer return the now-unused cancel function.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fbe8b10 and eb735e9.

📒 Files selected for processing (22)
  • block/publish_block_test.go (2 hunks)
  • block/reaper_test.go (4 hunks)
  • block/retriever.go (1 hunks)
  • block/submitter.go (1 hunks)
  • node/full_node_integration_test.go (4 hunks)
  • node/helpers.go (1 hunks)
  • pkg/cache/cache_test.go (1 hunks)
  • pkg/cmd/run_node_test.go (1 hunks)
  • pkg/config/config_test.go (1 hunks)
  • pkg/config/yaml.go (1 hunks)
  • pkg/genesis/io_test.go (1 hunks)
  • pkg/os/os.go (1 hunks)
  • pkg/os/os_test.go (1 hunks)
  • pkg/p2p/client_test.go (2 hunks)
  • pkg/p2p/utils_test.go (3 hunks)
  • pkg/signer/file/file_signer_test.go (1 hunks)
  • pkg/store/prefix_test.go (2 hunks)
  • pkg/store/store_test.go (5 hunks)
  • test/e2e/sut_helper.go (3 hunks)
  • types/serialization_test.go (1 hunks)
  • types/utils.go (1 hunks)
  • types/utils_test.go (3 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
node/helpers.go

[warning] 37-37: node/helpers.go#L37
Added line #L37 was not covered by tests


[warning] 40-40: node/helpers.go#L40
Added line #L40 was not covered by tests

block/submitter.go

[warning] 113-113: block/submitter.go#L113
Added line #L113 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (32)
pkg/genesis/io_test.go (1)

97-97: Approve modern any alias usage. Replacing interface{} with any improves readability and aligns with Go 1.18+ idioms.

pkg/p2p/client_test.go (2)

85-85: Use t.Context() for test context. Leveraging t.Context() simplifies test setup and ensures context cancellation with the test lifecycle.


106-106: Use t.Context() for test context. Consistent with modern Go testing patterns and the other test file updates.

pkg/p2p/utils_test.go (1)

60-61: Improved slice copying approach.

The change from using append(net.IP{}, unicastAddr...) to explicitly allocating memory with make followed by copy is a good optimization. This approach is more direct and potentially more efficient by pre-allocating the exact size needed.

pkg/config/config_test.go (1)

279-279: Good modernization of type signature.

Changing from interface{} to any follows modern Go conventions (Go 1.18+) and improves code readability while maintaining the same functionality. This is a recommended practice.

node/full_node_integration_test.go (4)

148-153: Loop syntax updated to use range-based iteration.

The loop has been updated to use the more idiomatic Go range-based iteration. This change maintains the same behavior as the original code while making it more concise.


239-245: Loop syntax updated to use range-based iteration with index.

The loop has been converted to use range-based iteration. The index variable is still needed here since it's used for logging, which is correctly preserved in the new syntax.


255-263: Loop syntax updated to use range-based iteration with index.

The loop has been converted to use range-based iteration while preserving the index variable needed for logging. This maintains the same functionality with more idiomatic Go syntax.


291-304: Loop syntax updated to use range-based iteration with index.

The loop has been converted to use range-based iteration while preserving the index variable that's needed for logging. This change follows modern Go conventions while maintaining the same behavior.

pkg/store/store_test.go (11)

43-44: Context management improved using t.Context().

Test code has been improved by using the built-in test context instead of creating a manual context. This is a best practice in Go testing that simplifies context management.


49-52: Context management improved using t.Context().

Test context handling has been improved by using the built-in test context for DB operations, following Go testing best practices.


55-56: Context management improved using t.Context().

Using the test's built-in context for the Height() call improves test code by eliminating manual context management.


100-101: Context management improved using t.Context().

Using the test's built-in context for the SaveBlockData() call improves test code by eliminating manual context management.


106-107: Context management improved using t.Context().

Using the test's built-in context for the GetBlockData() call improves test code by eliminating manual context management.


113-114: Context management improved using t.Context().

Using the test's built-in context for the GetSignature() call improves test code by eliminating manual context management.


135-138: Context management improved using t.Context().

Using the test's built-in context for the UpdateState() call improves test code by eliminating manual context management.


149-151: Context management improved using t.Context().

Using the test's built-in context for the GetState() call improves test code by eliminating manual context management.


174-176: Loop syntax updated to use range-based iteration.

The loop has been updated to use the more idiomatic Go range-based iteration. Since the loop only uses the index variable to generate keys and values, this change maintains the same behavior.


178-182: Loop syntax updated and context management improved.

The loop syntax has been updated to use range-based iteration, and the context for GetMetadata() has been changed to use the test's built-in context. Both changes follow Go best practices without altering behavior.


184-186: Context management improved using t.Context().

Using the test's built-in context for the GetMetadata() call improves test code by eliminating manual context management.

test/e2e/sut_helper.go (4)

154-158: Type declaration updated from interface{} to any.

The parameter type has been updated to use the more modern any type, which is an alias for interface{} introduced in Go 1.18. This improves code readability without changing functionality.


160-164: Type declaration updated from interface{} to any.

The parameter type has been updated to use the more modern any type, which is an alias for interface{} introduced in Go 1.18. This improves code readability without changing functionality.


185-187: Updated variadic parameter type from interface{} to any.

The variadic parameter type has been updated to use the more modern any type, which is an alias for interface{} introduced in Go 1.18. This improves code readability without changing functionality.


218-223: Loop syntax updated to use range-based iteration.

The loop in the Shutdown method has been updated to use the more idiomatic Go range-based iteration. Since the loop body doesn't use the index variable, this change maintains the same behavior while making the code more concise.

pkg/cmd/run_node_test.go (1)

102-103: Updated struct field types from interface{} to any.

The struct field types have been updated to use the more modern any type, which is an alias for interface{} introduced in Go 1.18. This improves code readability without changing functionality.

pkg/os/os.go (1)

13-13: Modernize variadic type alias for consistency

Replacing ...interface{} with ...any is a safe, idiomatic update for Go 1.18+. No functional change.

node/helpers.go (1)

37-37: Update variadic parameters to use any

Changing signatures from ...interface{} to ...any aligns with Go 1.18+ idioms without altering behavior. These helper methods remain no-op stubs and maintain expected signatures.

Also applies to: 40-40

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 37-37: node/helpers.go#L37
Added line #L37 was not covered by tests

pkg/os/os_test.go (1)

13-13: Synchronize mock logger with updated interface

Updating lastKV to []any and Info(...any) keeps the mock in sync with the logger interface. No logic changes.

Also applies to: 16-16

block/reaper_test.go (1)

28-28: Use t.Context() for consistent test context

Switching to the built-in t.Context() cleans up manual context setup and cancellation in tests, while preserving existing test logic.

Also applies to: 63-63, 96-96, 113-113

block/publish_block_test.go (3)

312-323: Great improvement using t.Context()

Replacing the manually created context with t.Context() improves the code by:

  • Better aligning with modern Go testing conventions
  • Reducing boilerplate context management code
  • Ensuring the test context is properly propagated

Since you've consistently applied this change to all mock expectations, this is a clean improvement.


329-330: Consistent context use in executor mocks

Good job maintaining consistency by updating these executor mock expectations to also use t.Context().


345-346: Clean sequencer mock and manager call updates

The sequencer mock and the publishBlock call have been properly updated to use t.Context(), completing the conversion from manual context to test framework context.

Comment threadpkg/config/yaml.go Outdated
Comment threadtypes/utils_test.go
// Generate 100 random transactions and check that they are all unique
txSet := make(map[string]bool)
for i := 0; i < 100; i++ {
for range 100 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Invalid loop syntax over integer. for range 100 is invalid since range requires a collection (slice, array, map, or channel). Replace with a traditional for-loop.

Proposed fix:

- for range 100 {+ for i := 0; i < 100; i++ {
📝 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.

Suggested change
forrange100 {
fori:=0; i<100; i++ {

Comment threadtypes/serialization_test.go Outdated
Comment on lines +102 to 106
for i := range goroutines {
go func(id int) {
defer wg.Done()
for j := 0; j < operations; j++ {
for j := range operations {
// Test concurrent item operations

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Range-over-integer causes compilation failure

range expects an iterable (array, slice, map, string, channel).
Here both goroutines and operations are plain int constants, so the test will not compile (cannot range over <int>).

-	for i := range goroutines {+	for i := 0; i < goroutines; i++ {- for j := range operations {+ for j := 0; j < operations; j++ {
📝 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.

Suggested change
fori:=rangegoroutines {
gofunc(idint) {
deferwg.Done()
forj:=0; j<operations; j++ {
forj:=rangeoperations {
// Test concurrent item operations
fori:=0; i<goroutines; i++ {
gofunc(idint) {
deferwg.Done()
forj:=0; j<operations; j++ {
// Test concurrent item operations

Comment threadpkg/signer/file/file_signer_test.go Outdated
Comment threadpkg/p2p/utils_test.go Outdated
Comment threadpkg/p2p/utils_test.go Outdated
Comment threadblock/retriever.go Outdated
Comment threadtypes/utils.go
Comment threadblock/submitter.go

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
pkg/cache/cache_test.go (1)

102-102: ⚠️ Potential issue

Range-over-integer causes compilation failure

Go's range keyword can only iterate over arrays, slices, maps, strings, or channels. Since goroutines is an integer constant (defined as 10 on line 96), using range goroutines will cause a compilation error.

-	for i := range goroutines {+	for i := 0; i < goroutines; i++ {
🧹 Nitpick comments (1)
pkg/cache/cache_test.go (1)

105-105: Inconsistent loop styles within the same function

While the outer loop was changed to use range (incorrectly), the inner loop still uses the traditional for j := 0; j < operations; j++ style. For consistency, either both loops should use the same style, or both should be updated correctly.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb735e9 and aaf0a3f.

📒 Files selected for processing (4)
  • pkg/cache/cache_test.go (1 hunks)
  • pkg/p2p/utils_test.go (2 hunks)
  • pkg/store/prefix_test.go (2 hunks)
  • pkg/store/store_test.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/store/prefix_test.go
  • pkg/p2p/utils_test.go
  • pkg/store/store_test.go
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: rollkit-docker / docker-build (GHCR; ghcr.io/rollkit/rollkit)
  • GitHub Check: test / Build All Rollkit Binaries
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary

@tac0turtle
tac0turtle added this pull request to the merge queueMay 2, 2025
Merged via the queue into main with commit dcb40d1May 2, 2025
@tac0turtle
tac0turtle deleted the marko/cleanup branch May 2, 2025 12:02
@tac0turtletac0turtle removed this from EvolveAug 25, 2025
@coderabbitaicoderabbitaiBot mentioned this pull request Jul 15, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tac0turtle@randygrok