-
Notifications
You must be signed in to change notification settings - Fork 146
chore: improve golangci-lint configuration #1258
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
base: main
Are you sure you want to change the base?
Conversation
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.
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughBroad refactoring across the codebase: adding test parallelization via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
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.
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 | 🟠 MajorDefer events when a parent transaction is active.
When
c.hasTxis false butc.parent.hasTxis true (e.g., a controller returned byLockLedgerwithin a transaction),handleEventexecutes 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 usingctxfor consistency within this test.The test declares
ctx := logging.TestingContext()at line 321 and uses it forUpdateAccountsMetadataat line 323, but this call now usest.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
ctxhere.Suggested change
- account, err := store.Accounts().GetOne(t.Context(), common.ResourceQuery[any]{ + account, err := store.Accounts().GetOne(ctx, common.ResourceQuery[any]{
Summary
goCamelconvention following Effective Go naming rules (json, yaml, xml, bson, env tags)pkg/client(generated SDK code) from lintingjson.Marshalerrorcontext.Background()/context.TODO()witht.Context()in testsTest plan
just lintpasses with 0 issuesgo test -race ./...passes all unit tests