Skip to content

Commit

Permalink
[chore] remove unnecessary underscores (open-telemetry#9580)
Browse files Browse the repository at this point in the history
As per feedback from my previous PR

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
Alex Boten authored Feb 13, 2024
1 parent 9c199ef commit 062d0a7
Show file tree
Hide file tree
Showing 54 changed files with 126 additions and 126 deletions.
2 changes: 1 addition & 1 deletion component/componenttest/nop_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func NewNopHost() component.Host {
return &nopHost{}
}

func (nh *nopHost) GetFactory(_ component.Kind, _ component.Type) component.Factory {
func (nh *nopHost) GetFactory(component.Kind, component.Type) component.Factory {
return nil
}

Expand Down
10 changes: 5 additions & 5 deletions config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
// testBalancerBuilder facilitates testing validateBalancerName().
type testBalancerBuilder struct{}

func (testBalancerBuilder) Build(_ balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
func (testBalancerBuilder) Build(balancer.ClientConn, balancer.BuildOptions) balancer.Balancer {
return nil
}

Expand Down Expand Up @@ -953,7 +953,7 @@ func TestDefaultUnaryInterceptorAuthFailure(t *testing.T) {
authCalled = true
return context.Background(), expectedErr
}
handler := func(_ context.Context, _ any) (any, error) {
handler := func(context.Context, any) (any, error) {
assert.FailNow(t, "the handler should not have been called on auth failure!")
return nil, nil
}
Expand All @@ -974,7 +974,7 @@ func TestDefaultUnaryInterceptorMissingMetadata(t *testing.T) {
assert.FailNow(t, "the auth func should not have been called!")
return context.Background(), nil
}
handler := func(_ context.Context, _ any) (any, error) {
handler := func(context.Context, any) (any, error) {
assert.FailNow(t, "the handler should not have been called!")
return nil, nil
}
Expand Down Expand Up @@ -1027,7 +1027,7 @@ func TestDefaultStreamInterceptorAuthFailure(t *testing.T) {
authCalled = true
return context.Background(), expectedErr
}
handler := func(_ any, _ grpc.ServerStream) error {
handler := func(any, grpc.ServerStream) error {
assert.FailNow(t, "the handler should not have been called on auth failure!")
return nil
}
Expand All @@ -1050,7 +1050,7 @@ func TestDefaultStreamInterceptorMissingMetadata(t *testing.T) {
assert.FailNow(t, "the auth func should not have been called!")
return context.Background(), nil
}
handler := func(_ any, _ grpc.ServerStream) error {
handler := func(any, grpc.ServerStream) error {
assert.FailNow(t, "the handler should not have been called!")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion config/confighttp/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func httpContentDecompressor(h http.Handler, eh func(w http.ResponseWriter, r *h
errHandler: errHandler,
base: h,
decoders: map[string]func(body io.ReadCloser) (io.ReadCloser, error){
"": func(_ io.ReadCloser) (io.ReadCloser, error) {
"": func(io.ReadCloser) (io.ReadCloser, error) {
// Not a compressed payload. Nothing to do.
return nil, nil
},
Expand Down
2 changes: 1 addition & 1 deletion config/confighttp/compression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func TestHTTPContentCompressionRequestWithNilBody(t *testing.T) {
type copyFailBody struct {
}

func (*copyFailBody) Read(_ []byte) (n int, err error) {
func (*copyFailBody) Read([]byte) (n int, err error) {
return 0, fmt.Errorf("read failed")
}

Expand Down
14 changes: 7 additions & 7 deletions config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type customRoundTripper struct {

var _ http.RoundTripper = (*customRoundTripper)(nil)

func (c *customRoundTripper) RoundTrip(_ *http.Request) (*http.Response, error) {
func (c *customRoundTripper) RoundTrip(*http.Request) (*http.Response, error) {
return nil, nil
}

Expand Down Expand Up @@ -159,7 +159,7 @@ func TestAllHTTPClientSettings(t *testing.T) {
},
ReadBufferSize: 1024,
WriteBufferSize: 512,
CustomRoundTripper: func(_ http.RoundTripper) (http.RoundTripper, error) { return nil, errors.New("error") },
CustomRoundTripper: func(http.RoundTripper) (http.RoundTripper, error) { return nil, errors.New("error") },
},
shouldError: true,
},
Expand Down Expand Up @@ -856,7 +856,7 @@ func TestHttpCorsInvalidSettings(t *testing.T) {
s, err := hss.ToServer(
componenttest.NewNopHost(),
componenttest.NewNopTelemetrySettings(),
http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}))
http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}))
require.NoError(t, err)
require.NotNil(t, s)
require.NoError(t, s.Close())
Expand Down Expand Up @@ -1186,7 +1186,7 @@ func TestServerAuth(t *testing.T) {
}

handlerCalled := false
handler := http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {
handler := http.HandlerFunc(func(http.ResponseWriter, *http.Request) {
handlerCalled = true
})

Expand Down Expand Up @@ -1231,7 +1231,7 @@ func TestFailedServerAuth(t *testing.T) {
},
}

srv, err := hss.ToServer(host, componenttest.NewNopTelemetrySettings(), http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}))
srv, err := hss.ToServer(host, componenttest.NewNopTelemetrySettings(), http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}))
require.NoError(t, err)

// test
Expand All @@ -1257,7 +1257,7 @@ func TestServerWithErrorHandler(t *testing.T) {
srv, err := hss.ToServer(
componenttest.NewNopHost(),
componenttest.NewNopTelemetrySettings(),
http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}),
http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}),
WithErrorHandler(eh),
)
require.NoError(t, err)
Expand Down Expand Up @@ -1285,7 +1285,7 @@ func TestServerWithDecoder(t *testing.T) {
srv, err := hss.ToServer(
componenttest.NewNopHost(),
componenttest.NewNopTelemetrySettings(),
http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}),
http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}),
WithDecoder("something-else", decoder),
)
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions config/configtls/configtls.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ func (c TLSSetting) loadTLSConfig() (*tls.Config, error) {
if err != nil {
return nil, fmt.Errorf("failed to load TLS cert and key: %w", err)
}
getCertificate = func(_ *tls.ClientHelloInfo) (*tls.Certificate, error) { return certReloader.GetCertificate() }
getClientCertificate = func(_ *tls.CertificateRequestInfo) (*tls.Certificate, error) { return certReloader.GetCertificate() }
getCertificate = func(*tls.ClientHelloInfo) (*tls.Certificate, error) { return certReloader.GetCertificate() }
getClientCertificate = func(*tls.CertificateRequestInfo) (*tls.Certificate, error) { return certReloader.GetCertificate() }
}

minTLS, err := convertVersion(c.MinVersion, defaultMinTLSVersion)
Expand Down Expand Up @@ -342,7 +342,7 @@ func (c TLSServerSetting) LoadTLSConfig() (*tls.Config, error) {
if err != nil {
return nil, err
}
tlsCfg.GetConfigForClient = func(_ *tls.ClientHelloInfo) (*tls.Config, error) { return reloader.getClientConfig(tlsCfg) }
tlsCfg.GetConfigForClient = func(*tls.ClientHelloInfo) (*tls.Config, error) { return reloader.getClientConfig(tlsCfg) }
}
tlsCfg.ClientCAs = reloader.certPool
tlsCfg.ClientAuth = tls.RequireAndVerifyClientCert
Expand Down
2 changes: 1 addition & 1 deletion confmap/confmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ type errConfig struct {
Foo string `mapstructure:"foo"`
}

func (tc *errConfig) Unmarshal(_ *Conf) error {
func (tc *errConfig) Unmarshal(*Conf) error {
return errors.New("never works")
}

Expand Down
2 changes: 1 addition & 1 deletion confmap/confmaptest/configtest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ func (s schemeProvider) Scheme() string {
return s.scheme
}

func (s schemeProvider) Shutdown(_ context.Context) error {
func (s schemeProvider) Shutdown(context.Context) error {
return nil
}
2 changes: 1 addition & 1 deletion confmap/converter/expandconverter/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type converter struct{}
// New returns a confmap.Converter, that expands all environment variables for a given confmap.Conf.
//
// Notice: This API is experimental.
func New(_ confmap.ConverterSettings) confmap.Converter {
func New(confmap.ConverterSettings) confmap.Converter {
return converter{}
}

Expand Down
2 changes: 1 addition & 1 deletion confmap/provider/envprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type provider struct{}
//
// This Provider supports "env" scheme, and can be called with a selector:
// `env:NAME_OF_ENVIRONMENT_VARIABLE`
func NewWithSettings(_ confmap.ProviderSettings) confmap.Provider {
func NewWithSettings(confmap.ProviderSettings) confmap.Provider {
return &provider{}
}

Expand Down
2 changes: 1 addition & 1 deletion confmap/provider/fileprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type provider struct{}
// `file:/path/to/file` - absolute path (unix, windows)
// `file:c:/path/to/file` - absolute path including drive-letter (windows)
// `file:c:\path\to\file` - absolute path including drive-letter (windows)
func NewWithSettings(_ confmap.ProviderSettings) confmap.Provider {
func NewWithSettings(confmap.ProviderSettings) confmap.Provider {
return &provider{}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func TestEmptyURI(t *testing.T) {

func TestRetrieveFromShutdownServer(t *testing.T) {
fp := New(HTTPScheme, confmap.ProviderSettings{})
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {}))
ts := httptest.NewServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}))
ts.Close()
_, err := fp.Retrieve(context.Background(), ts.URL, nil)
assert.Error(t, err)
Expand Down
2 changes: 1 addition & 1 deletion confmap/provider/yamlprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type provider struct{}
// Examples:
// `yaml:processors::batch::timeout: 2s`
// `yaml:processors::batch/foo::timeout: 3s`
func NewWithSettings(_ confmap.ProviderSettings) confmap.Provider {
func NewWithSettings(confmap.ProviderSettings) confmap.Provider {
return &provider{}
}

Expand Down
4 changes: 2 additions & 2 deletions confmap/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestResolverErrors(t *testing.T) {
locations: []string{"mock:", "err:"},
providers: []Provider{
&mockProvider{},
&mockProvider{scheme: "err", retM: map[string]any{}, closeFunc: func(_ context.Context) error { return errors.New("close_err") }},
&mockProvider{scheme: "err", retM: map[string]any{}, closeFunc: func(context.Context) error { return errors.New("close_err") }},
},
expectCloseErr: true,
},
Expand Down Expand Up @@ -270,7 +270,7 @@ func TestResolver(t *testing.T) {
numCalls := atomic.Int32{}
resolver, err := NewResolver(ResolverSettings{
URIs: []string{"mock:"},
Providers: makeMapProvidersMap(&mockProvider{retM: map[string]any{}, closeFunc: func(_ context.Context) error {
Providers: makeMapProvidersMap(&mockProvider{retM: map[string]any{}, closeFunc: func(context.Context) error {
numCalls.Add(1)
return nil
}}),
Expand Down
6 changes: 3 additions & 3 deletions connector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func TestBuilder(t *testing.T) {
{
name: "unknown",
id: component.MustNewID("unknown"),
err: func(_, _ component.DataType) string {
err: func(component.DataType, component.DataType) string {
return "connector factory not available for: \"unknown\""
},
},
Expand All @@ -257,14 +257,14 @@ func TestBuilder(t *testing.T) {
{
name: "all",
id: component.MustNewID("all"),
err: func(_, _ component.DataType) string {
err: func(component.DataType, component.DataType) string {
return ""
},
},
{
name: "all/named",
id: component.MustNewIDWithName("all", "named"),
err: func(_, _ component.DataType) string {
err: func(component.DataType, component.DataType) string {
return ""
},
},
Expand Down
6 changes: 3 additions & 3 deletions consumer/consumertest/err.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
// NewErr returns a Consumer that just drops all received data and returns the specified error to Consume* callers.
func NewErr(err error) Consumer {
return &baseConsumer{
ConsumeTracesFunc: func(_ context.Context, _ ptrace.Traces) error { return err },
ConsumeMetricsFunc: func(_ context.Context, _ pmetric.Metrics) error { return err },
ConsumeLogsFunc: func(_ context.Context, _ plog.Logs) error { return err },
ConsumeTracesFunc: func(context.Context, ptrace.Traces) error { return err },
ConsumeMetricsFunc: func(context.Context, pmetric.Metrics) error { return err },
ConsumeLogsFunc: func(context.Context, plog.Logs) error { return err },
}
}
6 changes: 3 additions & 3 deletions consumer/consumertest/nop.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
// NewNop returns a Consumer that just drops all received data and returns no error.
func NewNop() Consumer {
return &baseConsumer{
ConsumeTracesFunc: func(_ context.Context, _ ptrace.Traces) error { return nil },
ConsumeMetricsFunc: func(_ context.Context, _ pmetric.Metrics) error { return nil },
ConsumeLogsFunc: func(_ context.Context, _ plog.Logs) error { return nil },
ConsumeTracesFunc: func(context.Context, ptrace.Traces) error { return nil },
ConsumeMetricsFunc: func(context.Context, pmetric.Metrics) error { return nil },
ConsumeLogsFunc: func(context.Context, plog.Logs) error { return nil },
}
}
6 changes: 3 additions & 3 deletions exporter/exporterhelper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
}()
)

func newNoopObsrepSender(_ *ObsReport) requestSender {
func newNoopObsrepSender(*ObsReport) requestSender {
return &baseRequestSender{}
}

Expand All @@ -50,8 +50,8 @@ func TestBaseExporterWithOptions(t *testing.T) {
want := errors.New("my error")
be, err := newBaseExporter(
defaultSettings, defaultType, false, nil, nil, newNoopObsrepSender,
WithStart(func(_ context.Context, _ component.Host) error { return want }),
WithShutdown(func(_ context.Context) error { return want }),
WithStart(func(context.Context, component.Host) error { return want }),
WithShutdown(func(context.Context) error { return want }),
WithTimeout(NewDefaultTimeoutSettings()),
)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type fakeRequest struct {
err error
}

func (r fakeRequest) Export(_ context.Context) error {
func (r fakeRequest) Export(context.Context) error {
return r.err
}

Expand Down
8 changes: 4 additions & 4 deletions exporter/exporterhelper/retry_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
)

func mockRequestUnmarshaler(mr Request) exporterqueue.Unmarshaler[Request] {
return func(_ []byte) (Request, error) {
return func([]byte) (Request, error) {
return mr, nil
}
}

func mockRequestMarshaler(_ Request) ([]byte, error) {
func mockRequestMarshaler(Request) ([]byte, error) {
return []byte("mockRequest"), nil
}

Expand Down Expand Up @@ -261,7 +261,7 @@ func TestQueueRetryWithDisabledRetires(t *testing.T) {

type mockErrorRequest struct{}

func (mer *mockErrorRequest) Export(_ context.Context) error {
func (mer *mockErrorRequest) Export(context.Context) error {
return errors.New("transient error")
}

Expand Down Expand Up @@ -330,7 +330,7 @@ type observabilityConsumerSender struct {
droppedItemsCount *atomic.Int64
}

func newObservabilityConsumerSender(_ *ObsReport) requestSender {
func newObservabilityConsumerSender(*ObsReport) requestSender {
return &observabilityConsumerSender{
waitGroup: new(sync.WaitGroup),
droppedItemsCount: &atomic.Int64{},
Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func TestTracesRequestExporter_WithShutdown_ReturnError(t *testing.T) {
}

func newTraceDataPusher(retError error) consumer.ConsumeTracesFunc {
return func(_ context.Context, _ ptrace.Traces) error {
return func(context.Context, ptrace.Traces) error {
return retError
}
}
Expand Down
6 changes: 3 additions & 3 deletions exporter/exportertest/contract_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func checkMetrics(t *testing.T, params CheckConsumeContractParams, mockReceiver
fmt.Printf("Number of permanent errors: %d\n", reqCounter.error.permanent)
fmt.Printf("Number of non-permanent errors: %d\n", reqCounter.error.nonpermanent)

assert.EventuallyWithT(t, func(_ *assert.CollectT) {
assert.EventuallyWithT(t, func(*assert.CollectT) {
checkIfTestPassed(t, params.NumberOfTestElements, *reqCounter)
}, 2*time.Second, 100*time.Millisecond)
}
Expand Down Expand Up @@ -181,7 +181,7 @@ func checkTraces(t *testing.T, params CheckConsumeContractParams, mockReceiver c
fmt.Printf("Number of permanent errors: %d\n", reqCounter.error.permanent)
fmt.Printf("Number of non-permanent errors: %d\n", reqCounter.error.nonpermanent)

assert.EventuallyWithT(t, func(_ *assert.CollectT) {
assert.EventuallyWithT(t, func(*assert.CollectT) {
checkIfTestPassed(t, params.NumberOfTestElements, *reqCounter)
}, 2*time.Second, 100*time.Millisecond)
}
Expand Down Expand Up @@ -220,7 +220,7 @@ func checkLogs(t *testing.T, params CheckConsumeContractParams, mockReceiver com
fmt.Printf("Number of permanent errors: %d\n", reqCounter.error.permanent)
fmt.Printf("Number of non-permanent errors: %d\n", reqCounter.error.nonpermanent)

assert.EventuallyWithT(t, func(_ *assert.CollectT) {
assert.EventuallyWithT(t, func(*assert.CollectT) {
checkIfTestPassed(t, params.NumberOfTestElements, *reqCounter)
}, 2*time.Second, 100*time.Millisecond)
}
Expand Down
Loading

0 comments on commit 062d0a7

Please sign in to comment.