Skip to content

Conversation

@flemzord
Copy link
Member

@flemzord flemzord commented Feb 9, 2026

Summary

  • Configure tagliatelle linter with goCamel convention following Effective Go naming rules (json, yaml, xml, bson, env tags)
  • Exclude pkg/client (generated SDK code) from linting
  • Suppress gocyclo false positives on string mapping table, AST visitor, and bytecode interpreter
  • Fix unconvert unnecessary type conversions
  • Add nolint:unparam directives where parameters are intentionally kept for API consistency
  • Fix errchkjson unchecked json.Marshal error
  • Add missing t.Parallel() calls to satisfy tparallel linter (27 test functions)
  • Enable usetesting linter and replace context.Background()/context.TODO() with t.Context() in tests

Test plan

  • just lint passes with 0 issues
  • go test -race ./... passes all unit tests

Enable tagliatelle linter to enforce Effective Go naming conventions
on struct tags (json, yaml, xml, bson, env). Exclude generated SDK
code in pkg/client from linting. Add nolint directives for targetId
fields to preserve JSON API backward compatibility.
…positives

Exclude pkg/client from golangci-lint analysis as it contains generated
SDK code. Add nolint:gocyclo directives on three functions where high
cyclomatic complexity is structural (string mapping, AST visitor,
bytecode interpreter) rather than indicative of actual logic complexity.
Remove unnecessary type conversions for RuntimeType and string casts.
Add nolint:unparam directives where parameters are intentionally kept
for API consistency, recursive propagation, or test flexibility.
Handle the error return from json.Marshal instead of silently
discarding it. Panic on failure as DocID contains only basic types
that cannot fail to marshal.
Add t.Parallel() to test functions and subtests where it was missing,
ensuring both parent tests and their subtests call t.Parallel()
consistently across API v1, API v2, VM, replication, storage, and
accounts test files.
Enable usetesting linter and replace context.Background() and
context.TODO() with t.Context() (or b.Context()) in test files.
This ensures test contexts are properly cancelled when tests finish,
preventing resource leaks.
@flemzord flemzord requested a review from a team as a code owner February 9, 2026 12:03
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • internal/README.md is excluded by !internal/README.md

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Broad refactoring across the codebase: adding test parallelization via t.Parallel(), migrating test contexts from context.Background/TODO() to t.Context(), and introducing linting suppressions. Minor logic adjustments include a new event handler method, parser selection change, and error handling improvement.

Changes

Cohort / File(s) Summary
Linting Annotations
internal/api/bulking/elements.go, internal/log.go, pkg/events/message.go
Added //nolint:tagliatelle directives to TargetID fields in request and metadata structs to suppress lint warnings for camelCase JSON tags.
Cyclomatic Complexity Suppressions
internal/machine/script/compiler/source.go, internal/machine/vm/machine.go, internal/tracing/tracing.go
Added //nolint:gocyclo and //nolint:unparam directives to functions without altering behavior or control flow.
Test Parallelization: V1 API
internal/api/v1/controllers_accounts_add_metadata_test.go, internal/api/v1/controllers_accounts_count_test.go, internal/api/v1/controllers_accounts_list_test.go, internal/api/v1/controllers_accounts_read_test.go, internal/api/v1/controllers_balances_aggregates_test.go, internal/api/v1/controllers_logs_list_test.go, internal/api/v1/controllers_transactions_count_test.go, internal/api/v1/controllers_transactions_list_test.go
Added t.Parallel() inside subtests to enable concurrent test execution without modifying test logic or expectations.
Test Parallelization: V2 API
internal/api/v2/controllers_accounts_add_metadata_test.go, internal/api/v2/controllers_accounts_count_test.go, internal/api/v2/controllers_accounts_list_test.go, internal/api/v2/controllers_accounts_read_test.go, internal/api/v2/controllers_balances_test.go, internal/api/v2/controllers_logs_export_test.go, internal/api/v2/controllers_logs_import_test.go, internal/api/v2/controllers_logs_list_test.go, internal/api/v2/controllers_transactions_add_metadata_test.go, internal/api/v2/controllers_transactions_count_test.go, internal/api/v2/controllers_transactions_list_test.go, internal/api/v2/controllers_volumes_test.go
Added t.Parallel() inside subtests to enable concurrent test execution without modifying test logic or expectations.
Test Parallelization: Other
internal/bus/listener_test.go, internal/machine/vm/machine_test.go, internal/machine/vm/run_test.go, internal/replication/manager_test.go, internal/storage/ledger/logs_test.go, pkg/accounts/account_test.go
Added t.Parallel() to test functions and subtests to enable concurrent execution.
Context Migration
internal/bus/listener_test.go, internal/controller/ledger/controller_default_test.go, internal/machine/vm/machine_test.go, internal/machine/vm/run_test.go, internal/replication/drivers/batcher_test.go, internal/replication/drivers/clickhouse/driver_test.go, internal/replication/drivers/elasticsearch/driver_test.go, internal/replication/drivers/http/driver_test.go, internal/replication/drivers/noop/driver_test.go, internal/replication/drivers/stdout/driver_test.go, internal/storage/ledger/accounts_test.go, internal/storage/ledger/logs_test.go, test/performance/pkg/read/read_test.go
Replaced context.Background() and context.TODO() with t.Context() to derive contexts from testing.T; removed unused context imports.
Logic Changes
internal/controller/ledger/controller_default.go, internal/controller/ledger/controller_with_events.go, internal/replication/drivers/elasticsearch/driver.go
Modified parser selection to remove explicit type conversion; added new handleEvent method for event deferred execution at commit; improved error handling in DocID.String() to panic on JSON marshalling failure.
Test Helper Updates
internal/storage/ledger/main_test.go, internal/replication/manager.go
Added //nolint:unparam directives to test helpers and manager methods without changing signatures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A hoppy refactor hops along,
Tests run faster, concurrent and strong,
Contexts flow from T's gentle hands,
Lint directives calm the demands,
Now parallel hares bound through the test lands!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.85% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: improve golangci-lint configuration' accurately and concisely summarizes the main change—configuring and improving golangci-lint settings across the codebase.
Description check ✅ Passed The description provides a detailed, well-organized summary of all changes including linter configuration, test improvements, and verification steps, making it directly relevant to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/improve-golangci-lint-config

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/controller/ledger/controller_with_events.go (1)

30-42: ⚠️ Potential issue | 🟠 Major

Defer events when a parent transaction is active.

When c.hasTx is false but c.parent.hasTx is true (e.g., a controller returned by LockLedger within a transaction), handleEvent executes immediately and bypasses commit-time dispatch. This breaks the “emit at commit” semantics for nested controllers.

🔧 Suggested fix (prioritize parent tx before immediate execution)
 func (c *ControllerWithEvents) handleEvent(ctx context.Context, fn func()) {
-	if !c.hasTx {
-		fn()
-		return
-	}
-	if c.parent != nil && c.parent.hasTx {
+	if c.parent != nil && c.parent.hasTx {
 		c.parent.handleEvent(ctx, fn)
 		return
 	}
+	if !c.hasTx {
+		fn()
+		return
+	}
 
 	c.atCommit = append(c.atCommit, fn)
 }
🧹 Nitpick comments (1)
internal/storage/ledger/accounts_test.go (1)

327-329: Consider using ctx for consistency within this test.

The test declares ctx := logging.TestingContext() at line 321 and uses it for UpdateAccountsMetadata at line 323, but this call now uses t.Context(). This creates an inconsistency where one operation has the logging context and the other doesn't.

For consistency with both this test function and all other tests in this file, consider using ctx here.

Suggested change
-	account, err := store.Accounts().GetOne(t.Context(), common.ResourceQuery[any]{
+	account, err := store.Accounts().GetOne(ctx, common.ResourceQuery[any]{

gfyrag
gfyrag previously approved these changes Feb 9, 2026
Sign up for free to 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.

2 participants