Skip to content

Commit 9ce4616

Browse files
committed
chore: address linter issues and upgrade golang ci lint
1 parent 30bd4f6 commit 9ce4616

5 files changed

Lines changed: 34 additions & 39 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.63.4
23+
version: v2.1.6

.golangci.yml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
allow-parallel-runners: true
4-
5-
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
11-
exclude-rules:
12-
- path: "api/*"
13-
linters:
14-
- lll
15-
- path: "internal/*"
16-
linters:
17-
- dupl
18-
- lll
194
linters:
20-
disable-all: true
5+
default: none
216
enable:
7+
- copyloopvar
228
- dupl
239
- errcheck
24-
- copyloopvar
2510
- ginkgolinter
2611
- goconst
2712
- gocyclo
28-
- gofmt
29-
- goimports
30-
- gosimple
3113
- govet
3214
- ineffassign
33-
- lll
3415
- misspell
3516
- nakedret
3617
- prealloc
3718
- revive
3819
- staticcheck
39-
- typecheck
4020
- unconvert
4121
- unparam
4222
- unused
43-
44-
linters-settings:
45-
revive:
23+
settings:
24+
revive:
25+
rules:
26+
- name: comment-spacings
27+
exclusions:
28+
generated: lax
4629
rules:
47-
- name: comment-spacings
30+
- linters:
31+
- dupl
32+
path: internal/*
33+
paths:
34+
- third_party$
35+
- builtin$
36+
- examples$
37+
formatters:
38+
enable:
39+
- gofmt
40+
- goimports
41+
exclusions:
42+
generated: lax
43+
paths:
44+
- third_party$
45+
- builtin$
46+
- examples$

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ DEFAULTER_GEN_VERSION ?= v0.32.3
181181
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
182182
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
183183
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
184-
GOLANGCI_LINT_VERSION ?= v1.63.4
184+
GOLANGCI_LINT_VERSION ?= v2.1.6
185185

186186
.PHONY: kustomize
187187
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -214,7 +214,7 @@ $(ENVTEST): $(LOCALBIN)
214214
.PHONY: golangci-lint
215215
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
216216
$(GOLANGCI_LINT): $(LOCALBIN)
217-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
217+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
218218

219219
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
220220
# $1 - target path with name of binary

cmd/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import (
1010
"go.datum.net/datum/cmd/controller"
1111
)
1212

13-
var (
14-
cfgFile string
15-
)
16-
1713
// rootCmd represents the base command when called without any subcommands
1814
var rootCmd = &cobra.Command{
1915
Use: "datum",

test/utils/utils.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"os/exec"
1010
"strings"
1111

12-
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive
12+
ginkgo "github.com/onsi/ginkgo/v2" //nolint:golint,revive
1313
)
1414

1515
const (
@@ -22,7 +22,7 @@ const (
2222
)
2323

2424
func warnError(err error) {
25-
_, _ = fmt.Fprintf(GinkgoWriter, "warning: %v\n", err)
25+
_, _ = fmt.Fprintf(ginkgo.GinkgoWriter, "warning: %v\n", err)
2626
}
2727

2828
// Run executes the provided command within this context
@@ -31,12 +31,12 @@ func Run(cmd *exec.Cmd) (string, error) {
3131
cmd.Dir = dir
3232

3333
if err := os.Chdir(cmd.Dir); err != nil {
34-
_, _ = fmt.Fprintf(GinkgoWriter, "chdir dir: %s\n", err)
34+
_, _ = fmt.Fprintf(ginkgo.GinkgoWriter, "chdir dir: %s\n", err)
3535
}
3636

3737
cmd.Env = append(os.Environ(), "GO111MODULE=on")
3838
command := strings.Join(cmd.Args, " ")
39-
_, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command)
39+
_, _ = fmt.Fprintf(ginkgo.GinkgoWriter, "running: %s\n", command)
4040
output, err := cmd.CombinedOutput()
4141
if err != nil {
4242
return string(output), fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output))
@@ -182,7 +182,7 @@ func GetProjectDir() (string, error) {
182182
if err != nil {
183183
return wd, err
184184
}
185-
wd = strings.Replace(wd, "/test/e2e", "", -1)
185+
wd = strings.ReplaceAll(wd, "/test/e2e", "")
186186
return wd, nil
187187
}
188188

0 commit comments

Comments
 (0)