Skip to content

Commit

Permalink
[chore]: enable whitespace linter for pkg and internal (open-telemetr…
Browse files Browse the repository at this point in the history
…y#36298)

#### 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 <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 authored Nov 11, 2024
1 parent 64bcbb3 commit dc8197f
Show file tree
Hide file tree
Showing 91 changed files with 0 additions and 164 deletions.
1 change: 0 additions & 1 deletion internal/aws/awsutil/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func GetAWSConfigSession(logger *zap.Logger, cn ConnAttr, cfg *AWSSessionSetting
logger.Debug("Fetch region from ec2 metadata", zap.String("region", awsRegion))
}
}

}

if awsRegion == "" {
Expand Down
2 changes: 0 additions & 2 deletions internal/aws/containerinsight/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ func convertToFloat64(value any) float64 {

func checkMetricsAreExpected(t *testing.T, md pmetric.Metrics, fields map[string]any, tags map[string]string,
expectedUnits map[string]string) {

rms := md.ResourceMetrics()
assert.Equal(t, 1, rms.Len())

Expand Down Expand Up @@ -265,7 +264,6 @@ func TestConvertToOTLPMetricsForClusterMetrics(t *testing.T) {
}
md = ConvertToOTLPMetrics(fields, tags, zap.NewNop())
checkMetricsAreExpected(t, md, fields, tags, expectedUnits)

}

func TestConvertToOTLPMetricsForContainerMetrics(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/aws/cwlogs/cwlog_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func (client *Client) PutLogEvents(input *cloudwatchlogs.PutLogEventsInput, retr
client.logger.Error("cwlog_client: Error occurs in PutLogEvents", zap.Error(awsErr))
return err
}

}

//TODO: Should have metrics to provide visibility of these failures
Expand Down
3 changes: 0 additions & 3 deletions internal/aws/cwlogs/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ type logPusher struct {
// NewPusher creates a logPusher instance
func NewPusher(streamKey StreamKey, retryCnt int,
svcStructuredLog Client, logger *zap.Logger) Pusher {

pusher := newLogPusher(streamKey, svcStructuredLog, logger)

pusher.retryCnt = defaultRetryCount
Expand Down Expand Up @@ -250,7 +249,6 @@ func (p *logPusher) ForceFlush() error {
}

func (p *logPusher) pushEventBatch(req any) error {

// http://docs.aws.amazon.com/goto/SdkForGoV1/logs-2014-03-28/PutLogEvents
// The log events in the batch must be in chronological ordered by their
// timestamp (the time the event occurred, expressed as the number of milliseconds
Expand Down Expand Up @@ -296,7 +294,6 @@ func (p *logPusher) addLogEvent(logEvent *Event) *eventBatch {
}

func (p *logPusher) renewEventBatch() *eventBatch {

var prevBatch *eventBatch
if len(p.logEventBatch.putLogEventsInput.LogEvents) > 0 {
prevBatch = p.logEventBatch
Expand Down
1 change: 0 additions & 1 deletion internal/aws/cwlogs/pusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func TestPusher_addLogEventBatch(t *testing.T) {
p.logEventBatch.byteTotal = 1
assert.Nil(t, p.addLogEvent(nil))
assert.Len(t, p.logEventBatch.putLogEventsInput.LogEvents, 1)

}

func TestAddLogEventWithValidation(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/aws/k8s/k8sclient/obj_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func (s *ObjStore) Update(obj any) error {
// Delete implements the Delete method of the store interface.
// Delete deletes an existing entry in the ObjStore.
func (s *ObjStore) Delete(obj any) error {

o, err := meta.Accessor(obj)
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion internal/aws/metrics/metric_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func (m *MapWithExpiry) Shutdown() error {
return errors.New("shutdown called on an already closed channel")
default:
close(m.doneChan)

}
return nil
}
Expand Down
1 change: 0 additions & 1 deletion internal/aws/xray/tracesegment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ func TestTraceBodyUnMarshalling(t *testing.T) {
ExceptionID: String("abcdefghijklmnop"),
},
}, actualSeg, testCase+": unmarshalled segment is different from the expected")

},
},
{
Expand Down
1 change: 0 additions & 1 deletion internal/aws/xray/xray_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@ func TestUserAgent(t *testing.T) {
assert.Contains(t, req.HTTPRequest.UserAgent(), "xray-otel-exporter/")
assert.Contains(t, req.HTTPRequest.UserAgent(), "exec-env/")
assert.Contains(t, req.HTTPRequest.UserAgent(), "OS/")

}
1 change: 0 additions & 1 deletion internal/coreinternal/aggregateutil/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ func mergeNumberDataPoints(dpsMap map[string]pmetric.NumberDataPointSlice, agg A
dp.SetDoubleValue((medianNumbers[mNumber-1] + medianNumbers[mNumber]) / 2)
}
}

}
case pmetric.NumberDataPointValueTypeInt:
medianNumbers := []int64{dp.IntValue()}
Expand Down
6 changes: 0 additions & 6 deletions internal/coreinternal/attraction/attraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func TestAttributes_InsertValue(t *testing.T) {
}

func TestAttributes_InsertFromAttribute(t *testing.T) {

testCases := []testCase{
// Ensure no attribute is inserted because because attributes do not exist.
{
Expand Down Expand Up @@ -144,7 +143,6 @@ func TestAttributes_InsertFromAttribute(t *testing.T) {
}

func TestAttributes_UpdateValue(t *testing.T) {

testCases := []testCase{
// Ensure no changes to the span as there is no attributes map.
{
Expand Down Expand Up @@ -190,7 +188,6 @@ func TestAttributes_UpdateValue(t *testing.T) {
}

func TestAttributes_UpdateFromAttribute(t *testing.T) {

testCases := []testCase{
// Ensure no changes to the span as there is no attributes map.
{
Expand Down Expand Up @@ -418,7 +415,6 @@ func TestAttributes_Extract(t *testing.T) {
}

func TestAttributes_UpsertFromAttribute(t *testing.T) {

testCases := []testCase{
// Ensure `new_user_key` is not set for spans with no attributes.
{
Expand Down Expand Up @@ -926,7 +922,6 @@ func TestValidConfiguration(t *testing.T) {
{Key: "five", FromAttribute: "two", Action: UPSERT},
{Key: "two", Regex: compiledRegex, AttrNames: []string{"", "documentId"}, Action: EXTRACT},
}, ap.actions)

}

func hash(b []byte) string {
Expand All @@ -950,7 +945,6 @@ func (a mockInfoAuth) GetAttributeNames() []string {
}

func TestFromContext(t *testing.T) {

mdCtx := client.NewContext(context.TODO(), client.Info{
Metadata: client.NewMetadata(map[string][]string{
"source_single_val": {"single_val"},
Expand Down
1 change: 0 additions & 1 deletion internal/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func TestFetchingTimeouts(t *testing.T) {
t, time.Now().UnixNano(), shouldHaveTaken,
"Client timeouts don't appear to have been exercised.",
)

}

func TestToStatsJSONErrorHandling(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/filter/filterexpr/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func testMetricNameMatch(t *testing.T, dataType pmetric.MetricType) {
matched, err = matcher.MatchMetric(m)
assert.NoError(t, err)
assert.True(t, matched)

}

func TestMatchIntGaugeDataPointByMetricAndSecondPointLabelValue(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/filter/filterlog/filterlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var useOTTLBridge = featuregate.GlobalRegistry().MustRegister(
// The logic determining if a log should be processed is based on include and exclude settings.
// Include properties are checked before exclude settings are checked.
func NewSkipExpr(mp *filterconfig.MatchConfig) (expr.BoolExpr[ottllog.TransformContext], error) {

if useOTTLBridge.IsEnabled() {
return filterottl.NewLogSkipExprBridge(mp)
}
Expand Down
2 changes: 0 additions & 2 deletions internal/filter/filtermatcher/attributematcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func NewAttributesMatcher(config filterset.Config, attributes []filterconfig.Att
// Convert attribute values from mp representation to in-memory representation.
var rawAttributes []AttributeMatcher
for _, attribute := range attributes {

if attribute.Key == "" {
return nil, errors.New("can't have empty key in the list of attributes")
}
Expand Down Expand Up @@ -73,7 +72,6 @@ func NewAttributesMatcher(config filterset.Config, attributes []filterconfig.Att
}
default:
return nil, filterset.NewUnrecognizedMatchTypeError(config.MatchType)

}
}

Expand Down
1 change: 0 additions & 1 deletion internal/filter/filterspan/filterspan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ func TestServiceNameForResource(t *testing.T) {
resource := td.ResourceSpans().At(0).Resource()
name = serviceNameForResource(resource)
require.Equal(t, "<nil-service-name>", name)

}

func Test_NewSkipExpr_With_Bridge(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/k8stest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type K8sClient struct {
}

func NewK8sClient(kubeconfigPath string) (*K8sClient, error) {

if kubeconfigPath == "" {
return nil, errors.New("Please provide file path to load kubeconfig")
}
Expand Down
1 change: 0 additions & 1 deletion internal/k8stest/k8s_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func WaitForCollectorToStart(t *testing.T, client *K8sClient, podNamespace strin
return true
}
return false

}, time.Duration(podTimeoutMinutes)*time.Minute, 2*time.Second,
"collector pods were not ready within %d minutes", podTimeoutMinutes)
}
1 change: 0 additions & 1 deletion internal/kafka/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func configurePlaintext(config PlainTextConfig, saramaConfig *sarama.Config) {
}

func configureSASL(config SASLConfig, saramaConfig *sarama.Config) error {

if config.Username == "" {
return fmt.Errorf("username have to be provided")
}
Expand Down
1 change: 0 additions & 1 deletion internal/kafka/awsmsk/iam_scram_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,4 @@ func TestValidatingServerResponse(t *testing.T) {

_, err := new(IAMSASLClient).Step("")
assert.ErrorIs(t, err, ErrInvalidStateReached, "Must be an invalid step when not set up correctly")

}
1 change: 0 additions & 1 deletion internal/kafka/scram_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error) {
// completes is also an error.
func (x *XDGSCRAMClient) Step(challenge string) (response string, err error) {
return x.ClientConversation.Step(challenge)

}

// Done returns true if the conversation is completed or has errored.
Expand Down
2 changes: 0 additions & 2 deletions internal/kubelet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func (p *kubeConfigClientProvider) BuildClient() (Client, error) {
tok: nil,
logger: p.logger,
}, nil

}

type readOnlyClientProvider struct {
Expand All @@ -121,7 +120,6 @@ func (p *readOnlyClientProvider) BuildClient() (Client, error) {
tok: nil,
logger: p.logger,
}, nil

}

type tlsClientProvider struct {
Expand Down
1 change: 0 additions & 1 deletion internal/metadataproviders/system/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ func (p systemMetadataProvider) HostIPs() (ips []net.IP, err error) {

ips = append(ips, ip)
}

}
return ips, err
}
Expand Down
1 change: 0 additions & 1 deletion internal/otelarrow/compression/zstd/zstd.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ func SetDecoderConfig(cfg DecoderConfig) error {
updateOne(&staticInstances.byLevel[level].dec)
}
return nil

}

func (cfg EncoderConfig) options() (opts []zstdlib.EOption) {
Expand Down
3 changes: 0 additions & 3 deletions internal/otelarrow/test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func basicTestConfig(t *testing.T, tp testParams, cfgF CfgFunc) (*testConsumer,
require.NoError(t, err)

return testCon, exporter, receiver

}

func testIntegrationTraces(ctx context.Context, t *testing.T, tp testParams, cfgf CfgFunc, mkgen MkGen, errf ConsumerErrFunc, endf EndFunc) {
Expand Down Expand Up @@ -294,7 +293,6 @@ func bulkyGenFunc() MkGen {
return tracesGen.Generate(1000, time.Minute)
}
}

}

func standardEnding(t *testing.T, params testParams, testCon *testConsumer, expect [][]ptrace.Traces) (rops, eops map[string]int) {
Expand Down Expand Up @@ -601,7 +599,6 @@ func TestIntegrationSelfTracing(t *testing.T) {
var params = testParams{
threadCount: 10,
requestWhileTrue: func(test *testConsumer) bool {

cnt := 0
for _, span := range test.expSpans.GetSpans() {
if span.Name == "opentelemetry.proto.experimental.arrow.v1.ArrowTracesService/ArrowTraces" {
Expand Down
1 change: 0 additions & 1 deletion pkg/batchpersignal/batchpersignal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func TestSplitDifferentTracesIntoDifferentBatches(t *testing.T) {
assert.Equal(t, library.Name(), secondOutILS.Scope().Name())
assert.Equal(t, secondSpan.Name(), secondOutILS.Spans().At(0).Name())
assert.Equal(t, ils.SchemaUrl(), secondOutILS.SchemaUrl())

}

func TestSplitTracesWithNilTraceID(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/golden/sort_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestSortAttributes(t *testing.T) {
t.Errorf("Incorrect key at index %d. Expected: %s, Actual: %s", i, key, actualKeys[i])
}
}

}

func TestSortMetricsResourceAndScope(t *testing.T) {
Expand All @@ -56,5 +55,4 @@ func TestSortMetricsResourceAndScope(t *testing.T) {
after, err := ReadMetrics(afterPath)
require.NoError(t, err)
require.Equal(t, before, after)

}
1 change: 0 additions & 1 deletion pkg/ottl/boolean_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func (p *Parser[K]) newComparisonEvaluator(comparison *comparison) (BoolExpr[K],
}
return p.compare(a, b, comparison.Op), nil
}}, nil

}

func (p *Parser[K]) newBoolExpr(expr *booleanExpression) (BoolExpr[K], error) {
Expand Down
1 change: 0 additions & 1 deletion pkg/ottl/contexts/internal/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

func Test_MetricPathGetSetter(t *testing.T) {

refMetric := createMetricTelemetry()

newMetric := pmetric.NewMetric()
Expand Down
1 change: 0 additions & 1 deletion pkg/ottl/contexts/ottldatapoint/datapoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) {
tt.modified(exNumberDataPoint)

assert.Equal(t, exNumberDataPoint, numberDataPoint)

})
}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/ottl/contexts/ottllog/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ func Test_newPathGetSetter(t *testing.T) {
fmt.Println(log.Body().Slice().At(0).AsString())
newBodySlice.CopyTo(log.Body().Slice())
fmt.Println(log.Body().Slice().At(0).AsString())

},
bodyType: "slice",
},
Expand Down
1 change: 0 additions & 1 deletion pkg/ottl/contexts/ottlmetric/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
)

func Test_newPathGetSetter(t *testing.T) {

refMetric := createMetricTelemetry()

newCache := pcommon.NewMap()
Expand Down
1 change: 0 additions & 1 deletion pkg/ottl/contexts/ottlspanevent/span_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func (pep *pathExpressionParser) parsePath(path ottl.Path[TransformContext]) (ot
default:
return nil, internal.FormatDefaultErrorMessage(path.Name(), path.String(), "Span Event", internal.SpanEventRef)
}

}
func accessCache() ottl.StandardGetSetter[TransformContext] {
return ottl.StandardGetSetter[TransformContext]{
Expand Down
3 changes: 0 additions & 3 deletions pkg/ottl/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ func Test_e2e_editors(t *testing.T) {
sv, _ := v.Map().Get("slice")
s := sv.Slice()
s.AppendEmpty().SetStr("sample_value")

},
},
{
Expand All @@ -295,7 +294,6 @@ func Test_e2e_editors(t *testing.T) {
s := v.Map().PutEmptySlice("flags")
s.AppendEmpty().SetStr("pass")
s.AppendEmpty().SetStr("sample_value")

},
},
{
Expand Down Expand Up @@ -971,7 +969,6 @@ func Test_e2e_converters(t *testing.T) {
m := tCtx.GetLogRecord().Attributes().PutEmptyMap("test")
m.PutInt("foo", 2)
m.PutInt("bar", 5)

},
},
}
Expand Down
1 change: 0 additions & 1 deletion pkg/ottl/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func (m *mapGetter[K]) Get(ctx context.Context, tCtx K) (any, error) {
default:
evaluated[k] = t
}

}
result := pcommon.NewMap()
if err := result.FromRaw(evaluated); err != nil {
Expand Down
Loading

0 comments on commit dc8197f

Please sign in to comment.