From 5a6bf2a7b093ab35915bc035f8d6fd6eab5b0ca4 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Sun, 24 Nov 2024 20:26:06 +0200 Subject: [PATCH] refactor: fix copyloopvar, dupword lint issues --- .golangci.yml | 2 ++ _examples/federation/subgraphs/subgraphs.go | 1 - codegen/testserver/followschema/directive_test.go | 2 +- codegen/testserver/nullabledirectives/directive_test.go | 2 +- codegen/testserver/singlefile/directive_test.go | 2 +- graphql/context_operation_test.go | 2 +- graphql/omittable_test.go | 2 +- plugin/modelgen/models_test.go | 1 - 8 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 79d6627e8a9..5b63a26aa73 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -74,7 +74,9 @@ linters: disable-all: true enable: - bodyclose + - copyloopvar - dupl + - dupword - errcheck - gocritic - gofmt diff --git a/_examples/federation/subgraphs/subgraphs.go b/_examples/federation/subgraphs/subgraphs.go index b756dd55d68..7d09b2a50e3 100644 --- a/_examples/federation/subgraphs/subgraphs.go +++ b/_examples/federation/subgraphs/subgraphs.go @@ -41,7 +41,6 @@ func (s *Subgraphs) Shutdown(ctx context.Context) error { func (s *Subgraphs) ListenAndServe(ctx context.Context) error { group, _ := errgroup.WithContext(ctx) for _, srv := range s.servers { - srv := srv group.Go(func() error { err := srv.ListenAndServe() if err != nil && !errors.Is(err, http.ErrServerClosed) { diff --git a/codegen/testserver/followschema/directive_test.go b/codegen/testserver/followschema/directive_test.go index 5d1adea51ea..f62c34c4b11 100644 --- a/codegen/testserver/followschema/directive_test.go +++ b/codegen/testserver/followschema/directive_test.go @@ -20,7 +20,7 @@ func isNil(input any) bool { return true } // Using reflect to check if the value is nil. This is necessary for - // for any types that are not nil types but have a nil value (e.g. *string). + // any types that are not nil types but have a nil value (e.g. *string). value := reflect.ValueOf(input) return value.IsNil() } diff --git a/codegen/testserver/nullabledirectives/directive_test.go b/codegen/testserver/nullabledirectives/directive_test.go index 9d24fa6fe26..9e5f6fb9379 100644 --- a/codegen/testserver/nullabledirectives/directive_test.go +++ b/codegen/testserver/nullabledirectives/directive_test.go @@ -21,7 +21,7 @@ func isNil(input any) bool { return true } // Using reflect to check if the value is nil. This is necessary for - // for any types that are not nil types but have a nil value (e.g. *string). + // any types that are not nil types but have a nil value (e.g. *string). value := reflect.ValueOf(input) return value.IsNil() } diff --git a/codegen/testserver/singlefile/directive_test.go b/codegen/testserver/singlefile/directive_test.go index 545ddfa9713..294ed42c32b 100644 --- a/codegen/testserver/singlefile/directive_test.go +++ b/codegen/testserver/singlefile/directive_test.go @@ -20,7 +20,7 @@ func isNil(input any) bool { return true } // Using reflect to check if the value is nil. This is necessary for - // for any types that are not nil types but have a nil value (e.g. *string). + // any types that are not nil types but have a nil value (e.g. *string). value := reflect.ValueOf(input) return value.IsNil() } diff --git a/graphql/context_operation_test.go b/graphql/context_operation_test.go index 11891d3e05d..7f3df2ce33e 100644 --- a/graphql/context_operation_test.go +++ b/graphql/context_operation_test.go @@ -169,7 +169,7 @@ func TestCollectFields(t *testing.T) { require.Equal(t, []string{"fieldA", "fieldB", "fieldC"}, getNames(collected)) }) - t.Run("handles inline fragments with with include and skip", func(t *testing.T) { + t.Run("handles inline fragments with include and skip", func(t *testing.T) { ctx := testContext(ast.SelectionSet{ &ast.InlineFragment{ TypeCondition: "", diff --git a/graphql/omittable_test.go b/graphql/omittable_test.go index 79c59178a95..5081197eb52 100644 --- a/graphql/omittable_test.go +++ b/graphql/omittable_test.go @@ -31,7 +31,7 @@ func TestOmittable_MarshalJSON(t *testing.T) { expectedJSON: `{"Value": null}`, }, { - name: "omittable omittable", + name: "omittable omittable", //nolint:dupword input: struct{ Value Omittable[Omittable[uint64]] }{Value: OmittableOf(OmittableOf(uint64(42)))}, expectedJSON: `{"Value": 42}`, }, diff --git a/plugin/modelgen/models_test.go b/plugin/modelgen/models_test.go index 04e0619943a..6b25b787edf 100644 --- a/plugin/modelgen/models_test.go +++ b/plugin/modelgen/models_test.go @@ -200,7 +200,6 @@ func TestModelGeneration(t *testing.T) { }, } for _, tc := range cases { - tc := tc t.Run(tc.name, func(t *testing.T) { typeSpec, ok := generated.Scope.Lookup(tc.name).Decl.(*ast.TypeSpec) require.True(t, ok)