Skip to content

Commit a05740a

Browse files
authored
[chore]: enable nolintlint (#37351)
#### Description [nolintlint](https://golangci-lint.run/usage/linters/#nolintlint): Reports ill-formed or insufficient nolint directives. Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 6a7f685 commit a05740a

File tree

62 files changed

+75
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+75
-121
lines changed

.golangci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ linters-settings:
166166
explicit-exhaustive-switch: true
167167
ignore-enum-members: "pmetric.MetricTypeEmpty"
168168

169+
nolintlint:
170+
require-specific: true
171+
169172
predeclared:
170173
ignore: copy
171174

@@ -201,6 +204,7 @@ linters:
201204
- gosec
202205
- govet
203206
- misspell
207+
- nolintlint
204208
- predeclared
205209
- reassign
206210
- revive
@@ -227,3 +231,7 @@ issues:
227231
- text: "G115:"
228232
linters:
229233
- gosec
234+
- path: "pagefile.go" # This exclusion is required for Windows only
235+
text: "cachedBytes"
236+
linters:
237+
- unused

cmd/telemetrygen/internal/logs/worker.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,11 @@ func (w worker) simulateLogs(res *resource.Resource, exporterFunc func() (sdklog
5858

5959
if w.spanID != "" {
6060
// we checked this for errors in the Validate function
61-
// nolint: errcheck
6261
b, _ := hex.DecodeString(w.spanID)
6362
sid = trace.SpanID(b)
6463
}
6564
if w.traceID != "" {
6665
// we checked this for errors in the Validate function
67-
// nolint: errcheck
6866
b, _ := hex.DecodeString(w.traceID)
6967
tid = trace.TraceID(b)
7068
}

cmd/telemetrygen/internal/metrics/metrics.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,12 @@ func exemplarsFromConfig(c *Config) []metricdata.Exemplar[int64] {
128128

129129
if c.TraceID != "" {
130130
// we validated this already during the Validate() function for config
131-
// nolint: errcheck
132131
traceID, _ := hex.DecodeString(c.TraceID)
133132
exemplar.TraceID = traceID
134133
}
135134

136135
if c.SpanID != "" {
137136
// we validated this already during the Validate() function for config
138-
// nolint: errcheck
139137
spanID, _ := hex.DecodeString(c.SpanID)
140138
exemplar.SpanID = spanID
141139
}

connector/datadogconnector/example_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ func TestExamples(t *testing.T) {
2525
t.Setenv("DD_API_KEY", "aaaaaaaaa")
2626
factories := newTestComponents(t)
2727
const configFile = "./examples/config.yaml"
28-
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
29-
// nolint:staticcheck
3028
_, err := otelcoltest.LoadConfigAndValidate(configFile, factories)
3129
require.NoError(t, err, "All yaml config must validate. Please ensure that all necessary component factories are added in newTestComponents()")
3230
}

connector/servicegraphconnector/config_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ func TestLoadConfig(t *testing.T) {
2222
require.NoError(t, err)
2323

2424
factories.Connectors[metadata.Type] = NewFactory()
25-
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33594
26-
// nolint:staticcheck
2725
cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "service-graph-connector-config.yaml"), factories)
2826

2927
// Verify

connector/servicegraphconnector/internal/store/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (s *Store) Expire() {
110110
defer s.mtx.Unlock()
111111

112112
// Iterates until no more items can be evicted
113-
for s.tryEvictHead() { // nolint
113+
for s.tryEvictHead() {
114114
}
115115
}
116116

exporter/awskinesisexporter/internal/batch/batch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"errors"
88

99
"github.com/aws/aws-sdk-go-v2/aws"
10-
"github.com/aws/aws-sdk-go-v2/service/kinesis/types" //nolint:staticcheck // Some encoding types uses legacy prototype version
10+
"github.com/aws/aws-sdk-go-v2/service/kinesis/types"
1111
"go.opentelemetry.io/collector/consumer/consumererror"
1212

1313
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awskinesisexporter/internal/compress"

exporter/awss3exporter/config_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ func TestLoadConfig(t *testing.T) {
2424

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

3129
require.NoError(t, err)
@@ -57,8 +55,6 @@ func TestConfig(t *testing.T) {
5755

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

@@ -93,8 +89,6 @@ func TestConfigForS3CompatibleSystems(t *testing.T) {
9389

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

@@ -209,8 +203,6 @@ func TestMarshallerName(t *testing.T) {
209203

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

@@ -253,8 +245,6 @@ func TestCompressionName(t *testing.T) {
253245

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

exporter/awss3exporter/internal/upload/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (sw *s3manager) Upload(ctx context.Context, data []byte) error {
6363
}
6464

6565
func (sw *s3manager) contentBuffer(raw []byte) (*bytes.Buffer, error) {
66-
//nolint: gocritic // Leaving this as a switch statement to make it easier to add more later compressions
66+
//nolint:gocritic // Leaving this as a switch statement to make it easier to add more later compressions
6767
switch sw.builder.Compression {
6868
case configcompression.TypeGzip:
6969
content := bytes.NewBuffer(nil)

exporter/clickhouseexporter/exporter_metrics_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ func mustPushMetricsData(t *testing.T, exporter *metricsExporter, md pmetric.Met
518518
require.NoError(t, err)
519519
}
520520

521-
// nolint:unparam // not need to check this func
522521
func newTestMetricsExporter(t *testing.T, dsn string, fns ...func(*Config)) *metricsExporter {
523522
exporter, err := newMetricsExporter(zaptest.NewLogger(t), withTestExporterConfig(fns...)(dsn))
524523
require.NoError(t, err)

0 commit comments

Comments
 (0)