Skip to content

Commit

Permalink
[receiver/*] Fix lint issues (#22978)
Browse files Browse the repository at this point in the history
Fix lint issues in github.com/golangci/golangci-lint 1.52.2
  • Loading branch information
songy23 authored and Caleb-Hurshman committed Jul 6, 2023
1 parent 15d1360 commit 6256957
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion receiver/azuremonitorreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func createDefaultConfig() component.Config {
}
}

func createMetricsReceiver(ctx context.Context, params receiver.CreateSettings, rConf component.Config, consumer consumer.Metrics) (receiver.Metrics, error) {
func createMetricsReceiver(_ context.Context, params receiver.CreateSettings, rConf component.Config, consumer consumer.Metrics) (receiver.Metrics, error) {
cfg, ok := rConf.(*Config)
if !ok {
return nil, errConfigNotAzureMonitor
Expand Down
2 changes: 1 addition & 1 deletion receiver/azuremonitorreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *azureScraper) GetMetricsValuesClient() MetricsValuesClient {
return client
}

func (s *azureScraper) start(ctx context.Context, host component.Host) (err error) {
func (s *azureScraper) start(_ context.Context, host component.Host) (err error) {
s.cred, err = s.azIDCredentialsFunc(s.cfg.TenantID, s.cfg.ClientID, s.cfg.ClientSecret, nil)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions receiver/azuremonitorreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type armClientMock struct {
pages []armresources.ClientListResponse
}

func (acm *armClientMock) NewListPager(options *armresources.ClientListOptions) *runtime.Pager[armresources.ClientListResponse] {
func (acm *armClientMock) NewListPager(_ *armresources.ClientListOptions) *runtime.Pager[armresources.ClientListResponse] {
return runtime.NewPager(runtime.PagingHandler[armresources.ClientListResponse]{
More: func(page armresources.ClientListResponse) bool {
return acm.current < len(acm.pages)
Expand All @@ -120,7 +120,7 @@ type metricsDefinitionsClientMock struct {
pages map[string][]armmonitor.MetricDefinitionsClientListResponse
}

func (mdcm *metricsDefinitionsClientMock) NewListPager(resourceURI string, options *armmonitor.MetricDefinitionsClientListOptions) *runtime.Pager[armmonitor.MetricDefinitionsClientListResponse] {
func (mdcm *metricsDefinitionsClientMock) NewListPager(resourceURI string, _ *armmonitor.MetricDefinitionsClientListOptions) *runtime.Pager[armmonitor.MetricDefinitionsClientListResponse] {
return runtime.NewPager(runtime.PagingHandler[armmonitor.MetricDefinitionsClientListResponse]{
More: func(page armmonitor.MetricDefinitionsClientListResponse) bool {
return mdcm.current[resourceURI] < len(mdcm.pages[resourceURI])
Expand Down
9 changes: 4 additions & 5 deletions receiver/bigipreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package bigipreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/bigipreceiver"

import (
"errors"
"fmt"
"path/filepath"
"testing"
Expand Down Expand Up @@ -38,7 +37,7 @@ func TestValidate(t *testing.T) {
expectedErr: multierr.Combine(
errMissingUsername,
errMissingPassword,
fmt.Errorf("%s: %w", errInvalidEndpoint, errors.New(`parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`)),
fmt.Errorf("%w: %s", errInvalidEndpoint, `parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`),
),
},
{
Expand All @@ -51,7 +50,7 @@ func TestValidate(t *testing.T) {
},
expectedErr: multierr.Combine(
errMissingPassword,
fmt.Errorf("%s: %w", errInvalidEndpoint, errors.New(`parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`)),
fmt.Errorf("%w: %s", errInvalidEndpoint, `parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`),
),
},
{
Expand All @@ -64,7 +63,7 @@ func TestValidate(t *testing.T) {
},
expectedErr: multierr.Combine(
errMissingUsername,
fmt.Errorf("%s: %w", errInvalidEndpoint, errors.New(`parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`)),
fmt.Errorf("%w: %s", errInvalidEndpoint, `parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`),
),
},
{
Expand All @@ -77,7 +76,7 @@ func TestValidate(t *testing.T) {
},
},
expectedErr: multierr.Combine(
fmt.Errorf("%s: %w", errInvalidEndpoint, errors.New(`parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`)),
fmt.Errorf("%w: %s", errInvalidEndpoint, `parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`),
),
},
{
Expand Down
6 changes: 3 additions & 3 deletions receiver/carbonreceiver/transport/mock_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ func (m *MockReporter) OnDataReceived(ctx context.Context) context.Context {
return ctx
}

func (m *MockReporter) OnTranslationError(ctx context.Context, err error) {
func (m *MockReporter) OnTranslationError(_ context.Context, err error) {
}

func (m *MockReporter) OnMetricsProcessed(ctx context.Context, numReceivedMetricPoints int, err error) {
func (m *MockReporter) OnMetricsProcessed(_ context.Context, numReceivedMetricPoints int, err error) {
m.wgMetricsProcessed.Done()
}

func (m *MockReporter) OnDebugf(template string, args ...interface{}) {
func (m *MockReporter) OnDebugf(_ string, args ...interface{}) {
}

// WaitAllOnMetricsProcessedCalls blocks until the number of expected calls
Expand Down
8 changes: 4 additions & 4 deletions receiver/collectdreceiver/collectd.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ func (r *collectDRecord) newPoint(val *json.Number) (*metricspb.Point, bool, err
// becomes a dimension.
func (r *collectDRecord) getReasonableMetricName(index int, attrs map[string]string) (string, bool) {
usedDsName := false
cap := 0
capacity := 0
if r.TypeS != nil {
cap += len(*r.TypeS)
capacity += len(*r.TypeS)
}
if r.TypeInstance != nil {
cap += len(*r.TypeInstance)
capacity += len(*r.TypeInstance)
}
parts := make([]byte, 0, cap)
parts := make([]byte, 0, capacity)

if !isNilOrEmpty(r.TypeS) {
parts = append(parts, *r.TypeS...)
Expand Down

0 comments on commit 6256957

Please sign in to comment.