Skip to content

Commit

Permalink
refactor: solve staticcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hbagdi committed Aug 21, 2019
1 parent 1cf248e commit 5d2ed4f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion kong/custom/entity_crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type EntityCRUDDefinition struct {
PrimaryKey string `yaml:"primary_key" json:"primary_key"`
}

var r = regexp.MustCompile("(?:\\$\\{)(\\w+)(?:\\})")
var r = regexp.MustCompile(`(?:\$\{)(\w+)(?:\})`)

func render(template string, entity Entity) (string, error) {
result := template
Expand Down
5 changes: 2 additions & 3 deletions kong/kong.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request,
v interface{}) (*Response, error) {
var err error
if req == nil {
return nil, errors.New("Request object cannot be nil")
return nil, errors.New("request cannot be nil")
}
if ctx == nil {
ctx = defaultCtx
Expand All @@ -149,8 +149,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request,
}
// Call Close on exit
defer func() {
var e error
e = resp.Body.Close()
e := resp.Body.Close()
if e != nil {
err = e
}
Expand Down
6 changes: 3 additions & 3 deletions kong/kong_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestKongStatus(T *testing.T) {
assert.Nil(err)
assert.NotNil(client)

status, err := client.Status(nil)
status, err := client.Status(defaultCtx)
assert.Nil(err)
assert.NotNil(status)
}
Expand All @@ -28,7 +28,7 @@ func TestRoot(T *testing.T) {
assert.Nil(err)
assert.NotNil(client)

root, err := client.Root(nil)
root, err := client.Root(defaultCtx)
assert.Nil(err)
assert.NotNil(root)
assert.NotNil(root["version"])
Expand All @@ -52,7 +52,7 @@ func runWhenKong(t *testing.T, semverRange string) {
if err != nil {
t.Error(err)
}
res, err := client.Root(nil)
res, err := client.Root(defaultCtx)
if err != nil {
t.Error(err)
}
Expand Down
1 change: 1 addition & 0 deletions kong/oauth2_auth_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func TestOauth2CredentialGet(T *testing.T) {
oauth2Cred, err = client.Oauth2Credentials.Get(defaultCtx, consumer.ID,
String("foo-clientid"))
assert.Nil(err)
assert.NotNil(oauth2Cred)

oauth2Cred, err = client.Oauth2Credentials.Get(defaultCtx, consumer.ID,
String("does-not-exists"))
Expand Down
9 changes: 0 additions & 9 deletions kong/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,3 @@ func cidrPortArrayToString(arr []*CIDRPort) string {
buf.WriteString(" ]")
return buf.String()
}

func contains(slice []*string, s string) bool {
for _, el := range slice {
if *el == s {
return true
}
}
return false
}

0 comments on commit 5d2ed4f

Please sign in to comment.