Skip to content

Commit 85b2b3d

Browse files
authored
[chore]: fix staticcheck rules (processor) (#39196)
#### Description This fixes staticcheck issues in processor discovered after golangci-lint@v2 upgrade Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 8949d45 commit 85b2b3d

File tree

23 files changed

+46
-44
lines changed

23 files changed

+46
-44
lines changed

processor/attributesprocessor/attributes_log_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestLogProcessor_NilEmptyData(t *testing.T) {
7676
factory := NewFactory()
7777
cfg := factory.CreateDefaultConfig()
7878
oCfg := cfg.(*Config)
79-
oCfg.Settings.Actions = []attraction.ActionKeyValue{
79+
oCfg.Actions = []attraction.ActionKeyValue{
8080
{Key: "attribute1", Action: attraction.INSERT, Value: 123},
8181
{Key: "attribute1", Action: attraction.DELETE},
8282
}

processor/attributesprocessor/attributes_metric_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestMetricProcessor_NilEmptyData(t *testing.T) {
8484
factory := NewFactory()
8585
cfg := factory.CreateDefaultConfig()
8686
oCfg := cfg.(*Config)
87-
oCfg.Settings.Actions = []attraction.ActionKeyValue{
87+
oCfg.Actions = []attraction.ActionKeyValue{
8888
{Key: "attribute1", Action: attraction.INSERT, Value: 123},
8989
{Key: "attribute1", Action: attraction.DELETE},
9090
}

processor/attributesprocessor/attributes_trace_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestSpanProcessor_NilEmptyData(t *testing.T) {
8686
factory := NewFactory()
8787
cfg := factory.CreateDefaultConfig()
8888
oCfg := cfg.(*Config)
89-
oCfg.Settings.Actions = []attraction.ActionKeyValue{
89+
oCfg.Actions = []attraction.ActionKeyValue{
9090
{Key: "attribute1", Action: attraction.INSERT, Value: 123},
9191
{Key: "attribute1", Action: attraction.DELETE},
9292
}

processor/coralogixprocessor/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ type Config struct {
1919
}
2020

2121
func (c *Config) Validate() error {
22-
if c.databaseBlueprintsConfig.sampling.enabled && c.databaseBlueprintsConfig.sampling.maxCacheSizeMib <= 0 {
22+
if c.sampling.enabled && c.sampling.maxCacheSizeMib <= 0 {
2323
return fmt.Errorf("max_cache_size_mib must be a positive integer")
2424
}
25-
if c.databaseBlueprintsConfig.sampling.enabled && c.databaseBlueprintsConfig.sampling.maxCacheSizeMib != 0 {
25+
if c.sampling.enabled && c.sampling.maxCacheSizeMib != 0 {
2626
return fmt.Errorf("max_cache_size_mib can only be defined when sampling is enabled")
2727
}
2828
return nil

processor/deltatocumulativeprocessor/processor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func setupTestTelemetry() testTelemetry {
173173

174174
func (tt *testTelemetry) newSettings() processor.Settings {
175175
set := processortest.NewNopSettings(metadata.Type)
176-
set.TelemetrySettings.MeterProvider = tt.meterProvider
176+
set.MeterProvider = tt.meterProvider
177177
return set
178178
}
179179

processor/geoipprocessor/geoip_processor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func TestProcessor(t *testing.T) {
224224

225225
for _, tt := range testCases {
226226
t.Run(tt.name, func(t *testing.T) {
227-
var attributes []attribute.Key = defaultAttributes
227+
attributes := defaultAttributes
228228
if tt.attributes != nil {
229229
attributes = tt.attributes
230230
}

processor/k8sattributesprocessor/internal/kube/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,8 @@ func (c *WatchClient) getIdentifiersFromAssoc(pod *Pod) []PodIdentifier {
778778
skip := false
779779
for i, source := range assoc.Sources {
780780
// If association configured to take IP address from connection
781-
switch {
782-
case source.From == ConnectionSource:
781+
switch source.From {
782+
case ConnectionSource:
783783
if pod.Address == "" {
784784
skip = true
785785
break
@@ -793,7 +793,7 @@ func (c *WatchClient) getIdentifiersFromAssoc(pod *Pod) []PodIdentifier {
793793
break
794794
}
795795
ret[i] = PodIdentifierAttributeFromSource(source, pod.Address)
796-
case source.From == ResourceSource:
796+
case ResourceSource:
797797
attr := ""
798798
switch source.Name {
799799
case conventions.AttributeK8SNamespaceName:

processor/k8sattributesprocessor/pod_association.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ func extractPodID(ctx context.Context, attrs pcommon.Map, associations []kube.As
2929
ret := kube.PodIdentifier{}
3030
for i, source := range asso.Sources {
3131
// If association configured to take IP address from connection
32-
switch {
33-
case source.From == kube.ConnectionSource:
32+
switch source.From {
33+
case kube.ConnectionSource:
3434
if connectionIP == "" {
3535
skip = true
3636
break
3737
}
3838
ret[i] = kube.PodIdentifierAttributeFromConnection(connectionIP)
39-
case source.From == kube.ResourceSource:
39+
case kube.ResourceSource:
4040
// Extract values based on configured resource_attribute.
4141
attributeValue := stringAttributeFromMap(attrs, source.Name)
4242
if attributeValue == "" {

processor/logstransformprocessor/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var _ component.Config = (*Config)(nil)
2020

2121
// Validate checks if the processor configuration is valid
2222
func (cfg *Config) Validate() error {
23-
if len(cfg.BaseConfig.Operators) == 0 {
23+
if len(cfg.Operators) == 0 {
2424
return errors.New("no operators were configured for this logs transform processor")
2525
}
2626
return nil

processor/logstransformprocessor/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func createLogsProcessor(
4444
return nil, errors.New("could not initialize logs transform processor")
4545
}
4646

47-
if len(pCfg.BaseConfig.Operators) == 0 {
47+
if len(pCfg.Operators) == 0 {
4848
return nil, errors.New("no operators were configured for this logs transform processor")
4949
}
5050

0 commit comments

Comments
 (0)