Skip to content

Commit

Permalink
[chore]: enable whitespace linter (#11579)
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 Oct 31, 2024
1 parent 2d9d376 commit 0204d95
Show file tree
Hide file tree
Showing 47 changed files with 1 addition and 67 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ linters:
- unused
- unparam
- usestdlibvars
- whitespace

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
Expand Down
1 change: 0 additions & 1 deletion cmd/mdatagen/internal/embedded_templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ func TestEnsureTemplatesLoaded(t *testing.T) {
return nil
}))
assert.Equal(t, len(templateFiles), count, "Must match the expected number of calls")

}
1 change: 0 additions & 1 deletion cmd/mdatagen/internal/samplereceiver/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,4 @@ func TestComponentTelemetry(t *testing.T) {
},
})
require.NoError(t, tt.Shutdown(context.Background()))

}
1 change: 0 additions & 1 deletion component/componentstatus/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,4 @@ func TestAllPipelineIDs(t *testing.T) {
return false
})
assert.Equal(t, 1, count)

}
2 changes: 0 additions & 2 deletions component/componenttest/configtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ func validateConfigDataType(t reflect.Type) error {

// checkStructFieldTags inspects the tags of a struct field.
func checkStructFieldTags(f reflect.StructField) error {

tagValue := f.Tag.Get("mapstructure")
if tagValue == "" {

// Ignore special types.
switch f.Type.Kind() {
case reflect.Interface, reflect.Chan, reflect.Func, reflect.Uintptr, reflect.UnsafePointer:
Expand Down
1 change: 0 additions & 1 deletion config/configcompression/compressiontype.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@ func (ct *Type) UnmarshalText(in []byte) error {
return nil
}
return fmt.Errorf("unsupported compression type %q", typ)

}
1 change: 0 additions & 1 deletion config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@ func TestGRPCServerWarning(t *testing.T) {
require.Len(t, observed.FilterLevelExact(zap.WarnLevel).All(), test.len)
})
}

}

func TestGRPCServerSettingsError(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion config/confighttp/compressor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func BenchmarkCompression(b *testing.B) {
b.Run(fmt.Sprint(benchmark.name), func(b *testing.B) {
benchmark.function(b, benchmark.codec, &buffer, payload)
})

}
}

Expand Down
4 changes: 0 additions & 4 deletions config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ func TestPartialHTTPClientSettings(t *testing.T) {
assert.EqualValues(t, 0, transport.MaxConnsPerHost)
assert.EqualValues(t, 90*time.Second, transport.IdleConnTimeout)
assert.False(t, transport.DisableKeepAlives)

})
}
}
Expand Down Expand Up @@ -554,7 +553,6 @@ func TestHTTPServerWarning(t *testing.T) {
require.Len(t, observed.FilterLevelExact(zap.WarnLevel).All(), tt.len)
})
}

}

func TestHttpReception(t *testing.T) {
Expand Down Expand Up @@ -1279,7 +1277,6 @@ func TestServerWithDecoder(t *testing.T) {
srv.Handler.ServeHTTP(response, req)
// verify
assert.Equal(t, http.StatusOK, response.Result().StatusCode)

}

func TestServerWithDecompression(t *testing.T) {
Expand Down Expand Up @@ -1497,7 +1494,6 @@ func BenchmarkHttpRequest(b *testing.B) {
if !bb.clientPerThread {
c, err = hcs.ToClient(context.Background(), componenttest.NewNopHost(), nilProvidersSettings)
require.NoError(b, err)

}
b.RunParallel(func(pb *testing.PB) {
if c == nil {
Expand Down
1 change: 0 additions & 1 deletion config/configretry/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (bs *BackOffConfig) Validate() error {
if bs.MaxElapsedTime < bs.MaxInterval {
return errors.New("'max_elapsed_time' must not be less than 'max_interval'")
}

}
return nil
}
5 changes: 0 additions & 5 deletions config/configtls/configtls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ func TestLoadTLSServerConfig(t *testing.T) {
}

func TestLoadTLSServerConfigReload(t *testing.T) {

tmpCaPath := createTempClientCaFile(t)

overwriteClientCA(t, tmpCaPath, "ca-1.crt")
Expand Down Expand Up @@ -358,7 +357,6 @@ func TestLoadTLSServerConfigReload(t *testing.T) {
}

func TestLoadTLSServerConfigFailingReload(t *testing.T) {

tmpCaPath := createTempClientCaFile(t)

overwriteClientCA(t, tmpCaPath, "ca-1.crt")
Expand Down Expand Up @@ -389,7 +387,6 @@ func TestLoadTLSServerConfigFailingReload(t *testing.T) {
}

func TestLoadTLSServerConfigFailingInitialLoad(t *testing.T) {

tmpCaPath := createTempClientCaFile(t)

overwriteClientCA(t, tmpCaPath, "testCA-bad.txt")
Expand All @@ -405,7 +402,6 @@ func TestLoadTLSServerConfigFailingInitialLoad(t *testing.T) {
}

func TestLoadTLSServerConfigWrongPath(t *testing.T) {

tmpCaPath := createTempClientCaFile(t)

tlsSetting := ServerConfig{
Expand All @@ -419,7 +415,6 @@ func TestLoadTLSServerConfigWrongPath(t *testing.T) {
}

func TestLoadTLSServerConfigFailing(t *testing.T) {

tmpCaPath := createTempClientCaFile(t)

overwriteClientCA(t, tmpCaPath, "ca-1.crt")
Expand Down
1 change: 0 additions & 1 deletion config/internal/warning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ func TestShouldWarn(t *testing.T) {
assert.Equal(t, shouldWarn(test.endpoint), test.warn)
})
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func (fmp *provider) createClient() (*http.Client, error) {
}

func (fmp *provider) Retrieve(_ context.Context, uri string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) {

if !strings.HasPrefix(uri, string(fmp.scheme)+":") {
return nil, fmt.Errorf("%q uri is not supported by %q provider", uri, string(fmp.scheme))
}
Expand Down
1 change: 0 additions & 1 deletion confmap/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,4 @@ func TestNewRetrievedFromYAMLString(t *testing.T) {
}
})
}

}
1 change: 0 additions & 1 deletion exporter/debugexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func Test_UnmarshalMarshalled(t *testing.T) {
},
} {
t.Run(name, func(t *testing.T) {

conf := confmap.New()
err := conf.Marshal(tc.inCfg)
require.NoError(t, err)
Expand Down
1 change: 0 additions & 1 deletion exporter/debugexporter/internal/otlptext/databuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ func (b *dataBuffer) logProfileMappings(ms pprofile.MappingSlice) {
b.logEntry(" Has filenames: %t", mapping.HasFilenames())
b.logEntry(" Has line numbers: %t", mapping.HasLineNumbers())
b.logEntry(" Has inline frames: %t", mapping.HasInlineFrames())

}
}

Expand Down
1 change: 0 additions & 1 deletion exporter/debugexporter/internal/otlptext/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
)

func TestTracesText(t *testing.T) {

tests := []struct {
name string
in ptrace.Traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ func TestMergeSplitProfiles(t *testing.T) {
assert.Equal(t, tt.expected[i], r.(*profilesRequest))
}
})

}
}

Expand Down
1 change: 0 additions & 1 deletion exporter/exporterhelper/internal/queue_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ func TestQueueRetryWithDisabledQueue(t *testing.T) {
require.NoError(t, be.Shutdown(context.Background()))
})
}

}

func TestQueueFailedRequestDropped(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion exporter/exporterhelper/logs_batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func TestMergeSplitLogs(t *testing.T) {
assert.Equal(t, tt.expected[i], r.(*logsRequest))
}
})

}
}

Expand Down
11 changes: 0 additions & 11 deletions exporter/exportertest/mock_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,9 @@ func TestConsumeLogsNonPermanent(t *testing.T) {
assert.Equal(t, 0, mc.reqCounter.error.permanent)
assert.Equal(t, 0, mc.reqCounter.success)
assert.Equal(t, 1, mc.reqCounter.total)

}

func TestConsumeLogsPermanent(t *testing.T) {

mc := newMockConsumer(returnPermanentError)
validData := createLog("logId")
err := mc.ConsumeLogs(context.Background(), validData)
Expand All @@ -144,7 +142,6 @@ func TestConsumeLogsPermanent(t *testing.T) {
assert.Equal(t, 1, mc.reqCounter.error.permanent)
assert.Equal(t, 0, mc.reqCounter.success)
assert.Equal(t, 1, mc.reqCounter.total)

}

func TestConsumeLogsSuccess(t *testing.T) {
Expand All @@ -158,7 +155,6 @@ func TestConsumeLogsSuccess(t *testing.T) {
assert.Equal(t, 0, mc.reqCounter.error.permanent)
assert.Equal(t, 1, mc.reqCounter.success)
assert.Equal(t, 1, mc.reqCounter.total)

}

func TestConsumeTracesNonPermanent(t *testing.T) {
Expand All @@ -172,11 +168,9 @@ func TestConsumeTracesNonPermanent(t *testing.T) {
assert.Equal(t, 0, mc.reqCounter.error.permanent)
assert.Equal(t, 0, mc.reqCounter.success)
assert.Equal(t, 1, mc.reqCounter.total)

}

func TestConsumeTracesPermanent(t *testing.T) {

mc := newMockConsumer(returnPermanentError)
validData := createTrace("traceId")
err := mc.ConsumeTraces(context.Background(), validData)
Expand All @@ -187,7 +181,6 @@ func TestConsumeTracesPermanent(t *testing.T) {
assert.Equal(t, 1, mc.reqCounter.error.permanent)
assert.Equal(t, 0, mc.reqCounter.success)
assert.Equal(t, 1, mc.reqCounter.total)

}

func TestConsumeTracesSuccess(t *testing.T) {
Expand All @@ -201,7 +194,6 @@ func TestConsumeTracesSuccess(t *testing.T) {
assert.Equal(t, 0, mc.reqCounter.error.permanent)
assert.Equal(t, 1, mc.reqCounter.success)
assert.Equal(t, 1, mc.reqCounter.total)

}
func TestConsumeMetricsNonPermanent(t *testing.T) {
mc := newMockConsumer(returnNonPermanentError)
Expand All @@ -214,7 +206,6 @@ func TestConsumeMetricsNonPermanent(t *testing.T) {
assert.Equal(t, 0, mc.reqCounter.error.permanent)
assert.Equal(t, 0, mc.reqCounter.success)
assert.Equal(t, 1, mc.reqCounter.total)

}

func TestConsumeMetricsPermanent(t *testing.T) {
Expand All @@ -228,7 +219,6 @@ func TestConsumeMetricsPermanent(t *testing.T) {
assert.Equal(t, 1, mc.reqCounter.error.permanent)
assert.Equal(t, 0, mc.reqCounter.success)
assert.Equal(t, 1, mc.reqCounter.total)

}

func TestConsumeMetricsSuccess(t *testing.T) {
Expand All @@ -242,7 +232,6 @@ func TestConsumeMetricsSuccess(t *testing.T) {
assert.Equal(t, 0, mc.reqCounter.error.permanent)
assert.Equal(t, 1, mc.reqCounter.success)
assert.Equal(t, 1, mc.reqCounter.total)

}

func TestCapabilities(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion exporter/internal/queue/default_batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func (qb *DefaultBatcher) resetTimer() {

// startReadingFlushingGoroutine starts a goroutine that reads and then flushes.
func (qb *DefaultBatcher) startReadingFlushingGoroutine() {

qb.stopWG.Add(1)
go func() {
defer qb.stopWG.Done()
Expand Down
1 change: 0 additions & 1 deletion exporter/internal/queue/persistent_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ func (pq *persistentQueue[T]) OnProcessingFinished(index uint64, consumeErr erro

// Ensure the used size and the channel size are in sync.
pq.sizedChannel.syncSize()

}

// retrieveAndEnqueueNotDispatchedReqs gets the items for which sending was not finished, cleans the storage
Expand Down
1 change: 0 additions & 1 deletion exporter/internal/queue/persistent_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ func TestPersistentQueue_Shutdown(t *testing.T) {
for i := 0; i < 1000; i++ {
assert.NoError(t, pq.Offer(context.Background(), req))
}

}

func TestPersistentQueue_ConsumersProducers(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion exporter/otlpexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func TestUnmarshalInvalidConfig(t *testing.T) {
assert.ErrorContains(t, component.ValidateConfig(cfg), tt.errorMsg)
})
}

}

func TestValidDNSEndpoint(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion extension/auth/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,4 @@ func TestWithPerRPCCredentials(t *testing.T) {
assert.True(t, called)
assert.NotNil(t, p)
assert.NoError(t, err)

}
1 change: 0 additions & 1 deletion extension/zpagesextension/zpagesextension.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type registerableTracerProvider interface {
}

func (zpe *zpagesExtension) Start(ctx context.Context, host component.Host) error {

zPagesMux := http.NewServeMux()

sdktracer, ok := zpe.telemetry.TracerProvider.(registerableTracerProvider)
Expand Down
1 change: 0 additions & 1 deletion otelcol/command_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func newComponentsCommand(set CollectorSettings) *cobra.Command {
Long: "Outputs available components in this collector distribution including their stability levels. The output format is not stable and can change between releases.",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, _ []string) error {

factories, err := set.Factories()
if err != nil {
return fmt.Errorf("failed to initialize factories: %w", err)
Expand Down
1 change: 0 additions & 1 deletion otelcol/unmarshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type configSettings struct {
// unmarshal the configSettings from a confmap.Conf.
// After the config is unmarshalled, `Validate()` must be called to validate.
func unmarshal(v *confmap.Conf, factories Factories) (*configSettings, error) {

telFactory := telemetry.NewFactory()
defaultTelConfig := *telFactory.CreateDefaultConfig().(*telemetry.Config)

Expand Down
1 change: 0 additions & 1 deletion pdata/pcommon/value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func TestValueReadOnly(t *testing.T) {
v.CopyTo(v2)
assert.Equal(t, v.AsRaw(), v2.AsRaw())
assert.Panics(t, func() { v2.CopyTo(v) })

}

func TestValueType(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pdata/plog/pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func TestProtoSizer(t *testing.T) {
bytes, err := marshaler.MarshalLogs(ld)
require.NoError(t, err)
assert.Equal(t, len(bytes), size)

}

func TestProtoSizerEmptyLogs(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pdata/pprofile/pprofileotlp/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func (ms ExportResponse) unmarshalJsoniter(iter *jsoniter.Iterator) {
}
return true
})

}

// PartialSuccess returns the ExportLogsPartialSuccess associated with this ExportResponse.
Expand Down
1 change: 0 additions & 1 deletion pdata/ptrace/ptraceotlp/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func (ms ExportResponse) unmarshalJsoniter(iter *jsoniter.Iterator) {
}
return true
})

}

// PartialSuccess returns the ExportLogsPartialSuccess associated with this ExportResponse.
Expand Down
1 change: 0 additions & 1 deletion processor/batchprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func TestValidateConfig_ValidBatchSizes(t *testing.T) {
SendBatchMaxSize: 1000,
}
assert.NoError(t, cfg.Validate())

}

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

}

func TestUnmarshalConfigUnix(t *testing.T) {
Expand Down
Loading

0 comments on commit 0204d95

Please sign in to comment.