Skip to content

Commit

Permalink
feat: update golangci-lint and its configuration
Browse files Browse the repository at this point in the history
* disable new tagliatelle linter;
* sort disabled linters;
* move template to separate file;
* use `go install` for installing tools.

Signed-off-by: Alexey Palazhchenko <[email protected]>
  • Loading branch information
AlekSi authored and talos-bot committed Aug 11, 2021
1 parent c77e3bf commit 470baea
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2020-08-19T14:52:52Z by kres 29f29d8-dirty.
# Generated on 2021-08-11T16:23:52Z by kres c77e3bf-dirty.

**
!internal
!cmd
!internal
!go.mod
!go.sum
!.golangci.yml
Expand Down
24 changes: 10 additions & 14 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-03-11T14:02:06Z by kres 93ce485-dirty.

# Generated on 2021-08-11T16:25:38Z by kres c77e3bf-dirty.

# options for analysis running
run:
Expand All @@ -22,7 +21,6 @@ output:
uniq-by-line: true
path-prefix: ""


# all available settings of specific linters
linters-settings:
dogsled:
Expand Down Expand Up @@ -116,23 +114,23 @@ linters-settings:

linters:
enable-all: true
disable-all: false
fast: false
disable:
- exhaustivestruct
- forbidigo
- funlen
- gas
- typecheck
- gochecknoglobals
- gochecknoinits
- funlen
- godox
- gomnd
- goerr113
- gomnd
- nestif
- wrapcheck
- paralleltest
- exhaustivestruct
- forbidigo
disable-all: false
fast: false

- tagliatelle
- typecheck
- wrapcheck

issues:
exclude: []
Expand All @@ -141,10 +139,8 @@ issues:
exclude-case-sensitive: false
max-issues-per-linter: 10
max-same-issues: 3

new: false

severity:
default-severity: error

case-sensitive: false
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-05-21T00:52:36Z by kres c1b0c97-dirty.
# Generated on 2021-08-11T16:23:52Z by kres c77e3bf-dirty.

ARG TOOLCHAIN

Expand Down Expand Up @@ -31,11 +31,9 @@ FROM toolchain AS tools
ENV GO111MODULE on
ENV CGO_ENABLED 0
ENV GOPATH /go
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b /bin v1.38.0
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b /bin v1.41.1
ARG GOFUMPT_VERSION
RUN cd $(mktemp -d) \
&& go mod init tmp \
&& go get mvdan.cc/gofumpt/gofumports@${GOFUMPT_VERSION} \
RUN go install mvdan.cc/gofumpt/gofumports@${GOFUMPT_VERSION} \
&& mv /go/bin/gofumports /bin/gofumports

# tools and sources
Expand All @@ -45,8 +43,8 @@ COPY ./go.mod .
COPY ./go.sum .
RUN --mount=type=cache,target=/go/pkg go mod download
RUN --mount=type=cache,target=/go/pkg go mod verify
COPY ./internal ./internal
COPY ./cmd ./cmd
COPY ./internal ./internal
RUN --mount=type=cache,target=/go/pkg go list -mod=readonly all >/dev/null

# builds kres-linux-amd64
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2021-05-21T14:48:52Z by kres c09e0bc-dirty.
# Generated on 2021-08-11T11:26:17Z by kres 907039b-dirty.

# common variables

Expand Down Expand Up @@ -97,8 +97,8 @@ lint-gofumpt: ## Runs gofumpt linter.
fmt: ## Formats the source code
@docker run --rm -it -v $(PWD):/src -w /src golang:$(GO_VERSION) \
bash -c "export GO111MODULE=on; export GOPROXY=https://proxy.golang.org; \
cd /tmp && go mod init tmp && go get mvdan.cc/gofumpt/gofumports@$(GOFUMPT_VERSION) && \
cd - && gofumports -w -local github.com/talos-systems/kres ."
go install mvdan.cc/gofumpt/gofumports@$(GOFUMPT_VERSION) && \
gofumports -w -local github.com/talos-systems/kres ."

.PHONY: base
base: ## Prepare base toolchain
Expand Down
2 changes: 1 addition & 1 deletion internal/output/codecov/codecov.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package codecov

import (
_ "embed" //nolint:gci
_ "embed" //nolint:gci // allows go:embed usage
"fmt"
"io"

Expand Down
6 changes: 5 additions & 1 deletion internal/output/golangci/golangci.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package golangci

import (
_ "embed" //nolint:gci // allows go:embed usage
"fmt"
"io"

Expand All @@ -16,6 +17,9 @@ const (
filename = ".golangci.yml"
)

//go:embed golangci.yml
var configTemplate string

// Output implements .golangci.yml generation.
type Output struct {
output.FileAdapter
Expand Down Expand Up @@ -80,7 +84,7 @@ func (o *Output) config(w io.Writer) error {
return err
}

if _, err := fmt.Fprintf(w, config, o.canonicalPath); err != nil {
if _, err := fmt.Fprintf(w, configTemplate, o.canonicalPath); err != nil {
return err
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package golangci

const config = `
# options for analysis running
run:
timeout: 10m
Expand All @@ -24,7 +17,6 @@ output:
uniq-by-line: true
path-prefix: ""

# all available settings of specific linters
linters-settings:
dogsled:
Expand Down Expand Up @@ -118,23 +110,23 @@ linters-settings:

linters:
enable-all: true
disable-all: false
fast: false
disable:
- exhaustivestruct
- forbidigo
- funlen
- gas
- typecheck
- gochecknoglobals
- gochecknoinits
- funlen
- godox
- gomnd
- goerr113
- gomnd
- nestif
- wrapcheck
- paralleltest
- exhaustivestruct
- forbidigo
disable-all: false
fast: false
- tagliatelle
- typecheck
- wrapcheck

issues:
exclude: []
Expand All @@ -143,11 +135,8 @@ issues:
exclude-case-sensitive: false
max-issues-per-linter: 10
max-same-issues: 3
new: false

severity:
default-severity: error
case-sensitive: false
`
9 changes: 4 additions & 5 deletions internal/project/golang/gofumpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (lint *Gofumpt) CompileMakefile(output *makefile.Output) error {
Script(fmt.Sprintf(
`@docker run --rm -it -v $(PWD):/src -w /src golang:$(GO_VERSION) \
bash -c "export GO111MODULE=on; export GOPROXY=https://proxy.golang.org; \
cd /tmp && go mod init tmp && go get mvdan.cc/gofumpt/gofumports@$(GOFUMPT_VERSION) && \
cd - && gofumports -w -local %s ."`,
go install mvdan.cc/gofumpt/gofumports@$(GOFUMPT_VERSION) && \
gofumports -w -local %s ."`,
lint.meta.CanonicalPath,
))

Expand All @@ -64,9 +64,8 @@ func (lint *Gofumpt) CompileMakefile(output *makefile.Output) error {
func (lint *Gofumpt) ToolchainBuild(stage *dockerfile.Stage) error {
stage.
Step(step.Arg("GOFUMPT_VERSION")).
Step(step.Script(fmt.Sprintf(`cd $(mktemp -d) \
&& go mod init tmp \
&& go get mvdan.cc/gofumpt/gofumports@${GOFUMPT_VERSION} \
Step(step.Script(fmt.Sprintf(
`go install mvdan.cc/gofumpt/gofumports@${GOFUMPT_VERSION} \
&& mv /go/bin/gofumports %s/gofumports`, lint.meta.BinPath)))

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/project/golang/golangcilint.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewGolangciLint(meta *meta.Options) *GolangciLint {

meta: meta,

Version: "v1.38.0",
Version: "v1.41.1",
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/project/js/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (proto *Protobuf) ToolchainBuild(stage *dockerfile.Stage) error {
Step(step.Arg("PROTOBUF_TS_VERSION")).
Step(step.Script("npm install -g ts-proto@^${PROTOBUF_TS_VERSION}")).
Step(step.Arg("PROTOBUF_GRPC_GATEWAY_TS_VERSION")).
Step(step.Script("go get github.com/grpc-ecosystem/protoc-gen-grpc-gateway-ts@v${PROTOBUF_GRPC_GATEWAY_TS_VERSION}")).
Step(step.Script("go install github.com/grpc-ecosystem/protoc-gen-grpc-gateway-ts@v${PROTOBUF_GRPC_GATEWAY_TS_VERSION}")).
Step(step.Run("mv", filepath.Join(proto.meta.GoPath, "bin", "protoc-gen-grpc-gateway-ts"), proto.meta.BinPath))

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/project/js/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Package templates defines default templates for various JS components.
package templates

import _ "embed" // import embed to allow go:embed usage.
import _ "embed" // allows go:embed usage

// Babel babel.config.js.
//go:embed babel.js
Expand Down

0 comments on commit 470baea

Please sign in to comment.