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

Lint fixes #4541

Merged
merged 2 commits into from
Mar 26, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/configsource/etcd2configsource/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (s *etcd2ConfigSource) newWatcher(selector string, index uint64, watcherFun
}
}()

return func(ctx context.Context) error {
return func(_ context.Context) error {
cancel()
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/configsource/includeconfigsource/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (is *includeConfigSource) watchFile(file string, watcherFunc confmap.Watche

is.watchedFiles[file] = struct{}{}

return func(ctx context.Context) error {
return func(_ context.Context) error {
err := is.watcher.Remove(file)
if err != nil {
return err
Expand Down
26 changes: 13 additions & 13 deletions internal/configsource/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestConfigSourceResolved(t *testing.T) {

cp := confmap.NewFromStringMap(originalCfg)

res, closeFunc, err := ResolveWithConfigSources(context.Background(), cfgSources, nil, cp, func(event *confmap.ChangeEvent) {
res, closeFunc, err := ResolveWithConfigSources(context.Background(), cfgSources, nil, cp, func(*confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand All @@ -132,7 +132,7 @@ func TestConfigSourceManagerResolveRemoveConfigSourceSection(t *testing.T) {
"tstcfgsrc": &TestConfigSource{},
}

res, closeFunc, err := ResolveWithConfigSources(context.Background(), cfgSources, nil, confmap.NewFromStringMap(cfg), func(event *confmap.ChangeEvent) {
res, closeFunc, err := ResolveWithConfigSources(context.Background(), cfgSources, nil, confmap.NewFromStringMap(cfg), func(*confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestConfigSourceManagerResolveErrors(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
res, closeFunc, err := ResolveWithConfigSources(context.Background(), tt.configSourceMap, nil, confmap.NewFromStringMap(tt.config), func(event *confmap.ChangeEvent) {
res, closeFunc, err := ResolveWithConfigSources(context.Background(), tt.configSourceMap, nil, confmap.NewFromStringMap(tt.config), func(*confmap.ChangeEvent) {
panic("must not be called")
})
require.Error(t, err)
Expand Down Expand Up @@ -208,7 +208,7 @@ map:
require.NoError(t, err)
expectedCfg := expectedParser.ToStringMap()

res, closeFunc, err := ResolveWithConfigSources(context.Background(), cfgSources, nil, cp, func(event *confmap.ChangeEvent) {
res, closeFunc, err := ResolveWithConfigSources(context.Background(), cfgSources, nil, cp, func(*confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestConfigSourceManagerArraysAndMaps(t *testing.T) {
expectedParser, err := confmaptest.LoadConf(expectedFile)
require.NoError(t, err)

res, closeFunc, err := ResolveWithConfigSources(context.Background(), cfgSources, nil, cp, func(event *confmap.ChangeEvent) {
res, closeFunc, err := ResolveWithConfigSources(context.Background(), cfgSources, nil, cp, func(*confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand Down Expand Up @@ -270,7 +270,7 @@ func TestConfigSourceManagerParamsHandling(t *testing.T) {
}

// Set OnRetrieve to check if the parameters were parsed as expectedSettings.
tstCfgSrc.OnRetrieve = func(ctx context.Context, selector string, paramsConfigMap *confmap.Conf) error {
tstCfgSrc.OnRetrieve = func(_ context.Context, selector string, paramsConfigMap *confmap.Conf) error {
var val any
if paramsConfigMap != nil {
val = paramsConfigMap.ToStringMap()
Expand All @@ -287,7 +287,7 @@ func TestConfigSourceManagerParamsHandling(t *testing.T) {
expectedParser, err := confmaptest.LoadConf(expectedFile)
require.NoError(t, err)

res, closeFunc, err := ResolveWithConfigSources(context.Background(), map[string]ConfigSource{"tstcfgsrc": &tstCfgSrc}, nil, cp, func(event *confmap.ChangeEvent) {
res, closeFunc, err := ResolveWithConfigSources(context.Background(), map[string]ConfigSource{"tstcfgsrc": &tstCfgSrc}, nil, cp, func(*confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand Down Expand Up @@ -380,7 +380,7 @@ func TestConfigSourceManagerEnvVarHandling(t *testing.T) {
}

// Intercept "params_key" and create an entry with the params themselves.
tstCfgSrc.OnRetrieve = func(ctx context.Context, selector string, paramsConfigMap *confmap.Conf) error {
tstCfgSrc.OnRetrieve = func(_ context.Context, selector string, paramsConfigMap *confmap.Conf) error {
var val any
if paramsConfigMap != nil {
val = paramsConfigMap.ToStringMap()
Expand All @@ -399,7 +399,7 @@ func TestConfigSourceManagerEnvVarHandling(t *testing.T) {
expectedParser, err := confmaptest.LoadConf(expectedFile)
require.NoError(t, err)

res, closeFunc, err := ResolveWithConfigSources(context.Background(), map[string]ConfigSource{"tstcfgsrc": &tstCfgSrc}, nil, cp, func(event *confmap.ChangeEvent) {
res, closeFunc, err := ResolveWithConfigSources(context.Background(), map[string]ConfigSource{"tstcfgsrc": &tstCfgSrc}, nil, cp, func(_ *confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand Down Expand Up @@ -541,7 +541,7 @@ func TestManagerExpandString(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, closeFunc, err := resolveStringValue(ctx, cfgSources, nil, tt.input, func(event *confmap.ChangeEvent) {
got, closeFunc, err := resolveStringValue(ctx, cfgSources, nil, tt.input, func(_ *confmap.ChangeEvent) {
panic("must not be called")
})
if tt.wantErr != nil {
Expand Down Expand Up @@ -836,7 +836,7 @@ func (t *TestConfigSource) Retrieve(ctx context.Context, selector string, params
if entry.WatchForUpdateCh != nil {
doneCh := make(chan struct{})
startWatch(entry.WatchForUpdateCh, doneCh, watcher)
return confmap.NewRetrieved(entry.Value, confmap.WithRetrievedClose(func(ctx context.Context) error {
return confmap.NewRetrieved(entry.Value, confmap.WithRetrievedClose(func(_ context.Context) error {
close(doneCh)
return nil
}))
Expand Down Expand Up @@ -921,7 +921,7 @@ func TestConfigSourceConfmapProviderFallbackResolved(t *testing.T) {

res, closeFunc, err := ResolveWithConfigSources(
context.Background(), configSources, confmapProviders, cp,
func(event *confmap.ChangeEvent) {
func(_ *confmap.ChangeEvent) {
t.Fatal("shouldn't be called")
},
)
Expand Down Expand Up @@ -952,7 +952,7 @@ func TestConfigSourceConfmapProviderFallbackWithError(t *testing.T) {

res, closeFunc, err := ResolveWithConfigSources(
context.Background(), configSources, confmapProviders, cfg,
func(event *confmap.ChangeEvent) {
func(_ *confmap.ChangeEvent) {
t.Fatal("shouldn't be called")
},
)
Expand Down
2 changes: 1 addition & 1 deletion internal/configsource/vaultconfigsource/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (v *vaultConfigSource) Retrieve(_ context.Context, selector string, _ *conf
return nil, err
}

closeFunc = func(ctx context.Context) error {
closeFunc = func(_ context.Context) error {
close(doneCh)
return nil
}
Expand Down
18 changes: 9 additions & 9 deletions internal/configsource/vaultconfigsource/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ func TestVaultSessionForKV(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, source)

retrieved, err := source.Retrieve(context.Background(), "data.k0", nil, func(event *confmap.ChangeEvent) {
retrieved, err := source.Retrieve(context.Background(), "data.k0", nil, func(_ *confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
val, err := retrieved.AsRaw()
require.NoError(t, err)
require.Equal(t, "v0", val)

retrievedMetadata, err := source.Retrieve(context.Background(), "metadata.version", nil, func(event *confmap.ChangeEvent) {
retrievedMetadata, err := source.Retrieve(context.Background(), "metadata.version", nil, func(_ *confmap.ChangeEvent) {
panic("must not be called because it is the second retrieve")
})
require.NoError(t, err)
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestVaultPollingKVUpdate(t *testing.T) {
require.Equal(t, "v0", valK0)

// Retrieve key "k1"
retrievedK1, err := source.Retrieve(context.Background(), "data.k1", nil, func(event *confmap.ChangeEvent) {
retrievedK1, err := source.Retrieve(context.Background(), "data.k1", nil, func(_ *confmap.ChangeEvent) {
panic("must not be called because it is the second retrieve")
})
require.NoError(t, err)
Expand All @@ -150,7 +150,7 @@ func TestVaultPollingKVUpdate(t *testing.T) {
require.NotNil(t, source)

// Retrieve key
retrievedUpdatedK1, err := source.Retrieve(context.Background(), "data.k1", nil, func(event *confmap.ChangeEvent) {
retrievedUpdatedK1, err := source.Retrieve(context.Background(), "data.k1", nil, func(_ *confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestVaultRenewableSecret(t *testing.T) {
require.NoError(t, err)

// Retrieve key password, it is generated by vault no expected value.
retrievedPwd, err := source.Retrieve(context.Background(), "password", nil, func(event *confmap.ChangeEvent) {
retrievedPwd, err := source.Retrieve(context.Background(), "password", nil, func(_ *confmap.ChangeEvent) {
panic("must not be called because it is the second retrieve")
})
require.NoError(t, err)
Expand All @@ -214,7 +214,7 @@ func TestVaultRenewableSecret(t *testing.T) {
require.NotNil(t, source)

// Retrieve key username, it is generated by vault no expected value.
retrievedUpdatedUser, err := source.Retrieve(context.Background(), "username", nil, func(event *confmap.ChangeEvent) {
retrievedUpdatedUser, err := source.Retrieve(context.Background(), "username", nil, func(_ *confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand All @@ -223,7 +223,7 @@ func TestVaultRenewableSecret(t *testing.T) {
require.NotEqual(t, retrievedUserValue, retrievedUpdatedUserValue)

// Retrieve password and check that it changed.
retrievedUpdatedPwd, err := source.Retrieve(context.Background(), "password", nil, func(event *confmap.ChangeEvent) {
retrievedUpdatedPwd, err := source.Retrieve(context.Background(), "password", nil, func(_ *confmap.ChangeEvent) {
panic("must not be called because it is the second retrieve")
})
require.NoError(t, err)
Expand Down Expand Up @@ -279,7 +279,7 @@ func TestVaultV1SecretWithTTL(t *testing.T) {
require.NotNil(t, source)

// Retrieve value
retrievedValue, err = source.Retrieve(context.Background(), "my-value", nil, func(event *confmap.ChangeEvent) {
retrievedValue, err = source.Retrieve(context.Background(), "my-value", nil, func(_ *confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand Down Expand Up @@ -311,7 +311,7 @@ func TestVaultV1NonWatchableSecret(t *testing.T) {
require.NotNil(t, source)

// Retrieve value
retrievedValue, err := source.Retrieve(context.Background(), "my-value", nil, func(event *confmap.ChangeEvent) {
retrievedValue, err := source.Retrieve(context.Background(), "my-value", nil, func(_ *confmap.ChangeEvent) {
panic("must not be called")
})
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

func newMockConnectFunc(conn zkConnection) connectFunc {
return func(ctx context.Context) (zkConnection, error) {
return func(_ context.Context) (zkConnection, error) {
return conn, nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/configsource/zookeeperconfigsource/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *zkConfigSource) Retrieve(ctx context.Context, selector string, _ *confm

closeCh := make(chan struct{})
startWatcher(watchCh, closeCh, watcher)
return confmap.NewRetrieved(string(value), confmap.WithRetrievedClose(func(ctx context.Context) error {
return confmap.NewRetrieved(string(value), confmap.WithRetrievedClose(func(_ context.Context) error {
close(closeCh)
conn.Close()
return nil
Expand Down Expand Up @@ -95,7 +95,7 @@ func startWatcher(watchCh <-chan zk.Event, closeCh <-chan struct{}, watcher conf
// underlying connection until it is lost.
func newConnectFunc(endpoints []string, timeout time.Duration) connectFunc {
var conn *zk.Conn
return func(ctx context.Context) (zkConnection, error) {
return func(_ context.Context) (zkConnection, error) {
if conn != nil && conn.State() != zk.StateDisconnected {
return conn, nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/confmapprovider/configsource/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (t *TestConfigSource) Retrieve(ctx context.Context, selector string, params
if entry.WatchForUpdateCh != nil {
doneCh := make(chan struct{})
startWatch(entry.WatchForUpdateCh, doneCh, watcher)
return confmap.NewRetrieved(entry.Value, confmap.WithRetrievedClose(func(ctx context.Context) error {
return confmap.NewRetrieved(entry.Value, confmap.WithRetrievedClose(func(_ context.Context) error {
close(doneCh)
return nil
}))
Expand Down
2 changes: 1 addition & 1 deletion internal/confmapprovider/discovery/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (m *mapProvider) PropertiesFileProvider() confmap.Provider {
}

func (m *mapProvider) retrieve(scheme string) func(context.Context, string, confmap.WatcherFunc) (*confmap.Retrieved, error) {
return func(ctx context.Context, uri string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) {
return func(_ context.Context, uri string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) {
schemePrefix := fmt.Sprintf("%s:", scheme)
if !strings.HasPrefix(uri, schemePrefix) {
return nil, fmt.Errorf("uri %q is not supported by %s provider", uri, scheme)
Expand Down
2 changes: 1 addition & 1 deletion internal/exporter/httpsinkexporter/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (s *sink) start(ctx context.Context) {
s.server = &http.Server{
Addr: s.endpoint,
Handler: mux,
BaseContext: func(listener net.Listener) context.Context {
BaseContext: func(_ net.Listener) context.Context {
return ctx
},
ReadHeaderTimeout: 5 * time.Second,
Expand Down
2 changes: 1 addition & 1 deletion internal/receiver/discoveryreceiver/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (e *evaluator) evaluateMatch(match Match, pattern string, status discovery.
if program, err = expr.Compile(match.Expr, expr.Env(env)); err != nil {
err = fmt.Errorf("invalid match expr statement: %w", err)
} else {
matchFunc = func(p string) (bool, error) {
matchFunc = func(_ string) (bool, error) {
ret, runErr := vm.Run(program, env)
if runErr != nil {
return false, runErr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestTimestampFromMetric(t *testing.T) {
md.SetEmptySummary()
return true
}},
{name: "MetricTypeNone", metricFunc: func(md pmetric.Metric) bool { return true }},
{name: "MetricTypeNone", metricFunc: func(_ pmetric.Metric) bool { return true }},
} {
t.Run(test.name, func(t *testing.T) {
me := newMetricEvaluator(zap.NewNop(), &Config{}, make(chan plog.Logs), nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func newStatementEvaluator(logger *zap.Logger, id component.ID, config *Config,
// https://github.com/uber-go/zap/blob/e06e09a6d396031c89b87383eef3cad6f647cf2c/logger.go#L315.
// Using an arbitrary action offset.
zap.WithFatalHook(zapcore.WriteThenFatal+100),
zap.WrapCore(func(core zapcore.Core) zapcore.Core { return se }),
zap.WrapCore(func(_ zapcore.Core) zapcore.Core { return se }),
); err != nil {
return nil, err
}
Expand Down