Repository: jaegertracing/jaeger

Issue:
[Bug]: CI does not detect missing `go fmt` changes
### What happened?

If I run `make fmt` in the main branch it results in a number of files having whitespace diffs. The CI checks in `make lint` were supposed to catch these diffs and fail the CI.

### Steps to reproduce

`make fmt` or even `make lint`, then `git status`
```
$ gst
On branch main
Your branch is up to date with 'upstream/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   cmd/es-rollover/app/lookback/time_reference_test.go
	modified:   cmd/jaeger/internal/extension/remotestorage/server_test.go
	modified:   examples/hotrod/pkg/tracing/rpcmetrics/metrics_test.go
	modified:   internal/jptrace/sanitizer/emptyservicename_test.go
	modified:   internal/storage/metricstore/factory_test.go
	modified:   internal/storage/v1/cassandra/dependencystore/storage_test.go
	modified:   internal/storage/v1/cassandra/spanstore/dbmodel/converter_test.go
	modified:   internal/storage/v2/elasticsearch/tracestore/from_dbmodel_test.go
	modified:   internal/storage/v2/elasticsearch/tracestore/to_dbmodel_test.go
	modified:   internal/telemetry/settings_test.go
	modified:   internal/uimodel/converter/v1/json/from_domain_test.go
```

### Expected behavior

`make fmt` and `make lint` on `main` branch are supposed to produce no differences in files. `make lint` should've failed the CI.

### Relevant log output

```shell

```

### Screenshot

_No response_

### Additional context

_No response_

### Jaeger backend version

_No response_

### SDK

_No response_

### Pipeline

_No response_

### Stogage backend

_No response_

### Operating system

_No response_

### Deployment model

_No response_

### Deployment configs

```shell

```

Hints from issue comments:

Solution patch:
diff --git a/Makefile b/Makefile
index 2fb8da1a..6bb38b0d 100644
--- a/Makefile
+++ b/Makefile
@@ -150,7 +150,7 @@ fmt: $(GOFUMPT)
 	@./scripts/lint/updateLicense.py $(ALL_SRC) $(SCRIPTS_SRC)
 
 .PHONY: lint
-lint: lint-license lint-imports lint-semconv lint-goversion lint-goleak lint-go
+lint: lint-fmt lint-license lint-imports lint-semconv lint-goversion lint-goleak lint-go
 
 .PHONY: lint-license
 lint-license:
@@ -174,6 +174,14 @@ lint-imports:
 	@./scripts/lint/import-order-cleanup.py -o stdout -t $(ALL_SRC) > $(IMPORT_LOG)
 	@[ ! -s "$(IMPORT_LOG)" ] || (echo "Import ordering failures, run 'make fmt'" | cat - $(IMPORT_LOG) && false)
 
+.PHONY: lint-fmt
+lint-fmt: $(GOFUMPT)
+	@echo Verifying that all Go files are formatted with gofmt and gofumpt
+	@rm -f $(FMT_LOG)
+	@$(GOFMT) -d -e -s $(ALL_SRC) > $(FMT_LOG) || true
+	@$(GOFUMPT) -d -e $(ALL_SRC) >> $(FMT_LOG) || true
+	@[ ! -s "$(FMT_LOG)" ] || (echo "Formatting check failed. Please run 'make fmt'" && head -100 $(FMT_LOG) && false)
+
 .PHONY: lint-semconv
 lint-semconv:
 	./scripts/lint/check-semconv-version.sh
diff --git a/scripts/lint/import-order-cleanup.py b/scripts/lint/import-order-cleanup.py
index 64693229..af15326b 100755
--- a/scripts/lint/import-order-cleanup.py
+++ b/scripts/lint/import-order-cleanup.py
@@ -85,8 +85,9 @@ def main():
 
     for f in go_files:
         parsed, imports_reordered = parse_go_file(f)
-        if output == "stdout" and imports_reordered:
-            print(f + " imports out of order")
+        if output == "stdout":
+            if imports_reordered:
+                print(f + " imports out of order")
         else:
             with open(f, 'w') as ofile:
                 ofile.write(parsed)



Test patch:
diff --git a/cmd/es-rollover/app/lookback/time_reference_test.go b/cmd/es-rollover/app/lookback/time_reference_test.go
index 9171b091..edd04a1b 100644
--- a/cmd/es-rollover/app/lookback/time_reference_test.go
+++ b/cmd/es-rollover/app/lookback/time_reference_test.go
@@ -73,17 +73,17 @@ func TestGetTimeReference(t *testing.T) {
 
 func TestGetTimeReference_DefaultCase(t *testing.T) {
 	now := time.Date(2021, time.October, 10, 10, 10, 10, 10, time.UTC)
-	
+
 	unknownUnit := "unknown-unit"
 	unitCount := 30
-	
+
 	ref := getTimeReference(now, unknownUnit, unitCount)
-	
+
 	expectedTime := time.Date(2021, time.October, 10, 10, 9, 40, 0, time.UTC)
 	assert.Equal(t, expectedTime, ref)
-	
+
 	anotherUnknownUnit := "milliseconds"
 	ref2 := getTimeReference(now, anotherUnknownUnit, unitCount)
-	
+
 	assert.Equal(t, expectedTime, ref2)
 }
diff --git a/cmd/jaeger/internal/extension/remotestorage/server_test.go b/cmd/jaeger/internal/extension/remotestorage/server_test.go
index bff17d15..39fc39e2 100644
--- a/cmd/jaeger/internal/extension/remotestorage/server_test.go
+++ b/cmd/jaeger/internal/extension/remotestorage/server_test.go
@@ -176,15 +176,15 @@ func TestServer_Start(t *testing.T) {
 
 func TestTraceStorageFactory_DefaultCase(t *testing.T) {
 	fakeExt := fakeStorageExt{}
-	
+
 	factory, exists := fakeExt.TraceStorageFactory("unknown-factory-name")
-	
+
 	require.True(t, exists)
 	require.NotNil(t, factory)
-	
+
 	_, ok := factory.(*fakeFactory)
 	require.True(t, ok)
-	
+
 	factory2, exists2 := fakeExt.TraceStorageFactory("another-unknown-name")
 	require.True(t, exists2)
 	require.NotNil(t, factory2)
diff --git a/examples/hotrod/pkg/tracing/rpcmetrics/metrics_test.go b/examples/hotrod/pkg/tracing/rpcmetrics/metrics_test.go
index 923c1ad4..bd2fcc15 100644
--- a/examples/hotrod/pkg/tracing/rpcmetrics/metrics_test.go
+++ b/examples/hotrod/pkg/tracing/rpcmetrics/metrics_test.go
@@ -54,18 +54,18 @@ func TestRecordHTTPStatusCode_DefaultCase(t *testing.T) {
 	met := metricstest.NewFactory(0)
 	mbe := newMetricsByEndpoint(met, DefaultNameNormalizer, 2)
 	metrics := mbe.get("test-endpoint")
-	
+
 	metrics.recordHTTPStatusCode(100)
 	metrics.recordHTTPStatusCode(199)
 	metrics.recordHTTPStatusCode(600)
 	metrics.recordHTTPStatusCode(999)
-	
+
 	met.AssertCounterMetrics(t)
-	
+
 	metrics.recordHTTPStatusCode(200)
 	metrics.recordHTTPStatusCode(404)
 	metrics.recordHTTPStatusCode(500)
-	
+
 	met.AssertCounterMetrics(t,
 		metricstest.ExpectedMetric{Name: "http_requests", Tags: endpointTags("test_endpoint", "status_code", "2xx"), Value: 1},
 		metricstest.ExpectedMetric{Name: "http_requests", Tags: endpointTags("test_endpoint", "status_code", "4xx"), Value: 1},
diff --git a/internal/jptrace/sanitizer/emptyservicename_test.go b/internal/jptrace/sanitizer/emptyservicename_test.go
index 0a46bb16..82b1e56c 100644
--- a/internal/jptrace/sanitizer/emptyservicename_test.go
+++ b/internal/jptrace/sanitizer/emptyservicename_test.go
@@ -81,7 +81,7 @@ func TestEmptyServiceNameSanitizer_SubstitutesCorrectlyForNonStringType(t *testi
 
 func TestEmptyServiceNameSanitizer_DefaultCases(t *testing.T) {
 	validServiceName := "valid-service"
-	
+
 	traces := ptrace.NewTraces()
 	attributes := traces.
 		ResourceSpans().
@@ -89,10 +89,10 @@ func TestEmptyServiceNameSanitizer_DefaultCases(t *testing.T) {
 		Resource().
 		Attributes()
 	attributes.PutStr("service.name", validServiceName)
-	
+
 	sanitizer := NewEmptyServiceNameSanitizer()
 	sanitized := sanitizer(traces)
-	
+
 	serviceName, ok := sanitized.
 		ResourceSpans().
 		At(0).
@@ -101,14 +101,14 @@ func TestEmptyServiceNameSanitizer_DefaultCases(t *testing.T) {
 		Get("service.name")
 	require.True(t, ok)
 	require.Equal(t, validServiceName, serviceName.Str())
-	
+
 	attributes2 := traces.
 		ResourceSpans().
 		AppendEmpty().
 		Resource().
 		Attributes()
 	attributes2.PutStr("service.name", "")
-	
+
 	sanitized = sanitizer(traces)
 
 	serviceName, ok = sanitized.
@@ -119,7 +119,7 @@ func TestEmptyServiceNameSanitizer_DefaultCases(t *testing.T) {
 		Get("service.name")
 	require.True(t, ok)
 	require.Equal(t, validServiceName, serviceName.Str())
-	
+
 	serviceName2, ok := sanitized.
 		ResourceSpans().
 		At(1).
diff --git a/internal/storage/metricstore/factory_test.go b/internal/storage/metricstore/factory_test.go
index 23c992ef..0b91006d 100644
--- a/internal/storage/metricstore/factory_test.go
+++ b/internal/storage/metricstore/factory_test.go
@@ -107,9 +107,9 @@ func TestConfigurable(t *testing.T) {
 
 func TestFactory_GetFactoryOfType_UnknownType(t *testing.T) {
 	f := &Factory{}
-	
+
 	factory, err := f.getFactoryOfType("unknown-type")
-	
+
 	assert.Nil(t, factory)
 	require.Error(t, err)
 	assert.Contains(t, err.Error(), "unknown metrics type \"unknown-type\"")
diff --git a/internal/storage/v1/cassandra/dependencystore/storage_test.go b/internal/storage/v1/cassandra/dependencystore/storage_test.go
index b5c4720f..faea82bf 100644
--- a/internal/storage/v1/cassandra/dependencystore/storage_test.go
+++ b/internal/storage/v1/cassandra/dependencystore/storage_test.go
@@ -264,22 +264,22 @@ func TestDependencyStore_UnsupportedVersion(t *testing.T) {
 	logger := zap.NewNop()
 	metricsFactory := metrics.NullFactory
 	session := &mocks.Session{}
-	
+
 	store := &DependencyStore{
 		session:                  session,
 		dependenciesTableMetrics: casMetrics.NewTable(metricsFactory, "dependencies"),
 		logger:                   logger,
 		version:                  Version(999),
 	}
-	
+
 	deps := []model.DependencyLink{
 		{Parent: "parent", Child: "child", CallCount: 1},
 	}
-	
+
 	err := store.WriteDependencies(time.Now(), deps)
 	require.Error(t, err)
 	assert.Contains(t, err.Error(), "unsupported schema version")
-	
+
 	_, err = store.GetDependencies(context.Background(), time.Now(), time.Hour)
 	require.Error(t, err)
 	assert.Contains(t, err.Error(), "unsupported schema version")
diff --git a/internal/storage/v1/cassandra/spanstore/dbmodel/converter_test.go b/internal/storage/v1/cassandra/spanstore/dbmodel/converter_test.go
index a035c1e7..b80a8edd 100644
--- a/internal/storage/v1/cassandra/spanstore/dbmodel/converter_test.go
+++ b/internal/storage/v1/cassandra/spanstore/dbmodel/converter_test.go
@@ -338,10 +338,10 @@ func TestFromDBTag_DefaultCase(t *testing.T) {
 		ValueType:   "unknown-type",
 		ValueString: "test-value",
 	}
-	
+
 	converter := converter{}
 	result, err := converter.fromDBTag(tag)
-	
+
 	require.Error(t, err)
 	assert.Contains(t, err.Error(), "invalid ValueType")
 	assert.Equal(t, model.KeyValue{}, result)
diff --git a/internal/storage/v2/elasticsearch/tracestore/from_dbmodel_test.go b/internal/storage/v2/elasticsearch/tracestore/from_dbmodel_test.go
index 8575c68c..3741dfbd 100644
--- a/internal/storage/v2/elasticsearch/tracestore/from_dbmodel_test.go
+++ b/internal/storage/v2/elasticsearch/tracestore/from_dbmodel_test.go
@@ -149,15 +149,15 @@ func TestGetStatusCodeFromHTTPStatusAttr(t *testing.T) {
 
 func TestGetStatusCodeFromHTTPStatusAttr_DefaultSpanKind(t *testing.T) {
 	value := pcommon.NewValueInt(404)
-	
+
 	statusCode, err := getStatusCodeFromHTTPStatusAttr(value, ptrace.SpanKindInternal)
 	require.NoError(t, err)
 	assert.Equal(t, ptrace.StatusCodeError, statusCode)
-	
+
 	statusCode, err = getStatusCodeFromHTTPStatusAttr(value, ptrace.SpanKindProducer)
 	require.NoError(t, err)
 	assert.Equal(t, ptrace.StatusCodeError, statusCode)
-	
+
 	statusCode, err = getStatusCodeFromHTTPStatusAttr(value, ptrace.SpanKindConsumer)
 	require.NoError(t, err)
 	assert.Equal(t, ptrace.StatusCodeError, statusCode)
@@ -822,10 +822,10 @@ func TestDBSpanKindToOTELSpanKind(t *testing.T) {
 func TestDbSpanKindToOTELSpanKind_DefaultCase(t *testing.T) {
 	result := dbSpanKindToOTELSpanKind("unknown-span-kind")
 	assert.Equal(t, ptrace.SpanKindUnspecified, result)
-	
+
 	result = dbSpanKindToOTELSpanKind("")
 	assert.Equal(t, ptrace.SpanKindUnspecified, result)
-	
+
 	result = dbSpanKindToOTELSpanKind("invalid")
 	assert.Equal(t, ptrace.SpanKindUnspecified, result)
 }
@@ -834,11 +834,11 @@ func TestSetInternalSpanStatus_DefaultCase(t *testing.T) {
 	span := ptrace.NewSpan()
 	status := span.Status()
 	attrs := pcommon.NewMap()
-	
+
 	attrs.PutStr(conventions.OtelStatusCode, "UNKNOWN_STATUS")
-	
+
 	setSpanStatus(attrs, span)
-	
+
 	assert.Equal(t, ptrace.StatusCodeUnset, status.Code())
 	assert.Empty(t, status.Message())
 }
diff --git a/internal/storage/v2/elasticsearch/tracestore/to_dbmodel_test.go b/internal/storage/v2/elasticsearch/tracestore/to_dbmodel_test.go
index fb2f13a5..c8abbb32 100644
--- a/internal/storage/v2/elasticsearch/tracestore/to_dbmodel_test.go
+++ b/internal/storage/v2/elasticsearch/tracestore/to_dbmodel_test.go
@@ -791,9 +791,9 @@ func testSpans(t *testing.T, expectedSpan []byte, actualSpan dbmodel.Span) {
 
 func TestAttributeToDbTag_DefaultCase(t *testing.T) {
 	attr := pcommon.NewValueEmpty()
-	
+
 	tag := attributeToDbTag("test-key", attr)
-	
+
 	assert.Equal(t, "test-key", tag.Key)
 	assert.Equal(t, dbmodel.StringType, tag.Type)
 	assert.Nil(t, tag.Value)
@@ -801,7 +801,7 @@ func TestAttributeToDbTag_DefaultCase(t *testing.T) {
 
 func TestGetTagFromStatusCode_DefaultCase(t *testing.T) {
 	tag, shouldInclude := getTagFromStatusCode(ptrace.StatusCodeUnset)
-	
+
 	assert.False(t, shouldInclude)
 	assert.Equal(t, dbmodel.KeyValue{}, tag)
 }
diff --git a/internal/telemetry/settings_test.go b/internal/telemetry/settings_test.go
index 1c79fbcb..e5f22b2c 100644
--- a/internal/telemetry/settings_test.go
+++ b/internal/telemetry/settings_test.go
@@ -82,7 +82,7 @@ func TestHCAdapter(t *testing.T) {
 func TestHCAdapter_DefaultCase(t *testing.T) {
 	hc := healthcheck.New()
 	adapter := telemetry.HCAdapter(hc)
-	
+
 	event := componentstatus.NewEvent(componentstatus.Status(999))
 	adapter(event)
 	assert.Equal(t, healthcheck.Unavailable, hc.Get())
diff --git a/internal/uimodel/converter/v1/json/from_domain_test.go b/internal/uimodel/converter/v1/json/from_domain_test.go
index 7ed0c1a4..c4856f86 100644
--- a/internal/uimodel/converter/v1/json/from_domain_test.go
+++ b/internal/uimodel/converter/v1/json/from_domain_test.go
@@ -172,16 +172,16 @@ func TestDependenciesFromDomain(t *testing.T) {
 func TestConvertKeyValues_DefaultValueType(t *testing.T) {
 	// Create a custom ValueType that's not handled by the switch
 	customType := model.ValueType(999)
-	
+
 	kv := model.KeyValue{
 		Key:   "custom-key",
 		VType: customType,
 		VStr:  "custom-value",
 	}
-	
+
 	fd := fromDomain{}
 	result := fd.convertKeyValues(model.KeyValues{kv})
-	
+
 	require.Len(t, result, 1)
 	assert.Equal(t, "custom-key", result[0].Key)