Skip to content

Commit b345847

Browse files
authored
Merge pull request #3261 from robnester-rh/EC-1756
Migrate golangci-lint from v1 to v2
2 parents b5e1ab0 + 7d35b0d commit b345847

5 files changed

Lines changed: 345 additions & 273 deletions

File tree

.golangci.yaml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,48 @@
1313
# limitations under the License.
1414

1515
---
16+
version: "2"
17+
1618
run:
1719
build-tags:
1820
- acceptance
1921
- generative
2022
- integration
2123
- unit
24+
2225
linters:
2326
enable:
24-
- gci
25-
- goimports
2627
- gosec
2728
- misspell
28-
linters-settings:
29-
gci:
30-
sections:
31-
- standard
32-
- default
33-
- prefix(github.com/conforma/cli)
29+
- staticcheck
30+
settings:
31+
gosec:
32+
excludes:
33+
- G122
34+
- G702
35+
- G703
36+
staticcheck:
37+
checks:
38+
- "all"
39+
- "-QF*"
40+
- "-ST*"
41+
exclusions:
42+
presets:
43+
- comments
44+
- common-false-positives
45+
- legacy
46+
- std-error-handling
47+
48+
formatters:
49+
enable:
50+
- gci
51+
- goimports
52+
settings:
53+
gci:
54+
sections:
55+
- standard
56+
- default
57+
- prefix(github.com/conforma/cli)
3458

3559
issues:
36-
exclude-rules: []
60+
exclude-generated: lax

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,17 @@ lint: tekton-lint go-mod-lint ## Run linter
207207
@go run -modfile tools/go.mod github.com/google/addlicense -c '$(COPY)' -y '' -s -check $(LICENSE_IGNORE) . | sed 's/^/Missing license header in: /g'
208208
# piping to sed above looses the exit code, luckily addlicense is fast so we invoke it for the second time to exit 1 in case of issues
209209
@go run -modfile tools/go.mod github.com/google/addlicense -c '$(COPY)' -y '' -s -check $(LICENSE_IGNORE) . >/dev/null 2>&1
210-
@go run -modfile tools/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint run --sort-results $(if $(GITHUB_ACTIONS), --timeout=10m0s)
211-
@(cd acceptance && go run -modfile ../tools/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint run --path-prefix acceptance --sort-results $(if $(GITHUB_ACTIONS), --timeout=10m0s))
210+
@go run -modfile tools/go.mod github.com/golangci/golangci-lint/v2/cmd/golangci-lint run $(if $(GITHUB_ACTIONS), --timeout=10m0s)
211+
@(cd acceptance && go run -modfile ../tools/go.mod github.com/golangci/golangci-lint/v2/cmd/golangci-lint run --path-prefix acceptance $(if $(GITHUB_ACTIONS), --timeout=10m0s))
212212

213213
.PHONY: lint-fix
214214
lint-fix: ## Fix linting issues automagically
215215
@go run -modfile tools/go.mod github.com/google/addlicense -c '$(COPY)' -y '' -s $(LICENSE_IGNORE) .
216-
@go run -modfile tools/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint run --fix
217-
@(cd acceptance && go run -modfile ../tools/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint run --path-prefix acceptance --fix)
216+
@go run -modfile tools/go.mod github.com/golangci/golangci-lint/v2/cmd/golangci-lint run --fix
217+
@(cd acceptance && go run -modfile ../tools/go.mod github.com/golangci/golangci-lint/v2/cmd/golangci-lint run --path-prefix acceptance --fix)
218218
# We don't apply the fixes from the internal (error handling) linter.
219219
# TODO: fix the outstanding error handling lint issues and enable the fixer
220220
# @go run -modfile tools/go.mod ./internal/lint -fix $$(go list ./... | grep -v '/acceptance/')
221-
@go run -modfile tools/go.mod github.com/daixiang0/gci write -s standard -s default -s "prefix(github.com/conforma/cli)" .
222221

223222
node_modules: package-lock.json
224223
@npm ci

0 commit comments

Comments
 (0)