all: Adopt recommended linters in CI and address the problems pointed by them#142
Conversation
…backend" -l -w .`
…se transaction, and there would be no value in doing so. Kinda bogus code.
…ls functions are meant to be used from within tests by requiring a test object and handling the internal error inside of it.
…ts. This exposed some issues that will be handled in the next commit.
…surfaced thanks to better error handling.
There was a problem hiding this comment.
Pull Request Overview
This PR updates the CI configuration to run linters correctly and fixes several issues flagged by the linters such as error wrapping, incorrect error messages, variable shadowing, and test assertions. Key changes include:
- Improving error handling (using fmt.Errorf with %w) and consistent error messages.
- Refactoring test files to use testify/require and reorganizing imports.
- Updating CI workflows and linter configurations to enforce code standards.
Reviewed Changes
Copilot reviewed 101 out of 101 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/data/payments_test.go | Removed duplicate import lines and reordered imports for clarity |
| internal/data/payments.go | Improved error checking by using errors.Is for sql.ErrNoRows |
| internal/data/fixtures.go | Reordered import statements with minor cleanup |
| internal/data/accounts_test.go | Cleaned up blank lines in test setup |
| internal/apptracker/sentry/sentry_tracker*.go | Updated error wrapping and test setups for Sentry tracker functionality |
| internal/apptracker/sentry/mocks.go | Added helper for mock setup with t.Cleanup for restoration of function pointers |
| cmd/utils/* | Updated error messages and error wrapping in signature client handling |
| cmd/utils/password_prompter.go | Added error wrapping for IO related calls |
| cmd/migrate.go, cmd/ingest.go, cmd/distribution_account.go | Minor error wrapping and formatting improvements |
| .golangci.yml & .github/workflows/go.yaml | Updated linter configurations and CI workflows with improved caching |
Comments suppressed due to low confidence (1)
internal/apptracker/sentry/sentry_tracker.go:37
- Ensure that deferring FlushFunc (and similarly, RecoverFunc on the next line) is appropriate even when the Sentry initialization fails. Consider calling these functions only upon successful initialization to prevent unintended side effects.
defer FlushFunc(time.Second * time.Duration(flushFreq))
| func (t *transactionService) BuildAndSignTransactionWithChannelAccount(ctx context.Context, operations []txnbuild.Operation, timeoutInSecs int64) (*txnbuild.Transaction, error) { | ||
| var tx *txnbuild.Transaction | ||
| var channelAccountPublicKey string | ||
| err := db.RunInTransaction(ctx, t.DB, nil, func(dbTx db.Transaction) error { |
There was a problem hiding this comment.
I removed the call to RunInTransaction here because it was not being used. The dbTx was not being applied anywhere and considering there's only one database query, at the very last step here, then the database transaction serves no purpose here.
| if errors.Is(err, store.ErrPublicKeyAlreadyExists) { | ||
| return err | ||
| } | ||
| return fmt.Errorf("storing distribution account encrypted private key: %w", err) |
There was a problem hiding this comment.
I removed this assertion because the function returns the same error anyway, and it can be parsed downstream using errors.Is
8fa8c7f to
38f1464
Compare
…r!) by allowing retryCounts and retryIntervals to be (optionally) parametrized.
…cy, and start using the EXPECT() method, which has better syntax.
What
Adopt recommended linters in CI and address the problems pointed by them
Fixes include:
GET /tss/transactions/{hash}would return an invalid JSON when the resource was not foundfmt.Errorf("{message}: %w"), which made issues hard to debug.errors.Asanderrors.Is, so wrapped errors can also be captured....Error) and error variables (should start withErr...) to be go idiomatic.Additionally:
mocks.go, for consistency.goimportsWhy
It's good practice to use linters, specially the ones that capture errors and help making the code more debuggable and idiomatic.
Checklist
PR Structure
allif the changes are broad or impact many packages.Thoroughness
Release