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

Bump github.com/golangci/golangci-lint from 1.55.2 to 1.59.1 and fix linter errors #5579

Merged
merged 9 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion cmd/agent/app/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestAgentSamplingEndpoint(t *testing.T) {
}

func TestAgentMetricsEndpoint(t *testing.T) {
withRunningAgent(t, func(httpAddr string, errorch chan error) {
withRunningAgent(t, func(httpAddr string, _ chan error) {
url := fmt.Sprintf("http://%s/metrics", httpAddr)
resp, err := http.Get(url)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func main() {
Use: "jaeger-agent",
Short: "(deprecated) Jaeger agent is a local daemon program which collects tracing data.",
Long: `(deprecated) Jaeger agent is a daemon program that runs on every host and receives tracing data submitted by Jaeger client libraries.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ /* args */ []string) error {
if err := svc.Start(v); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func main() {
Short: "Jaeger all-in-one distribution with agent, collector and query in one process.",
Long: `Jaeger all-in-one distribution with agent, collector and query. Use with caution this version
by default uses only in-memory database.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ /* args */ []string) error {
if err := svc.Start(v); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/anonymizer/app/anonymizer/anonymizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestAnonymizer_SaveMapping(t *testing.T) {
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
anonymizer := Anonymizer{
logger: nopLogger,
mapping: mapping,
Expand Down
2 changes: 1 addition & 1 deletion cmd/anonymizer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func main() {
Use: "jaeger-anonymizer",
Short: "Jaeger anonymizer hashes fields of a trace for easy sharing",
Long: `Jaeger anonymizer queries Jaeger query for a trace, anonymizes fields, and store in file`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ /* args */ []string) {
prefix := options.OutputDir + "/" + options.TraceID
conf := writer.Config{
MaxSpansCount: options.MaxSpansCount,
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (c *Collector) Start(options *flags.CollectorOptions) error {

var additionalProcessors []ProcessSpan
if c.aggregator != nil {
additionalProcessors = append(additionalProcessors, func(span *model.Span, tenant string) {
additionalProcessors = append(additionalProcessors, func(span *model.Span, _ /* tenant */ string) {
c.aggregator.HandleRootSpan(span, c.logger)
})
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/handler/otlp_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestStartOtlpReceiver_Error(t *testing.T) {
func TestProtoFromTracesError(t *testing.T) {
mockErr := errors.New("mock error")
c := &consumerDelegate{
protoFromTraces: func(td ptrace.Traces) ([]*model.Batch, error) {
protoFromTraces: func(_ ptrace.Traces) ([]*model.Batch, error) {
return nil, mockErr
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/collector/app/model_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
func TestChainedProcessSpan(t *testing.T) {
happened1 := false
happened2 := false
func1 := func(span *model.Span, tenant string) { happened1 = true }
func2 := func(span *model.Span, tenant string) { happened2 = true }
func1 := func(_ *model.Span, _ /* tenant */ string) { happened1 = true }
func2 := func(_ *model.Span, _ /* tenant */ string) { happened2 = true }
chained := ChainedProcessSpan(func1, func2)
chained(&model.Span{}, "")
assert.True(t, happened1)
Expand Down
6 changes: 3 additions & 3 deletions cmd/collector/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,16 @@ func (options) apply(opts ...Option) options {
ret.hostMetrics = metrics.NullFactory
}
if ret.preProcessSpans == nil {
ret.preProcessSpans = func(spans []*model.Span, tenant string) {}
ret.preProcessSpans = func(_ []*model.Span, _ /* tenant */ string) {}
}
if ret.sanitizer == nil {
ret.sanitizer = func(span *model.Span) *model.Span { return span }
}
if ret.preSave == nil {
ret.preSave = func(span *model.Span, tenant string) {}
ret.preSave = func(_ *model.Span, _ /* tenant */ string) {}
}
if ret.spanFilter == nil {
ret.spanFilter = func(span *model.Span) bool { return true }
ret.spanFilter = func(_ *model.Span) bool { return true }
}
if ret.numWorkers == 0 {
ret.numWorkers = flags.DefaultNumWorkers
Expand Down
8 changes: 4 additions & 4 deletions cmd/collector/app/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ func TestAllOptionSet(t *testing.T) {
Options.ReportBusy(true),
Options.BlockingSubmit(true),
Options.ExtraFormatTypes(types),
Options.SpanFilter(func(span *model.Span) bool { return true }),
Options.SpanFilter(func(_ *model.Span) bool { return true }),
Options.HostMetrics(metrics.NullFactory),
Options.ServiceMetrics(metrics.NullFactory),
Options.Logger(zap.NewNop()),
Options.NumWorkers(5),
Options.PreProcessSpans(func(spans []*model.Span, tenant string) {}),
Options.PreProcessSpans(func(_ []*model.Span, _ /* tenant */ string) {}),
Options.Sanitizer(func(span *model.Span) *model.Span { return span }),
Options.QueueSize(10),
Options.DynQueueSizeWarmup(1000),
Options.DynQueueSizeMemory(1024),
Options.PreSave(func(span *model.Span, tenant string) {}),
Options.PreSave(func(_ *model.Span, _ /* tenant */ string) {}),
Options.CollectorTags(map[string]string{"extra": "tags"}),
Options.SpanSizeMetricsEnabled(true),
Options.OnDroppedSpan(func(span *model.Span) {}),
Options.OnDroppedSpan(func(_ *model.Span) {}),
)
assert.EqualValues(t, 5, opts.numWorkers)
assert.EqualValues(t, 10, opts.queueSize)
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/server/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestFailServe(t *testing.T) {
Handler: handler.NewGRPCHandler(logger, &mockSpanProcessor{}, &tenancy.Manager{}),
SamplingStore: &mockSamplingStore{},
Logger: logger,
OnError: func(e error) {
OnError: func(_ error) {
assert.Len(t, logs.All(), 1)
assert.Equal(t, "Could not launch gRPC service", logs.All()[0].Message)
wg.Done()
Expand Down
4 changes: 2 additions & 2 deletions cmd/collector/app/span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func TestSpanProcessorCountSpan(t *testing.T) {
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
mb := metricstest.NewFactory(time.Hour)
defer mb.Backend.Stop()
m := mb.Namespace(metrics.NSOptions{})
Expand Down Expand Up @@ -635,7 +635,7 @@ func TestAdditionalProcessors(t *testing.T) {

// additional processor is called
count := 0
f := func(s *model.Span, t string) {
f := func(_ *model.Span, _ string) {
count++
}
p = NewSpanProcessor(w, []ProcessSpan{f}, Options.QueueSize(1))
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func main() {
Use: "jaeger-collector",
Short: "Jaeger collector receives and processes traces from Jaeger agents and clients",
Long: `Jaeger collector receives traces from Jaeger agents and runs them through a processing pipeline.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ /* args */ []string) error {
if err := svc.Start(v); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/es-index-cleaner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func main() {
Use: "jaeger-es-index-cleaner NUM_OF_DAYS http://HOSTNAME:PORT",
Short: "Jaeger es-index-cleaner removes Jaeger indices",
Long: "Jaeger es-index-cleaner removes Jaeger indices",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
if len(args) != 2 {
return fmt.Errorf("wrong number of arguments")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/es-rollover/app/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestExecuteAction(t *testing.T) {
Viper: v,
Logger: logger,
TLSFlags: tlsFlags,
}, func(c client.Client, cfg Config) Action {
}, func(c client.Client, _ Config) Action {
assert.Equal(t, "https://localhost:9300", c.Endpoint)
transport, ok := c.Client.Transport.(*http.Transport)
require.True(t, ok)
Expand Down
16 changes: 8 additions & 8 deletions cmd/es-rollover/app/init/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestRolloverAction(t *testing.T) {
}{
{
name: "Unsupported version",
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
setupCallExpectations: func(_ *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, _ *mocks.MockILMAPI) {
clusterClient.On("Version").Return(uint(5), nil)
},
config: Config{
Expand All @@ -110,7 +110,7 @@ func TestRolloverAction(t *testing.T) {
},
{
name: "error getting version",
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
setupCallExpectations: func(_ *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, _ *mocks.MockILMAPI) {
clusterClient.On("Version").Return(uint(0), errors.New("version error"))
},
expectedErr: errors.New("version error"),
Expand All @@ -123,7 +123,7 @@ func TestRolloverAction(t *testing.T) {
},
{
name: "ilm doesnt exist",
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
setupCallExpectations: func(_ *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
clusterClient.On("Version").Return(uint(7), nil)
ilmClient.On("Exists", "myilmpolicy").Return(false, nil)
},
Expand All @@ -138,7 +138,7 @@ func TestRolloverAction(t *testing.T) {
},
{
name: "fail get ilm policy",
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
setupCallExpectations: func(_ *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
clusterClient.On("Version").Return(uint(7), nil)
ilmClient.On("Exists", "myilmpolicy").Return(false, errors.New("error getting ilm policy"))
},
Expand All @@ -153,7 +153,7 @@ func TestRolloverAction(t *testing.T) {
},
{
name: "fail to create template",
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, _ *mocks.MockILMAPI) {
clusterClient.On("Version").Return(uint(7), nil)
indexClient.On("CreateTemplate", mock.Anything, "jaeger-span").Return(errors.New("error creating template"))
},
Expand All @@ -167,7 +167,7 @@ func TestRolloverAction(t *testing.T) {
},
{
name: "fail to get jaeger indices",
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, _ *mocks.MockILMAPI) {
clusterClient.On("Version").Return(uint(7), nil)
indexClient.On("CreateTemplate", mock.Anything, "jaeger-span").Return(nil)
indexClient.On("CreateIndex", "jaeger-span-archive-000001").Return(nil)
Expand All @@ -183,7 +183,7 @@ func TestRolloverAction(t *testing.T) {
},
{
name: "fail to create alias",
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, _ *mocks.MockILMAPI) {
clusterClient.On("Version").Return(uint(7), nil)
indexClient.On("CreateTemplate", mock.Anything, "jaeger-span").Return(nil)
indexClient.On("CreateIndex", "jaeger-span-archive-000001").Return(nil)
Expand All @@ -203,7 +203,7 @@ func TestRolloverAction(t *testing.T) {
},
{
name: "create rollover index",
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, ilmClient *mocks.MockILMAPI) {
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, clusterClient *mocks.MockClusterAPI, _ *mocks.MockILMAPI) {
clusterClient.On("Version").Return(uint(7), nil)
indexClient.On("CreateTemplate", mock.Anything, "jaeger-span").Return(nil)
indexClient.On("CreateIndex", "jaeger-span-archive-000001").Return(nil)
Expand Down
2 changes: 1 addition & 1 deletion cmd/es-rollover/app/rollover/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestRolloverAction(t *testing.T) {
unmarshalErrExpected: true,
createAliasErr: errors.New("unable to create alias"),
indices: readIndices,
setupCallExpectations: func(indexClient *mocks.MockIndexAPI, test *testCase) {},
setupCallExpectations: func(_ *mocks.MockIndexAPI, _ *testCase) {},
},
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/es-rollover/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func main() {
Long: "creates indices and aliases",
Args: cobra.ExactArgs(1),
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return app.ExecuteAction(app.ActionExecuteOptions{
Args: args,
Viper: v,
Expand Down Expand Up @@ -88,7 +88,7 @@ func main() {
Short: "rollover to new write index",
Long: "rollover to new write index",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
rolloverCfg.InitFromViper(v)
return app.ExecuteAction(app.ActionExecuteOptions{
Args: args,
Expand Down Expand Up @@ -117,7 +117,7 @@ func main() {
Short: "removes old indices from read alias",
Long: "removes old indices from read alias",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
lookbackCfg.InitFromViper(v)
return app.ExecuteAction(app.ActionExecuteOptions{
Args: args,
Expand Down
2 changes: 1 addition & 1 deletion cmd/esmapping-generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {
Use: "jaeger-esmapping-generator",
Short: "Jaeger esmapping-generator prints rendered mappings as string",
Long: `Jaeger esmapping-generator renders passed templates with provided values and prints rendered output to stdout`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ /* args */ []string) {
if !renderer.IsValidOption(options.Mapping) {
logger.Fatal("please pass either 'jaeger-service' or 'jaeger-span' as argument")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/ingester/app/consumer/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func newSaramaClusterConsumer(saramaPartitionConsumer sarama.PartitionConsumer,
}
saramaClusterConsumer := &kmocks.Consumer{}
saramaClusterConsumer.On("Partitions").Return((<-chan cluster.PartitionConsumer)(pcha))
saramaClusterConsumer.On("Close").Return(nil).Run(func(args mock.Arguments) {
saramaClusterConsumer.On("Close").Return(nil).Run(func(_ mock.Arguments) {
mc.Close()
close(pcha)
})
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestSaramaConsumerWrapper_start_Messages(t *testing.T) {
isProcessed := sync.WaitGroup{}
isProcessed.Add(1)
mp := &pmocks.SpanProcessor{}
mp.On("Process", saramaMessageWrapper{msg}).Return(func(msg processor.Message) error {
mp.On("Process", saramaMessageWrapper{msg}).Return(func(_ processor.Message) error {
isProcessed.Done()
return nil
})
Expand Down
8 changes: 4 additions & 4 deletions cmd/ingester/app/consumer/deadlock_detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestPanicForPartition(*testing.T) {
metricsFactory: metricstest.NewFactory(0),
logger: l,
interval: 1,
panicFunc: func(partition int32) {
panicFunc: func(_ /* partition */ int32) {
wg.Done()
},
}
Expand All @@ -104,7 +104,7 @@ func TestGlobalPanic(*testing.T) {
metricsFactory: metricstest.NewFactory(0),
logger: l,
interval: 1,
panicFunc: func(partition int32) {
panicFunc: func(_ /* partition */ int32) {
wg.Done()
},
}
Expand All @@ -119,7 +119,7 @@ func TestNoGlobalPanicIfDeadlockDetectorDisabled(t *testing.T) {
metricsFactory: metricstest.NewFactory(0),
logger: l,
interval: 0,
panicFunc: func(partition int32) {
panicFunc: func(_ /* partition */ int32) {
t.Errorf("Should not panic when deadlock detector is disabled")
},
}
Expand All @@ -137,7 +137,7 @@ func TestNoPanicForPartitionIfDeadlockDetectorDisabled(t *testing.T) {
metricsFactory: metricstest.NewFactory(0),
logger: l,
interval: 0,
panicFunc: func(partition int32) {
panicFunc: func(_ /* partition */ int32) {
t.Errorf("Should not panic when deadlock detector is disabled")
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ingester/app/consumer/offset/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestHandleReset(t *testing.T) {
func TestCache(t *testing.T) {
offset := int64(1498)

fakeMarker := func(offset int64) {
fakeMarker := func(_ /* offset */ int64) {
assert.Fail(t, "Shouldn't mark cached offset")
}
manager := NewManager(offset, fakeMarker, "test_topic", 1, metrics.NullFactory)
Expand Down
2 changes: 1 addition & 1 deletion cmd/ingester/app/processor/decorator/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func Test_ProcessBackoff(t *testing.T) {
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
rd := &retryDecorator{
retryAttempts: metrics.NullCounter,
options: retryOptions{
Expand Down
2 changes: 1 addition & 1 deletion cmd/ingester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func main() {
Use: "jaeger-ingester",
Short: "Jaeger ingester consumes from Kafka and writes to storage.",
Long: `Jaeger ingester consumes spans from a particular Kafka topic and writes them to a configured storage.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ /* args */ []string) error {
if err := svc.Start(v); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/docs/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Command(v *viper.Viper) *cobra.Command {
Use: "docs",
Short: "Generates documentation",
Long: `Generates command and flags documentation`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ /* args */ []string) error {
for cmd.Parent() != nil {
cmd = cmd.Parent()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/env/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func Command() *cobra.Command {
Use: "env",
Short: "Help about environment variables.",
Long: long,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ /* args */ []string) {
fmt.Fprint(cmd.OutOrStdout(), long)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/flags/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestAdminServerHandlesPortZero(t *testing.T) {
onlyEntry := message.All()[0]
hostPort := onlyEntry.ContextMap()["http.host-port"].(string)
port, _ := strconv.Atoi(strings.Split(hostPort, ":")[3])
assert.Greater(t, port, 0)
assert.Positive(t, port, 0)
FlamingSaint marked this conversation as resolved.
Show resolved Hide resolved
}

func TestAdminHealthCheck(t *testing.T) {
Expand Down
Loading
Loading