Skip to content

Commit

Permalink
[chore] more lint fixes (#31287)
Browse files Browse the repository at this point in the history
Related
#31240

Signed-off-by: Alex Boten <aboten@lightstep.com>
  • Loading branch information
Alex Boten authored Feb 15, 2024
1 parent 65948d4 commit fee9489
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 105 deletions.
2 changes: 1 addition & 1 deletion receiver/opencensusreceiver/opencensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestReceiveOnUnixDomainSocket_endToEnd(t *testing.T) {
`
c := http.Client{
Transport: &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (conn net.Conn, err error) {
DialContext: func(context.Context, string, string) (conn net.Conn, err error) {
return net.Dial("unix", socketName)
},
},
Expand Down
2 changes: 1 addition & 1 deletion receiver/oracledbreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type sqlOpenerFunc func(dataSourceName string) (*sql.DB, error)

func createReceiverFunc(sqlOpenerFunc sqlOpenerFunc, clientProviderFunc clientProviderFunc) receiver.CreateMetricsFunc {
return func(
ctx context.Context,
_ context.Context,
settings receiver.CreateSettings,
cfg component.Config,
consumer consumer.Metrics,
Expand Down
8 changes: 4 additions & 4 deletions receiver/oracledbreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestScraper_Scrape(t *testing.T) {
}{
{
name: "valid",
dbclientFn: func(db *sql.DB, s string, logger *zap.Logger) dbClient {
dbclientFn: func(_ *sql.DB, s string, _ *zap.Logger) dbClient {
return &fakeDbClient{
Responses: [][]metricRow{
queryResponses[s],
Expand All @@ -59,7 +59,7 @@ func TestScraper_Scrape(t *testing.T) {
},
{
name: "bad tablespace usage",
dbclientFn: func(db *sql.DB, s string, logger *zap.Logger) dbClient {
dbclientFn: func(_ *sql.DB, s string, _ *zap.Logger) dbClient {
if s == tablespaceUsageSQL {
return &fakeDbClient{Responses: [][]metricRow{
{
Expand All @@ -75,7 +75,7 @@ func TestScraper_Scrape(t *testing.T) {
},
{
name: "no limit on tablespace",
dbclientFn: func(db *sql.DB, s string, logger *zap.Logger) dbClient {
dbclientFn: func(_ *sql.DB, s string, _ *zap.Logger) dbClient {
if s == tablespaceMaxSpaceSQL {
return &fakeDbClient{Responses: [][]metricRow{
{
Expand All @@ -91,7 +91,7 @@ func TestScraper_Scrape(t *testing.T) {
},
{
name: "bad value on tablespace",
dbclientFn: func(db *sql.DB, s string, logger *zap.Logger) dbClient {
dbclientFn: func(_ *sql.DB, s string, _ *zap.Logger) dbClient {
if s == tablespaceMaxSpaceSQL {
return &fakeDbClient{Responses: [][]metricRow{
{
Expand Down
4 changes: 2 additions & 2 deletions receiver/podmanreceiver/podman_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func newPodmanConnection(logger *zap.Logger, endpoint string, sshKey string, ssh
func tcpConnection(_url *url.URL) *http.Client {
return &http.Client{
Transport: &http.Transport{
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
DialContext: func(context.Context, string, string) (net.Conn, error) {
return net.Dial("tcp", _url.Host)
},
DisableCompression: true,
Expand Down Expand Up @@ -168,7 +168,7 @@ func sshConnection(logger *zap.Logger, _url *url.URL, secure bool, key, passphra

return &http.Client{
Transport: &http.Transport{
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
DialContext: func(context.Context, string, string) (net.Conn, error) {
return bastion.Dial("unix", _url.Path)
},
},
Expand Down
2 changes: 1 addition & 1 deletion receiver/postgresqlreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestValidate(t *testing.T) {
}{
{
desc: "missing username and password",
defaultConfigModifier: func(cfg *Config) {},
defaultConfigModifier: func(*Config) {},
expected: multierr.Combine(
errors.New(ErrNoUsername),
errors.New(ErrNoPassword),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestStalenessMarkersEndToEnd(t *testing.T) {

// 1. Setup the server that sends series that intermittently appear and disappear.
n := &atomic.Uint64{}
scrapeServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
scrapeServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
// Increment the scrape count atomically per scrape.
i := n.Add(1)

Expand Down Expand Up @@ -81,7 +81,7 @@ jvm_memory_pool_bytes_used{pool="CodeHeap 'non-nmethods'"} %.1f`, float64(i))

// 2. Set up the Prometheus RemoteWrite endpoint.
prweUploads := make(chan *prompb.WriteRequest)
prweServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
prweServer := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, req *http.Request) {
// Snappy decode the uploads.
payload, rerr := io.ReadAll(req.Body)
require.NoError(t, rerr)
Expand Down
2 changes: 1 addition & 1 deletion receiver/prometheusreceiver/metrics_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ func TestGCInterval(t *testing.T) {

func TestUserAgent(t *testing.T) {
uaCh := make(chan string, 1)
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
select {
case uaCh <- r.UserAgent():
default:
Expand Down
6 changes: 3 additions & 3 deletions receiver/rabbitmqreceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestGetQueuesDetails(t *testing.T) {
desc: "Non-200 Response",
testFunc: func(t *testing.T) {
// Setup test server
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusUnauthorized)
}))
defer ts.Close()
Expand All @@ -115,7 +115,7 @@ func TestGetQueuesDetails(t *testing.T) {
desc: "Bad payload returned",
testFunc: func(t *testing.T) {
// Setup test server
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, err := w.Write([]byte("{}"))
require.NoError(t, err)
}))
Expand All @@ -134,7 +134,7 @@ func TestGetQueuesDetails(t *testing.T) {
data := loadAPIResponseData(t, queuesAPIResponseFile)

// Setup test server
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, err := w.Write(data)
require.NoError(t, err)
}))
Expand Down
8 changes: 4 additions & 4 deletions receiver/rabbitmqreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ func TestScaperScrape(t *testing.T) {
}{
{
desc: "Nil client",
setupMockClient: func(t *testing.T) client {
setupMockClient: func(*testing.T) client {
return nil
},
expectedMetricGen: func(t *testing.T) pmetric.Metrics {
expectedMetricGen: func(*testing.T) pmetric.Metrics {
return pmetric.NewMetrics()
},
expectedErr: errClientNotInit,
},
{
desc: "API Call Failure",
setupMockClient: func(t *testing.T) client {
setupMockClient: func(*testing.T) client {
mockClient := mocks.MockClient{}
mockClient.On("GetQueues", mock.Anything).Return(nil, errors.New("some api error"))
return &mockClient
},
expectedMetricGen: func(t *testing.T) pmetric.Metrics {
expectedMetricGen: func(*testing.T) pmetric.Metrics {

return pmetric.NewMetrics()
},
Expand Down
4 changes: 2 additions & 2 deletions receiver/riakreceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestNewClient(t *testing.T) {
func TestGetStatsDetails(t *testing.T) {
t.Run("Non-200 Response", func(t *testing.T) {
// Setup test server
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusUnauthorized)
}))
defer ts.Close()
Expand All @@ -99,7 +99,7 @@ func TestGetStatsDetails(t *testing.T) {
data := loadAPIResponseData(t, statsAPIResponseFile)

// Setup test server
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, err := w.Write(data)
require.NoError(t, err)
}))
Expand Down
8 changes: 4 additions & 4 deletions receiver/riakreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ func TestScaperScrape(t *testing.T) {
}{
{
desc: "Nil client",
setupMockClient: func(t *testing.T) client {
setupMockClient: func(*testing.T) client {
return nil
},
expectedMetricGen: func(t *testing.T) pmetric.Metrics {
expectedMetricGen: func(*testing.T) pmetric.Metrics {
return pmetric.NewMetrics()
},
setupCfg: func() *Config {
Expand All @@ -100,12 +100,12 @@ func TestScaperScrape(t *testing.T) {
},
{
desc: "API Call Failure",
setupMockClient: func(t *testing.T) client {
setupMockClient: func(*testing.T) client {
mockClient := mocks.MockClient{}
mockClient.On("GetStats", mock.Anything).Return(nil, errors.New("some api error"))
return &mockClient
},
expectedMetricGen: func(t *testing.T) pmetric.Metrics {
expectedMetricGen: func(*testing.T) pmetric.Metrics {
return pmetric.NewMetrics()
},
setupCfg: func() *Config {
Expand Down
16 changes: 8 additions & 8 deletions receiver/saphanareceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ func TestSimpleQueryOutput(t *testing.T) {
orderedStats: []queryStat{
{
key: "value",
addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string,
m map[string]string) error {
addMetricFunction: func(*metadata.MetricsBuilder, pcommon.Timestamp, string,
map[string]string) error {
// Function is a no-op as it's not required for this test
return nil
},
},
{
key: "rate",
addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string,
m map[string]string) error {
addMetricFunction: func(*metadata.MetricsBuilder, pcommon.Timestamp, string,
map[string]string) error {
// Function is a no-op as it's not required for this test
return nil
},
Expand Down Expand Up @@ -192,16 +192,16 @@ func TestNullOutput(t *testing.T) {
orderedStats: []queryStat{
{
key: "value",
addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string,
m map[string]string) error {
addMetricFunction: func(*metadata.MetricsBuilder, pcommon.Timestamp, string,
map[string]string) error {
// Function is a no-op as it's not required for this test
return nil
},
},
{
key: "rate",
addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string,
m map[string]string) error {
addMetricFunction: func(*metadata.MetricsBuilder, pcommon.Timestamp, string,
map[string]string) error {
// Function is a no-op as it's not required for this test
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion receiver/saphanareceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestValidate(t *testing.T) {
}{
{
desc: "missing username and password",
defaultConfigModifier: func(cfg *Config) {},
defaultConfigModifier: func(*Config) {},
expected: multierr.Combine(
errors.New(ErrNoUsername),
errors.New(ErrNoPassword),
Expand Down
Loading

0 comments on commit fee9489

Please sign in to comment.