Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting issues detected by golangci-lint 1.60.3 #1510

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading