From 09af7f9d4e3636489737d94cc7c8b512d2a2b03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lovro=20Ma=C5=BEgon?= Date: Wed, 11 Sep 2024 16:35:51 +0200 Subject: [PATCH] enable remaining linters --- .golangci.yml | 10 +++++----- acceptance_test.go | 1 + destination/destination.go | 7 +++++-- destination/pubsub/writer.go | 8 +++++++- source/source.go | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fcbdc21..66f0f23 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -64,8 +64,8 @@ linters: - errorlint - exhaustive # - forbidigo - # - forcetypeassert # TODO enable - # - funlen # TODO enable + - forcetypeassert + - funlen - gci - ginkgolinter - gocheckcompilerdirectives @@ -74,7 +74,7 @@ linters: - goconst - gocritic - godot - # - err113 # TODO enable + - err113 - gofmt - gofumpt - goheader @@ -114,12 +114,12 @@ linters: - stylecheck - tenv - testableexamples - # - thelper # TODO enable + - thelper - unconvert - unparam - unused - usestdlibvars - wastedassign - whitespace - # - wrapcheck # TODO enable + - wrapcheck - zerologlint diff --git a/acceptance_test.go b/acceptance_test.go index 9ffdfb6..eed2c23 100644 --- a/acceptance_test.go +++ b/acceptance_test.go @@ -62,6 +62,7 @@ func TestAcceptance(t *testing.T) { SourceConfig: cfg, DestinationConfig: cfg, BeforeTest: func(t *testing.T) { + t.Helper() subject := t.Name() + uuid.New().String() cfg[destination.ConfigSubject] = subject }, diff --git a/destination/destination.go b/destination/destination.go index ca099b4..d1b3be5 100644 --- a/destination/destination.go +++ b/destination/destination.go @@ -54,7 +54,7 @@ func (d *Destination) Parameters() config.Parameters { func (d *Destination) Configure(ctx context.Context, cfg config.Config) error { err := sdk.Util.ParseConfig(ctx, cfg, &d.config, NewDestination().Parameters()) if err != nil { - return err + return err //nolint:wrapcheck // we don't need to wrap the error here } connName := d.config.GetConnectionName() @@ -101,7 +101,10 @@ func (d *Destination) Write(_ context.Context, records []opencdc.Record) (int, e // Teardown gracefully closes connections. func (d *Destination) Teardown(context.Context) error { if d.writer != nil { - return d.writer.Close() + err := d.writer.Close() + if err != nil { + return fmt.Errorf("failed to close writer: %w", err) + } } return nil diff --git a/destination/pubsub/writer.go b/destination/pubsub/writer.go index b6b77b8..0a0f4da 100644 --- a/destination/pubsub/writer.go +++ b/destination/pubsub/writer.go @@ -15,6 +15,8 @@ package pubsub import ( + "fmt" + "github.com/conduitio/conduit-commons/opencdc" "github.com/nats-io/nats.go" ) @@ -42,7 +44,11 @@ func NewWriter(params WriterParams) (*Writer, error) { // Write writes directly and synchronously a record to a subject. func (w *Writer) Write(record opencdc.Record) error { - return w.conn.Publish(w.subject, record.Payload.After.Bytes()) + err := w.conn.Publish(w.subject, record.Payload.After.Bytes()) + if err != nil { + return fmt.Errorf("failed to publish message: %w", err) + } + return nil } // Close closes the underlying NATS connection. diff --git a/source/source.go b/source/source.go index b178956..d21826f 100644 --- a/source/source.go +++ b/source/source.go @@ -56,7 +56,7 @@ func (s *Source) Parameters() config.Parameters { func (s *Source) Configure(ctx context.Context, cfg config.Config) error { err := sdk.Util.ParseConfig(ctx, cfg, &s.config, NewSource().Parameters()) if err != nil { - return err + return err //nolint:wrapcheck // we don't need to wrap the error here } connName := s.config.GetConnectionName()