Skip to content

Commit

Permalink
[chore]: enable whitespace linter for extension (#36310)
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 12, 2024
1 parent 163c689 commit f655764
Show file tree
Hide file tree
Showing 25 changed files with 0 additions and 45 deletions.
1 change: 0 additions & 1 deletion extension/basicauthextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func newClientAuthExtension(cfg *Config) auth.Client {
}

func newServerAuthExtension(cfg *Config) (auth.Server, error) {

if cfg.Htpasswd == nil || (cfg.Htpasswd.File == "" && cfg.Htpasswd.Inline == "") {
return nil, errNoCredentialSource
}
Expand Down
1 change: 0 additions & 1 deletion extension/basicauthextension/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ func TestBasicAuth_ClientValid(t *testing.T) {
}

func TestBasicAuth_ClientInvalid(t *testing.T) {

t.Run("invalid username format", func(t *testing.T) {
ext := newClientAuthExtension(&Config{
ClientAuth: &ClientAuthSettings{
Expand Down
1 change: 0 additions & 1 deletion extension/bearertokenauthextension/bearertokenauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func TestBearerAuthenticatorHttp(t *testing.T) {
assert.NoError(t, err)
authHeaderValue := resp.Header.Get("Authorization")
assert.Equal(t, authHeaderValue, fmt.Sprintf("%s %s", scheme, string(cfg.BearerToken)))

}

func TestBearerAuthenticator(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions extension/headerssetterextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func newHeadersSetterExtension(cfg *Config, logger *zap.Logger) (auth.Client, er
return &headersPerRPC{headers: headers}, nil
}),
), nil

}

// headersPerRPC is a gRPC credentials.PerRPCCredentials implementation sets
Expand All @@ -89,7 +88,6 @@ func (h *headersPerRPC) GetRequestMetadata(
ctx context.Context,
_ ...string,
) (map[string]string, error) {

metadata := make(map[string]string, len(h.headers))
for _, header := range h.headers {
value, err := header.source.Get(ctx)
Expand Down
1 change: 0 additions & 1 deletion extension/healthcheckextension/healthcheckextension.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type healthCheckExtension struct {
var _ extensioncapabilities.PipelineWatcher = (*healthCheckExtension)(nil)

func (hc *healthCheckExtension) Start(ctx context.Context, host component.Host) error {

hc.logger.Info("Starting health_check extension", zap.Any("config", hc.config))
ln, err := hc.config.ToListener(ctx)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ func TestCheck(t *testing.T) {
}
})
}

}

func TestWatch(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3143,5 +3143,4 @@ func TestConfig(t *testing.T) {
assert.Equal(t, tc.expectedBody, body)
})
}

}
1 change: 0 additions & 1 deletion extension/jaegerremotesampling/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func TestLoadConfig(t *testing.T) {
}

func TestValidate(t *testing.T) {

testCases := []struct {
desc string
cfg Config
Expand Down
1 change: 0 additions & 1 deletion extension/observer/ecsobserver/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ func TestFetcher_AttachService(t *testing.T) {
deployID := i % nServices
task.TaskDefinitionArn = aws.String(fmt.Sprintf("def%d:1", deployID))
task.StartedBy = aws.String(fmt.Sprintf("deploy%d", deployID))

}))

ctx := context.Background()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,4 @@ func TestValueFrom(t *testing.T) {
assert.True(t, ok)
assert.Equal(t, "e2", v)
})

}
1 change: 0 additions & 1 deletion extension/observer/hostobserver/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func TestHostObserver(t *testing.T) {
assert.Equal(t, filepath.Base(exe), details.ProcessName)
assert.Equal(t, tt.protocol, details.Transport)
assert.Equal(t, isIPv6, details.IsIPv6)

}
})
}
Expand Down
1 change: 0 additions & 1 deletion extension/observer/k8sobserver/ingress_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func convertIngressToEndpoints(idNamespace string, ingress *v1.Ingress) []observ
})
}
}

}

return endpoints
Expand Down
1 change: 0 additions & 1 deletion extension/observer/k8sobserver/pod_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ func TestPodObjectToPortEndpoint(t *testing.T) {

endpoints := convertPodToEndpoints("namespace", podWithNamedPorts)
require.Equal(t, expectedEndpoints, endpoints)

}
2 changes: 0 additions & 2 deletions extension/opampextension/monitor_ppid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ func TestMonitorPPID(t *testing.T) {
case <-time.After(5 * time.Second):
t.Fatalf("Timed out waiting for command to stop")
}

})

}

func longRunningComand(ctx context.Context) *exec.Cmd {
Expand Down
1 change: 0 additions & 1 deletion extension/opampextension/opamp_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func TestCreateAgentDescription(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {

cfg := createDefaultConfig().(*Config)
tc.cfg(cfg)

Expand Down
1 change: 0 additions & 1 deletion extension/remotetapextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type remoteObserverExtension struct {
}

func (s *remoteObserverExtension) Start(ctx context.Context, host component.Host) error {

htmlContent, err := fs.Sub(httpFS, "html")
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion extension/sigv4authextension/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func TestRoundTripper(t *testing.T) {
assert.Equal(t, cfg.Service, si.service)
assert.Equal(t, awsSDKInfo, si.awsSDKInfo)
assert.Equal(t, cfg.credsProvider, si.credsProvider)

}

func TestPerRPCCredentials(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion extension/sigv4authextension/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ func TestCreate(t *testing.T) {
ext, err := createExtension(context.Background(), extensiontest.NewNopSettings(), cfg)
assert.NoError(t, err)
assert.NotNil(t, ext)

}
1 change: 0 additions & 1 deletion extension/storage/dbstorage/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func testExtensionIntegrity(t *testing.T, se storage.Extension) {

// Repeatedly thrash client
for j := 0; j < 100; j++ {

// Make sure my values are still mine
for i := 0; i < len(keys); i++ {
v, err := c.Get(ctx, keys[i])
Expand Down
2 changes: 0 additions & 2 deletions extension/storage/filestorage/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func TestClientBatchOperations(t *testing.T) {
for i := range testGetEntries {
require.Equal(t, testGetEntries[i].Key, testEntriesDelete[i].Key)
require.Nil(t, testGetEntries[i].Value)

}
}

Expand Down Expand Up @@ -175,7 +174,6 @@ func TestNewClientTransactionErrors(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {

tempDir := t.TempDir()
dbFile := filepath.Join(tempDir, "my_db")

Expand Down
1 change: 0 additions & 1 deletion extension/storage/filestorage/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func TestDirectoryCreateConfig(t *testing.T) {
cfg.CreateDirectory = false
cfg.DirectoryPermissions = "07771"
return cfg

},
err: nil,
},
Expand Down
2 changes: 0 additions & 2 deletions extension/storage/filestorage/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func TestExtensionIntegrity(t *testing.T) {

// Repeatedly thrash client
for j := 0; j < 100; j++ {

// Make sure my values are still mine
for i := 0; i < len(keys); i++ {
v, err := c.Get(ctx, keys[i])
Expand Down Expand Up @@ -143,7 +142,6 @@ func TestClientHandlesSimpleCases(t *testing.T) {
data, err = client.Get(ctx, "key")
require.NoError(t, err)
require.Nil(t, data)

}

func TestTwoClientsWithDifferentNames(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions extension/storage/redisstorageextension/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func TestExtensionIntegrity(t *testing.T) {

// Repeatedly thrash client
for j := 0; j < 100; j++ {

// Make sure my values are still mine
for i := 0; i < len(keys); i++ {
v, err := c.Get(ctx, keys[i])
Expand Down Expand Up @@ -136,7 +135,6 @@ func TestClientHandlesSimpleCases(t *testing.T) {
data, err = client.Get(ctx, "key")
require.NoError(t, err)
require.Nil(t, data)

}

func TestTwoClientsWithDifferentNames(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions extension/sumologicextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ func (se *SumologicExtension) heartbeatLoop() {
zap.String(collectorNameField, colCreds.Credentials.CollectorName),
zap.String(collectorIDField, colCreds.Credentials.CollectorID),
)

} else {
se.logger.Error("Heartbeat error", zap.Error(err))
}
Expand All @@ -618,7 +617,6 @@ func (se *SumologicExtension) heartbeatLoop() {
timer.Reset(se.conf.HeartBeatInterval)
case <-se.closeChan:
}

}
}
}
Expand Down
15 changes: 0 additions & 15 deletions extension/sumologicextension/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func TestBasicStart(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// register
case 1:
assert.Equal(t, registerURL, req.URL.Path)
Expand Down Expand Up @@ -159,7 +158,6 @@ func TestStoreCredentials(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// register
case 1:
assert.Equal(t, registerURL, req.URL.Path)
Expand Down Expand Up @@ -402,7 +400,6 @@ func TestLocalFSCredentialsStore_WorkCorrectlyForMultipleExtensions(t *testing.T
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// register
case 1:
assert.Equal(t, registerURL, req.URL.Path)
Expand Down Expand Up @@ -506,7 +503,6 @@ func TestRegisterEmptyCollectorName(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// register
case 1:
assert.Equal(t, registerURL, req.URL.Path)
Expand Down Expand Up @@ -575,7 +571,6 @@ func TestRegisterEmptyCollectorNameForceRegistration(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// register
case 1:
assert.Equal(t, registerURL, req.URL.Path)
Expand Down Expand Up @@ -669,7 +664,6 @@ func TestCollectorSendsBasicAuthHeadersOnRegistration(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// register
case 1:
assert.Equal(t, registerURL, req.URL.Path)
Expand Down Expand Up @@ -773,7 +767,6 @@ func TestCollectorCheckingCredentialsFoundInLocalStorage(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// heatbeat
case 1:
assert.NotEqual(t, registerURL, req.URL.Path,
Expand Down Expand Up @@ -821,7 +814,6 @@ func TestCollectorCheckingCredentialsFoundInLocalStorage(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// failing heatbeat
case 1:
assert.NotEqual(t, registerURL, req.URL.Path,
Expand Down Expand Up @@ -885,7 +877,6 @@ func TestCollectorCheckingCredentialsFoundInLocalStorage(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// failing heatbeat
case 1:
assert.NotEqual(t, registerURL, req.URL.Path,
Expand Down Expand Up @@ -953,7 +944,6 @@ func TestCollectorCheckingCredentialsFoundInLocalStorage(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch reqNum {

// register
case 1:
assert.Equal(t, registerURL, req.URL.Path)
Expand Down Expand Up @@ -1044,7 +1034,6 @@ func TestRegisterEmptyCollectorNameWithBackoff(t *testing.T) {
reqNum := atomic.AddInt32(&reqCount, 1)

switch {

// register
case reqNum <= retriesLimit:
assert.Equal(t, registerURL, req.URL.Path)
Expand All @@ -1056,7 +1045,6 @@ func TestRegisterEmptyCollectorNameWithBackoff(t *testing.T) {
if reqCount < retriesLimit {
w.WriteHeader(http.StatusTooManyRequests)
} else {

_, err = w.Write([]byte(`{
"collectorCredentialID": "aaaaaaaaaaaaaaaaaaaa",
"collectorCredentialKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
Expand Down Expand Up @@ -1163,7 +1151,6 @@ func TestRegistrationRedirect(t *testing.T) {
destSrv := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, req *http.Request) {
switch atomic.AddInt32(&destReqCount, 1) {

// register
case 1:
assert.Equal(t, registerURL, req.URL.Path)
Expand Down Expand Up @@ -1221,7 +1208,6 @@ func TestRegistrationRedirect(t *testing.T) {
origSrv := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, req *http.Request) {
switch atomic.AddInt32(&origReqCount, 1) {

// register
case 1:
assert.Equal(t, registerURL, req.URL.Path)
Expand Down Expand Up @@ -1431,7 +1417,6 @@ func TestRegistrationRequestPayload(t *testing.T) {
assert.Equal(t, metadataURL, req.URL.Path)
w.WriteHeader(http.StatusOK)
}

})
}())

Expand Down

0 comments on commit f655764

Please sign in to comment.