Skip to content

Commit d1bb46a

Browse files
authored
[chore]: update golangci-lint to v2 (#3884)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent 4ccd143 commit d1bb46a

File tree

2 files changed

+79
-71
lines changed

2 files changed

+79
-71
lines changed

.golangci.yaml

Lines changed: 76 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,90 @@
1+
version: "2"
12
run:
23
concurrency: 3
34
timeout: 5m
45
issues-exit-code: 1
56
tests: true
67

7-
# all available settings of specific linters
8-
linters-settings:
9-
goheader:
10-
template: |-
11-
Copyright The OpenTelemetry Authors
12-
SPDX-License-Identifier: Apache-2.0
13-
goimports:
14-
local-prefixes: github.com/open-telemetry/opentelemetry-operator
15-
gci:
16-
sections:
17-
- standard
18-
- default
19-
- prefix(github.com/open-telemetry/opentelemetry-operator)
20-
misspell:
21-
locale: US
22-
ignore-words:
23-
- cancelled
24-
- metre
25-
- meter
26-
- metres
27-
- kilometre
28-
- kilometres
29-
govet:
30-
# settings per analyzer
31-
settings:
32-
printf: # analyzer name, run `go tool vet help` to see all analyzers
33-
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
34-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
35-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
36-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
37-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
38-
39-
enable-all: true
40-
# TODO: Enable this and fix the alignment issues.
41-
disable:
42-
- fieldalignment
43-
gofmt:
44-
simplify: true
45-
revive:
46-
confidence: 0.8
47-
48-
depguard:
49-
rules:
50-
main:
51-
deny:
52-
- pkg: sync/atomic
53-
desc: "Use go.uber.org/atomic instead of sync/atomic"
54-
- pkg: github.com/pkg/errors
55-
desc: "Use 'errors' or 'fmt' instead of github.com/pkg/errors"
56-
57-
issues:
58-
exclude-rules:
59-
- linters:
60-
- gci
61-
source: "// \\+kubebuilder"
62-
638
linters:
9+
# all available settings of specific linters
10+
settings:
11+
depguard:
12+
rules:
13+
main:
14+
deny:
15+
- pkg: sync/atomic
16+
desc: Use go.uber.org/atomic instead of sync/atomic
17+
- pkg: github.com/pkg/errors
18+
desc: Use 'errors' or 'fmt' instead of github.com/pkg/errors
19+
goheader:
20+
template: |-
21+
Copyright The OpenTelemetry Authors
22+
SPDX-License-Identifier: Apache-2.0
23+
govet:
24+
# TODO: Enable this and fix the alignment issues.
25+
disable:
26+
- fieldalignment
27+
enable-all: true
28+
# settings per analyzer
29+
settings:
30+
printf: # analyzer name, run `go tool vet help` to see all analyzers
31+
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
32+
- (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Infof
33+
- (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Warnf
34+
- (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Errorf
35+
- (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Fatalf
36+
misspell:
37+
locale: US
38+
ignore-rules:
39+
- cancelled
40+
revive:
41+
confidence: 0.8
42+
staticcheck:
43+
checks:
44+
- all
45+
- -QF1001 # FIXME Apply De Morgan’s law
46+
- -QF1003 # FIXME Convert if/else-if chain to tagged switch
47+
- -QF1004 # FIXME Use strings.ReplaceAll instead of strings.Replace with n == -1
48+
- -QF1008 # FIXME Omit embedded fields from selector expression
49+
- -QF1011 # FIXME Omit redundant type from variable declaration
50+
- -ST1003 # FIXME Poorly chosen identifier
51+
- -ST1005 # FIXME Incorrectly formatted error string
52+
- -ST1012 # FIXME Poorly chosen name for error variable
53+
- -ST1016 # FIXME Use consistent method receiver names
54+
- -ST1019 # FIXME Importing the same package multiple times
55+
- -ST1023 # FIXME Redundant type in variable declaration
6456
enable:
57+
- depguard
58+
- errcheck
59+
- errorlint
60+
- exhaustive
61+
- godot
6562
- goheader
66-
- goimports
67-
- misspell
6863
- gosec
6964
- govet
70-
- exhaustive
71-
- godot
72-
- unparam
73-
- gosimple
74-
- unused
75-
- staticcheck
7665
- ineffassign
77-
- typecheck
66+
- misspell
67+
- staticcheck
7868
- unparam
79-
- depguard
80-
- errcheck
81-
- errorlint
69+
- unused
70+
exclusions:
71+
generated: lax
72+
presets:
73+
- comments
74+
- common-false-positives
75+
- legacy
76+
- std-error-handling
77+
formatters:
78+
enable:
8279
- gci
80+
- gofmt
81+
settings:
82+
gci:
83+
sections:
84+
- standard
85+
- default
86+
- prefix(github.com/open-telemetry/opentelemetry-operator)
87+
gofmt:
88+
simplify: true
89+
exclusions:
90+
generated: lax

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ KUSTOMIZE_VERSION ?= v5.6.0
500500
# renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen
501501
CONTROLLER_TOOLS_VERSION ?= v0.17.1
502502
# renovate: datasource=github-releases depName=golangci/golangci-lint
503-
GOLANGCI_LINT_VERSION ?= v1.64.8
503+
GOLANGCI_LINT_VERSION ?= v2.0.2
504504
# renovate: datasource=go depName=sigs.k8s.io/kind
505505
KIND_VERSION ?= v0.27.0
506506
# renovate: datasource=go depName=github.com/kyverno/chainsaw
@@ -515,7 +515,7 @@ kustomize: ## Download kustomize locally if necessary.
515515

516516
.PHONY: golangci-lint
517517
golangci-lint: ## Download golangci-lint locally if necessary.
518-
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
518+
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
519519

520520
.PHONY: kind
521521
kind: ## Download kind locally if necessary.
@@ -549,7 +549,7 @@ TMP_DIR=$$(mktemp -d) ;\
549549
cd $$TMP_DIR ;\
550550
go mod init tmp ;\
551551
echo "Downloading $(2)" ;\
552-
go get -d $(2)@$(3) ;\
552+
go get $(2)@$(3) ;\
553553
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
554554
rm -rf $$TMP_DIR ;\
555555
}

0 commit comments

Comments
 (0)