Skip to content

Commit d5dcb3d

Browse files
authored
Use golangci-lint v2 (#1150)
Signed-off-by: apedriza <adripedriza@gmail.com>
1 parent 023c388 commit d5dcb3d

File tree

5 files changed

+55
-17
lines changed

5 files changed

+55
-17
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ jobs:
5151

5252
- name: Run linter
5353
env:
54-
GOLANGCI_LINT_FLAGS: --out-format=github-actions
54+
GOLANGCI_LINT_FLAGS: --output.text.path=stdout
5555
run: |
5656
make lint

.golangci.yml

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,57 @@
1-
# options for analysis running
1+
version: "2"
22
run:
3-
timeout: 8m
4-
53
build-tags:
64
- hack
7-
skip-dirs-use-default: false
8-
skip-files:
9-
- "zz_*"
10-
tests: true
115
modules-download-mode: readonly
6+
tests: true
127
allow-parallel-runners: true
13-
148
linters:
9+
default: none
10+
enable:
11+
- depguard
12+
- goheader
13+
- revive
14+
settings:
15+
revive:
16+
rules:
17+
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
18+
- name: blank-imports
19+
- name: context-as-argument
20+
- name: context-keys-type
21+
- name: dot-imports
22+
- name: error-return
23+
- name: error-strings
24+
- name: error-naming
25+
- name: exported
26+
- name: if-return
27+
- name: increment-decrement
28+
- name: var-naming
29+
- name: var-declaration
30+
- name: package-comments
31+
- name: range
32+
- name: receiver-naming
33+
- name: time-naming
34+
- name: unexported-return
35+
- name: indent-error-flow
36+
- name: errorf
37+
- name: empty-block
38+
- name: superfluous-else
39+
- name: unused-parameter
40+
- name: unreachable-code
41+
- name: redefines-builtin-id
42+
exclusions:
43+
generated: strict
44+
paths:
45+
# Ignore issues in generated files.
46+
- zz_generated.*\.go$
47+
formatters:
1548
enable:
16-
- depguard # Checks if package imports are in a list of acceptable packages
17-
- gofmt # Checks whether code was gofmt-ed
18-
- goheader # Checks is file headers matche a given pattern
19-
- revive # Stricter drop-in replacement for golint
49+
- gofmt
50+
exclusions:
51+
generated: strict
52+
paths:
53+
- zz_generated.*\.go$
54+
# Warn only about new issues, not existing ones.
55+
# TODO: Remove this filter at some point and ensure all old issues are fixed.
56+
issues:
57+
new-from-merge-base: HEAD~

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ lint: hack/lint/.golangci-lint.stamp
307307
--rm \
308308
-v "$(CURDIR):/go/src/github.com/k0sproject/k0smotron:ro" \
309309
-w /go/src/github.com/k0sproject/k0smotron \
310-
k0smotron.golangci-lint golangci-lint run $(GOLANGCI_LINT_FLAGS) $(GO_LINT_DIRS)
310+
k0smotron.golangci-lint golangci-lint run --config .golangci.yml $(GOLANGCI_LINT_FLAGS) $(GO_LINT_DIRS)
311311

312312
# KinD helpers
313313
.PHONY: kind-cluster

Makefile.variables

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
KUSTOMIZE_VERSION ?= v5.0.1
22
CONTROLLER_TOOLS_VERSION ?= v0.14.0
3-
GO_VERSION ?= 1.22.6
4-
GOLANGCILINT_VERSION ?= 1.52.2
3+
GO_VERSION ?= 1.23.0
4+
GOLANGCILINT_VERSION ?= 2.3.0
55
CRDOC_VERSION ?= v0.6.2

hack/lint/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARG BUILD_IMG
33
FROM ${BUILD_IMG} AS builder
44
ARG GOLANGCILINT_VERSION
55

6-
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCILINT_VERSION}
6+
RUN go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v${GOLANGCILINT_VERSION}
77

88
# Ref https://github.com/golangci/golangci-lint/pull/4034
99
RUN git config --global --add safe.directory '*'

0 commit comments

Comments
 (0)