From 25a87b4fc499ab0d13fdd4a579a9360577c04893 Mon Sep 17 00:00:00 2001 From: Oscar Utbult Date: Sat, 22 Oct 2022 22:25:51 +0200 Subject: [PATCH] golangci-lint: add recommended revive checks to linter-settings but disable checks with to many findings. Fix findings --- .golangci.yml | 45 ++++++++++++++++++++++++++++++---- Makefile | 2 +- test/e2e/utils/test_context.go | 4 +-- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 88e1f7b5285..a23b1fa124c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,7 @@ +run: + deadline: 5m + allow-parallel-runners: true + issues: # don't skip warning about doc comments # don't exclude the default set of lint @@ -13,8 +17,42 @@ linters-settings: enable=fieldalignment: true revive: rules: - - name: if-return - disabled: true + # The following rules are recommended https://github.com/mgechev/revive#recommended-configuration + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings. + - name: if-return + disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings. + - name: increment-decrement + - name: var-naming + disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings. + - name: var-declaration + - name: package-comments + disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings. + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: empty-block + disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings. + - name: superfluous-else + - name: unused-parameter + disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings. + - name: unreachable-code + - name: redefines-builtin-id + # + # Rules in addition to the recommended configuration above. + # + - name: bool-literal-in-expr + - name: constant-logical-expr linters: disable-all: true @@ -40,6 +78,3 @@ linters: - unconvert - unparam - unused - -run: - deadline: 5m diff --git a/Makefile b/Makefile index 5e1e9c8c13c..9367def062b 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint golangci-lint: @[ -f $(GOLANGCI_LINT) ] || { \ set -e ;\ - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.49.0 ;\ + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.51.1 ;\ } .PHONY: apidiff diff --git a/test/e2e/utils/test_context.go b/test/e2e/utils/test_context.go index fe1fe00d07f..d9630d6c7d8 100644 --- a/test/e2e/utils/test_context.go +++ b/test/e2e/utils/test_context.go @@ -270,14 +270,14 @@ func (t *TestContext) LoadImageToKindCluster() error { } // LoadImageToKindClusterWithName loads a local docker image with the name informed to the kind cluster -func (tc TestContext) LoadImageToKindClusterWithName(image string) error { +func (t TestContext) LoadImageToKindClusterWithName(image string) error { cluster := "kind" if v, ok := os.LookupEnv("KIND_CLUSTER"); ok { cluster = v } kindOptions := []string{"load", "docker-image", "--name", cluster, image} cmd := exec.Command("kind", kindOptions...) - _, err := tc.Run(cmd) + _, err := t.Run(cmd) return err }