Skip to content

Commit

Permalink
Enable Lint Rule: unused-parameter (jaegertracing#5534)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
-  Partial Fix for jaegertracing#5506

## Description of the changes
- Enabled unused-parameter in revive linter
- Removed or replaced unused parameters with ( _ )
- Added comments for unclear parameters 

## How was this change tested?
- `make lint` `make test`

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`
  -

---------

Signed-off-by: FlamingSaint <[email protected]>
  • Loading branch information
FlamingSaint authored Jun 7, 2024
1 parent 2773ecd commit 3d4b6b6
Show file tree
Hide file tree
Showing 95 changed files with 157 additions and 160 deletions.
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ linters-settings:
# not sure how different from previous one
- name: cyclomatic
disabled: true
# do a clean-up and enable
- name: unused-parameter
disabled: true
# we use storage_v2, so...
- name: var-naming
disabled: true
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/app/processors/thrift_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type failingHandler struct {
err error
}

func (h failingHandler) Process(_ context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
func (h failingHandler) Process(context.Context, thrift.TProtocol /* iprot */, thrift.TProtocol /* oprot */) (success bool, err thrift.TException) {
return false, thrift.NewTApplicationException(0, h.err.Error())
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/app/reporter/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func AddFlags(flags *flag.FlagSet) {
}

// InitFromViper initializes Options with properties retrieved from Viper.
func (b *Options) InitFromViper(v *viper.Viper, logger *zap.Logger) *Options {
func (b *Options) InitFromViper(v *viper.Viper, _ *zap.Logger) *Options {
b.ReporterType = Type(v.GetString(reporterType))
if !setupcontext.IsAllInOne() {
if len(v.GetString(agentTags)) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/app/reporter/grpc/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (h *mockSpanHandler) getRequests() []*api_v2.PostSpansRequest {
return h.requests
}

func (h *mockSpanHandler) PostSpans(c context.Context, r *api_v2.PostSpansRequest) (*api_v2.PostSpansResponse, error) {
func (h *mockSpanHandler) PostSpans(_ context.Context, r *api_v2.PostSpansRequest) (*api_v2.PostSpansResponse, error) {
h.mux.Lock()
defer h.mux.Unlock()
h.requests = append(h.requests, r)
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestReporter_MakeModelKeyValue(t *testing.T) {

type mockMultitenantSpanHandler struct{}

func (*mockMultitenantSpanHandler) PostSpans(ctx context.Context, r *api_v2.PostSpansRequest) (*api_v2.PostSpansResponse, error) {
func (*mockMultitenantSpanHandler) PostSpans(ctx context.Context, _ *api_v2.PostSpansRequest) (*api_v2.PostSpansResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return &api_v2.PostSpansResponse{}, status.Errorf(codes.PermissionDenied, "missing tenant header")
Expand Down
6 changes: 3 additions & 3 deletions cmd/collector/app/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ type mockAggregator struct {
closeCount atomic.Int32
}

func (t *mockAggregator) RecordThroughput(service, operation string, samplerType model.SamplerType, probability float64) {
func (t *mockAggregator) RecordThroughput(string /* service */, string /* operation */, model.SamplerType, float64 /* probability */) {
t.callCount.Add(1)
}

func (t *mockAggregator) HandleRootSpan(span *model.Span, logger *zap.Logger) {
func (t *mockAggregator) HandleRootSpan(*model.Span, *zap.Logger) {
t.callCount.Add(1)
}

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

type mockStrategyStore struct{}

func (*mockStrategyStore) GetSamplingStrategy(_ context.Context, serviceName string) (*api_v2.SamplingStrategyResponse, error) {
func (*mockStrategyStore) GetSamplingStrategy(context.Context, string /* serviceName */) (*api_v2.SamplingStrategyResponse, error) {
return &api_v2.SamplingStrategyResponse{}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/collector/app/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func addGRPCFlags(flags *flag.FlagSet, cfg serverFlagsConfig, defaultHostPort st
cfg.tls.AddFlags(flags)
}

func (opts *HTTPOptions) initFromViper(v *viper.Viper, logger *zap.Logger, cfg serverFlagsConfig) error {
func (opts *HTTPOptions) initFromViper(v *viper.Viper, _ *zap.Logger, cfg serverFlagsConfig) error {
opts.HostPort = ports.FormatHostPort(v.GetString(cfg.prefix + "." + flagSuffixHostPort))
opts.IdleTimeout = v.GetDuration(cfg.prefix + "." + flagSuffixHTTPIdleTimeout)
opts.ReadTimeout = v.GetDuration(cfg.prefix + "." + flagSuffixHTTPReadTimeout)
Expand All @@ -247,7 +247,7 @@ func (opts *HTTPOptions) initFromViper(v *viper.Viper, logger *zap.Logger, cfg s
return nil
}

func (opts *GRPCOptions) initFromViper(v *viper.Viper, logger *zap.Logger, cfg serverFlagsConfig) error {
func (opts *GRPCOptions) initFromViper(v *viper.Viper, _ *zap.Logger, cfg serverFlagsConfig) error {
opts.HostPort = ports.FormatHostPort(v.GetString(cfg.prefix + "." + flagSuffixHostPort))
opts.MaxReceiveMessageLength = v.GetInt(cfg.prefix + "." + flagSuffixGRPCMaxReceiveMessageLength)
opts.MaxConnectionAge = v.GetDuration(cfg.prefix + "." + flagSuffixGRPCMaxConnectionAge)
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/handler/http_thrift_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func TestCannotReadBodyFromRequest(t *testing.T) {

type errReader struct{}

func (*errReader) Read(p []byte) (int, error) {
func (*errReader) Read([]byte) (int, error) {
return 0, fmt.Errorf("Simulated error reading body")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/sampling/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

type mockSamplingStore struct{}

func (mockSamplingStore) GetSamplingStrategy(ctx context.Context, serviceName string) (*api_v2.SamplingStrategyResponse, error) {
func (mockSamplingStore) GetSamplingStrategy(_ context.Context, serviceName string) (*api_v2.SamplingStrategyResponse, error) {
if serviceName == "error" {
return nil, errors.New("some error")
} else if serviceName == "nil" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/sanitizer/cache/auto_refresh_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *autoRefreshCache) Get(key string) string {
}

// Put implementation that does nothing
func (*autoRefreshCache) Put(key string, value string) error {
func (*autoRefreshCache) Put(string /* key */, string /* value */) error {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var (
// dont_go:generate mockery -name=ServiceAliasMappingStorage
// dont_go:generate mockery -name=ServiceAliasMappingExternalSource

func getCache(t *testing.T) (*autoRefreshCache, *mocks.ServiceAliasMappingExternalSource, *mocks.ServiceAliasMappingStorage) {
func getCache(*testing.T) (*autoRefreshCache, *mocks.ServiceAliasMappingExternalSource, *mocks.ServiceAliasMappingStorage) {
mockExtSource := &mocks.ServiceAliasMappingExternalSource{}
mockStorage := &mocks.ServiceAliasMappingStorage{}
logger := zap.NewNop()
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/sanitizer/sanitizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/jaegertracing/jaeger/model"
)

func TestNewStandardSanitizers(t *testing.T) {
func TestNewStandardSanitizers(*testing.T) {
NewStandardSanitizers()
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/sanitizer/service_name_sanitizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (d *fixedMappingCache) Get(key string) string {
return k
}

func (*fixedMappingCache) Put(key string, value string) error {
func (*fixedMappingCache) Put(string /* key */, string /* value */) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/sanitizer/zipkin/span_sanitizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
positiveDuration = int64(1)
)

func TestNewStandardSanitizers(t *testing.T) {
func TestNewStandardSanitizers(*testing.T) {
NewStandardSanitizers()
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/collector/app/server/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

type mockSamplingStore struct{}

func (mockSamplingStore) GetSamplingStrategy(_ context.Context, serviceName string) (*api_v2.SamplingStrategyResponse, error) {
func (mockSamplingStore) GetSamplingStrategy(context.Context, string /* serviceName */) (*api_v2.SamplingStrategyResponse, error) {
return nil, nil
}

Expand All @@ -38,6 +38,6 @@ func (*mockSpanProcessor) Close() error {
return nil
}

func (*mockSpanProcessor) ProcessSpans(spans []*model.Span, _ processor.SpansOptions) ([]bool, error) {
func (*mockSpanProcessor) ProcessSpans([]*model.Span, processor.SpansOptions) ([]bool, error) {
return []bool{}, nil
}
2 changes: 1 addition & 1 deletion cmd/collector/app/span_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (sp *spanProcessor) saveSpan(span *model.Span, tenant string) {
sp.metrics.SaveLatency.Record(time.Since(startTime))
}

func (sp *spanProcessor) countSpan(span *model.Span, tenant string) {
func (sp *spanProcessor) countSpan(span *model.Span, _ string /* tenant */) {
sp.bytesProcessed.Add(uint64(span.Size()))
sp.spansProcessed.Add(1)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ type blockingWriter struct {
inWriteSpan atomic.Int32
}

func (w *blockingWriter) WriteSpan(ctx context.Context, span *model.Span) error {
func (w *blockingWriter) WriteSpan(context.Context, *model.Span) error {
w.inWriteSpan.Add(1)
w.Lock()
defer w.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion cmd/ingester/app/consumer/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func newSaramaClusterConsumer(saramaPartitionConsumer sarama.PartitionConsumer,
func newConsumer(
t *testing.T,
metricsFactory metrics.Factory,
topic string,
_ string, /* topic */
processor processor.SpanProcessor,
consumer consumer.Consumer,
) *Consumer {
Expand Down
4 changes: 2 additions & 2 deletions cmd/ingester/app/consumer/deadlock_detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestPanicFunc(t *testing.T) {
})
}

func TestPanicForPartition(t *testing.T) {
func TestPanicForPartition(*testing.T) {
l, _ := zap.NewDevelopment()
wg := sync.WaitGroup{}
wg.Add(1)
Expand All @@ -96,7 +96,7 @@ func TestPanicForPartition(t *testing.T) {
wg.Wait()
}

func TestGlobalPanic(t *testing.T) {
func TestGlobalPanic(*testing.T) {
l, _ := zap.NewDevelopment()
wg := sync.WaitGroup{}
wg.Add(1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/flags/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/jaegertracing/jaeger/pkg/healthcheck"
)

func TestAddFlags(t *testing.T) {
func TestAddFlags(*testing.T) {
s := NewService(0)
s.AddFlags(new(flag.FlagSet))

Expand Down
4 changes: 2 additions & 2 deletions cmd/internal/status/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func readyHandler(w http.ResponseWriter, r *http.Request) {
func readyHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("{\"status\":\"Server available\"}"))
}

func unavailableHandler(w http.ResponseWriter, r *http.Request) {
func unavailableHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusServiceUnavailable)
w.Write([]byte("{\"status\":\"Server not available\"}"))
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (*server) Dependencies() []component.ID {
return []component.ID{jaegerstorage.ID}
}

func (s *server) Start(ctx context.Context, host component.Host) error {
func (s *server) Start(_ context.Context, host component.Host) error {
f, err := jaegerstorage.GetStorageFactory(s.config.TraceStoragePrimary, host)
if err != nil {
return fmt.Errorf("cannot find primary storage %s: %w", s.config.TraceStoragePrimary, err)
Expand Down
6 changes: 3 additions & 3 deletions cmd/jaeger/internal/extension/jaegerquery/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ func (fakeStorageExt) Factory(name string) (storage.Factory, bool) {
return fakeFactory{name: name}, true
}

func (fakeStorageExt) Start(ctx context.Context, host component.Host) error {
func (fakeStorageExt) Start(context.Context, component.Host) error {
return nil
}

func (fakeStorageExt) Shutdown(ctx context.Context) error {
func (fakeStorageExt) Shutdown(context.Context) error {
return nil
}

type storageHost struct {
extension component.Component
}

func (storageHost) ReportFatalError(err error) {
func (storageHost) ReportFatalError(error) {
}

func (host storageHost) GetExtensions() map[component.ID]component.Component {
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/extension/jaegerstorage/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (s *storageExt) Start(ctx context.Context, host component.Host) error {
return nil
}

func (s *storageExt) Shutdown(ctx context.Context) error {
func (s *storageExt) Shutdown(context.Context) error {
var errs []error
for _, factory := range s.factories {
if closer, ok := factory.(io.Closer); ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type errorFactory struct {
closeErr error
}

func (errorFactory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error {
func (errorFactory) Initialize(metrics.Factory, *zap.Logger) error {
panic("not implemented")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func createDefaultConfig() component.Config {
return &Config{}
}

func createTracesReceiver(ctx context.Context, set receiver.CreateSettings, config component.Config, nextConsumer consumer.Traces) (receiver.Traces, error) {
func createTracesReceiver(_ context.Context, set receiver.CreateSettings, config component.Config, nextConsumer consumer.Traces) (receiver.Traces, error) {
cfg := config.(*Config)

return newTracesReceiver(cfg, set, nextConsumer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ type mockStorageExt struct {
factory *factoryMocks.Factory
}

func (*mockStorageExt) Start(ctx context.Context, host component.Host) error {
func (*mockStorageExt) Start(context.Context, component.Host) error {
panic("not implemented")
}

func (*mockStorageExt) Shutdown(ctx context.Context) error {
func (*mockStorageExt) Shutdown(context.Context) error {
panic("not implemented")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/integration/span_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,6 @@ func (r *spanReader) FindTraces(ctx context.Context, query *spanstore.TraceQuery
return traces, nil
}

func (*spanReader) FindTraceIDs(ctx context.Context, query *spanstore.TraceQueryParameters) ([]model.TraceID, error) {
func (*spanReader) FindTraceIDs(context.Context, *spanstore.TraceQueryParameters) ([]model.TraceID, error) {
panic("not implemented")
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newStorageCleaner(config *Config, telemetrySettings component.TelemetrySett
}
}

func (c *storageCleaner) Start(ctx context.Context, host component.Host) error {
func (c *storageCleaner) Start(_ context.Context, host component.Host) error {
storageFactory, err := jaegerstorage.GetStorageFactory(c.config.TraceStorage, host)
if err != nil {
return fmt.Errorf("cannot find storage factory '%s': %w", c.config.TraceStorage, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ type mockStorageExt struct {
factory storage.Factory
}

func (*mockStorageExt) Start(ctx context.Context, host component.Host) error {
func (*mockStorageExt) Start(context.Context, component.Host) error {
panic("not implemented")
}

func (*mockStorageExt) Shutdown(ctx context.Context) error {
func (*mockStorageExt) Shutdown(context.Context) error {
panic("not implemented")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/query/app/apiv3/http_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (h *HTTPGateway) addRoute(
router *mux.Router,
f func(http.ResponseWriter, *http.Request),
route string,
args ...any,
_ ...any, /* args */
) *mux.Route {
var handler http.Handler = http.HandlerFunc(f)
if h.TenancyMgr.Enabled {
Expand Down
2 changes: 1 addition & 1 deletion cmd/query/app/apiv3/http_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

func setupHTTPGatewayNoServer(
t *testing.T,
_ *testing.T,
basePath string,
tenancyOptions tenancy.Options,
) *testGateway {
Expand Down
2 changes: 1 addition & 1 deletion cmd/query/app/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (g *GRPCHandler) sendSpanChunks(spans []*model.Span, sendFn func(*api_v2.Sp
}

// GetServices is the gRPC handler to fetch services.
func (g *GRPCHandler) GetServices(ctx context.Context, r *api_v2.GetServicesRequest) (*api_v2.GetServicesResponse, error) {
func (g *GRPCHandler) GetServices(ctx context.Context, _ *api_v2.GetServicesRequest) (*api_v2.GetServicesResponse, error) {
services, err := g.queryService.GetServices(ctx)
if err != nil {
g.logger.Error("failed to fetch services", zap.Error(err))
Expand Down
2 changes: 1 addition & 1 deletion cmd/query/app/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ type httpResponseErrWriter struct{}
func (*httpResponseErrWriter) Write([]byte) (int, error) {
return 0, fmt.Errorf("failed to write")
}
func (*httpResponseErrWriter) WriteHeader(statusCode int) {}
func (*httpResponseErrWriter) WriteHeader(int /* statusCode */) {}
func (*httpResponseErrWriter) Header() http.Header {
return http.Header{}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/query/app/internal/api_v3/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (td *TracesData) Marshal() ([]byte, error) {
}

// MarshalTo implements gogocodec.CustomType.
func (*TracesData) MarshalTo(data []byte) (n int, err error) {
func (*TracesData) MarshalTo([]byte /* data */) (n int, err error) {
// TODO unclear when this might be called, perhaps when type is embedded inside other structs.
panic("unimplemented")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/query/app/querysvc/query_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ type fakeStorageFactory2 struct {
wErr error
}

func (*fakeStorageFactory1) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error {
func (*fakeStorageFactory1) Initialize(metrics.Factory, *zap.Logger) error {
return nil
}
func (*fakeStorageFactory1) CreateSpanReader() (spanstore.Reader, error) { return nil, nil }
Expand Down
Loading

0 comments on commit 3d4b6b6

Please sign in to comment.