Skip to content

Commit

Permalink
[chore]: enable whitespace linter for receivers (#36159)
Browse files Browse the repository at this point in the history
#### Description

[whitespace](https://golangci-lint.run/usage/linters/#whitespace) is a
linter that checks for unnecessary newlines at the start and end of
functions.

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Nov 11, 2024
1 parent 4b322db commit 3e42ac8
Show file tree
Hide file tree
Showing 81 changed files with 0 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func (acc *metricDataAccumulator) getMetricsData(containerStatsMap map[string]*C
acc.accumulate(convertToOTLPMetrics(containerPrefix, containerMetrics, containerResource, timestamp))
aggregateTaskMetrics(&taskMetrics, containerMetrics)
} else if containerMetadata.FinishedAt != "" && containerMetadata.StartedAt != "" {

duration, err := calculateDuration(containerMetadata.StartedAt, containerMetadata.FinishedAt)

if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions receiver/k8sobjectsreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ type Config struct {
}

func (c *Config) Validate() error {

validObjects, err := c.getValidObjects()
if err != nil {
return err
Expand Down Expand Up @@ -149,7 +148,6 @@ func (c *Config) getValidObjects() (map[string][]*schema.GroupVersionResource, e
Resource: resource.Name,
})
}

}
return validObjects, nil
}
1 change: 0 additions & 1 deletion receiver/k8sobjectsreceiver/mock_dynamic_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func newMockDynamicClient() mockDynamicClient {
return mockDynamicClient{
client: fakeClient,
}

}

func (c mockDynamicClient) getMockDynamicClient() (dynamic.Interface, error) {
Expand Down
2 changes: 0 additions & 2 deletions receiver/k8sobjectsreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ func (kr *k8sobjectsreceiver) startPull(ctx context.Context, config *K8sObjectsC
case <-stopperChan:
return
}

}

}

func (kr *k8sobjectsreceiver) startWatch(ctx context.Context, config *K8sObjectsConfig, resource dynamic.ResourceInterface) {
Expand Down
3 changes: 0 additions & 3 deletions receiver/k8sobjectsreceiver/unstructured_to_logdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func TestUnstructuredListToLogData(t *testing.T) {
assert.False(t, ok)
assert.Equal(t, 1, rl.ScopeLogs().Len())
assert.Equal(t, 3, logRecords.Len())

})

t.Run("Test event.name in watch events", func(t *testing.T) {
Expand Down Expand Up @@ -129,7 +128,6 @@ func TestUnstructuredListToLogData(t *testing.T) {
eventName, ok := attrs.Get("event.name")
require.True(t, ok)
assert.EqualValues(t, "generic-name", eventName.AsRaw())

})

t.Run("Test event observed timestamp is present", func(t *testing.T) {
Expand Down Expand Up @@ -168,5 +166,4 @@ func TestUnstructuredListToLogData(t *testing.T) {
assert.Positive(t, logRecords.At(0).ObservedTimestamp().AsTime().Unix())
assert.Equal(t, logRecords.At(0).ObservedTimestamp().AsTime().Unix(), observedAt.Unix())
})

}
1 change: 0 additions & 1 deletion receiver/kafkametricsreceiver/broker_scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (s *brokerScraper) shutdown(context.Context) error {
}

func (s *brokerScraper) scrape(context.Context) (pmetric.Metrics, error) {

var scrapeErrors = scrapererror.ScrapeErrors{}

if s.client == nil {
Expand Down
3 changes: 0 additions & 3 deletions receiver/kafkareceiver/header_extraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func TestHeaderExtractionTraces(t *testing.T) {
}
cancelFunc()
wg.Wait()

}

func TestHeaderExtractionLogs(t *testing.T) {
Expand Down Expand Up @@ -147,7 +146,6 @@ func TestHeaderExtractionLogs(t *testing.T) {
}
cancelFunc()
wg.Wait()

}

func TestHeaderExtractionMetrics(t *testing.T) {
Expand Down Expand Up @@ -210,7 +208,6 @@ func TestHeaderExtractionMetrics(t *testing.T) {
}
cancelFunc()
wg.Wait()

}

func validateHeader(t *testing.T, rs pcommon.Resource, headerKey string, headerValue string) {
Expand Down
1 change: 0 additions & 1 deletion receiver/kubeletstatsreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ func TestLoadConfig(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, tt.expected, cfg)
}

})
}
}
Expand Down
1 change: 0 additions & 1 deletion receiver/kubeletstatsreceiver/internal/kubelet/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ func (m *Metadata) getContainerID(podUID string, containerName string) (string,
return stripContainerID(containerStatus.ContainerID), nil
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ func TestSetExtraLabelsForVolumeTypes(t *testing.T) {

// Test happy paths for volume type metadata.
func TestCpuAndMemoryGetters(t *testing.T) {

tests := []struct {
name string
metadata Metadata
Expand Down
1 change: 0 additions & 1 deletion receiver/kubeletstatsreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ func TestScraperWithMetadata(t *testing.T) {
pmetrictest.IgnoreMetricDataPointsOrder(),
pmetrictest.IgnoreTimestamp(),
pmetrictest.IgnoreMetricsOrder()))

})
}
}
Expand Down
1 change: 0 additions & 1 deletion receiver/lokireceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func createLogsReceiver(
cfg component.Config,
consumer consumer.Logs,
) (receiver.Logs, error) {

rCfg := cfg.(*Config)
return newLokiReceiver(rCfg, consumer, settings)
}
1 change: 0 additions & 1 deletion receiver/lokireceiver/loki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ func TestSendingPushRequestToGRPCEndpoint(t *testing.T) {
}

func TestExpectedStatus(t *testing.T) {

testcases := []struct {
name string
err error
Expand Down
1 change: 0 additions & 1 deletion receiver/mongodbatlasreceiver/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ func payloadToLogs(now time.Time, payload []byte) (plog.Logs, error) {

attrs.PutStr("net.peer.name", host)
attrs.PutInt("net.peer.port", port)

}

return logs, nil
Expand Down
1 change: 0 additions & 1 deletion receiver/mongodbatlasreceiver/alerts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ func TestVerifyHMACSignature(t *testing.T) {
} else {
require.NoError(t, err)
}

})
}
}
Expand Down
1 change: 0 additions & 1 deletion receiver/mongodbatlasreceiver/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ func (er *eventsReceiver) transformOrgEvents(now pcommon.Timestamp, events []*mo

func (er *eventsReceiver) transformEvents(now pcommon.Timestamp, events []*mongodbatlas.Event, resourceLogs *plog.ResourceLogs) {
for _, event := range events {

logRecord := resourceLogs.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty()
bodyBytes, err := json.Marshal(event)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion receiver/mongodbatlasreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func NewFactory() receiver.Factory {
createDefaultConfig,
receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability),
receiver.WithLogs(createCombinedLogReceiver, metadata.LogsStability))

}

func createMetricsReceiver(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ func (s *MongoDBAtlasClient) GetOrganization(ctx context.Context, orgID string)
return nil, fmt.Errorf("error retrieving project page: %w", err)
}
return org, nil

}

// Projects returns a list of projects accessible within the provided organization
Expand Down Expand Up @@ -719,7 +718,6 @@ type GetAccessLogsOptions struct {

// GetAccessLogs returns the access logs specified for the cluster requested
func (s *MongoDBAtlasClient) GetAccessLogs(ctx context.Context, groupID string, clusterName string, opts *GetAccessLogsOptions) (ret []*mongodbatlas.AccessLogs, err error) {

options := mongodbatlas.AccessLogOptions{
// Earliest Timestamp in epoch milliseconds from when Atlas should access log results
Start: fmt.Sprintf("%d", opts.MinDate.UTC().UnixMilli()),
Expand Down
1 change: 0 additions & 1 deletion receiver/mongodbatlasreceiver/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestFilterClusters(t *testing.T) {
ic, err := filterClusters(clusters, includeProject)
require.NoError(t, err)
require.Equal(t, []mongodbatlas.Cluster{{Name: "cluster1", ID: "1"}, {Name: "cluster3", ID: "3"}}, ic)

}

func TestDefaultLoggingConfig(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion receiver/mongodbatlasreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ func (s *mongodbatlasreceiver) getNodeClusterNameMap(
// Remove the port from the node
n, _, _ := strings.Cut(node, ":")
clusterMap[n] = cluster.Name

}

providerMap[cluster.Name] = providerValues{
Expand Down
2 changes: 0 additions & 2 deletions receiver/mongodbreceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func TestListDatabaseNames(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "admin", dbNames[0])
})

}

type commandString = string
Expand Down Expand Up @@ -232,7 +231,6 @@ func TestGetVersionFailures(t *testing.T) {
require.ErrorContains(t, err, tc.partialError)
})
}

}

func loadDBStats() (bson.D, error) {
Expand Down
2 changes: 0 additions & 2 deletions receiver/mysqlreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func TestScrape(t *testing.T) {
// and the other failure comes from a row that fails to parse as a number
require.Equal(t, 5, partialError.Failed, "Expected partial error count to be 5")
})

}

var _ client = (*mockClient)(nil)
Expand Down Expand Up @@ -194,7 +193,6 @@ func (c *mockClient) getTableStats() ([]TableStats, error) {
stats = append(stats, s)
}
return stats, nil

}

func (c *mockClient) getTableIoWaitsStats() ([]TableIoWaitsStats, error) {
Expand Down
1 change: 0 additions & 1 deletion receiver/opencensusreceiver/internal/octrace/opencensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type Receiver struct {

// New creates a new opencensus.Receiver reference.
func New(nextConsumer consumer.Traces, set receiver.Settings) (*Receiver, error) {

obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{
ReceiverID: set.ID,
Transport: receiverTransport,
Expand Down
1 change: 0 additions & 1 deletion receiver/opencensusreceiver/opencensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func (ocr *ocReceiver) Start(ctx context.Context, host component.Host) error {

// Shutdown is a method to turn off receiving.
func (ocr *ocReceiver) Shutdown(context.Context) error {

if ocr.cancel != nil {
ocr.cancel()
}
Expand Down
3 changes: 0 additions & 3 deletions receiver/opencensusreceiver/opencensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ func TestStartWithoutConsumersShouldFail(t *testing.T) {
}

func TestStartListenerClosed(t *testing.T) {

addr := testutil.GetAvailableLocalAddress(t)

// Set the buffer count to 1 to make it flush the test span immediately.
Expand Down Expand Up @@ -503,7 +502,6 @@ func TestOCReceiverTrace_HandleNextConsumerResponse(t *testing.T) {
t *testing.T,
cc *grpc.ClientConn,
msg *agenttracepb.ExportTraceServiceRequest) error {

acc := agenttracepb.NewTraceServiceClient(cc)
stream, err := acc.Export(context.Background())
require.NoError(t, err)
Expand Down Expand Up @@ -661,7 +659,6 @@ func TestOCReceiverMetrics_HandleNextConsumerResponse(t *testing.T) {
t *testing.T,
cc *grpc.ClientConn,
msg *agentmetricspb.ExportMetricsServiceRequest) error {

acc := agentmetricspb.NewMetricsServiceClient(cc)
stream, err := acc.Export(context.Background())
require.NoError(t, err)
Expand Down
1 change: 0 additions & 1 deletion receiver/oracledbreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func (c Config) Validate() error {

// If DataSource is defined it takes precedence over the rest of the connection options.
if c.DataSource == "" {

if c.Endpoint == "" {
allErrs = multierr.Append(allErrs, errEmptyEndpoint)
}
Expand Down
2 changes: 0 additions & 2 deletions receiver/oracledbreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ var queryResponses = map[string][]metricRow{
}

func TestScraper_Scrape(t *testing.T) {

tests := []struct {
name string
dbclientFn func(db *sql.DB, s string, logger *zap.Logger) dbClient
Expand Down Expand Up @@ -165,5 +164,4 @@ func TestScraper_Scrape(t *testing.T) {
assert.Equal(t, int64(78944), found.Sum().DataPoints().At(0).IntValue())
})
}

}
1 change: 0 additions & 1 deletion receiver/otelarrowreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func TestUnmarshalConfig(t *testing.T) {
WaiterLimit: 100,
},
}, cfg)

}

// Tests that a deprecated config validation sets RequestLimitMiB and WaiterLimit in the correct config block.
Expand Down
4 changes: 0 additions & 4 deletions receiver/otelarrowreceiver/internal/arrow/arrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ func (id *inFlightData) anyDone(ctx context.Context) {
// tracks everything that needs to be used by instrumention when the
// batch finishes.
func (r *receiverStream) recvOne(streamCtx context.Context, serverStream anyStreamServer, hrcv *headerReceiver, pendingCh chan<- batchResp, method string, ac arrowRecord.ConsumerAPI) (retErr error) {

// Receive a batch corresponding with one ptrace.Traces, pmetric.Metrics,
// or plog.Logs item.
req, recvErr := serverStream.Recv()
Expand All @@ -565,12 +564,10 @@ func (r *receiverStream) recvOne(streamCtx context.Context, serverStream anyStre
if recvErr != nil {
if errors.Is(recvErr, io.EOF) {
return recvErr

} else if errors.Is(recvErr, context.Canceled) {
// This is a special case to avoid introducing a span error
// for a canceled operation.
return io.EOF

} else if status, ok := status.FromError(recvErr); ok && status.Code() == codes.Canceled {
// This is a special case to avoid introducing a span error
// for a canceled operation.
Expand Down Expand Up @@ -773,7 +770,6 @@ func (r *receiverStream) srvSendLoop(ctx context.Context, serverStream anyStream
// slice of pdata objects of the corresponding data type as `any`.
// along with the number of items and true uncompressed size.
func (r *Receiver) consumeBatch(arrowConsumer arrowRecord.ConsumerAPI, records *arrowpb.BatchArrowRecords) (retData any, numItems int, uncompSize int64, retErr error) {

payloads := records.GetArrowPayloads()
if len(payloads) == 0 {
return nil, 0, 0, nil
Expand Down
1 change: 0 additions & 1 deletion receiver/otelarrowreceiver/internal/arrow/arrow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,6 @@ func testReceiverAuthHeaders(t *testing.T, includeMeta bool, dataAuth bool) {
batch = copyBatch(batch)

if len(md) != 0 {

hpb.Reset()
for key, vals := range md {
for _, val := range vals {
Expand Down
2 changes: 0 additions & 2 deletions receiver/podmanreceiver/libpod_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func TestEvents(t *testing.T) {

loop:
for {

select {
case err := <-errs:
if err != nil && !errors.Is(err, io.EOF) {
Expand All @@ -252,5 +251,4 @@ loop:
}

assert.Equal(t, expectedEvents, actualEvents)

}
2 changes: 0 additions & 2 deletions receiver/podmanreceiver/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ EVENT_LOOP:
for {
eventCh, errCh := pc.events(ctx, filters)
for {

select {
case <-ctx.Done():
return
Expand Down Expand Up @@ -132,7 +131,6 @@ EVENT_LOOP:
}
}
}

}
}
}
Expand Down
1 change: 0 additions & 1 deletion receiver/prometheusreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ func validateHTTPClientConfig(cfg *commonconfig.HTTPClientConfig) error {
return err
}
return nil

}

func checkFile(fn string) error {
Expand Down
2 changes: 0 additions & 2 deletions receiver/prometheusreceiver/internal/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,6 @@ func TestMetricBuilderSummary(t *testing.T) {
})
}
}

}

func TestMetricBuilderNativeHistogram(t *testing.T) {
Expand Down Expand Up @@ -2003,5 +2002,4 @@ func assertEquivalentMetrics(t *testing.T, want, got pmetric.Metrics) {
assert.EqualValues(t, wmap, gmap)
}
}

}
Loading

0 comments on commit 3e42ac8

Please sign in to comment.