Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed Aug 16, 2024
1 parent dc96c47 commit 7e362ad
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ linters:
- govet
- importas
- lll
- megacheck
- gosimple
- staticcheck
- unused
- misspell
- nakedret
- nilerr
Expand Down
2 changes: 1 addition & 1 deletion pkg/file/readfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ kong.log.set_serialize_value("span_id", parse_traceid(ngx.ctx.KONG_SPANS[1].span
cmpopts.EquateEmpty(),
}
if diff := cmp.Diff(got, tt.want, opt...); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/file/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ func copyToService(fService FService) service {
func unwrapURL(urlString string, fService *FService) error {
parsed, err := url.Parse(urlString)
if err != nil {
return fmt.Errorf("invalid url: " + urlString)
return fmt.Errorf("invalid url: %s", urlString)
}
if parsed.Scheme == "" {
return fmt.Errorf("invalid url:" + urlString)
return fmt.Errorf("invalid url: %s", urlString)
}

fService.Protocol = kong.String(parsed.Scheme)
Expand Down Expand Up @@ -721,7 +721,7 @@ func (u FConsumerGroupObject) sortKey() string {
// +k8s:deepcopy-gen=true
type FRBACRole struct {
kong.RBACRole `yaml:",inline,omitempty"`
EndpointPermissions []*FRBACEndpointPermission `json:"endpoint_permissions,omitempty" yaml:"endpoint_permissions,omitempty"` //nolint
EndpointPermissions []*FRBACEndpointPermission `json:"endpoint_permissions,omitempty" yaml:"endpoint_permissions,omitempty"` //nolint:lll
}

// FRBACEndpointPermission is a wrapper type for RBACEndpointPermission.
Expand Down
2 changes: 1 addition & 1 deletion pkg/file/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ func WriteContentToFile(content *Content, filename string, format Format) error
return err
}
default:
return fmt.Errorf("unknown file format: " + string(format))
return fmt.Errorf("unknown file format: %s", format)
}

if filename == "-" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/state/filter_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func insertFilterChain(txn *memdb.Txn, filterChain FilterChain) error {
return err
}

if filterChain.Filters == nil || len(filterChain.Filters) == 0 {
if len(filterChain.Filters) == 0 {
return fmt.Errorf("inserting filter chain %v: at least one filter is required", filterChain.Console())
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (kc *KongClientConfig) ForWorkspace(name string) KongClientConfig {
//
// This is the same as DefaultBackoff (https:/hashicorp/go-retryablehttp/blob/v0.7.1/client.go#L503)
// except that here we are only retrying on 429s.
func backoffStrategy(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {
func backoffStrategy(minDuration, maxDuration time.Duration, attemptNum int, resp *http.Response) time.Duration {
const (
base = 10
bitSize = 64
Expand All @@ -169,10 +169,10 @@ func backoffStrategy(min, max time.Duration, attemptNum int, resp *http.Response
}
}

mult := math.Pow(baseExponential, float64(attemptNum)) * float64(min)
mult := math.Pow(baseExponential, float64(attemptNum)) * float64(minDuration)
sleep := time.Duration(mult)
if float64(sleep) != mult || sleep > max {
sleep = max
if float64(sleep) != mult || sleep > maxDuration {
sleep = maxDuration
}
return sleep
}
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func testKongState(t *testing.T, client *kong.Client, isKonnect bool,
}
kongState, err := deckDump.Get(ctx, client, dumpConfig)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

opt := []cmp.Option{
Expand All @@ -238,7 +238,7 @@ func testKongState(t *testing.T, client *kong.Client, isKonnect bool,
opt = append(opt, ignoreFields...)

if diff := cmp.Diff(kongState, &expectedState, opt...); diff != "" {
t.Errorf(diff)
t.Error(diff)
}
}

Expand Down

0 comments on commit 7e362ad

Please sign in to comment.