Skip to content

Commit

Permalink
[chore] addressing lint issues
Browse files Browse the repository at this point in the history
Updating golangci-lint raises many unused-parameter errors, this is addressing some of those.

Linked issue: open-telemetry#20424

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
Alex Boten committed May 29, 2023
1 parent d6c8a06 commit c485cde
Show file tree
Hide file tree
Showing 48 changed files with 79 additions and 83 deletions.
2 changes: 1 addition & 1 deletion cmd/configschema/docsgen/docsgen/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type fakeFilesystemWriter struct {
configFiles, fileContents []string
}

func (wr *fakeFilesystemWriter) writeFile(filename string, data []byte, perm os.FileMode) error {
func (wr *fakeFilesystemWriter) writeFile(filename string, data []byte, _ os.FileMode) error {
wr.configFiles = append(wr.configFiles, filename)
wr.fileContents = append(wr.fileContents, string(data))
return nil
Expand Down
10 changes: 5 additions & 5 deletions cmd/telemetrygen/internal/metrics/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ type mockExporter struct {
rms []*metricdata.ResourceMetrics
}

func (m *mockExporter) Temporality(kind sdkmetric.InstrumentKind) metricdata.Temporality {
func (m *mockExporter) Temporality(_ sdkmetric.InstrumentKind) metricdata.Temporality {
return metricdata.DeltaTemporality
}

func (m *mockExporter) Aggregation(kind sdkmetric.InstrumentKind) aggregation.Aggregation {
func (m *mockExporter) Aggregation(_ sdkmetric.InstrumentKind) aggregation.Aggregation {
return aggregation.Default{}
}

func (m *mockExporter) Export(ctx context.Context, metrics *metricdata.ResourceMetrics) error {
func (m *mockExporter) Export(_ context.Context, metrics *metricdata.ResourceMetrics) error {
m.rms = append(m.rms, metrics)
return nil
}

func (m *mockExporter) ForceFlush(ctx context.Context) error {
func (m *mockExporter) ForceFlush(_ context.Context) error {
return nil
}

func (m *mockExporter) Shutdown(ctx context.Context) error {
func (m *mockExporter) Shutdown(_ context.Context) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions exporter/datadogexporter/zaplogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
type zaplogger struct{ logger *zap.Logger }

// Trace implements Logger.
func (z *zaplogger) Trace(v ...interface{}) { /* N/A */ }
func (z *zaplogger) Trace(_ ...interface{}) { /* N/A */ }

// Tracef implements Logger.
func (z *zaplogger) Tracef(format string, params ...interface{}) { /* N/A */ }
func (z *zaplogger) Tracef(_ string, _ ...interface{}) { /* N/A */ }

// Debug implements Logger.
func (z *zaplogger) Debug(v ...interface{}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ConvertAllConverter struct {
logger *zap.Logger
}

func (c *ConvertAllConverter) AcceptsSpans(attributes pcommon.Map, spanSlice ptrace.SpanSlice) bool {
func (c *ConvertAllConverter) AcceptsSpans(_ pcommon.Map, _ ptrace.SpanSlice) bool {
return true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ type SpanConverter struct {
logger *zap.Logger
}

func (c *SpanConverter) AcceptsSpans(attributes pcommon.Map, spanSlice ptrace.SpanSlice) bool {

func (c *SpanConverter) AcceptsSpans(_ pcommon.Map, _ ptrace.SpanSlice) bool {
return true
}

Expand Down
2 changes: 1 addition & 1 deletion exporter/jaegerexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func TestConnectionStateChange(t *testing.T) {
assert.Equal(t, connectivity.Ready, state)
}

func TestConnectionReporterEndsOnStopped(t *testing.T) {
func TestConnectionReporterEndsOnStopped(_ *testing.T) {
sr := &mockStateReporter{
state: connectivity.Connecting,
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/loadbalancingexporter/resolver_dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (r *dnsResolver) start(ctx context.Context) error {
return nil
}

func (r *dnsResolver) shutdown(ctx context.Context) error {
func (r *dnsResolver) shutdown(_ context.Context) error {
r.changeCallbackLock.Lock()
r.onChangeCallbacks = nil
r.changeCallbackLock.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion exporter/loadbalancingexporter/resolver_static.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (r *staticResolver) start(ctx context.Context) error {
return err
}

func (r *staticResolver) shutdown(ctx context.Context) error {
func (r *staticResolver) shutdown(_ context.Context) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion exporter/lokiexporter/internal/tenant/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ContextTenantSource struct {
Key string
}

func (ts *ContextTenantSource) GetTenant(ctx context.Context, logs plog.Logs) (string, error) {
func (ts *ContextTenantSource) GetTenant(ctx context.Context, _ plog.Logs) (string, error) {
cl := client.FromContext(ctx)
ss := cl.Metadata.Get(ts.Key)

Expand Down
2 changes: 1 addition & 1 deletion exporter/lokiexporter/internal/tenant/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ type StaticTenantSource struct {
Value string
}

func (ts *StaticTenantSource) GetTenant(_ context.Context, logs plog.Logs) (string, error) {
func (ts *StaticTenantSource) GetTenant(_ context.Context, _ plog.Logs) (string, error) {
return ts.Value, nil
}
10 changes: 5 additions & 5 deletions exporter/parquetexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ type parquetExporter struct {
path string
}

func (e parquetExporter) start(ctx context.Context, host component.Host) error {
func (e parquetExporter) start(_ context.Context, _ component.Host) error {
return nil
}

func (e parquetExporter) shutdown(ctx context.Context) error {
func (e parquetExporter) shutdown(_ context.Context) error {
return nil
}

func (e parquetExporter) consumeMetrics(ctx context.Context, ld pmetric.Metrics) error {
func (e parquetExporter) consumeMetrics(_ context.Context, _ pmetric.Metrics) error {
return nil
}

func (e parquetExporter) consumeTraces(ctx context.Context, ld ptrace.Traces) error {
func (e parquetExporter) consumeTraces(_ context.Context, _ ptrace.Traces) error {
return nil
}

func (e parquetExporter) consumeLogs(ctx context.Context, ld plog.Logs) error {
func (e parquetExporter) consumeLogs(_ context.Context, _ plog.Logs) error {
return nil
}
2 changes: 1 addition & 1 deletion exporter/tanzuobservabilityexporter/trace_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (m *mockSender) SendSpan(
name string,
startMillis, durationMillis int64,
source, traceID, spanID string,
parents, followsFrom []string,
parents, _ []string,
spanTags []senders.SpanTag,
spanLogs []senders.SpanLog,
) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/aws/ecsutil/rest_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestRestClientFromClient(t *testing.T) {

type fakeErrorClient struct{}

func (f *fakeErrorClient) Get(path string) ([]byte, error) {
func (f *fakeErrorClient) Get(_ string) ([]byte, error) {
return nil, fmt.Errorf("")
}

Expand All @@ -52,7 +52,7 @@ func TestRestClientError(t *testing.T) {

type fakeMetadataErrorClient struct{}

func (f *fakeMetadataErrorClient) Get(path string) ([]byte, error) {
func (f *fakeMetadataErrorClient) Get(_ string) ([]byte, error) {
return nil, fmt.Errorf("")
}

Expand Down
4 changes: 2 additions & 2 deletions internal/aws/k8s/k8sclient/obj_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ func (s *ObjStore) ListKeys() []string {
}

// Get implements the Get method of the store interface.
func (s *ObjStore) Get(obj interface{}) (item interface{}, exists bool, err error) {
func (s *ObjStore) Get(_ interface{}) (item interface{}, exists bool, err error) {
return nil, false, nil
}

// GetByKey implements the GetByKey method of the store interface.
func (s *ObjStore) GetByKey(key string) (item interface{}, exists bool, err error) {
func (s *ObjStore) GetByKey(_ string) (item interface{}, exists bool, err error) {
return nil, false, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/aws/metrics/metric_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewFloat64DeltaCalculator() MetricCalculator {
return NewMetricCalculator(calculateDelta)
}

func calculateDelta(prev *MetricValue, val interface{}, timestamp time.Time) (interface{}, bool) {
func calculateDelta(prev *MetricValue, val interface{}, _ time.Time) (interface{}, bool) {
var deltaValue float64
if prev != nil {
deltaValue = val.(float64) - prev.RawValue.(float64)
Expand Down
2 changes: 1 addition & 1 deletion internal/metadataproviders/consul/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewProvider(client *api.Client, allowedLabels map[string]interface{}) Provi
return &consulMetadataImpl{consulClient: client, allowedLabels: allowedLabels}
}

func (d *consulMetadataImpl) Metadata(ctx context.Context) (*Metadata, error) {
func (d *consulMetadataImpl) Metadata(_ context.Context) (*Metadata, error) {
var metadata Metadata
self, err := d.consulClient.Agent().Self()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/fileconsumer/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (r *Reader) ReadToEnd(ctx context.Context) {
// consumeHeaderLine checks if the given token is a line of the header, and consumes it if it is.
// The return value dictates whether the given line was a header line or not.
// If false is returned, the full header can be assumed to be read.
func (r *Reader) consumeHeaderLine(ctx context.Context, attrs *FileAttributes, token []byte) {
func (r *Reader) consumeHeaderLine(ctx context.Context, _ *FileAttributes, token []byte) {
if !r.headerSettings.matchRegex.Match(token) {
// Finalize and cleanup the pipeline
r.HeaderFinalized = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ type Decorator interface {
type Option func(*Cadvisor)

// WithDecorator constructs an option for configuring the metric decorator
func WithDecorator(d interface{}) Option {
func WithDecorator(_ interface{}) Option {
return func(c *Cadvisor) {
// do nothing
}
}

func WithECSInfoCreator(f interface{}) Option {
func WithECSInfoCreator(_ interface{}) Option {
return func(c *Cadvisor) {
// do nothing
}
}

// New is a dummy function to construct a dummy Cadvisor struct for windows
func New(containerOrchestrator string, hostInfo HostInfo, logger *zap.Logger, options ...Option) (*Cadvisor, error) {
func New(_ string, _ HostInfo, _ *zap.Logger, _ ...Option) (*Cadvisor, error) {
return &Cadvisor{}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ func (c *MockCgroupScanner) getMemReserved() int64 {
return c.memReserved
}

func (c *MockCgroupScanner) getCPUReservedInTask(taskID string, clusterName string) int64 {
func (c *MockCgroupScanner) getCPUReservedInTask(_ string, _ string) int64 {
return int64(10)
}

func (c *MockCgroupScanner) getMEMReservedInTask(taskID string, clusterName string, containers []ECSContainer) int64 {
func (c *MockCgroupScanner) getMEMReservedInTask(_ string, _ string, _ []ECSContainer) int64 {
return int64(512)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type mockHTTPClient struct {
err error
}

func (m *mockHTTPClient) Do(reqest *http.Request) (*http.Response, error) {
func (m *mockHTTPClient) Do(_ *http.Request) (*http.Response, error) {
return m.response, m.err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type mockMetadataClient struct {
count int
}

func (m *mockMetadataClient) GetInstanceIdentityDocumentWithContext(ctx context.Context) (awsec2metadata.EC2InstanceIdentityDocument, error) {
func (m *mockMetadataClient) GetInstanceIdentityDocumentWithContext(_ context.Context) (awsec2metadata.EC2InstanceIdentityDocument, error) {
m.count++
if m.count == 1 {
return awsec2metadata.EC2InstanceIdentityDocument{}, errors.New("error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type mockEC2TagsClient struct {
containerOrchestrator string
}

func (m *mockEC2TagsClient) DescribeTagsWithContext(ctx context.Context, input *ec2.DescribeTagsInput,
opts ...request.Option) (*ec2.DescribeTagsOutput, error) {
func (m *mockEC2TagsClient) DescribeTagsWithContext(_ context.Context, _ *ec2.DescribeTagsInput,
_ ...request.Option) (*ec2.DescribeTagsOutput, error) {
m.count++
if m.count == 1 {
return &ec2.DescribeTagsOutput{}, errors.New("error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (m *mockEC2Metadata) getRegion() string {
type mockEBSVolume struct {
}

func (m *mockEBSVolume) getEBSVolumeID(devName string) string {
func (m *mockEBSVolume) getEBSVolumeID(_ string) string {
return "ebs-volume-id"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ func (client *MockClient) ServiceToPodNum() map[k8sclient.Service]int {
type mockEventBroadcaster struct {
}

func (m *mockEventBroadcaster) StartRecordingToSink(sink record.EventSink) watch.Interface {
func (m *mockEventBroadcaster) StartRecordingToSink(_ record.EventSink) watch.Interface {
return watch.NewFake()
}

func (m *mockEventBroadcaster) StartLogging(logf func(format string, args ...interface{})) watch.Interface {
func (m *mockEventBroadcaster) StartLogging(_ func(format string, args ...interface{})) watch.Interface {
return watch.NewFake()
}

func (m *mockEventBroadcaster) NewRecorder(scheme *runtime.Scheme, source v1.EventSource) record.EventRecorder {
func (m *mockEventBroadcaster) NewRecorder(_ *runtime.Scheme, _ v1.EventSource) record.EventRecorder {
return record.NewFakeRecorder(100)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (s *ServiceStore) RefreshTick(ctx context.Context) {

// Decorate decorates metrics and update kubernetesBlob
// service info is not mandatory
func (s *ServiceStore) Decorate(ctx context.Context, metric CIMetric, _ map[string]interface{}) bool {
func (s *ServiceStore) Decorate(_ context.Context, metric CIMetric, _ map[string]interface{}) bool {
if metric.HasTag(ci.K8sPodNameKey) {
podKey := createPodKeyFromMetric(metric)
if podKey == "" {
Expand Down
2 changes: 1 addition & 1 deletion receiver/awsecscontainermetricsreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func createDefaultConfig() component.Config {

// CreateMetricsReceiver creates an AWS ECS Container Metrics receiver.
func createMetricsReceiver(
ctx context.Context,
_ context.Context,
params receiver.CreateSettings,
baseCfg component.Config,
consumer consumer.Metrics,
Expand Down
2 changes: 1 addition & 1 deletion receiver/awsecscontainermetricsreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func newAWSECSContainermetrics(
}

// Start begins collecting metrics from Amazon ECS task metadata endpoint.
func (aecmr *awsEcsContainerMetricsReceiver) Start(ctx context.Context, host component.Host) error {
func (aecmr *awsEcsContainerMetricsReceiver) Start(ctx context.Context, _ component.Host) error {
ctx, aecmr.cancel = context.WithCancel(ctx)
go func() {
ticker := time.NewTicker(aecmr.config.CollectionInterval)
Expand Down
2 changes: 1 addition & 1 deletion receiver/awsecscontainermetricsreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestCollectDataFromEndpointWithConsumerError(t *testing.T) {
type invalidFakeClient struct {
}

func (f invalidFakeClient) GetResponse(path string) ([]byte, error) {
func (f invalidFakeClient) GetResponse(_ string) ([]byte, error) {
return nil, fmt.Errorf("intentional error")
}

Expand Down
2 changes: 1 addition & 1 deletion receiver/awsxrayreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func createDefaultConfig() component.Config {
}

func createTracesReceiver(
ctx context.Context,
_ context.Context,
params receiver.CreateSettings,
cfg component.Config,
consumer consumer.Traces) (receiver.Traces, error) {
Expand Down
4 changes: 2 additions & 2 deletions receiver/awsxrayreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (m *mockPoller) SegmentsChan() <-chan udppoller.RawSegment {
return make(chan udppoller.RawSegment, 1)
}

func (m *mockPoller) Start(ctx context.Context) {}
func (m *mockPoller) Start(_ context.Context) {}

func (m *mockPoller) Close() error {
if m.closeErr != nil {
Expand All @@ -272,7 +272,7 @@ func (m *mockProxy) ListenAndServe() error {
return errors.New("returning from ListenAndServe() always errors out")
}

func (m *mockProxy) Shutdown(ctx context.Context) error {
func (m *mockProxy) Shutdown(_ context.Context) error {
if m.closeErr != nil {
return m.closeErr
}
Expand Down
4 changes: 2 additions & 2 deletions receiver/azureblobreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (f *blobReceiverFactory) createDefaultConfig() component.Config {
}

func (f *blobReceiverFactory) createLogsReceiver(
ctx context.Context,
_ context.Context,
set receiver.CreateSettings,
cfg component.Config,
nextConsumer consumer.Logs,
Expand All @@ -69,7 +69,7 @@ func (f *blobReceiverFactory) createLogsReceiver(
}

func (f *blobReceiverFactory) createTracesReceiver(
ctx context.Context,
_ context.Context,
set receiver.CreateSettings,
cfg component.Config,
nextConsumer consumer.Traces,
Expand Down
2 changes: 1 addition & 1 deletion receiver/azureblobreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type blobReceiver struct {
obsrecv *obsreport.Receiver
}

func (b *blobReceiver) Start(ctx context.Context, host component.Host) error {
func (b *blobReceiver) Start(ctx context.Context, _ component.Host) error {
err := b.blobEventHandler.run(ctx)

return err
Expand Down
Loading

0 comments on commit c485cde

Please sign in to comment.