From df3d8a96bac6c270e15f11482f13a26f22fd2689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Va=C5=A1ko?= Date: Tue, 4 Jun 2024 10:45:59 +0200 Subject: [PATCH 1/2] lint: Add musttag linter. --- build/ci/golangci.yml | 1 + internal/pkg/service/common/etcdop/op/op_test.go | 2 +- internal/pkg/service/stream/api/mapper/task.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/ci/golangci.yml b/build/ci/golangci.yml index 78fcad6952..bc69cc2eff 100644 --- a/build/ci/golangci.yml +++ b/build/ci/golangci.yml @@ -137,6 +137,7 @@ linters: - importas - ineffassign - makezero + - musttag - nakedret - nilerr - noctx diff --git a/internal/pkg/service/common/etcdop/op/op_test.go b/internal/pkg/service/common/etcdop/op/op_test.go index 45ba373628..4f6789b7b3 100644 --- a/internal/pkg/service/common/etcdop/op/op_test.go +++ b/internal/pkg/service/common/etcdop/op/op_test.go @@ -21,7 +21,7 @@ type testOp struct { } type testValue struct { - Foo string + Foo string `json:"foo"` } type opTestCase[R any] struct { diff --git a/internal/pkg/service/stream/api/mapper/task.go b/internal/pkg/service/stream/api/mapper/task.go index 97d4811066..84986949b5 100644 --- a/internal/pkg/service/stream/api/mapper/task.go +++ b/internal/pkg/service/stream/api/mapper/task.go @@ -56,7 +56,7 @@ func (m *Mapper) NewTaskResponse(entity task.Task) (*api.Task, error) { // Outputs if entity.Outputs != nil { response.Outputs = &api.TaskOutputs{} - err := mapstructure.Decode(entity.Outputs, response.Outputs) + err := mapstructure.Decode(entity.Outputs, response.Outputs) // nolint: musttag if err != nil { return nil, err } From 036ec3580761c14556033bb2c71864e93fdc73ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Va=C5=A1ko?= Date: Thu, 21 Nov 2024 09:48:45 +0100 Subject: [PATCH 2/2] fix: Omit linter from test code and migration which will be removed --- internal/pkg/service/stream/migrate/core/source.go | 2 +- test/stream/bridge/keboola/setup_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/pkg/service/stream/migrate/core/source.go b/internal/pkg/service/stream/migrate/core/source.go index 618798dbd2..bcd6b23051 100644 --- a/internal/pkg/service/stream/migrate/core/source.go +++ b/internal/pkg/service/stream/migrate/core/source.go @@ -128,7 +128,7 @@ func (r *Receiver) createSourcePayload() (*bytes.Buffer, error) { } payloadBuf := new(bytes.Buffer) - err := json.NewEncoder(payloadBuf).Encode(s) + err := json.NewEncoder(payloadBuf).Encode(s) // nolint:musttag if err != nil { return nil, err } diff --git a/test/stream/bridge/keboola/setup_test.go b/test/stream/bridge/keboola/setup_test.go index ed0acc4bda..5c9927a516 100644 --- a/test/stream/bridge/keboola/setup_test.go +++ b/test/stream/bridge/keboola/setup_test.go @@ -316,7 +316,7 @@ func (ts *testState) setupSourceThroughAPI(t *testing.T, ctx context.Context, ex Type: "http", Name: "testSource", } - out, err := json.Marshal(payload) + out, err := json.Marshal(payload) // nolint:musttag if !assert.NoError(t, err) { ts.logger.Errorf(ctx, "unable to marshal source create payload: %v", err) return @@ -369,7 +369,7 @@ func (ts *testState) setupSinkThroughAPI(t *testing.T, ctx context.Context, expe Type: definition.SinkTypeTable, Name: "testSink", } - out, err := json.Marshal(payload) + out, err := json.Marshal(payload) // nolint:musttag if !assert.NoError(t, err) { ts.logger.Errorf(ctx, "unable to marshal sink create payload: %v", err) return