diff --git a/.golangci.yml b/.golangci.yml index a0a56fd5fc1..f7430dba67f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -46,7 +46,8 @@ run: # output configuration options output: # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - formats: colored-line-number + formats: + - format: colored-line-number # print lines of code with issue, default is true print-issued-lines: true @@ -126,7 +127,6 @@ linters-settings: disable: - float-compare - formatter - - go-require - require-error enable-all: true @@ -174,3 +174,12 @@ issues: - EXC0009 - EXC0010 - EXC0011 + + # Maximum issues count per one linter. + # Set to 0 to disable. + # Default: 50 + max-issues-per-linter: 0 + # Maximum count of issues with the same text. + # Set to 0 to disable. + # Default: 3 + max-same-issues: 0 diff --git a/Makefile.Common b/Makefile.Common index d0e8a2615f4..fb97b7edf23 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -38,7 +38,7 @@ SEMCONVGEN := $(TOOLS_BIN_DIR)/semconvgen SEMCONVKIT := $(TOOLS_BIN_DIR)/semconvkit TESTIFYLINT := $(TOOLS_BIN_DIR)/testifylint -TESTIFYLINT_OPT?= --enable-all --disable=float-compare,formatter,go-require,require-error +TESTIFYLINT_OPT?= --enable-all --disable=float-compare,formatter,require-error .PHONY: install-tools install-tools: $(TOOLS_BIN_NAMES) diff --git a/config/confighttp/compression_test.go b/config/confighttp/compression_test.go index a4fcb013f4f..78fcc8cd555 100644 --- a/config/confighttp/compression_test.go +++ b/config/confighttp/compression_test.go @@ -85,7 +85,7 @@ func TestHTTPClientCompression(t *testing.T) { t.Run(tt.name, func(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) - require.NoError(t, err, "failed to read request body: %v", err) + assert.NoError(t, err, "failed to read request body: %v", err) assert.EqualValues(t, tt.reqBody, body) w.WriteHeader(http.StatusOK) })) @@ -125,7 +125,7 @@ func TestHTTPCustomDecompression(t *testing.T) { return } - require.NoError(t, err, "failed to read request body: %v", err) + assert.NoError(t, err, "failed to read request body: %v", err) assert.EqualValues(t, "decompressed body", string(body)) w.WriteHeader(http.StatusOK) }) @@ -250,7 +250,7 @@ func TestHTTPContentDecompressionHandler(t *testing.T) { return } - require.NoError(t, err, "failed to read request body: %v", err) + assert.NoError(t, err, "failed to read request body: %v", err) assert.EqualValues(t, testBody, string(body)) w.WriteHeader(http.StatusOK) }), defaultMaxRequestBodySize, defaultErrorHandler, defaultCompressionAlgorithms, noDecoders)) @@ -279,7 +279,7 @@ func TestHTTPContentCompressionRequestWithNilBody(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) body, err := io.ReadAll(r.Body) - require.NoError(t, err, "failed to read request body: %v", err) + assert.NoError(t, err, "failed to read request body: %v", err) assert.EqualValues(t, compressedGzipBody.Bytes(), body) })) defer server.Close() diff --git a/config/confighttp/confighttp_test.go b/config/confighttp/confighttp_test.go index 9d08b561cc7..4fbe16be8cb 100644 --- a/config/confighttp/confighttp_test.go +++ b/config/confighttp/confighttp_test.go @@ -1504,7 +1504,7 @@ func BenchmarkHttpRequest(b *testing.B) { componenttest.NewNopTelemetrySettings(), http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, errWrite := fmt.Fprint(w, "test") - require.NoError(b, errWrite) + assert.NoError(b, errWrite) })) require.NoError(b, err) ln, err := hss.ToListener(context.Background()) diff --git a/exporter/exporterhelper/batch_sender_test.go b/exporter/exporterhelper/batch_sender_test.go index 5f5d49bec9a..a1c894102ca 100644 --- a/exporter/exporterhelper/batch_sender_test.go +++ b/exporter/exporterhelper/batch_sender_test.go @@ -549,8 +549,8 @@ func TestBatchSender_ShutdownDeadlock(t *testing.T) { sink := newFakeRequestSink() // Send 2 concurrent requests - go func() { require.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) }() - go func() { require.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) }() + go func() { assert.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) }() + go func() { assert.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) }() // Wait for the requests to enter the merge function <-waitMerge @@ -561,7 +561,7 @@ func TestBatchSender_ShutdownDeadlock(t *testing.T) { doneShutdown := make(chan struct{}) go func() { close(startShutdown) - require.NoError(t, be.Shutdown(context.Background())) + assert.NoError(t, be.Shutdown(context.Background())) close(doneShutdown) }() <-startShutdown @@ -590,7 +590,7 @@ func TestBatchSenderWithTimeout(t *testing.T) { for i := 0; i < 3; i++ { wg.Add(1) go func() { - require.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) + assert.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) wg.Done() }() } @@ -644,11 +644,11 @@ func TestBatchSenderTimerResetNoConflict(t *testing.T) { // Send 2 concurrent requests that should be merged in one batch in the same interval as the flush timer go func() { - require.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) + assert.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) }() time.Sleep(30 * time.Millisecond) go func() { - require.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) + assert.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) }() // The batch should be sent either with the flush interval or by reaching the minimum items size with no conflict @@ -676,10 +676,10 @@ func TestBatchSenderTimerFlush(t *testing.T) { // Send 2 concurrent requests that should be merged in one batch and sent immediately go func() { - require.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) + assert.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) }() go func() { - require.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) + assert.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) }() assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.LessOrEqual(c, uint64(1), sink.requestsCount.Load()) @@ -688,7 +688,7 @@ func TestBatchSenderTimerFlush(t *testing.T) { // Send another request that should be flushed after 100ms instead of 50ms since last flush go func() { - require.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) + assert.NoError(t, be.send(context.Background(), &fakeRequest{items: 4, sink: sink})) }() // Confirm that it is not flushed in 50ms diff --git a/exporter/internal/queue/persistent_queue_test.go b/exporter/internal/queue/persistent_queue_test.go index a6a7b8b974e..230d20f3f56 100644 --- a/exporter/internal/queue/persistent_queue_test.go +++ b/exporter/internal/queue/persistent_queue_test.go @@ -563,7 +563,7 @@ func TestPersistentQueueStartWithNonDispatchedConcurrent(t *testing.T) { go func() { defer conWg.Done() for i := 0; i < 10; i++ { - require.True(t, pq.Consume(func(context.Context, tracesRequest) error { return nil })) + assert.True(t, pq.Consume(func(context.Context, tracesRequest) error { return nil })) } }() } diff --git a/exporter/otlphttpexporter/otlp_test.go b/exporter/otlphttpexporter/otlp_test.go index 935d7f115ec..edf85f5d405 100644 --- a/exporter/otlphttpexporter/otlp_test.go +++ b/exporter/otlphttpexporter/otlp_test.go @@ -205,9 +205,9 @@ func TestErrorResponses(t *testing.T) { writer.WriteHeader(test.responseStatus) if test.responseBody != nil { msg, err := proto.Marshal(test.responseBody.Proto()) - require.NoError(t, err) + assert.NoError(t, err) _, err = writer.Write(msg) - require.NoError(t, err) + assert.NoError(t, err) } }) defer srv.Close() @@ -461,10 +461,10 @@ func TestPartialSuccess_logs(t *testing.T) { partial.SetErrorMessage("hello") partial.SetRejectedLogRecords(1) b, err := response.MarshalProto() - require.NoError(t, err) + assert.NoError(t, err) writer.Header().Set("Content-Type", "application/x-protobuf") _, err = writer.Write(b) - require.NoError(t, err) + assert.NoError(t, err) }) defer srv.Close() @@ -801,10 +801,10 @@ func TestPartialSuccess_traces(t *testing.T) { partial.SetErrorMessage("hello") partial.SetRejectedSpans(1) bytes, err := response.MarshalProto() - require.NoError(t, err) + assert.NoError(t, err) writer.Header().Set("Content-Type", "application/x-protobuf") _, err = writer.Write(bytes) - require.NoError(t, err) + assert.NoError(t, err) }) defer srv.Close() @@ -841,10 +841,10 @@ func TestPartialSuccess_metrics(t *testing.T) { partial.SetErrorMessage("hello") partial.SetRejectedDataPoints(1) bytes, err := response.MarshalProto() - require.NoError(t, err) + assert.NoError(t, err) writer.Header().Set("Content-Type", "application/x-protobuf") _, err = writer.Write(bytes) - require.NoError(t, err) + assert.NoError(t, err) }) defer srv.Close() diff --git a/internal/e2e/otlphttp_test.go b/internal/e2e/otlphttp_test.go index e5f7a0c430f..620c76d3d6a 100644 --- a/internal/e2e/otlphttp_test.go +++ b/internal/e2e/otlphttp_test.go @@ -232,18 +232,18 @@ func TestIssue_4221(t *testing.T) { svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { defer func() { assert.NoError(t, r.Body.Close()) }() compressedData, err := io.ReadAll(r.Body) - require.NoError(t, err) + assert.NoError(t, err) gzipReader, err := gzip.NewReader(bytes.NewReader(compressedData)) - require.NoError(t, err) + assert.NoError(t, err) data, err := io.ReadAll(gzipReader) - require.NoError(t, err) + assert.NoError(t, err) base64Data := base64.StdEncoding.EncodeToString(data) // Verify same base64 encoded string is received. assert.Equal(t, "CscBCkkKIAoMc2VydmljZS5uYW1lEhAKDnVvcC5zdGFnZS1ldS0xCiUKGW91dHN5c3RlbXMubW9kdWxlLnZlcnNpb24SCAoGOTAzMzg2EnoKEQoMdW9wX2NhbmFyaWVzEgExEmUKEEMDhT8Ib0+Mhs8Zi2VR34QSCOVRPDJ5XEG5IgA5QE41aASRrxZBQE41aASRrxZKEAoKc3Bhbl9pbmRleBICGANKHwoNY29kZS5mdW5jdGlvbhIOCgxteUZ1bmN0aW9uMzZ6AA==", base64Data) unbase64Data, err := base64.StdEncoding.DecodeString(base64Data) - require.NoError(t, err) + assert.NoError(t, err) tr := ptraceotlp.NewExportRequest() - require.NoError(t, tr.UnmarshalProto(unbase64Data)) + assert.NoError(t, tr.UnmarshalProto(unbase64Data)) span := tr.Traces().ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0) traceID := span.TraceID() assert.Equal(t, "4303853f086f4f8c86cf198b6551df84", hex.EncodeToString(traceID[:])) diff --git a/otelcol/collector_test.go b/otelcol/collector_test.go index b4381384a44..420db4ad414 100644 --- a/otelcol/collector_test.go +++ b/otelcol/collector_test.go @@ -483,7 +483,7 @@ func startCollector(ctx context.Context, t *testing.T, col *Collector) *sync.Wai wg.Add(1) go func() { defer wg.Done() - require.NoError(t, col.Run(ctx)) + assert.NoError(t, col.Run(ctx)) }() return wg }