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

[chore] fix linting #32004

Merged
merged 2 commits into from Mar 27, 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 cmd/configschema/comments.go
Expand Up @@ -30,7 +30,7 @@ func commentsForStruct(v reflect.Value, dr DirResolver) (map[string]string, erro

func searchDirsForComments(packageDir, typeName string) (map[string]string, error) {
out := map[string]string{}
err := filepath.WalkDir(packageDir, func(path string, d fs.DirEntry, err error) error {
err := filepath.WalkDir(packageDir, func(path string, d fs.DirEntry, _ error) error {
if d.IsDir() {
commentsForStructName(out, path, typeName)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/configschema/docsgen/docsgen/cli_test.go
Expand Up @@ -33,7 +33,7 @@ func TestWriteConfigDoc(t *testing.T) {
Type: component.MustNewType("redis"),
CfgInstance: cfg,
},
func(dir string, bytes []byte, perm os.FileMode) error {
func(dir string, _ []byte, _ os.FileMode) error {
outputFilename = dir
return nil
},
Expand All @@ -48,7 +48,7 @@ func TestHandleCLI_NoArgs(t *testing.T) {
defaultComponents(t),
configschema.NewDefaultDirResolver(),
testTemplate(t),
func(filename string, data []byte, perm os.FileMode) error { return nil },
func(_ string, _ []byte, _ os.FileMode) error { return nil },
wr,
)
assert.Equal(t, 3, len(wr.lines))
Expand Down
2 changes: 1 addition & 1 deletion cmd/githubgen/main.go
Expand Up @@ -117,7 +117,7 @@ func run(folder string, allowlistFilePath string, generators []generator) error
var foldersList []string
maxLength := 0
allCodeowners := map[string]struct{}{}
err := filepath.Walk(folder, func(path string, info fs.FileInfo, err error) error {
err := filepath.Walk(folder, func(path string, info fs.FileInfo, _ error) error {
if info.Name() == "metadata.yaml" {
m, err := loadMetadata(path)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion connector/datadogconnector/connector.go
Expand Up @@ -192,7 +192,7 @@ func (c *traceToMetricConnector) enrichStatsPayload(stats *pb.StatsPayload) {
tagList.Store(tag, struct{}{})
}
stat.Tags = make([]string, 0)
tagList.Range(func(key, value any) bool {
tagList.Range(func(key, _ any) bool {
stat.Tags = append(stat.Tags, key.(string))
return true
})
Expand Down
2 changes: 1 addition & 1 deletion connector/datadogconnector/connector_test.go
Expand Up @@ -138,7 +138,7 @@ func TestContainerTags(t *testing.T) {
// check if the container tags are added to the cache
assert.Equal(t, 1, len(connector.containerTagCache.Items()))
count := 0
connector.containerTagCache.Items()["my-container-id"].Object.(*sync.Map).Range(func(key, value any) bool {
connector.containerTagCache.Items()["my-container-id"].Object.(*sync.Map).Range(func(_, _ any) bool {
count++
return true
})
Expand Down
2 changes: 1 addition & 1 deletion connector/grafanacloudconnector/connector.go
Expand Up @@ -47,7 +47,7 @@ func newConnector(logger *zap.Logger, set component.TelemetrySettings, config co
"grafanacloud_host_count",
metric.WithDescription("Number of unique hosts"),
metric.WithUnit("1"),
metric.WithInt64Callback(func(ctx context.Context, result metric.Int64Observer) error {
metric.WithInt64Callback(func(_ context.Context, result metric.Int64Observer) error {
result.Observe(int64(hm.count()))
return nil
}),
Expand Down
2 changes: 1 addition & 1 deletion connector/servicegraphconnector/connector_test.go
Expand Up @@ -288,7 +288,7 @@ func TestUpdateDurationMetrics(t *testing.T) {
},
}
for _, tc := range testCases {
t.Run(tc.caseStr, func(t *testing.T) {
t.Run(tc.caseStr, func(_ *testing.T) {
p.updateDurationMetrics(metricKey, tc.duration, tc.duration)
})
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/awsemfexporter/grouped_metric_test.go
Expand Up @@ -495,7 +495,7 @@ func TestTranslateUnit(t *testing.T) {
"Bi": "Bits",
}
for input, output := range translateUnitCases {
t.Run(input, func(tt *testing.T) {
t.Run(input, func(_ *testing.T) {
metric.SetUnit(input)

v := translateUnit(metric, translator.metricDescriptor)
Expand Down
2 changes: 1 addition & 1 deletion exporter/awsxrayexporter/awsxray.go
Expand Up @@ -52,7 +52,7 @@ func newTracesExporter(
context.TODO(),
set,
cfg,
func(ctx context.Context, td ptrace.Traces) error {
func(_ context.Context, td ptrace.Traces) error {
var err error
logger.Debug("TracesExporter", typeLog, nameLog, zap.Int("#spans", td.SpanCount()))

Expand Down
2 changes: 1 addition & 1 deletion exporter/clickhouseexporter/exporter_logs_test.go
Expand Up @@ -39,7 +39,7 @@ func TestLogsExporter_New(t *testing.T) {
}

failWithMsg := func(msg string) validate {
return func(t *testing.T, exporter *logsExporter, err error) {
return func(t *testing.T, _ *logsExporter, err error) {
require.Error(t, err)
require.Contains(t, err.Error(), msg)
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/clickhouseexporter/exporter_metrics_test.go
Expand Up @@ -37,7 +37,7 @@ func TestExporter_pushMetricsData(t *testing.T) {
t.Parallel()
t.Run("push success", func(t *testing.T) {
items := &atomic.Int32{}
initClickhouseTestServer(t, func(query string, values []driver.Value) error {
initClickhouseTestServer(t, func(query string, _ []driver.Value) error {
if strings.HasPrefix(query, "INSERT") {
items.Add(1)
}
Expand All @@ -49,7 +49,7 @@ func TestExporter_pushMetricsData(t *testing.T) {
require.Equal(t, int32(15), items.Load())
})
t.Run("push failure", func(t *testing.T) {
initClickhouseTestServer(t, func(query string, values []driver.Value) error {
initClickhouseTestServer(t, func(query string, _ []driver.Value) error {
if strings.HasPrefix(query, "INSERT") {
return fmt.Errorf("mock insert error")
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/clickhouseexporter/exporter_sql_test.go
Expand Up @@ -66,7 +66,7 @@ func testClusterConfig(t *testing.T, completion clusterTestCompletion) {

for _, tt := range tests {
t.Run("test cluster config "+tt.name, func(t *testing.T) {
initClickhouseTestServer(t, func(query string, values []driver.Value) error {
initClickhouseTestServer(t, func(query string, _ []driver.Value) error {
if tt.shouldPass {
require.NoError(t, checkClusterQueryDefinition(query, tt.cluster))
} else {
Expand Down Expand Up @@ -157,7 +157,7 @@ func testTableEngineConfig(t *testing.T, completion tableEngineTestCompletion) {
expectedEngineValue := fmt.Sprintf("%s(%s)", tt.expectedTableName, tt.engineParams)

t.Run("test table engine config "+tt.name, func(t *testing.T) {
initClickhouseTestServer(t, func(query string, values []driver.Value) error {
initClickhouseTestServer(t, func(query string, _ []driver.Value) error {
firstLine := getQueryFirstLine(query)
if !strings.HasPrefix(strings.ToLower(firstLine), "create table") {
return nil
Expand Down
Expand Up @@ -186,7 +186,7 @@ func TestPushMetadata(t *testing.T) {
}

handler := http.NewServeMux()
handler.HandleFunc("/intake", func(w http.ResponseWriter, r *http.Request) {
handler.HandleFunc("/intake", func(_ http.ResponseWriter, r *http.Request) {
assert.Equal(t, r.Header.Get("DD-Api-Key"), "apikey")
assert.Equal(t, r.Header.Get("User-Agent"), "otelcontribcol/1.0")

Expand Down
8 changes: 4 additions & 4 deletions exporter/datadogexporter/internal/testutil/test_utils.go
Expand Up @@ -55,7 +55,7 @@ func DatadogServerMock(overwriteHandlerFuncs ...OverwriteHandleFunc) *DatadogSer
MetricV1Endpoint: metricsEndpoint,
MetricV2Endpoint: metricsV2Endpoint,
MetadataEndpoint: newMetadataEndpoint(metadataChan),
"/": func(w http.ResponseWriter, r *http.Request) {},
"/": func(_ http.ResponseWriter, _ *http.Request) {},
}
for _, f := range overwriteHandlerFuncs {
p, hf := f()
Expand Down Expand Up @@ -84,7 +84,7 @@ type HTTPRequestRecorder struct {
}

func (rec *HTTPRequestRecorder) HandlerFunc() (string, http.HandlerFunc) {
return rec.Pattern, func(w http.ResponseWriter, r *http.Request) {
return rec.Pattern, func(_ http.ResponseWriter, r *http.Request) {
rec.Header = r.Header
rec.ByteBody, _ = io.ReadAll(r.Body)
}
Expand All @@ -97,7 +97,7 @@ type HTTPRequestRecorderWithChan struct {
}

func (rec *HTTPRequestRecorderWithChan) HandlerFunc() (string, http.HandlerFunc) {
return rec.Pattern, func(w http.ResponseWriter, r *http.Request) {
return rec.Pattern, func(_ http.ResponseWriter, r *http.Request) {
bytesBody, _ := io.ReadAll(r.Body)
rec.ReqChan <- bytesBody
}
Expand Down Expand Up @@ -163,7 +163,7 @@ func metricsV2Endpoint(w http.ResponseWriter, _ *http.Request) {
}

func newMetadataEndpoint(c chan []byte) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
return func(_ http.ResponseWriter, r *http.Request) {
body, _ := io.ReadAll(r.Body)
c <- body
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/datadogexporter/traces_exporter_test.go
Expand Up @@ -120,7 +120,7 @@ func TestTracesSource(t *testing.T) {
assert.NoError(t, err)
}))
defer metricsServer.Close()
tracesServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
tracesServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
rw.WriteHeader(http.StatusAccepted)
}))
defer tracesServer.Close()
Expand Down
20 changes: 10 additions & 10 deletions exporter/dynatraceexporter/metrics_exporter_test.go
Expand Up @@ -351,7 +351,7 @@ func Test_SumMetrics(t *testing.T) {
}

func Test_exporter_PushMetricsData_EmptyPayload(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {
t.Fatal("Server should not be called")
}))
defer ts.Close()
Expand Down Expand Up @@ -383,7 +383,7 @@ func Test_exporter_PushMetricsData_EmptyPayload(t *testing.T) {
}

func Test_exporter_PushMetricsData_isDisabled(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {
t.Fatal("Server should not be called")
}))
defer ts.Close()
Expand Down Expand Up @@ -421,7 +421,7 @@ func Test_exporter_PushMetricsData_isDisabled(t *testing.T) {
}

func Test_exporter_send_BadRequest(t *testing.T) {
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.StatusBadRequest)
body, _ := json.Marshal(metricsResponse{
Ok: 0,
Expand Down Expand Up @@ -450,7 +450,7 @@ func Test_exporter_send_BadRequest(t *testing.T) {
}

func Test_exporter_send_Unauthorized(t *testing.T) {
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)
_, _ = w.Write([]byte{})
}))
Expand All @@ -475,7 +475,7 @@ func Test_exporter_send_Unauthorized(t *testing.T) {
}

func Test_exporter_send_TooLarge(t *testing.T) {
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.StatusRequestEntityTooLarge)
_, _ = w.Write([]byte{})
}))
Expand All @@ -500,7 +500,7 @@ func Test_exporter_send_TooLarge(t *testing.T) {
}

func Test_exporter_send_NotFound(t *testing.T) {
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(404)
_, _ = w.Write([]byte{})
}))
Expand Down Expand Up @@ -528,7 +528,7 @@ func Test_exporter_send_NotFound(t *testing.T) {
}

func Test_exporter_send_TooManyRequests(t *testing.T) {
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.StatusTooManyRequests)
_, _ = w.Write([]byte{})
}))
Expand All @@ -551,7 +551,7 @@ func Test_exporter_send_TooManyRequests(t *testing.T) {
}

func Test_exporter_send_MiscellaneousErrorCode(t *testing.T) {
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.StatusExpectationFailed)
_, _ = w.Write([]byte{})
}))
Expand All @@ -577,7 +577,7 @@ func Test_exporter_send_MiscellaneousErrorCode(t *testing.T) {
func Test_exporter_send_chunking(t *testing.T) {
sentChunks := 0

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.StatusBadRequest)
body, _ := json.Marshal(metricsResponse{
Ok: 0,
Expand Down Expand Up @@ -617,7 +617,7 @@ func Test_exporter_send_chunking(t *testing.T) {
}

func Test_exporter_PushMetricsData_Error(t *testing.T) {
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(200)
}))
ts.Close()
Expand Down
2 changes: 1 addition & 1 deletion exporter/elasticsearchexporter/logs_exporter_test.go
Expand Up @@ -357,7 +357,7 @@ func TestExporter_PushEvent(t *testing.T) {

t.Run("do not retry invalid request", func(t *testing.T) {
attempts := &atomic.Int64{}
server := newESTestServer(t, func(docs []itemRequest) ([]itemResponse, error) {
server := newESTestServer(t, func(_ []itemRequest) ([]itemResponse, error) {
attempts.Add(1)
return nil, &httpTestError{message: "oops", status: http.StatusBadRequest}
})
Expand Down
2 changes: 1 addition & 1 deletion exporter/elasticsearchexporter/traces_exporter_test.go
Expand Up @@ -338,7 +338,7 @@ func TestExporter_PushTraceRecord(t *testing.T) {

t.Run("do not retry invalid request", func(t *testing.T) {
attempts := &atomic.Int64{}
server := newESTestServer(t, func(docs []itemRequest) ([]itemResponse, error) {
server := newESTestServer(t, func(_ []itemRequest) ([]itemResponse, error) {
attempts.Add(1)
return nil, &httpTestError{message: "oops", status: http.StatusBadRequest}
})
Expand Down
2 changes: 1 addition & 1 deletion exporter/elasticsearchexporter/utils_test.go
Expand Up @@ -127,7 +127,7 @@ func (r *bulkRecorder) countItems() (count int) {
func newESTestServer(t *testing.T, bulkHandler bulkHandler) *httptest.Server {
mux := http.NewServeMux()

mux.HandleFunc("/", handleErr(func(w http.ResponseWriter, req *http.Request) error {
mux.HandleFunc("/", handleErr(func(w http.ResponseWriter, _ *http.Request) error {
w.Header().Add("X-Elastic-Product", "Elasticsearch")

enc := json.NewEncoder(w)
Expand Down
4 changes: 2 additions & 2 deletions exporter/honeycombmarkerexporter/logs_exporter_test.go
Expand Up @@ -227,7 +227,7 @@ func TestExportMarkers_Error(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
markerServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
markerServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
rw.WriteHeader(tt.responseCode)
}))
defer markerServer.Close()
Expand Down Expand Up @@ -277,7 +277,7 @@ func TestExportMarkers_NoAPICall(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
markerServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
markerServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
assert.Fail(t, "should not call the markers api")
rw.WriteHeader(http.StatusBadRequest) // 400
}))
Expand Down
4 changes: 2 additions & 2 deletions exporter/influxdbexporter/writer_test.go
Expand Up @@ -107,7 +107,7 @@ func Test_influxHTTPWriterBatch_maxPayload(t *testing.T) {
t.Run(testCase.name, func(t *testing.T) {
var httpRequests []*http.Request

mockHTTPService := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
mockHTTPService := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
httpRequests = append(httpRequests, r)
}))
t.Cleanup(mockHTTPService.Close)
Expand Down Expand Up @@ -149,7 +149,7 @@ func Test_influxHTTPWriterBatch_maxPayload(t *testing.T) {
func Test_influxHTTPWriterBatch_EnqueuePoint_emptyTagValue(t *testing.T) {
var recordedRequest *http.Request
var recordedRequestBody []byte
noopHTTPServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
noopHTTPServer := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
if assert.Nil(t, recordedRequest) {
recordedRequest = r
recordedRequestBody, _ = io.ReadAll(r.Body)
Expand Down
4 changes: 2 additions & 2 deletions exporter/instanaexporter/exporter_test.go
Expand Up @@ -21,7 +21,7 @@ import (
)

func TestPushConvertedTraces(t *testing.T) {
traceServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
traceServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
rw.WriteHeader(http.StatusAccepted)
}))
defer traceServer.Close()
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestSelfSignedBackend(t *testing.T) {
var err error
caFile := "testdata/ca.crt"
handler := http.NewServeMux()
handler.HandleFunc("/bundle", func(w http.ResponseWriter, r *http.Request) {
handler.HandleFunc("/bundle", func(w http.ResponseWriter, _ *http.Request) {
_, err = io.WriteString(w, "Hello from CA self signed server")

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion exporter/kafkaexporter/config_test.go
Expand Up @@ -35,7 +35,7 @@ func TestLoadConfig(t *testing.T) {
}{
{
id: component.NewIDWithName(metadata.Type, ""),
option: func(conf *Config) {
option: func(_ *Config) {
// intentionally left blank so we use default config
},
expected: &Config{
Expand Down
2 changes: 1 addition & 1 deletion exporter/kineticaexporter/metrics_exporter.go
Expand Up @@ -208,7 +208,7 @@ func createTablesForMetricType(ctx context.Context, metricTypeDDLs []string, kiW
schema = ""
}

lo.ForEach(metricTypeDDLs, func(ddl string, index int) {
lo.ForEach(metricTypeDDLs, func(ddl string, _ int) {

stmt := strings.ReplaceAll(ddl, "%s", schema)
kiWriter.logger.Debug("Creating Table - ", zap.String("DDL", stmt))
Expand Down