Skip to content

Commit fe4d7a6

Browse files
committed
ci: update golangci-lint to v2.9
1 parent 3e13025 commit fe4d7a6

20 files changed

Lines changed: 71 additions & 22 deletions

File tree

.github/workflows/validate.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: validate
33
on:
44
push:
55
branches:
6-
- 'main'
6+
- "main"
77
pull_request:
88

99
permissions:
@@ -59,4 +59,4 @@ jobs:
5959
- name: Run golangci-lint
6060
uses: golangci/golangci-lint-action@v9
6161
with:
62-
version: v2.7
62+
version: v2.9

.golangci.yaml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ linters:
5959
- gocheckcompilerdirectives
6060
- goconst
6161
- gocritic
62+
# - godoclint
6263
- godot
6364
- goprintffuncname
6465
- gosec
@@ -70,10 +71,12 @@ linters:
7071
- inamedparam
7172
- ineffassign
7273
- intrange
73-
- ireturn
74+
- iotamixing
75+
# - ireturn
7476
- makezero
7577
- mirror
7678
- misspell
79+
- modernize
7780
- musttag
7881
- nakedret
7982
- nestif
@@ -82,15 +85,15 @@ linters:
8285
- nilnil
8386
- noctx
8487
- noinlineerr
85-
- nolintlint
88+
# - nolintlint
8689
- nonamedreturns
8790
- nosprintfhostport
8891
- paralleltest
8992
- perfsprint
9093
- prealloc
9194
- predeclared
9295
- reassign
93-
- recvcheck
96+
# - recvcheck
9497
- revive
9598
- sloglint
9699
- staticcheck
@@ -124,6 +127,7 @@ linters:
124127
disable:
125128
- assign-exclusive
126129
- if
130+
- err
127131

128132
unused:
129133
field-writes-are-uses: false
@@ -161,6 +165,17 @@ linters:
161165
disabled-checks:
162166
- unnamedResult
163167
- singleCaseSwitch
168+
settings:
169+
hugeParam:
170+
sizeThreshold: 256
171+
172+
# godoclint:
173+
# default: all
174+
# disable:
175+
# - require-pkg-doc
176+
# options:
177+
# max-len:
178+
# length: 80
164179

165180
godot:
166181
scope: all
@@ -178,7 +193,6 @@ linters:
178193
- os.RemoveAll
179194

180195
grouper:
181-
const-require-single-const: true
182196
import-require-single-import: true
183197
var-require-single-var: true
184198

@@ -197,6 +211,9 @@ linters:
197211
disabled: true
198212
- name: max-public-structs
199213
disabled: true
214+
- name: nested-structs
215+
exclude:
216+
- "**/*_test.go"
200217
# Needed for future use.
201218
- name: unused-receiver
202219
disabled: true
@@ -220,6 +237,8 @@ linters:
220237
# Requires default cases.
221238
- name: enforce-switch-style
222239
disabled: true
240+
- name: unhandled-error
241+
disabled: true
223242

224243
depguard:
225244
rules:
@@ -246,6 +265,10 @@ linters:
246265
- godot
247266
- gosec
248267
- gosmopolitan
268+
- prealloc
269+
- godoclint
270+
- path: _test\.go
271+
text: "fieldalignment:"
249272
- source: "= `"
250273
linters:
251274
- grouper

cmd/kclipper/commands/root_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestRunCmd(t *testing.T) {
5353
}
5454

5555
func BenchmarkRun(b *testing.B) {
56-
for range b.N {
56+
for b.Loop() {
5757
tc := commands.NewRootCmd("bench_run", "", "")
5858
stdout := &bytes.Buffer{}
5959
stderr := &bytes.Buffer{}

pkg/crd/crd_kcl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func (s *KCLPackage) GenerateC(ctx context.Context) error {
6868
merr = multierror.Append(merr, err)
6969
}
7070
}
71+
7172
if merr != nil {
7273
return fmt.Errorf("failed to generate KCL from CRDs: %w", merr)
7374
}
@@ -101,6 +102,7 @@ func (s *KCLPackage) writeToKCLSchema(uCRD *unstructured.Unstructured) error {
101102
merr = multierror.Append(merr, fmt.Errorf("%s: %w", v.GetAPIVersion(), err))
102103
}
103104
}
105+
104106
if merr != nil {
105107
return multierror.Prefix(merr, ErrGenerateKCL.Error()+":") //nolint:wrapcheck // Multierror
106108
}

pkg/helm/chart_data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func (c *Chart) Template(ctx context.Context) ([]*unstructured.Unstructured, err
6767
if c.TemplateOpts.Timeout > 0 {
6868
ctx, cancel = context.WithTimeout(ctx, c.TemplateOpts.Timeout)
6969
}
70+
7071
defer cancel()
7172

7273
pulledChart, err := c.Client.Pull(ctx,

pkg/helm/chart_files.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func (c *ChartFiles) GetValuesJSONSchema(gen JSONSchemaGenerator, match func(str
9191
if err != nil {
9292
return fmt.Errorf("get relative path: %w", err)
9393
}
94+
9495
// Use the relative path to match against the provided filter.
9596
if match(relPath) {
9697
// Append the unmodified/absolute path to the matched files.
@@ -164,6 +165,7 @@ func (c *ChartFiles) GetCRDFiles(gen CRDGenerator, match func(string) bool) ([]*
164165
if err != nil {
165166
return fmt.Errorf("get relative path: %w", err)
166167
}
168+
167169
// Use the relative path to match against the provided filter.
168170
if match(relPath) {
169171
// Append the unmodified/absolute path to the matched files.

pkg/helmrepo/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ func (m *Manager) addByName(name string, repo *Repo) error {
201201
// Get returns a repo by its name or URL. It calls [Manager.GetByName] or
202202
// [Manager.GetByURL] depending on the input.
203203
func (m *Manager) Get(repo string) (*Repo, error) {
204-
if strings.HasPrefix(repo, "@") {
205-
return m.GetByName(strings.TrimPrefix(repo, "@"))
204+
if after, ok := strings.CutPrefix(repo, "@"); ok {
205+
return m.GetByName(after)
206206
}
207207

208208
return m.GetByURL(repo)

pkg/kclautomation/automation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (a Automation) GetSpecs(specPath string) ([]string, error) {
8282

8383
// SpecPathJoin joins path components with dots, splitting any components that already contain dots.
8484
func SpecPathJoin(path ...string) string {
85-
pathParts := []string{}
85+
pathParts := make([]string, 0, len(path))
8686
for _, p := range path {
8787
pathParts = append(pathParts, strings.FieldsFunc(p, func(c rune) bool {
8888
return c == '.'

pkg/kclautomation/file_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func TestFile_OverrideFile(t *testing.T) {
9393
// since the exact formatting (spaces, etc.) may vary
9494
for _, spec := range tc.specs {
9595
key := spec
96-
if idx := strings.Index(spec, "="); idx >= 0 {
97-
key = spec[:idx]
96+
if before, _, ok := strings.Cut(spec, "="); ok {
97+
key = before
9898
}
9999

100100
assert.Contains(t, string(content), key)

pkg/kclmodule/kclchart/chart.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (c *Chart) GenerateKCL(w io.Writer) error {
2727
return fmt.Errorf("failed to create schema reflector: %w", err)
2828
}
2929

30-
js := r.Reflect(reflect.TypeOf(Chart{}))
30+
js := r.Reflect(reflect.TypeFor[Chart]())
3131
js.Schema.Description = "All possible chart configuration, inheriting from `helm.Chart(helm.ChartBase)`."
3232

3333
js.SetProperty("chart", jsonschema.WithDefault(c.Chart))

0 commit comments

Comments
 (0)