Skip to content

Commit 88de773

Browse files
authored
feat: Update golanci-lint version and fix warnings (#990)
* feat: Update golanci-lint version and fix warnings * feat: Add go version 1.23 to matrix in CI * feat: Only lint for one of the go versions, test with all
1 parent f1d4b2a commit 88de773

File tree

24 files changed

+87
-89
lines changed

24 files changed

+87
-89
lines changed

.github/workflows/ci.yaml

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [ubuntu-latest, macos-latest]
11-
go-version: ["1.18", "1.19", "1.20", "1.21", "1.22"]
11+
go-version: ["1.18", "1.19", "1.20", "1.21", "1.22", "1.23"]
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- name: Checkout
@@ -18,20 +18,19 @@ jobs:
1818
with:
1919
go-version: ${{ matrix.go-version }}
2020
- name: Install project tools and dependencies
21-
if: ${{ matrix.go-version != '1.18' }}
21+
if: ${{ matrix.go-version == '1.23' }}
2222
run: make project-tools
2323
- name: Lint
24-
if: ${{ matrix.go-version != '1.18' }}
24+
if: ${{ matrix.go-version == '1.23' }}
2525
run: |
2626
make lint
2727
scripts/check-sync-tidy.sh
2828
- name: Lint scripts
29-
if: ${{ matrix.go-version == '1.22' }}
29+
if: ${{ matrix.go-version == '1.23' }}
3030
run: |
3131
make lint-scripts
3232
- name: Test
3333
run: make test
3434
- name: Test scripts
35-
if: ${{ matrix.go-version == '1.22' }}
36-
run: |
37-
make test-scripts
35+
if: ${{ matrix.go-version >= '1.22' }}
36+
run: make test-scripts

core/auth/auth.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ func SetupAuth(cfg *config.Configuration) (rt http.RoundTripper, err error) {
5656
return nil, fmt.Errorf("configuring token authentication: %w", err)
5757
}
5858
return tokenRoundTripper, nil
59-
} else {
60-
authRoundTripper, err := DefaultAuth(cfg)
61-
if err != nil {
62-
return nil, fmt.Errorf("configuring default authentication: %w", err)
63-
}
64-
return authRoundTripper, nil
6559
}
60+
authRoundTripper, err := DefaultAuth(cfg)
61+
if err != nil {
62+
return nil, fmt.Errorf("configuring default authentication: %w", err)
63+
}
64+
return authRoundTripper, nil
6665
}
6766

6867
// DefaultAuth will search for a valid service account key or token in several locations.

core/clients/key_flow_continuous_refresh_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestContinuousRefreshToken(t *testing.T) {
100100
}
101101

102102
numberDoCalls := 0
103-
mockDo := func(req *http.Request) (resp *http.Response, err error) {
103+
mockDo := func(_ *http.Request) (resp *http.Response, err error) {
104104
numberDoCalls++
105105

106106
if tt.doError != nil {

core/clients/key_flow_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func TestRequestToken(t *testing.T) {
268268

269269
for _, tt := range testCases {
270270
t.Run(tt.name, func(t *testing.T) {
271-
mockDo := func(req *http.Request) (resp *http.Response, err error) {
271+
mockDo := func(_ *http.Request) (resp *http.Response, err error) {
272272
return tt.mockResponse, tt.mockError
273273
}
274274

core/clients/no_auth_flow_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ func TestNoAuthFlow_Do(t *testing.T) {
6666
c := &NoAuthFlow{
6767
client: tt.fields.client,
6868
}
69-
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
69+
handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
7070
w.Header().Set("Content-Type", "application/json")
7171
w.WriteHeader(http.StatusOK)
72-
fmt.Fprintln(w, `{"status":"ok"}`)
72+
_, _ = fmt.Fprintln(w, `{"status":"ok"}`)
7373
})
7474
server := httptest.NewServer(handler)
7575
defer server.Close()

core/clients/token_flow_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ func TestTokenFlow_Do(t *testing.T) {
7171
client: tt.fields.client,
7272
config: tt.fields.config,
7373
}
74-
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
74+
handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
7575
w.Header().Set("Content-Type", "application/json")
7676
w.WriteHeader(http.StatusOK)
77-
fmt.Fprintln(w, `{"status":"ok"}`)
77+
_, _ = fmt.Fprintln(w, `{"status":"ok"}`)
7878
})
7979
server := httptest.NewServer(handler)
8080
defer server.Close()

core/config/config.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -237,21 +237,21 @@ func WithToken(token string) ConfigurationOption {
237237

238238
// Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client. This option has no effect, and will be removed in a later update
239239
func WithMaxRetries(_ int) ConfigurationOption {
240-
return func(config *Configuration) error {
240+
return func(_ *Configuration) error {
241241
return nil
242242
}
243243
}
244244

245245
// Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client. This option has no effect, and will be removed in a later update
246246
func WithWaitBetweenCalls(_ time.Duration) ConfigurationOption {
247-
return func(config *Configuration) error {
247+
return func(_ *Configuration) error {
248248
return nil
249249
}
250250
}
251251

252252
// Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client. This option has no effect, and will be removed in a later update
253253
func WithRetryTimeout(_ time.Duration) ConfigurationOption {
254-
return func(config *Configuration) error {
254+
return func(_ *Configuration) error {
255255
return nil
256256
}
257257
}

golang-ci.yaml

+6-11
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ linters-settings:
1414
# it's a comma-separated list of prefixes
1515
local-prefixes: github.com/freiheit-com/nmww
1616
depguard:
17-
list-type: blacklist
18-
include-go-root: false
19-
packages:
20-
- github.com/stretchr/testify
21-
packages-with-error-message:
22-
# specify an error message to output when a blacklisted package is used
23-
- github.com/stretchr/testify: "do not use a testing framework"
17+
rules:
18+
main:
19+
list-mode: lax # Everything is allowed unless it is denied
20+
deny:
21+
- pkg: "github.com/stretchr/testify"
22+
desc: Do not use a testing framework
2423
misspell:
2524
# Correct spellings using locale preferences for US or UK.
2625
# Default is to use a neutral variety of English.
@@ -75,7 +74,6 @@ linters:
7574
- unused
7675
# additional linters
7776
- errorlint
78-
- exportloopref
7977
- gochecknoinits
8078
- gocritic
8179
- gofmt
@@ -91,9 +89,6 @@ linters:
9189
- forcetypeassert
9290
- errcheck
9391
disable:
94-
- structcheck # deprecated
95-
- deadcode # deprecated
96-
- varcheck # deprecated
9792
- noctx # false positive: finds errors with http.NewRequest that dont make sense
9893
- unparam # false positives
9994
issues:

scripts/project.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ elif [ "$action" = "tools" ]; then
1616

1717
go mod download
1818

19-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
19+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0
2020
else
2121
echo "Invalid action: '$action', please use $0 help for help"
2222
fi

services/dns/wait/wait_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func TestCreateZoneWaitHandler(t *testing.T) {
9494
if tt.wantResp {
9595
wantRes = &dns.ZoneResponse{
9696
Zone: &dns.Zone{
97-
State: &tt.resourceState,
97+
State: utils.Ptr(tt.resourceState),
9898
Id: utils.Ptr("zid"),
9999
},
100100
}
@@ -162,7 +162,7 @@ func TestUpdateZoneWaitHandler(t *testing.T) {
162162
if tt.wantResp {
163163
wantRes = &dns.ZoneResponse{
164164
Zone: &dns.Zone{
165-
State: &tt.resourceState,
165+
State: utils.Ptr(tt.resourceState),
166166
Id: utils.Ptr("zid"),
167167
},
168168
}
@@ -230,7 +230,7 @@ func TestDeleteZoneWaitHandler(t *testing.T) {
230230
if tt.wantResp {
231231
wantRes = &dns.ZoneResponse{
232232
Zone: &dns.Zone{
233-
State: &tt.resourceState,
233+
State: utils.Ptr(tt.resourceState),
234234
Id: utils.Ptr("zid"),
235235
},
236236
}
@@ -300,7 +300,7 @@ func TestCreateRecordSetWaitHandler(t *testing.T) {
300300
if tt.wantResp {
301301
wantRes = &dns.RecordSetResponse{
302302
Rrset: &dns.RecordSet{
303-
State: &tt.resourceState,
303+
State: utils.Ptr(tt.resourceState),
304304
Id: utils.Ptr("rid"),
305305
},
306306
}
@@ -368,7 +368,7 @@ func TestUpdateRecordSetWaitHandler(t *testing.T) {
368368
if tt.wantResp {
369369
wantRes = &dns.RecordSetResponse{
370370
Rrset: &dns.RecordSet{
371-
State: &tt.resourceState,
371+
State: utils.Ptr(tt.resourceState),
372372
Id: utils.Ptr("rid"),
373373
},
374374
}
@@ -436,7 +436,7 @@ func TestDeleteRecordSetWaitHandler(t *testing.T) {
436436
if tt.wantResp {
437437
wantRes = &dns.RecordSetResponse{
438438
Rrset: &dns.RecordSet{
439-
State: &tt.resourceState,
439+
State: utils.Ptr(tt.resourceState),
440440
Id: utils.Ptr("rid"),
441441
},
442442
}

services/iaas/wait/wait_test.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func TestCreateNetworkAreaWaitHandler(t *testing.T) {
183183
if tt.wantResp {
184184
wantRes = &iaas.NetworkArea{
185185
AreaId: utils.Ptr("naid"),
186-
State: &tt.resourceState,
186+
State: utils.Ptr(tt.resourceState),
187187
}
188188
}
189189

@@ -242,7 +242,7 @@ func TestUpdateNetworkAreaWaitHandler(t *testing.T) {
242242
if tt.wantResp {
243243
wantRes = &iaas.NetworkArea{
244244
AreaId: utils.Ptr("naid"),
245-
State: &tt.resourceState,
245+
State: utils.Ptr(tt.resourceState),
246246
}
247247
}
248248

@@ -303,7 +303,7 @@ func TestDeleteNetworkAreaWaitHandler(t *testing.T) {
303303
if tt.wantResp {
304304
wantRes = &iaas.NetworkArea{
305305
AreaId: utils.Ptr("naid"),
306-
State: &tt.resourceState,
306+
State: utils.Ptr(tt.resourceState),
307307
}
308308
}
309309

@@ -362,7 +362,7 @@ func TestCreateNetworkWaitHandler(t *testing.T) {
362362
if tt.wantResp {
363363
wantRes = &iaas.Network{
364364
NetworkId: utils.Ptr("nid"),
365-
State: &tt.resourceState,
365+
State: utils.Ptr(tt.resourceState),
366366
}
367367
}
368368

@@ -421,7 +421,7 @@ func TestUpdateNetworkWaitHandler(t *testing.T) {
421421
if tt.wantResp {
422422
wantRes = &iaas.Network{
423423
NetworkId: utils.Ptr("nid"),
424-
State: &tt.resourceState,
424+
State: utils.Ptr(tt.resourceState),
425425
}
426426
}
427427

@@ -482,7 +482,7 @@ func TestDeleteNetworkWaitHandler(t *testing.T) {
482482
if tt.wantResp {
483483
wantRes = &iaas.Network{
484484
NetworkId: utils.Ptr("nid"),
485-
State: &tt.resourceState,
485+
State: utils.Ptr(tt.resourceState),
486486
}
487487
}
488488

@@ -548,7 +548,7 @@ func TestCreateVolumeWaitHandler(t *testing.T) {
548548
if tt.wantResp {
549549
wantRes = &iaas.Volume{
550550
Id: utils.Ptr("vid"),
551-
Status: &tt.resourceState,
551+
Status: utils.Ptr(tt.resourceState),
552552
}
553553
}
554554

@@ -609,7 +609,7 @@ func TestDeleteVolumeWaitHandler(t *testing.T) {
609609
if tt.wantResp {
610610
wantRes = &iaas.Volume{
611611
Id: utils.Ptr("vid"),
612-
Status: &tt.resourceState,
612+
Status: utils.Ptr(tt.resourceState),
613613
}
614614
}
615615

@@ -675,7 +675,7 @@ func TestCreateServerWaitHandler(t *testing.T) {
675675
if tt.wantResp {
676676
wantRes = &iaas.Server{
677677
Id: utils.Ptr("sid"),
678-
Status: &tt.resourceState,
678+
Status: utils.Ptr(tt.resourceState),
679679
}
680680
}
681681

@@ -736,7 +736,7 @@ func TestDeleteServerWaitHandler(t *testing.T) {
736736
if tt.wantResp {
737737
wantRes = &iaas.Server{
738738
Id: utils.Ptr("sid"),
739-
Status: &tt.resourceState,
739+
Status: utils.Ptr(tt.resourceState),
740740
}
741741
}
742742

@@ -814,7 +814,7 @@ func TestResizeServerWaitHandler(t *testing.T) {
814814
if tt.wantResp {
815815
wantRes = &iaas.Server{
816816
Id: utils.Ptr("sid"),
817-
Status: &tt.finalResourceState,
817+
Status: utils.Ptr(tt.finalResourceState),
818818
}
819819
}
820820

@@ -880,7 +880,7 @@ func TestStartServerWaitHandler(t *testing.T) {
880880
if tt.wantResp {
881881
wantRes = &iaas.Server{
882882
Id: utils.Ptr("sid"),
883-
Status: &tt.resourceState,
883+
Status: utils.Ptr(tt.resourceState),
884884
}
885885
}
886886

@@ -946,7 +946,7 @@ func TestStopServerWaitHandler(t *testing.T) {
946946
if tt.wantResp {
947947
wantRes = &iaas.Server{
948948
Id: utils.Ptr("sid"),
949-
Status: &tt.resourceState,
949+
Status: utils.Ptr(tt.resourceState),
950950
}
951951
}
952952

@@ -1012,7 +1012,7 @@ func TestDeallocateServerWaitHandler(t *testing.T) {
10121012
if tt.wantResp {
10131013
wantRes = &iaas.Server{
10141014
Id: utils.Ptr("sid"),
1015-
Status: &tt.resourceState,
1015+
Status: utils.Ptr(tt.resourceState),
10161016
}
10171017
}
10181018

@@ -1078,7 +1078,7 @@ func TestRescueServerWaitHandler(t *testing.T) {
10781078
if tt.wantResp {
10791079
wantRes = &iaas.Server{
10801080
Id: utils.Ptr("sid"),
1081-
Status: &tt.resourceState,
1081+
Status: utils.Ptr(tt.resourceState),
10821082
}
10831083
}
10841084

@@ -1144,7 +1144,7 @@ func TestUnrescueServerWaitHandler(t *testing.T) {
11441144
if tt.wantResp {
11451145
wantRes = &iaas.Server{
11461146
Id: utils.Ptr("sid"),
1147-
Status: &tt.resourceState,
1147+
Status: utils.Ptr(tt.resourceState),
11481148
}
11491149
}
11501150

@@ -1238,8 +1238,8 @@ func TestProjectRequestWaitHandler(t *testing.T) {
12381238
if tt.wantResp {
12391239
wantRes = &iaas.Request{
12401240
RequestId: utils.Ptr("rid"),
1241-
RequestAction: &tt.requestAction,
1242-
Status: &tt.requestState,
1241+
RequestAction: utils.Ptr(tt.requestAction),
1242+
Status: utils.Ptr(tt.requestState),
12431243
}
12441244
}
12451245

0 commit comments

Comments
 (0)