Skip to content

Commit a6eab9f

Browse files
committed
Linter fixes
1 parent c868476 commit a6eab9f

File tree

6 files changed

+14
-22
lines changed

6 files changed

+14
-22
lines changed

.golangci.yaml

+4-12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ linters:
88
# Temporary
99
- 'cyclop'
1010
- 'dupl'
11+
- 'err113'
1112
- 'exhaustruct'
1213
- 'forbidigo'
1314
- 'funlen'
@@ -17,28 +18,19 @@ linters:
1718
- 'gocritic'
1819
- 'gocyclo'
1920
- 'godox'
20-
- 'goerr113'
21-
- 'gomnd'
2221
- 'gosec'
2322
- 'lll'
2423
- 'maintidx'
24+
- 'mnd'
2525
- 'nestif'
2626
- 'nlreturn'
2727
- 'paralleltest'
28+
- 'perfsprint'
2829
- 'revive'
2930
- 'stylecheck'
3031
- 'varnamelen'
3132
- 'wrapcheck'
3233
- 'wsl'
3334

3435
# Deprecated
35-
- 'deadcode'
36-
- 'exhaustivestruct'
37-
- 'golint'
38-
- 'ifshort'
39-
- 'interfacer'
40-
- 'maligned'
41-
- 'nosnakecase'
42-
- 'scopelint'
43-
- 'structcheck'
44-
- 'varcheck'
36+
- 'exportloopref'

fields/fwupdate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type firmwareUpdateApiResponseEmbeddedFirmwareDataLink struct {
3838
Href *url.URL `json:"href"`
3939
}
4040

41-
func (l firmwareUpdateApiResponseEmbeddedFirmwareDataLink) MarshalJSON() ([]byte, error) {
41+
func (l *firmwareUpdateApiResponseEmbeddedFirmwareDataLink) MarshalJSON() ([]byte, error) {
4242
var href string
4343
if l.Href != nil {
4444
href = l.Href.String()

fields/main_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func TestResourceTypes(t *testing.T) {
151151

152152
err := resource.processJSON(([]byte)(testData))
153153

154-
assert.Empty(t, err, "No error processing JSON")
154+
assert.NoError(t, err, "No error processing JSON")
155155
assert.Equal(t, expectation.StructName, resource.StructName)
156156
assert.Equal(t, expectation.ResourcePath, resource.ResourcePath)
157157
assert.Equal(t, expectation.Types, resource.Types)

fields/version_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ func TestLatestUnifiVersion(t *testing.T) {
7474
assert.Contains(query["filter"], firmwareUpdateApiFilter("product", unifiControllerProduct))
7575

7676
resp, err := json.Marshal(respData)
77-
require.NoError(err)
77+
assert.NoError(err)
7878

7979
_, err = rw.Write(resp)
80-
require.NoError(err)
80+
assert.NoError(err)
8181
}))
8282
defer server.Close()
8383

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/paultyng/go-unifi
22

3-
go 1.22
3+
go 1.22.1
4+
45
toolchain go1.23.1
56

67
require (

unifi/unifi.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"encoding/json"
77
"fmt"
88
"io"
9-
"io/ioutil"
109
"net/http"
1110
"net/http/cookiejar"
1211
"net/url"
@@ -114,7 +113,7 @@ func (c *Client) setAPIUrlStyle(ctx context.Context) error {
114113
return err
115114
}
116115
defer resp.Body.Close()
117-
_, _ = io.Copy(ioutil.Discard, resp.Body)
116+
_, _ = io.Copy(io.Discard, resp.Body)
118117

119118
if resp.StatusCode == http.StatusOK {
120119
// the new API returns a 200 for a / request
@@ -226,7 +225,7 @@ func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody int
226225
req.Header.Add("Content-Type", "application/json; charset=utf-8")
227226

228227
if c.csrf != "" {
229-
req.Header.Set("X-CSRF-Token", c.csrf)
228+
req.Header.Set("X-Csrf-Token", c.csrf)
230229
}
231230

232231
resp, err := c.c.Do(req)
@@ -239,8 +238,8 @@ func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody int
239238
return &NotFoundError{}
240239
}
241240

242-
if csrf := resp.Header.Get("x-csrf-token"); csrf != "" {
243-
c.csrf = resp.Header.Get("x-csrf-token")
241+
if csrf := resp.Header.Get("X-Csrf-Token"); csrf != "" {
242+
c.csrf = resp.Header.Get("X-Csrf-Token")
244243
}
245244

246245
if resp.StatusCode != http.StatusOK {

0 commit comments

Comments
 (0)