Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit c656c06

Browse files
author
Aaron Godin
committed
Update make test to run the latest golangci-lint version through go run
1 parent 9495dcd commit c656c06

10 files changed

+13
-24
lines changed

.golangci.toml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[run]
22
timeout = "10m"
33

4-
[linters-settings.golint]
5-
min-confidence = 3
6-
74
[linters-settings.goconst]
85
min-len = 5
96
min-occurrences = 5
@@ -13,14 +10,13 @@ disable-all = true
1310
enable = [
1411
"bodyclose",
1512
"deadcode",
16-
"depguard",
1713
"dogsled",
1814
"errcheck",
1915
"gochecknoinits",
2016
"goconst",
2117
"gocritic",
2218
"goimports",
23-
"golint",
19+
"revive",
2420
"goprintffuncname",
2521
"gosec",
2622
"gosimple",
@@ -81,3 +77,4 @@ text = "404"
8177
[[issues.exclude-rules]]
8278
linters = ["misspell"]
8379
text = "Unknwon` is a misspelling of `Unknown"
80+

Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ drone:
77

88
test:
99
go version
10-
golangci-lint --version
11-
golangci-lint run ./...
10+
go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run ./...
1211
go test -cover -race -vet all -mod readonly ./...
1312

api_key_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
"role": "Admin",
2323
"expiration": "2021-10-30T10:52:03+03:00"
2424
}
25-
]` //#nosec
25+
]` //#nosec
2626
)
2727

2828
func TestCreateAPIKey(t *testing.T) {

client.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"log"
109
"net/http"
1110
"net/url"
@@ -112,7 +111,7 @@ func (c *Client) request(method, requestPath string, query url.Values, body []by
112111
}
113112

114113
// read the body (even on non-successful HTTP status codes), as that's what the unit tests expect
115-
bodyContents, err = ioutil.ReadAll(resp.Body)
114+
bodyContents, err = io.ReadAll(resp.Body)
116115
resp.Body.Close() //nolint:errcheck
117116

118117
// if there was an error reading the body, try again

client_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"errors"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"net/http/httptest"
1010
"net/url"
@@ -195,7 +195,7 @@ func TestClient_requestWithRetries(t *testing.T) {
195195

196196
try++
197197

198-
got, err := ioutil.ReadAll(r.Body)
198+
got, err := io.ReadAll(r.Body)
199199
if err != nil {
200200
t.Errorf("retry %d: unexpected error reading body: %v", try, err)
201201
}

cloud_plugin.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package gapi
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
)
99

@@ -74,7 +74,7 @@ func (c *Client) IsCloudPluginInstalled(stackSlug string, pluginSlug string) (bo
7474
if resp.StatusCode == http.StatusNotFound {
7575
return false, nil
7676
}
77-
bodyContents, err := ioutil.ReadAll(resp.Body)
77+
bodyContents, err := io.ReadAll(resp.Body)
7878
if err != nil {
7979
return false, err
8080
}

datasource.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func JSONDataWithHeaders(jsonData, secureJSONData map[string]interface{}, header
173173
for name, value := range headers {
174174
jsonData[fmt.Sprintf("httpHeaderName%d", idx)] = name
175175
secureJSONData[fmt.Sprintf("httpHeaderValue%d", idx)] = value
176-
idx += 1
176+
idx++
177177
}
178178

179179
return jsonData, secureJSONData

resource_permissions.go

-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ type ResourcePermission struct {
1313
IsServiceAccount bool `json:"isServiceAccount"`
1414
UserID int64 `json:"userId,omitempty"`
1515
UserLogin string `json:"userLogin,omitempty"`
16-
UserAvatarURL string `json:"userAvatarUrl,omitempty"`
1716
Team string `json:"team,omitempty"`
1817
TeamID int64 `json:"teamId,omitempty"`
19-
TeamAvatarUrl string `json:"teamAvatarUrl,omitempty"`
2018
BuiltInRole string `json:"builtInRole,omitempty"`
2119
Actions []string `json:"actions"`
2220
Permission string `json:"permission"`

service_account_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const (
7474
"secondsUntilExpiration": 0,
7575
"hasExpired": false
7676
}
77-
]` //#nosec
77+
]` //#nosec
7878
)
7979

8080
func TestCreateServiceAccountToken(t *testing.T) {

slo.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
)
88

9-
var sloPath string = "/api/plugins/grafana-slo-app/resources/v1/slo"
9+
var sloPath = "/api/plugins/grafana-slo-app/resources/v1/slo"
1010

1111
type Slos struct {
1212
Slos []Slo `json:"slos"`
@@ -205,9 +205,5 @@ func (c *Client) UpdateSlo(uuid string, slo Slo) error {
205205
return err
206206
}
207207

208-
if err := c.request("PUT", path, nil, data, nil); err != nil {
209-
return err
210-
}
211-
212-
return nil
208+
return c.request("PUT", path, nil, data, nil)
213209
}

0 commit comments

Comments
 (0)