Skip to content

Commit a25bfa9

Browse files
committed
chore: upgrade golangci-lint
1 parent 4ee469e commit a25bfa9

File tree

5 files changed

+126
-104
lines changed

5 files changed

+126
-104
lines changed

.golangci.yaml

Lines changed: 112 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,126 @@
1+
version: "2"
12
run:
23
go: "1.22"
3-
timeout: 10m
44
tests: false
55
allow-parallel-runners: true
6-
linters-settings:
7-
funlen:
8-
lines: 150
9-
statements: 60
10-
cyclop:
11-
max-complexity: 20
12-
skip-tests: true
13-
gosec:
14-
exclude-generated: true
15-
lll:
16-
line-length: 150
17-
misspell:
18-
locale: US
19-
nolintlint:
20-
allow-unused: false
21-
require-explanation: true
22-
require-specific: false
23-
varnamelen:
24-
ignore-names:
25-
- err
26-
- wg
27-
- fs
28-
- id
29-
- vm
30-
- ns
31-
- ip
32-
33-
issues:
34-
exclude-dirs:
35-
- "./*/mock"
36-
exclude-files:
37-
- pkg/ocm/fakes/fakes.go
38-
- pkg/cache/fakes/cache.go
39-
- pkg/untar/untar.go
40-
max-same-issues: 0
41-
max-issues-per-linter: 0
42-
exclude-rules:
43-
- text: "should not use dot imports|don't use an underscore in package name"
44-
linters:
45-
- golint
46-
- source: "https://"
47-
linters:
48-
- lll
49-
- path: pkg/defaults/
50-
linters:
51-
- lll
52-
- path: _test\.go
53-
linters:
54-
- goerr113
55-
- gocyclo
56-
- errcheck
57-
- gosec
58-
- dupl
59-
- funlen
60-
- scopelint
61-
- testpackage
62-
- goconst
63-
- godox
64-
- path: internal/version/
65-
linters:
66-
- gochecknoglobals
67-
- path: internal/command/
68-
linters:
69-
- exhaustivestruct
70-
- lll
71-
- wrapcheck
72-
- source: "// .* #\\d+"
73-
linters:
74-
- godox
75-
- path: test/e2e/
76-
linters:
77-
- goerr113
78-
- gomnd
79-
# remove this once https://github.com/golangci/golangci-lint/issues/2649 is closed
80-
- path: /
81-
linters:
82-
- typecheck
83-
846
linters:
85-
enable-all: true
7+
default: all
868
disable:
87-
- gci
9+
- copyloopvar
8810
- depguard
89-
- exhaustivestruct
90-
- golint
91-
- interfacer
92-
- ireturn
93-
- maligned
94-
- nilnil
95-
- scopelint
96-
- tagliatelle
97-
- gomoddirectives
98-
- varcheck
99-
- nosnakecase
100-
- structcheck
101-
- ifshort
102-
- deadcode
11+
- err113
12+
- exhaustruct
10313
- forbidigo
104-
- prealloc
14+
- gochecknoglobals
10515
- gochecknoinits
106-
- exhaustruct
107-
- goerr113
16+
- gomoddirectives
10817
- govet
18+
- ireturn
19+
- nilnil
10920
- nonamedreturns
21+
- paralleltest
22+
- perfsprint
23+
- prealloc
24+
- staticcheck
25+
- tagliatelle
11026
- varnamelen
11127
- wrapcheck
112-
- staticcheck
113-
- gochecknoglobals
114-
- paralleltest
11528
- wsl
116-
- perfsprint
29+
- funcorder
30+
- recvcheck
31+
settings:
32+
cyclop:
33+
max-complexity: 20
34+
funlen:
35+
lines: 150
36+
statements: 60
37+
lll:
38+
line-length: 150
39+
misspell:
40+
locale: US
41+
nolintlint:
42+
require-explanation: true
43+
require-specific: false
44+
allow-unused: false
45+
varnamelen:
46+
ignore-names:
47+
- err
48+
- wg
49+
- fs
50+
- id
51+
- vm
52+
- ns
53+
- ip
54+
exclusions:
55+
generated: lax
56+
presets:
57+
- comments
58+
- common-false-positives
59+
- legacy
60+
- std-error-handling
61+
rules:
62+
- linters:
63+
- golint
64+
text: should not use dot imports|don't use an underscore in package name
65+
- linters:
66+
- lll
67+
source: https://
68+
- linters:
69+
- lll
70+
path: pkg/defaults/
71+
- linters:
72+
- dupl
73+
- err113
74+
- errcheck
75+
- funlen
76+
- goconst
77+
- gocyclo
78+
- godox
79+
- gosec
80+
- scopelint
81+
- testpackage
82+
path: _test\.go
83+
- linters:
84+
- gochecknoglobals
85+
path: internal/version/
86+
- linters:
87+
- exhaustivestruct
88+
- lll
89+
- wrapcheck
90+
path: internal/command/
91+
- linters:
92+
- godox
93+
source: '// .* #\d+'
94+
- linters:
95+
- err113
96+
- mnd
97+
path: test/e2e/
98+
- linters:
99+
- cyclop
100+
path: (.+)_test\.go
101+
paths:
102+
- pkg/ocm/fakes/fakes.go
103+
- pkg/cache/fakes/cache.go
104+
- pkg/untar/untar.go
105+
- ./*/mock
106+
- third_party$
107+
- builtin$
108+
- examples$
109+
issues:
110+
max-issues-per-linter: 0
111+
max-same-issues: 0
112+
formatters:
113+
enable:
114+
- gofmt
115+
- gofumpt
116+
- goimports
117+
exclusions:
118+
generated: lax
119+
paths:
120+
- pkg/ocm/fakes/fakes.go
121+
- pkg/cache/fakes/cache.go
122+
- pkg/untar/untar.go
123+
- ./*/mock
124+
- third_party$
125+
- builtin$
126+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ KUSTOMIZE_VERSION ?= v3.8.7
155155
CONTROLLER_TOOLS_VERSION ?= v0.14.0
156156
GEN_API_REF_DOCS_VERSION ?= e327d0730470cbd61b06300f81c5fcf91c23c113
157157
MKCERT_VERSION ?= v1.4.4
158-
GOLANGCI_LINT_VERSION ?= v1.57.2
158+
GOLANGCI_LINT_VERSION ?= v2.1.1
159159

160160
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
161161
.PHONY: kustomize

controllers/configuration_strat_merge_patch.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import (
1313
kustypes "sigs.k8s.io/kustomize/api/types"
1414
)
1515

16+
const (
17+
FSOwnerReadWrite = 0o600
18+
)
19+
1620
// the following is influenced by https://github.com/fluxcd/kustomize-controller
1721
func (m *MutationReconcileLooper) strategicMergePatch(
1822
resource []byte,
@@ -53,7 +57,7 @@ func (m *MutationReconcileLooper) strategicMergePatch(
5357
}
5458

5559
kustomize := filepath.Join(workDir, "kustomization.yaml")
56-
err = os.WriteFile(kustomize, manifest, os.ModePerm)
60+
err = os.WriteFile(kustomize, manifest, FSOwnerReadWrite)
5761
if err != nil {
5862
return "", err
5963
}

controllers/spifftemplatedoc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"container/list"
66
"fmt"
7+
"math"
78

89
"github.com/mikefarah/yq/v4/pkg/yqlib"
910
"github.com/open-component-model/ocm/pkg/contexts/ocm/utils/localize"
@@ -33,6 +34,9 @@ func makeYqNode(docBytes []byte, fileName string, docIndex, fileIndex uint) (*yq
3334

3435
ret.SetDocument(docIndex)
3536
ret.SetFilename(fileName)
37+
if fileIndex > math.MaxInt {
38+
return nil, fmt.Errorf("file index value would cause integer overflow: %d", fileIndex)
39+
}
3640
ret.SetFileIndex(int(fileIndex))
3741

3842
return ret, nil

internal/wasm/io/write.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io
22

33
import (
44
"context"
5+
"math"
56

67
wasmerr "github.com/open-component-model/ocm-controller/pkg/wasm/errors"
78
"github.com/tetratelabs/wazero/api"
@@ -27,6 +28,9 @@ func Write(ctx context.Context, m api.Module, data []byte) (result uint64) {
2728
}
2829
}()
2930

31+
if ptr > math.MaxUint32 {
32+
return wasmerr.ErrWrite
33+
}
3034
if !mem.Write(uint32(ptr), data) {
3135
return wasmerr.ErrWrite
3236
}

0 commit comments

Comments
 (0)