Skip to content

Commit

Permalink
[chore] Add // nolint:staticcheck to unblock release (open-telemetry#…
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Jun 17, 2024
1 parent 2f079f9 commit 3ee48c4
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 5 deletions.
2 changes: 2 additions & 0 deletions connector/datadogconnector/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func TestExamples(t *testing.T) {
t.Setenv("DD_API_KEY", "testvalue")
factories := newTestComponents(t)
const configFile = "./examples/config.yaml"
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err := otelcoltest.LoadConfigAndValidate(configFile, factories)
require.NoError(t, err, "All yaml config must validate. Please ensure that all necessary component factories are added in newTestComponents()")
}
Expand Down
3 changes: 2 additions & 1 deletion connector/servicegraphconnector/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func TestLoadConfig(t *testing.T) {
require.NoError(t, err)

factories.Connectors[metadata.Type] = NewFactory()

// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "service-graph-connector-config.yaml"), factories)

// Verify
Expand Down
10 changes: 10 additions & 0 deletions exporter/awss3exporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "default.yaml"), factories)

require.NoError(t, err)
Expand Down Expand Up @@ -50,6 +52,8 @@ func TestConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[factory.Type()] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(
filepath.Join("testdata", "config.yaml"), factories)

Expand Down Expand Up @@ -78,6 +82,8 @@ func TestConfigForS3CompatibleSystems(t *testing.T) {

factory := NewFactory()
factories.Exporters[factory.Type()] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(
filepath.Join("testdata", "config-s3-compatible-systems.yaml"), factories)

Expand Down Expand Up @@ -189,6 +195,8 @@ func TestMarshallerName(t *testing.T) {

factory := NewFactory()
factories.Exporters[factory.Type()] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(
filepath.Join("testdata", "marshaler.yaml"), factories)

Expand Down Expand Up @@ -229,6 +237,8 @@ func TestCompressionName(t *testing.T) {

factory := NewFactory()
factories.Exporters[factory.Type()] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(
filepath.Join("testdata", "compression.yaml"), factories)

Expand Down
5 changes: 4 additions & 1 deletion exporter/datadogexporter/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func TestExamples(t *testing.T) {
t.Run(filepath.Base(f.Name()), func(t *testing.T) {
t.Setenv("DD_API_KEY", "testvalue")
name := filepath.Join(folder, f.Name())
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err := otelcoltest.LoadConfigAndValidate(name, factories)
require.NoError(t, err, "All yaml config must validate. Please ensure that all necessary component factories are added in newTestComponents()")
})
Expand Down Expand Up @@ -83,7 +85,8 @@ func TestExamples(t *testing.T) {
require.Equal(t, n, len(data))
require.NoError(t, f.Close())
defer os.RemoveAll(f.Name())

// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err = otelcoltest.LoadConfigAndValidate(f.Name(), factories)
require.NoError(t, err, "All yaml config must validate. Please ensure that all necessary component factories are added in newTestComponents()")
})
Expand Down
2 changes: 2 additions & 0 deletions exporter/datadogexporter/integrationtest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ func getIntegrationTestCollector(t *testing.T, cfgStr string, url string, factor
require.NoError(t, err)
_, err = confFile.Write([]byte(cfg))
require.NoError(t, err)
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err = otelcoltest.LoadConfigAndValidate(confFile.Name(), factories)
require.NoError(t, err, "All yaml config must be valid.")

Expand Down
2 changes: 2 additions & 0 deletions exporter/googlemanagedprometheusexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion exporter/loadbalancingexporter/metrics_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ func TestBuildExporterConfigUnknown(t *testing.T) {
require.NoError(t, err)

factories.Exporters[metadata.Type] = NewFactory()

// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "test-build-exporter-config.yaml"), factories)
require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down
3 changes: 2 additions & 1 deletion exporter/loadbalancingexporter/trace_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ func TestBuildExporterConfig(t *testing.T) {
require.NoError(t, err)

factories.Exporters[metadata.Type] = NewFactory()

// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "test-build-exporter-config.yaml"), factories)
require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down
3 changes: 2 additions & 1 deletion processor/probabilisticsamplerprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func TestLoadInvalidConfig(t *testing.T) {

factory := NewFactory()
factories.Processors[metadata.Type] = factory

// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", test.file), factories)
require.ErrorContains(t, err, test.contains)
})
Expand Down
2 changes: 2 additions & 0 deletions processor/sumologicprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Processors[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
Expand Down
2 changes: 2 additions & 0 deletions receiver/azureblobreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
Expand Down
2 changes: 2 additions & 0 deletions receiver/azureeventhubreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
Expand Down
6 changes: 6 additions & 0 deletions receiver/gitproviderreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
Expand Down Expand Up @@ -61,6 +63,8 @@ func TestLoadInvalidConfig_NoScrapers(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-noscrapers.yaml"), factories)

require.Contains(t, err.Error(), "must specify at least one scraper")
Expand All @@ -72,6 +76,8 @@ func TestLoadInvalidConfig_InvalidScraperKey(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-invalidscraperkey.yaml"), factories)

require.Contains(t, err.Error(), "error reading configuration for \"gitprovider\": invalid scraper key: \"invalidscraperkey\"")
Expand Down
6 changes: 6 additions & 0 deletions receiver/hostmetricsreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
Expand Down Expand Up @@ -127,6 +129,8 @@ func TestLoadInvalidConfig_NoScrapers(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-noscrapers.yaml"), factories)

require.Contains(t, err.Error(), "must specify at least one scraper when using hostmetrics receiver")
Expand All @@ -138,6 +142,8 @@ func TestLoadInvalidConfig_InvalidScraperKey(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-invalidscraperkey.yaml"), factories)

require.Contains(t, err.Error(), "error reading configuration for \"hostmetrics\": invalid scraper key: invalidscraperkey")
Expand Down
4 changes: 4 additions & 0 deletions receiver/hostmetricsreceiver/hostmetrics_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func TestLoadConfigRootPath(t *testing.T) {
factories, _ := otelcoltest.NopFactories()
factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-root-path.yaml"), factories)
require.NoError(t, err)
globalRootPath = ""
Expand All @@ -63,6 +65,8 @@ func TestLoadInvalidConfig_RootPathNotExist(t *testing.T) {
factories, _ := otelcoltest.NopFactories()
factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
_, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "config-bad-root-path.yaml"), factories)
assert.ErrorContains(t, err, "invalid root_path:")
globalRootPath = ""
Expand Down
4 changes: 4 additions & 0 deletions receiver/receivercreator/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ func TestInvalidResourceAttributeEndpointType(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "invalid-resource-attributes.yaml"), factories)
require.Contains(t, err.Error(), "error reading configuration for \"receiver_creator\": resource attributes for unsupported endpoint type \"not.a.real.type\"")
require.Nil(t, cfg)
Expand All @@ -156,6 +158,8 @@ func TestInvalidReceiverResourceAttributeValueType(t *testing.T) {

factory := NewFactory()
factories.Receivers[metadata.Type] = factory
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "invalid-receiver-resource-attributes.yaml"), factories)
require.Contains(t, err.Error(), "error reading configuration for \"receiver_creator\": unsupported `resource_attributes` \"one\" value <nil> in examplereceiver/1")
require.Nil(t, cfg)
Expand Down
2 changes: 2 additions & 0 deletions receiver/snmpreceiver/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func TestIntegration(t *testing.T) {
factory := NewFactory()
factories.Receivers[metadata.Type] = factory
configFile := filepath.Join("testdata", "integration", testCase.configFilename)
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
// nolint:staticcheck
cfg, err := otelcoltest.LoadConfigAndValidate(configFile, factories)
require.NoError(t, err)
snmpConfig := cfg.Receivers[component.NewID(metadata.Type)].(*Config)
Expand Down

0 comments on commit 3ee48c4

Please sign in to comment.