From 92e1dfc63d701ecb73811f307163fb7797938e38 Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Tue, 19 Apr 2022 14:30:10 -0400 Subject: [PATCH 1/5] Add superfluous-else rule to revive linter --- tools/configs/golangci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/configs/golangci.yaml b/tools/configs/golangci.yaml index 52a78f7864..340d130c90 100644 --- a/tools/configs/golangci.yaml +++ b/tools/configs/golangci.yaml @@ -653,6 +653,8 @@ linters-settings: ignore-generated-header: true severity: warning rules: + - name: superfluous-else + severity: error - name: indent-error-flow severity: warning - name: add-constant From 38a85f7e12b49d2a0dd8250b41edfd016e56693e Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Tue, 19 Apr 2022 14:30:47 -0400 Subject: [PATCH 2/5] Remove default revive linter rules Do not want to enable these now --- tools/configs/golangci.yaml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tools/configs/golangci.yaml b/tools/configs/golangci.yaml index 340d130c90..0319aee845 100644 --- a/tools/configs/golangci.yaml +++ b/tools/configs/golangci.yaml @@ -655,15 +655,6 @@ linters-settings: rules: - name: superfluous-else severity: error - - name: indent-error-flow - severity: warning - - name: add-constant - severity: warning - arguments: - - maxLitCount: "3" - allowStrs: '""' - allowInts: "0,1,2" - allowFloats: "0.0,0.,1.0,1.,2.0,2." staticcheck: # Select the Go version to target. The default is '1.13'. From 3523391e86182b169af36305e09c52f354376deb Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Tue, 19 Apr 2022 14:34:35 -0400 Subject: [PATCH 3/5] Remove extra else from CreateDescriptions If also inverted as it clarifies that the error is secondary to the continue --- query/graphql/schema/descriptions.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/query/graphql/schema/descriptions.go b/query/graphql/schema/descriptions.go index b27b575354..4b8642fda3 100644 --- a/query/graphql/schema/descriptions.go +++ b/query/graphql/schema/descriptions.go @@ -139,11 +139,10 @@ func (g *Generator) CreateDescriptions( if _, exists := desc.GetField(fname); exists { // lets make sure its an _id field, otherwise // we might have an error here - if strings.HasSuffix(fname, "_id") { - continue - } else { + if !strings.HasSuffix(fname, "_id") { return nil, fmt.Errorf("Error: found a duplicate field '%s' for type %s", fname, t.Name()) } + continue } fd := client.FieldDescription{ From d0613053327e735b0d0270dae0038dfaca3e8b45 Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Tue, 19 Apr 2022 14:36:10 -0400 Subject: [PATCH 4/5] Remove extra else from generate code --- query/graphql/schema/generate.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/query/graphql/schema/generate.go b/query/graphql/schema/generate.go index 7128448e17..c6acb14afd 100644 --- a/query/graphql/schema/generate.go +++ b/query/graphql/schema/generate.go @@ -220,9 +220,9 @@ func (g *Generator) expandInputArgument(obj *gql.Object) error { case *gql.Object: if _, complete := g.expandedFields[fieldKey]; complete { continue - } else { - g.expandedFields[fieldKey] = true } + g.expandedFields[fieldKey] = true + // make sure all the sub fields are expanded first if err := g.expandInputArgument(t); err != nil { return err @@ -242,9 +242,8 @@ func (g *Generator) expandInputArgument(obj *gql.Object) error { listType := t.OfType if _, complete := g.expandedFields[fieldKey]; complete { continue - } else { - g.expandedFields[fieldKey] = true } + g.expandedFields[fieldKey] = true if listObjType, ok := listType.(*gql.Object); ok { if err := g.expandInputArgument(listObjType); err != nil { From ae2fcb0321b085a5204eae082bd079a84dbceefc Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Tue, 19 Apr 2022 14:31:14 -0400 Subject: [PATCH 5/5] Enable revive linter --- tools/configs/golangci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/configs/golangci.yaml b/tools/configs/golangci.yaml index 0319aee845..d8efb2c9b8 100644 --- a/tools/configs/golangci.yaml +++ b/tools/configs/golangci.yaml @@ -95,6 +95,7 @@ linters: - errcheck - forbidigo - lll + - revive # - wrapcheck # - errorlint # - gci