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

Commit 5220fb1

Browse files
authored
Merge pull request #4 from grafana/chore/linting
Chore: Lint with golangci-lint
2 parents 9a60962 + 7b36aeb commit 5220fb1

File tree

5 files changed

+92
-6
lines changed

5 files changed

+92
-6
lines changed

Diff for: .golangci.toml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
[run]
2+
timeout = "10m"
3+
4+
[linters-settings.golint]
5+
min-confidence = 3
6+
7+
[linters-settings.goconst]
8+
min-len = 5
9+
min-occurrences = 5
10+
11+
[linters]
12+
disable-all = true
13+
enable = [
14+
"bodyclose",
15+
"deadcode",
16+
"depguard",
17+
"dogsled",
18+
"errcheck",
19+
"gochecknoinits",
20+
"goconst",
21+
"gocritic",
22+
"goimports",
23+
"golint",
24+
"goprintffuncname",
25+
"gosec",
26+
"gosimple",
27+
"govet",
28+
"ineffassign",
29+
"misspell",
30+
"nakedret",
31+
"rowserrcheck",
32+
"exportloopref",
33+
"staticcheck",
34+
"structcheck",
35+
#"stylecheck",
36+
"typecheck",
37+
"unconvert",
38+
"unused",
39+
"varcheck",
40+
"whitespace",
41+
"gocyclo",
42+
"unparam",
43+
]
44+
45+
[[issues.exclude-rules]]
46+
linters = ["gosec"]
47+
text = "G108"
48+
49+
[[issues.exclude-rules]]
50+
linters = ["gosec"]
51+
text = "G110"
52+
53+
[[issues.exclude-rules]]
54+
linters = ["gosec"]
55+
text = "G201"
56+
57+
[[issues.exclude-rules]]
58+
linters = ["gosec"]
59+
text = "G202"
60+
61+
[[issues.exclude-rules]]
62+
linters = ["gosec"]
63+
text = "G306"
64+
65+
[[issues.exclude-rules]]
66+
linters = ["gosec"]
67+
text = "401"
68+
69+
[[issues.exclude-rules]]
70+
linters = ["gosec"]
71+
text = "402"
72+
73+
[[issues.exclude-rules]]
74+
linters = ["gosec"]
75+
text = "501"
76+
77+
[[issues.exclude-rules]]
78+
linters = ["gosec"]
79+
text = "404"
80+
81+
[[issues.exclude-rules]]
82+
linters = ["misspell"]
83+
text = "Unknwon` is a misspelling of `Unknown"

Diff for: client.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ type Client struct {
2323
*http.Client
2424
}
2525

26-
//New creates a new grafana client
27-
//auth can be in user:pass format, or it can be an api key
26+
// New creates a new grafana client.
27+
// auth can be in user:pass format, or it can be an api key
2828
func New(auth, baseURL string) (*Client, error) {
2929
u, err := url.Parse(baseURL)
3030
if err != nil {
@@ -54,6 +54,7 @@ func (c *Client) request(method, requestPath string, query url.Values, body io.R
5454
if err != nil {
5555
return err
5656
}
57+
defer resp.Body.Close()
5758

5859
bodyContents, err := ioutil.ReadAll(resp.Body)
5960
if err != nil {

Diff for: folder_permissions_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package gapi
22

33
import (
4-
"github.com/gobs/pretty"
54
"testing"
5+
6+
"github.com/gobs/pretty"
67
)
78

89
const (

Diff for: team.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (c *Client) Team(id int64) (*Team, error) {
8080
// email arg is an optional value.
8181
// If you don't want to set email, please set "" (empty string).
8282
func (c *Client) AddTeam(name string, email string) error {
83-
path := fmt.Sprintf("/api/teams")
83+
path := "/api/teams"
8484
team := Team{
8585
Name: name,
8686
Email: email,

Diff for: teams_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package gapi
22

33
import (
4-
"github.com/gobs/pretty"
54
"testing"
5+
6+
"github.com/gobs/pretty"
67
)
78

89
const (
@@ -145,7 +146,7 @@ func TestTeam(t *testing.T) {
145146
Permission: 0,
146147
}
147148
t.Run("check data", func(t *testing.T) {
148-
if expect.Id != resp.Id || expect.Name != expect.Name {
149+
if resp.Id != expect.Id || resp.Name != expect.Name {
149150
t.Error("Not correctly parsing returned team.")
150151
}
151152
})

0 commit comments

Comments
 (0)