Repository navigation
fix(lint): replace deferred rollback nolint with explicit error handling - #1474
Conversation
Five `defer tx.Rollback(ctx) //nolint:errcheck` sites in the Postgres
store layers are replaced with a defer closure that captures the rollback
error into a named variable, satisfying errcheck's check-blank=true
setting without suppressing anything:
defer func() {
if rbErr := tx.Rollback(ctx); rbErr != nil {
_ = rbErr // rollback error intentionally discarded
}
}()
This is a real fix, not a wider suppression: the function return value is
captured (not blanked at the call site), which is the pattern errcheck
with check-blank=true accepts. The //nolint:errcheck directives on all
five sites are removed.
Files changed:
- internal/config/store_postgres.go (DeleteCloudAccount, SetPlanAccounts)
- internal/config/store_postgres_recommendations.go (ReplaceRecommendations, UpsertRecommendations)
- internal/auth/store_postgres.go (CreateAdminIfNone)
golangci-lint v2.10.1 reports 0 issues after this change. go build, go
vet, and go test ./internal/config/... ./internal/auth/... ./internal/api/...
all pass.
Justified nolints deliberately left intact:
- revive:exported stutter on 8 type names (naming is intentional, rename
would be a breaking API change; nolints are correct suppressions)
- errorlint on handler_purchases.go isPermissionDenied (strict type
assertion is deliberate; see the detailed comment at that site)
- all gosec, gocritic, unparam, staticcheck, misspell, govet nolints
assessed as justified in the lint scope report
|
@coderabbitai review |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 56 seconds Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Action performedReview finished.
|
Summary
defer tx.Rollback(ctx) //nolint:errchecksites in the Postgres store layer with a proper defer closure that captures the rollback error into a named variable, satisfying errcheck'scheck-blank=trueconfig without any new suppressions.check-blank=trueis active.//nolint:errcheckdirectives on all five sites are removed.Files changed (BATCH 1 - errcheck only):
internal/config/store_postgres.golines 2999 and 3307 (DeleteCloudAccount,SetPlanAccounts)internal/config/store_postgres_recommendations.golines 31 and 78 (ReplaceRecommendations,UpsertRecommendations)internal/auth/store_postgres.goline 438 (CreateAdminIfNone)Pattern used (mirrors
WithTxinstore_postgres_suppressions.go):Justified nolints deliberately left intact:
revive:exportedstutter on 8 type names (AuthContext,ConfigSetting,SchedulerConfig,PurchaseDefaults,APIKeyInfo,AnalyticsStore,MockSESClient,MockSNSClient) - the "stutter" violation requires renaming exported types, a breaking API change; the nolints are correct suppressions.errorlintonhandler_purchases.go:isPermissionDenied- strict (unwrapped) type assertion is deliberate; the detailed comment at that site explains whyerrors.As-style wrapping would misclassify wrapped backend errors.Test plan
golangci-lint v2.10.1 --timeout=5mreports 0 issues (same asmain)go build ./...clean in root modulego vet ./...clean in root modulego test ./internal/config/... ./internal/auth/... ./internal/api/...- 3096 tests pass