Skip to content

Commit e5be52f

Browse files
saschagrunertk8s-ci-robot
authored andcommitted
Switch to golangci-lint v2
Signed-off-by: Sascha Grunert <[email protected]>
1 parent 48bdbcb commit e5be52f

File tree

19 files changed

+167
-152
lines changed

19 files changed

+167
-152
lines changed

.golangci.yml

+62-46
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
---
2+
version: "2"
23
run:
34
concurrency: 6
4-
timeout: 10m
5-
issues:
6-
exclude-rules:
7-
- path: internal/pkg/daemon/bpfrecorder/generated.go
8-
linters:
9-
- gofumpt
10-
- lll
115
linters:
12-
disable-all: true
6+
default: none
137
enable:
148
- asasalint
159
- asciicheck
@@ -32,7 +26,6 @@ linters:
3226
- exptostd
3327
- fatcontext
3428
- forcetypeassert
35-
- gci
3629
- ginkgolinter
3730
- gocheckcompilerdirectives
3831
- gochecknoinits
@@ -43,14 +36,10 @@ linters:
4336
- gocyclo
4437
- godot
4538
- godox
46-
- gofmt
47-
- gofumpt
4839
- goheader
49-
- goimports
5040
- gomodguard
5141
- goprintffuncname
5242
- gosec
53-
- gosimple
5443
- gosmopolitan
5544
- govet
5645
- grouper
@@ -87,14 +76,12 @@ linters:
8776
- spancheck
8877
- sqlclosecheck
8978
- staticcheck
90-
- stylecheck
9179
- tagalign
9280
- tagliatelle
9381
- testableexamples
9482
- testifylint
9583
- thelper
9684
- tparallel
97-
- typecheck
9885
- unconvert
9986
- unparam
10087
- unused
@@ -121,35 +108,64 @@ linters:
121108
# - testpackage
122109
# - varnamelen
123110
# - wrapcheck
124-
linters-settings:
125-
revive:
111+
settings:
112+
errcheck:
113+
check-type-assertions: true
114+
check-blank: true
115+
gocognit:
116+
min-complexity: 40
117+
goconst:
118+
min-occurrences: 6
119+
gocritic:
120+
enable-all: true
121+
godox:
122+
keywords:
123+
- BUG
124+
- FIXME
125+
- HACK
126+
gomoddirectives:
127+
replace-allow-list:
128+
- golang.org/x/sys
129+
gosec:
130+
excludes:
131+
- G115
132+
nestif:
133+
min-complexity: 15
134+
revive:
135+
rules:
136+
- name: unused-parameter
137+
disabled: true
138+
exclusions:
139+
generated: lax
140+
presets:
141+
- comments
142+
- common-false-positives
143+
- legacy
144+
- std-error-handling
126145
rules:
127-
- name: unused-parameter
128-
disabled: true
129-
goconst:
130-
min-occurrences: 6
131-
gomoddirectives:
132-
replace-allow-list:
133-
- golang.org/x/sys
134-
gocognit:
135-
min-complexity: 40
136-
gosec:
137-
excludes:
138-
- G115 # Potential integer overflow when converting between types
139-
nestif:
140-
min-complexity: 15
141-
gci:
142-
sections:
143-
- standard
144-
- default
145-
- localmodule
146-
errcheck:
147-
check-type-assertions: true
148-
check-blank: true
149-
godox:
150-
keywords:
151-
- BUG
152-
- FIXME
153-
- HACK
154-
gocritic:
155-
enable-all: true
146+
- linters:
147+
- lll
148+
path: internal/pkg/daemon/bpfrecorder/generated.go
149+
paths:
150+
- third_party$
151+
- builtin$
152+
- examples$
153+
formatters:
154+
enable:
155+
- gci
156+
- gofmt
157+
- gofumpt
158+
- goimports
159+
settings:
160+
gci:
161+
sections:
162+
- standard
163+
- default
164+
- localmodule
165+
exclusions:
166+
generated: lax
167+
paths:
168+
- third_party$
169+
- builtin$
170+
- examples$
171+
- internal/pkg/daemon/bpfrecorder/generated.go

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
GO ?= go
1616

17-
GOLANGCI_LINT_VERSION = v1.64.5
17+
GOLANGCI_LINT_VERSION = v2.0.1
1818
REPO_INFRA_VERSION = v0.2.5
1919
KUSTOMIZE_VERSION = 5.5.0
2020
OPERATOR_SDK_VERSION ?= v1.37.0

api/profilebase/v1alpha1/profilebase.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func IsDisabled(prfSpec *SpecBase) bool {
5252
}
5353

5454
func IsReconcilable(prfBase SecurityProfileBase) bool {
55-
return !(prfBase.IsDisabled() || prfBase.IsPartial())
55+
return !prfBase.IsDisabled() && !prfBase.IsPartial()
5656
}
5757

5858
func ListProfilesByRecording(

api/spod/v1alpha1/spod_types.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -382,22 +382,22 @@ type SecurityProfilesOperatorDaemonList struct {
382382

383383
func (s *SPODStatus) StatePending() {
384384
s.State = SPODStatePending
385-
s.ConditionedStatus.SetConditions(Pending())
385+
s.SetConditions(Pending())
386386
}
387387

388388
func (s *SPODStatus) StateCreating() {
389389
s.State = SPODStateCreating
390-
s.ConditionedStatus.SetConditions(Creating())
390+
s.SetConditions(Creating())
391391
}
392392

393393
func (s *SPODStatus) StateUpdating() {
394394
s.State = SPODStateUpdating
395-
s.ConditionedStatus.SetConditions(Updating())
395+
s.SetConditions(Updating())
396396
}
397397

398398
func (s *SPODStatus) StateRunning() {
399399
s.State = SPODStateRunning
400-
s.ConditionedStatus.SetConditions(Available())
400+
s.SetConditions(Available())
401401
}
402402

403403
func init() { //nolint:gochecknoinits // required to init the scheme

dependencies.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies:
22
- name: golangci-lint
3-
version: 1.64.5
3+
version: 2.0.1
44
refPaths:
55
- path: Makefile
66
match: GOLANGCI_LINT_VERSION

internal/pkg/cli/installer/options_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestFromContext(t *testing.T) {
4747
},
4848
assert: func(options *Options, err error) {
4949
require.NoError(t, err)
50-
require.Equal(t, "", options.ExecutablePath)
50+
require.Empty(t, options.ExecutablePath)
5151
require.Equal(t, "profile.yml", options.ProfilePath)
5252
},
5353
},
@@ -57,7 +57,7 @@ func TestFromContext(t *testing.T) {
5757
},
5858
assert: func(options *Options, err error) {
5959
require.NoError(t, err)
60-
require.Equal(t, "", options.ExecutablePath)
60+
require.Empty(t, options.ExecutablePath)
6161
require.Equal(t, DefaultProfileFile, options.ProfilePath)
6262
},
6363
},

internal/pkg/cli/platform.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ func ParsePlatform(input string) (*v1.Platform, error) {
4040
parts := strings.Split(platformStr, "/")
4141

4242
switch len(parts) {
43-
case 3: //nolint:gomnd // intentional
43+
case 3:
4444
res.Variant = parts[2]
4545

4646
fallthrough
47-
case 2: //nolint:gomnd // intentional
47+
case 2:
4848
res.Architecture = parts[1]
4949
case 1:
5050
res.Architecture = runtime.GOARCH

internal/pkg/daemon/bpfrecorder/generate/main.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ func run() error {
8989

9090
//nolint:gosec // permissions are fine
9191
if err := os.WriteFile(
92-
//nolint:gomnd // filemode is fine
9392
generatedGo, []byte(builder.String()), 0o644,
9493
); err != nil {
9594
return fmt.Errorf("writing generated object: %w", err)
@@ -168,11 +167,11 @@ func generateBtf(builder *strings.Builder) error {
168167
}
169168
if _, ok := btfs[os][osVersion][arch]; !ok {
170169
btfs[os][osVersion][arch] = map[types.Kernel][]byte{}
171-
fmt.Fprintf(docs, "%s- %s\n", strings.Repeat(" ", 4), arch) //nolint:gomnd // indent
170+
fmt.Fprintf(docs, "%s- %s\n", strings.Repeat(" ", 4), arch)
172171
}
173172

174173
btfs[os][osVersion][arch][kernel] = btfBytes
175-
fmt.Fprintf(docs, "%s- %s\n", strings.Repeat(" ", 6), kernel) //nolint:gomnd // indent
174+
fmt.Fprintf(docs, "%s- %s\n", strings.Repeat(" ", 6), kernel)
176175
kernels++
177176

178177
return nil
@@ -191,7 +190,7 @@ func generateBtf(builder *strings.Builder) error {
191190
fmt.Fprintf(docs, "\nSum: %d\n", kernels)
192191

193192
if err := os.WriteFile(
194-
docsFile, docs.Bytes(), fs.FileMode(0o644), //nolint:gomnd // filemode is fine
193+
docsFile, docs.Bytes(), fs.FileMode(0o644),
195194
); err != nil {
196195
return fmt.Errorf("write docs file: %w", err)
197196
}

internal/pkg/daemon/profilerecorder/profilerecorder.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func (r *RecorderReconciler) Reconcile(ctx context.Context, req reconcile.Reques
242242
}
243243

244244
if pod.Status.Phase == corev1.PodPending {
245-
if _, ok := r.podsToWatch.Load(req.NamespacedName.String()); ok {
245+
if _, ok := r.podsToWatch.Load(req.String()); ok {
246246
// We're tracking this pod already
247247
return reconcile.Result{}, nil
248248
}
@@ -292,7 +292,7 @@ func (r *RecorderReconciler) Reconcile(ctx context.Context, req reconcile.Reques
292292
}
293293

294294
for _, prf := range profiles {
295-
logger.Info("Recording profile", "kind", prf.kind, "name", prf.name, "pod", req.NamespacedName.String())
295+
logger.Info("Recording profile", "kind", prf.kind, "name", prf.name, "pod", req.String())
296296
}
297297

298298
// for pods managed by a replicated controller, let's store the replicated
@@ -303,7 +303,7 @@ func (r *RecorderReconciler) Reconcile(ctx context.Context, req reconcile.Reques
303303
}
304304

305305
r.podsToWatch.Store(
306-
req.NamespacedName.String(),
306+
req.String(),
307307
podToWatch{baseName, recorder, profiles},
308308
)
309309
r.record.Event(pod, util.EventTypeNormal, reasonProfileRecording, "Recording profiles")

0 commit comments

Comments
 (0)