Skip to content

Commit 55fc999

Browse files
authored
CLOUDP-309672: bump golangci lint and Go 1.24 (#2249)
* bump golangci-lint * regenerate devbox.lock * migrate golangci-lint * remove deprecated stylecheck linter * disallow QF1008 as it produces false positives * bump Go to 1.24 * update devbox.lock * bump to go 1.24 * recompute licenses * fix go 1.24 compile issues * make check-missing-files
1 parent 36bbd42 commit 55fc999

25 files changed

+165
-215
lines changed

.github/actions/gen-install-scripts/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23
1+
FROM golang:1.24
22

33
ENV KUBECTL_VERSION 1.18.12
44
ENV GO111MODULE on

.golangci.yml

Lines changed: 83 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,108 @@
1+
version: "2"
12
linters:
2-
disable-all: true
3+
default: none
34
enable:
4-
#- bodyclose
5+
- copyloopvar
56
- depguard
67
- dogsled
78
- dupl
89
- errcheck
910
- errorlint
10-
- copyloopvar
11-
#- gocritic
1211
- gocyclo
13-
- goimports
1412
- goprintffuncname
1513
- gosec
16-
- gosimple
1714
- govet
18-
- gofmt
15+
- importas
1916
- ineffassign
2017
- misspell
2118
- noctx
2219
- prealloc
2320
- rowserrcheck
2421
- staticcheck
25-
- stylecheck
26-
- typecheck
2722
- unconvert
2823
- unparam
2924
- unused
3025
- whitespace
31-
- importas
32-
33-
linters-settings:
34-
misspell:
35-
locale: US
36-
goimports:
37-
local-prefixes: github.com/mongodb/mongodb-atlas-kubernetes/v2
38-
depguard:
26+
settings:
27+
staticcheck:
28+
checks:
29+
- -QF1008 # produces false positives
30+
depguard:
31+
rules:
32+
all:
33+
deny:
34+
- pkg: io/ioutil
35+
desc: io/ioutil package has been deprecated
36+
misspell:
37+
locale: US
38+
exclusions:
39+
generated: lax
3940
rules:
40-
all:
41-
deny:
42-
- pkg: io/ioutil
43-
desc: 'io/ioutil package has been deprecated'
44-
41+
- linters:
42+
- errcheck
43+
- gochecknoglobals
44+
- gocyclo
45+
- nlreturn
46+
- wrapcheck
47+
path: test
48+
- linters:
49+
- gochecknoglobals
50+
- wrapcheck
51+
path: cmd/manager/main.go
52+
- linters:
53+
- noctx
54+
- staticcheck
55+
path: test/e2e
56+
- linters:
57+
- staticcheck
58+
path: test/helper
59+
text: 'ST1000:|ST1001:|ST1003:'
60+
- linters:
61+
- noctx
62+
path: test/helper/e2e/appclient
63+
- linters:
64+
- dupl
65+
- prealloc
66+
- unparam
67+
path: pkg/controller
68+
- linters:
69+
- prealloc
70+
path: pkg/controller/atlasdatabaseuser/connectionsecrets
71+
- linters:
72+
- staticcheck
73+
path: pkg/util/testutil/
74+
- path: (.+)\.go$
75+
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
76+
- path: (.+)\.go$
77+
text: func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
78+
- path: (.+)\.go$
79+
text: (possible misuse of unsafe.Pointer|should have signature)
80+
- path: (.+)\.go$
81+
text: Use of unsafe calls should be audited
82+
- path: (.+)\.go$
83+
text: Subprocess launch(ed with variable|ing should be audited)
84+
- path: (.+)\.go$
85+
text: (G104|G307)
86+
- path: (.+)\.go$
87+
text: at least one file in a package should have a package comment
88+
paths:
89+
- third_party$
90+
- builtin$
91+
- examples$
4592
issues:
46-
exclude-use-default: false
47-
exclude:
48-
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
49-
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
50-
51-
# EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments
52-
# - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
53-
54-
# EXC0003 golint: False positive when tests are defined in package 'test'
55-
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
56-
57-
# EXC0004 govet: Common false positives
58-
- (possible misuse of unsafe.Pointer|should have signature)
59-
60-
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
61-
# - ineffective break statement. Did you mean to break out of the outer loop
62-
63-
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
64-
- Use of unsafe calls should be audited
65-
66-
# EXC0007 gosec: Too many false-positives for parametrized shell calls
67-
- Subprocess launch(ed with variable|ing should be audited)
68-
69-
# EXC0008 gosec: Duplicated errcheck checks
70-
- (G104|G307)
71-
72-
# EXC0009 gosec: Too many issues in popular repos
73-
# - (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
74-
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
75-
# - Potential file inclusion via variable
76-
# EXC0011 stylecheck: Annoying issue about not having a comment. The rare codebase has such comments
77-
# - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
78-
79-
- at least one file in a package should have a package comment
80-
81-
exclude-rules:
82-
- path: test
83-
linters:
84-
- gocyclo
85-
- gochecknoglobals
86-
- wrapcheck
87-
- nlreturn
88-
- errcheck
89-
- path: cmd/manager/main.go
90-
linters:
91-
- gochecknoglobals
92-
- wrapcheck
93-
- path: test/e2e
94-
linters:
95-
- stylecheck
96-
- noctx
97-
- path: test/helper
98-
linters:
99-
- stylecheck
100-
text: "ST1000:|ST1001:|ST1003:"
101-
- path: test/helper/e2e/appclient
102-
linters:
103-
- noctx
104-
- path: pkg/controller
105-
linters:
106-
- prealloc
107-
- dupl
108-
- unparam
109-
- path: pkg/controller/atlasdatabaseuser/connectionsecrets
110-
linters:
111-
- prealloc
112-
- path: pkg/util/testutil/
113-
linters:
114-
- stylecheck
11593
max-issues-per-linter: 0
11694
max-same-issues: 0
95+
formatters:
96+
enable:
97+
- gofmt
98+
- goimports
99+
settings:
100+
goimports:
101+
local-prefixes:
102+
- github.com/mongodb/mongodb-atlas-kubernetes/v2
103+
exclusions:
104+
generated: lax
105+
paths:
106+
- third_party$
107+
- builtin$
108+
- examples$

.licenses-gomod.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
100644 b86911852bbd66c78ee866ced36337387d6e656b go.mod
1+
100644 976f4db9d4ec5098fc83e7fa82aecadcb4e557a7 go.mod

api/v1/atlasbackuppolicy_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ var _ api.AtlasCustomResource = &AtlasBackupPolicy{}
4747
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
4848
//
4949
// AtlasBackupPolicy is the Schema for the atlasbackuppolicies API
50-
//
51-
//nolint:stylecheck
5250
type AtlasBackupPolicy struct {
5351
metav1.TypeMeta `json:",inline"`
5452
metav1.ObjectMeta `json:"metadata,omitempty"`

api/v1/atlasbackupschedule_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ var _ api.AtlasCustomResource = &AtlasBackupSchedule{}
9393
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
9494
//
9595
// AtlasBackupSchedule is the Schema for the atlasbackupschedules API
96-
//
97-
//nolint:stylecheck
9896
type AtlasBackupSchedule struct {
9997
metav1.TypeMeta `json:",inline"`
10098
metav1.ObjectMeta `json:"metadata,omitempty"`

api/v1/atlasfederatedauth_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ var _ api.AtlasCustomResource = &AtlasFederatedAuth{}
128128
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
129129
//
130130
// AtlasFederatedAuth is the Schema for the Atlasfederatedauth API
131-
//
132-
//nolint:stylecheck
133131
type AtlasFederatedAuth struct {
134132
metav1.TypeMeta `json:",inline"`
135133
metav1.ObjectMeta `json:"metadata,omitempty"`

api/v1/atlassearchindexconfig_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ func init() {
1919
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
2020
//
2121
// AtlasSearchIndexConfig is the Schema for the AtlasSearchIndexConfig API
22-
//
23-
//nolint:stylecheck
2422
type AtlasSearchIndexConfig struct {
2523
metav1.TypeMeta `json:",inline"`
2624
metav1.ObjectMeta `json:"metadata,omitempty"`

api/v1/global_deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type CustomZoneMapping struct {
1111

1212
// ManagedNamespace represents the information about managed namespace configuration.
1313
type ManagedNamespace struct {
14-
Db string `json:"db"` //nolint:stylecheck // not changing this as is a breaking change
14+
Db string `json:"db"` // not changing this as is a breaking change
1515
Collection string `json:"collection"`
1616
CustomShardKey string `json:"customShardKey,omitempty"`
1717
NumInitialChunks int `json:"numInitialChunks,omitempty"`

api/v1/status/deployment_searchindex.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ type DeploymentSearchIndexStatus struct {
1616
}
1717

1818
// +k8s:deepcopy-gen=false
19-
//
20-
//nolint:stylecheck
2119
type IndexStatusOption func(status *DeploymentSearchIndexStatus)
2220

2321
func NewDeploymentSearchIndexStatus(status IndexStatus, options ...IndexStatusOption) DeploymentSearchIndexStatus {

api/v1/status/global_deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type CustomZoneMapping struct {
77
}
88

99
type ManagedNamespace struct {
10-
Db string `json:"db"` //nolint:stylecheck // not changing this as is a breaking change
10+
Db string `json:"db"` // not changing this as is a breaking change
1111
Collection string `json:"collection"`
1212
CustomShardKey string `json:"customShardKey,omitempty"`
1313
NumInitialChunks int `json:"numInitialChunks,omitempty"`

0 commit comments

Comments
 (0)