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

Lines changed: 6 additions & 7 deletions
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

Lines changed: 5 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 11 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 6 deletions
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
}

0 commit comments

Comments
 (0)