From fa5c9742dada3c5c3941f4f011906112abcb80b0 Mon Sep 17 00:00:00 2001 From: Integralist Date: Fri, 3 Nov 2023 16:26:07 +0000 Subject: [PATCH 1/3] ci: add golangci-lint action --- .github/workflows/pr.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d2ea7004b..13dbc483d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,6 +23,11 @@ jobs: run: make vet - name: tfproviderlintx run: make tfproviderlintx + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + args: "--verbose" test: strategy: matrix: From 4a6f24c7ef5a22d35e84d356826714b691a85924 Mon Sep 17 00:00:00 2001 From: Integralist Date: Fri, 3 Nov 2023 16:38:32 +0000 Subject: [PATCH 2/3] feat: add golangci-lint Makefile target --- .golangci.yml | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 5 +- 2 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..e53b6b51d --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,169 @@ +# https://golangci-lint.run/usage/configuration/ + +issues: + max-per-linter: 0 + max-same-issues: 0 +run: + allow-parallel-runners: true +linters: + disable-all: true + enable: + - bodyclose + - durationcheck + - errcheck + - exhaustive + - exportloopref + - forcetypeassert + - gocritic + - godot + - gofumpt + - goimports + - gosec + - gosimple + - govet + - ineffassign + - makezero + - misspell + - nilerr + - predeclared + - revive + - staticcheck + - tenv + - typecheck + - unconvert + - unparam + - unused + - vet +linters-settings: + revive: + enableAllRules: true + rules: + - name: "add-constant" + severity: "warning" + arguments: + - maxLitCount: "10" + allowInts: "0,1,2,3,4,5" + disabled: true # most of the time it's fine, and the performance isn't a concern + - name: "argument-limit" + severity: "warning" + arguments: [6] + - name: "atomic" + severity: "warning" + - name: "bare-return" + severity: "warning" + - name: "bool-literal-in-expr" + severity: "warning" + - name: "confusing-naming" + severity: "warning" + - name: "confusing-results" + severity: "warning" + - name: "constant-logical-expr" + severity: "error" + - name: "context-as-argument" + severity: "error" + - name: "context-keys-type" + severity: "error" + - name: "deep-exit" + severity: "warning" + - name: "defer" + severity: "warning" + - name: "early-return" + severity: "warning" + - name: "empty-block" + severity: "error" + - name: "empty-lines" + severity: "warning" + - name: "error-naming" + severity: "error" + - name: "error-return" + severity: "error" + - name: "error-strings" + severity: "error" + - name: "errorf" + severity: "warning" + - name: "exported" + severity: "error" + - name: "flag-parameter" + severity: "warning" + - name: "function-result-limit" + severity: "warning" + arguments: [4] + - name: "function-length" + severity: "warning" + arguments: [50, 0] + - name: "get-return" + severity: "error" + - name: "identical-branches" + severity: "error" + - name: "if-return" + severity: "warning" + - name: "increment-decrement" + severity: "error" + - name: "indent-error-flow" + severity: "warning" + - name: "import-shadowing" + severity: "warning" + - name: "modifies-parameter" + severity: "warning" + - name: "modifies-value-receiver" + severity: "warning" + - name: "nested-structs" + severity: "warning" + - name: "optimize-operands-order" + severity: "warning" + - name: "package-comments" + severity: "warning" + - name: "range" + severity: "warning" + - name: "range-val-in-closure" + severity: "warning" + - name: "range-val-address" + severity: "warning" + - name: "receiver-naming" + severity: "warning" + - name: "redefines-builtin-id" + severity: "error" + - name: "string-of-int" + severity: "warning" + - name: "struct-tag" + severity: "warning" + - name: "superfluous-else" + severity: "warning" + - name: "time-equal" + severity: "warning" + - name: "time-naming" + severity: "warning" + - name: "var-declaration" + severity: "warning" + - name: "var-naming" + severity: "warning" + - name: "unconditional-recursion" + severity: "error" + - name: "unexported-naming" + severity: "warning" + - name: "unexported-return" + severity: "error" + - name: "unhandled-error" + severity: "warning" + arguments: + - "fmt.Print" + - "fmt.Printf" + - "fmt.Println" + - "fmt.Fprint" + - "fmt.Fprintf" + - "fmt.Fprintln" + - name: "unnecessary-stmt" + severity: "warning" + - name: "unreachable-code" + severity: "warning" + - name: "unused-parameter" + severity: "warning" + - name: "unused-receiver" + severity: "warning" + disabled: true + - name: "use-any" + severity: "warning" + - name: "useless-break" + severity: "warning" + - name: "waitgroup-by-value" + severity: "warning" diff --git a/Makefile b/Makefile index 9abed8b17..efd8349d7 100644 --- a/Makefile +++ b/Makefile @@ -137,4 +137,7 @@ clean: validate-interface: @./tests/interface/script.sh -.PHONY: all build clean clean_test default errcheck fmt fmtcheck generate-docs goreleaser goreleaser-bin sweep test test-compile testacc validate-docs validate-interface vet +lint: + golangci-lint run --verbose + +.PHONY: all build clean clean_test default errcheck fmt fmtcheck generate-docs goreleaser goreleaser-bin lint sweep test test-compile testacc validate-docs validate-interface vet From 8557003c6f77c10b237d88d52423ffc8471771d5 Mon Sep 17 00:00:00 2001 From: Integralist Date: Fri, 3 Nov 2023 16:39:01 +0000 Subject: [PATCH 3/3] ci: remove golangci-lint action --- .github/workflows/pr.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 13dbc483d..d2ea7004b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,11 +23,6 @@ jobs: run: make vet - name: tfproviderlintx run: make tfproviderlintx - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: latest - args: "--verbose" test: strategy: matrix: