Skip to content

Commit f2ac6ba

Browse files
authored
Merge pull request k8snetworkplumbingwg#121 from SchSeba/multiple_bumps
multiple bumps: golang version, golangci-lint v2, update lint config, fix lint issues
2 parents 8ba6a2b + 1426b3f commit f2ac6ba

File tree

7 files changed

+108
-71
lines changed

7 files changed

+108
-71
lines changed

.github/workflows/buildtest.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
name: build
1010
strategy:
1111
matrix:
12-
go-version: [1.24.x]
12+
go-version: [1.25.x]
1313
os: [ubuntu-22.04]
1414
goos: [linux]
1515
goarch: [amd64]
@@ -35,7 +35,7 @@ jobs:
3535
- name: set up Go
3636
uses: actions/setup-go@v6
3737
with:
38-
go-version: 1.24.x
38+
go-version: 1.25.x
3939
- name: check out code into the Go module directory
4040
uses: actions/checkout@v6
4141
- name: run unit-test
@@ -49,7 +49,7 @@ jobs:
4949
- name: Set up Go
5050
uses: actions/setup-go@v6
5151
with:
52-
go-version: 1.24.x
52+
go-version: 1.25.x
5353
- name: Check out code into the Go module directory
5454
uses: actions/checkout@v6
5555
- name: Go test with coverage

.github/workflows/static-scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: set up Go
99
uses: actions/setup-go@v6
1010
with:
11-
go-version: 1.24.x
11+
go-version: 1.25.x
1212
- name: checkout PR
1313
uses: actions/checkout@v6
1414
- name: run make lint

.golangci.yml

Lines changed: 98 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,123 @@
1-
linters-settings:
2-
revive:
3-
rules:
4-
- name: dot-imports
5-
arguments:
6-
- allowedPackages:
7-
- "github.com/onsi/ginkgo/v2"
8-
- "github.com/onsi/gomega"
9-
dupl:
10-
threshold: 150
11-
funlen:
12-
lines: 100
13-
statements: 50
14-
goconst:
15-
min-len: 2
16-
min-occurrences: 2
17-
gocognit:
18-
min-complexity: 30
19-
goimports:
20-
local-prefixes: github.com/k8snetworkplumbingwg/rdma-cni
21-
mnd:
22-
# don't include the "operation" and "assign"
23-
checks: [argument,case,condition,return]
24-
govet:
25-
settings:
26-
printf:
27-
funcs:
28-
- (github.com/rs/zerolog/zerolog.Event).Msgf
29-
lll:
30-
line-length: 120
31-
misspell:
32-
locale: US
33-
prealloc:
34-
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
35-
# True by default.
36-
simple: true
37-
range-loops: true # Report preallocation suggestions on range loops, true by default
38-
for-loops: false # Report preallocation suggestions on for loops, false by default
1+
# Tested with golangci-lint ver. 2.x
2+
version: "2"
3+
4+
run:
5+
timeout: 10m
396

407
linters:
41-
# please, do not use `enable-all`: it's deprecated and will be removed soon.
42-
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
43-
disable-all: true
8+
default: none
449
enable:
10+
- asciicheck # checks for non-ASCII identifiers
11+
- bidichk # checks for dangerous unicode sequences (security)
4512
- bodyclose
13+
- copyloopvar
14+
- depguard
4615
- dogsled
4716
- dupl
4817
- errcheck
18+
- errname # checks error naming conventions
19+
- exhaustive
4920
- funlen
21+
- gocheckcompilerdirectives # validates go compiler directives
5022
- gochecknoinits
23+
- gocognit
5124
- goconst
5225
- gocritic
53-
- gocognit
54-
- gofmt
55-
- goimports
56-
- mnd
5726
- goprintffuncname
5827
- gosec
59-
- gosimple
28+
- staticcheck
6029
- govet
6130
- ineffassign
6231
- lll
32+
- makezero # finds slice declarations with non-zero initial length
6333
- misspell
34+
- mnd
6435
- nakedret
6536
- prealloc
37+
- reassign # checks package variable reassignment
6638
- revive
67-
- rowserrcheck
68-
- staticcheck
69-
- stylecheck
70-
- typecheck
7139
- unconvert
7240
- unparam
7341
- unused
7442
- whitespace
7543

76-
issues:
77-
# Excluding configuration per-path, per-linter, per-text and per-source
78-
exclude-rules:
79-
- path: _test\.go
80-
linters:
81-
- mnd
82-
- goconst
83-
- dupl
84-
- text: "Magic number: 1"
85-
linters:
86-
- mnd
44+
settings:
45+
depguard:
46+
rules:
47+
main:
48+
deny:
49+
- pkg: github.com/sirupsen/logrus
50+
desc: "logging is allowed only by logutils.Log"
51+
revive:
52+
rules:
53+
- name: dot-imports
54+
arguments:
55+
- allowedPackages:
56+
- "github.com/onsi/ginkgo/v2"
57+
- "github.com/onsi/gomega"
58+
dupl:
59+
threshold: 150
60+
funlen:
61+
lines: 100
62+
statements: 50
63+
goconst:
64+
min-len: 2
65+
min-occurrences: 2
66+
gocognit:
67+
min-complexity: 30
68+
govet:
69+
settings:
70+
printf:
71+
funcs:
72+
- (github.com/rs/zerolog/zerolog.Event).Msgf
73+
lll:
74+
line-length: 120
75+
misspell:
76+
locale: US
77+
mnd:
78+
checks:
79+
- argument
80+
- case
81+
- condition
82+
- return
83+
prealloc:
84+
simple: true
85+
range-loops: true
86+
for-loops: false
87+
staticcheck:
88+
checks:
89+
- all
90+
- -QF1001
91+
- -QF1003
92+
- -QF1008
93+
dot-import-whitelist:
94+
- github.com/onsi/ginkgo/v2
95+
- github.com/onsi/gomega
96+
97+
exclusions:
98+
generated: lax
99+
presets:
100+
- comments
101+
- std-error-handling
102+
paths:
103+
- vendor/
104+
- .github/
105+
- images/
106+
rules:
107+
- path: _test\.go
108+
linters:
109+
- mnd
110+
- goconst
111+
- dupl
112+
- text: "Magic number: 1"
113+
linters:
114+
- mnd
115+
116+
formatters:
117+
enable:
118+
- gofmt
119+
- goimports
120+
settings:
121+
goimports:
122+
local-prefixes:
123+
- github.com/k8snetworkplumbingwg/rdma-cni

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM golang:alpine AS builder
1+
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder
22

33
ARG TARGETPLATFORM
44
ARG TARGETARCH

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ GOLANGCI_LINT = $(BINDIR)/golangci-lint
5252
# golangci-lint version should be updated periodically
5353
# we keep it fixed to avoid it from unexpectedly failing on the project
5454
# in case of a version bump
55-
GOLANGCI_LINT_VER = v1.64.7
55+
GOLANGCI_LINT_VER = v2.7.2
5656
MOCKERY_VERSION ?= v3.5.4
5757
TIMEOUT = 30
5858
Q = $(if $(filter 1,$V),,@)
@@ -73,8 +73,8 @@ $(BUILDDIR)/$(BINARY_NAME): $(GOFILES) | $(BUILDDIR)
7373
@$(GO_BUILD_OPTS) go build -o $(BUILDDIR)/$(BINARY_NAME) $(GO_TAGS) -ldflags $(LDFLAGS) -v cmd/rdma/main.go
7474

7575
# Tools
76-
$(GOLANGCI_LINT): ; $(info building golangci-lint...)
77-
$Q curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BINDIR) $(GOLANGCI_LINT_VER)
76+
$(GOLANGCI_LINT): | $(BINDIR) ; $(info installing golangci-lint...)
77+
$Q GOBIN=$(BINDIR) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VER)
7878

7979
MOCKERY= $(BINDIR)/mockery
8080
$(MOCKERY): ; $(info building mockery...)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/k8snetworkplumbingwg/rdma-cni
22

3-
go 1.24.2
3+
go 1.25.3
44

55
require (
66
github.com/Mellanox/rdmamap v1.1.0

pkg/cache/fs_ops.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type FileSystemOps interface {
2727
type stdFileSystemOps struct{}
2828

2929
func (sfs *stdFileSystemOps) ReadFile(filename string) ([]byte, error) {
30-
return os.ReadFile(filename)
30+
return os.ReadFile(filename) //nolint:gosec
3131
}
3232

3333
func (sfs *stdFileSystemOps) WriteFile(filename string, data []byte, perm os.FileMode) error {

0 commit comments

Comments
 (0)