Skip to content

Commit

Permalink
Fix linting issues detected by golangci-lint 1.60.3 (#1510)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiangreco authored Aug 29, 2024
1 parent 8ed02a6 commit ab4fa45
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ run:
timeout: 5m

output:
format: line-number
formats:
- format: line-number
path: stderr

linters:
disable-all: true
enable:
- asasalint
- bodyclose
- copyloopvar
- errcheck
- errorlint
- exhaustive
- exportloopref
- gofmt
- gofumpt
- goimports
Expand Down
3 changes: 0 additions & 3 deletions pkg/clients/cloudwatch/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ func (c client) GetMetricStatistics(ctx context.Context, logger logging.Logger,

ptrs := make([]*types.Datapoint, 0, len(resp.Datapoints))
for _, datapoint := range resp.Datapoints {
// Force a dereference to avoid loop variable pointer issues
datapoint := datapoint
ptrs = append(ptrs, &datapoint)
}

Expand All @@ -192,7 +190,6 @@ func toModelDatapoints(cwDatapoints []*types.Datapoint) []*model.Datapoint {
for _, cwDatapoint := range cwDatapoints {
extendedStats := make(map[string]*float64, len(cwDatapoint.ExtendedStatistics))
for name, value := range cwDatapoint.ExtendedStatistics {
value := value
extendedStats[name] = &value
}
modelDataPoints = append(modelDataPoints, &model.Datapoint{
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (j *CustomNamespace) validateCustomNamespaceJob(logger logging.Logger, jobI
} else {
return fmt.Errorf("no IAM roles configured. If the current IAM role is desired, an empty Role should be configured")
}
if j.Regions == nil || len(j.Regions) == 0 {
if len(j.Regions) == 0 {
return fmt.Errorf("CustomNamespace job [%s/%d]: Regions should not be empty", j.Name, jobIdx)
}
if len(j.Metrics) == 0 {
Expand Down
11 changes: 4 additions & 7 deletions pkg/config/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package config

import "context"

var (
flagsCtxKey = struct{}{}
defaultFeatureFlags = noFeatureFlags{}
)
type flagsCtxKey struct{}

// AwsSdkV2 is a feature flag used to enable the use of aws sdk v2 which is expected to come with performance benefits
const AwsSdkV2 = "aws-sdk-v2"
Expand All @@ -21,15 +18,15 @@ type FeatureFlags interface {

// CtxWithFlags injects a FeatureFlags inside a given context.Context, so that they are easily communicated through layers.
func CtxWithFlags(ctx context.Context, ctrl FeatureFlags) context.Context {
return context.WithValue(ctx, flagsCtxKey, ctrl)
return context.WithValue(ctx, flagsCtxKey{}, ctrl)
}

// FlagsFromCtx retrieves a FeatureFlags from a given context.Context, defaulting to one with all feature flags disabled if none is found.
func FlagsFromCtx(ctx context.Context) FeatureFlags {
if ctrl := ctx.Value(flagsCtxKey); ctrl != nil {
if ctrl := ctx.Value(flagsCtxKey{}); ctrl != nil {
return ctrl.(FeatureFlags)
}
return defaultFeatureFlags
return noFeatureFlags{}
}

// noFeatureFlags implements a no-op FeatureFlags
Expand Down
1 change: 0 additions & 1 deletion pkg/job/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func runStaticJob(
func createStaticDimensions(dimensions []model.Dimension) []model.Dimension {
out := make([]model.Dimension, 0, len(dimensions))
for _, d := range dimensions {
d := d
out = append(out, model.Dimension{
Name: d.Name,
Value: d.Value,
Expand Down

0 comments on commit ab4fa45

Please sign in to comment.