From 6e5aefbb984e49db0c4de52be168059625e381c8 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 19 Oct 2023 12:24:07 +0200 Subject: [PATCH] update golangci-lint to 1.54.2 also update config to show all issues at once and set same exlucde rules as buildkit ones. Signed-off-by: CrazyMax --- .golangci.yml | 32 ++++++++++++++++++++++++++------ hack/dockerfiles/lint.Dockerfile | 10 +++++++--- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f82887de..f4d908f9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,12 +26,13 @@ linters: linters-settings: depguard: - list-type: blacklist - include-go-root: true - packages: - # The io/ioutil package has been deprecated. - # https://go.dev/doc/go1.16#ioutil - - io/ioutil + rules: + main: + deny: + # The io/ioutil package has been deprecated. + # https://go.dev/doc/go1.16#ioutil + - pkg: "io/ioutil" + desc: The io/ioutil package has been deprecated. forbidigo: forbid: - '^fmt\.Errorf(# use errors\.Errorf instead)?$' @@ -47,3 +48,22 @@ issues: - linters: - revive text: "stutters" + - linters: + - revive + text: "empty-block" + - linters: + - revive + text: "superfluous-else" + - linters: + - revive + text: "unused-parameter" + - linters: + - revive + text: "redefines-builtin-id" + - linters: + - revive + text: "if-return" + +# show all +max-issues-per-linter: 0 +max-same-issues: 0 diff --git a/hack/dockerfiles/lint.Dockerfile b/hack/dockerfiles/lint.Dockerfile index b0d5d7f2..7e46879d 100644 --- a/hack/dockerfiles/lint.Dockerfile +++ b/hack/dockerfiles/lint.Dockerfile @@ -1,10 +1,14 @@ # syntax=docker/dockerfile:1 ARG GO_VERSION=1.21.3 +ARG GOLANGCI_LINT_VERSION=1.54.2 FROM golang:${GO_VERSION}-alpine RUN apk add --no-cache git gcc musl-dev -RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.1 +ENV GOFLAGS="-buildvcs=false" +ARG GOLANGCI_LINT_VERSION +RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v${GOLANGCI_LINT_VERSION} WORKDIR /go/src/github.com/docker/buildx -RUN --mount=target=/go/src/github.com/docker/buildx --mount=target=/root/.cache,type=cache \ - golangci-lint run +RUN --mount=target=/go/src/github.com/docker/buildx \ + --mount=target=/root/.cache,type=cache \ + golangci-lint run