Skip to content

Commit

Permalink
[chore]: enable formatter rule from testifylint
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 committed Sep 14, 2024
1 parent c52a9a7 commit a5d9840
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 17 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ linters-settings:
testifylint:
disable:
- float-compare
- formatter
- go-require
- require-error
- suite-subtest-run
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ GOTESTSUM := $(TOOLS_BIN_DIR)/gotestsum
TESTIFYLINT := $(TOOLS_BIN_DIR)/testifylint

GOTESTSUM_OPT?= --rerun-fails=1
TESTIFYLINT_OPT?= --enable-all --disable=float-compare,formatter,go-require,require-error,suite-subtest-run,useless-assert
TESTIFYLINT_OPT?= --enable-all --disable=float-compare,go-require,require-error,suite-subtest-run,useless-assert

# BUILD_TYPE should be one of (dev, release).
BUILD_TYPE?=release
Expand Down
4 changes: 2 additions & 2 deletions exporter/azuredataexplorerexporter/metricsdata_to_adx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func Test_rawMetricsToAdxMetrics(t *testing.T) {
// Metric assertions
assert.Equal(t, expectedMetric.MetricName, actualMetrics[i].MetricName)
assert.Equal(t, expectedMetric.MetricType, actualMetrics[i].MetricType)
assert.Equal(t, expectedMetric.MetricValue, actualMetrics[i].MetricValue, fmt.Sprintf("Mismatch for value for test %s", tt.name))
assert.Equal(t, expectedMetric.MetricValue, actualMetrics[i].MetricValue, "Mismatch for value for test %s", tt.name)
assert.Equal(t, expectedMetric.MetricDescription, actualMetrics[i].MetricDescription)
assert.Equal(t, expectedMetric.MetricUnit, actualMetrics[i].MetricUnit)
assert.Equal(t, expectedMetric.MetricAttributes, actualMetrics[i].MetricAttributes)
Expand Down Expand Up @@ -556,7 +556,7 @@ func Test_mapToAdxMetric(t *testing.T) {
// Metric assertions
assert.Equal(t, expectedMetric.MetricName, actualMetrics[i].MetricName)
assert.Equal(t, expectedMetric.MetricType, actualMetrics[i].MetricType)
assert.Equal(t, expectedMetric.MetricValue, actualMetrics[i].MetricValue, fmt.Sprintf("Mismatch for value for test %s", tt.name))
assert.Equal(t, expectedMetric.MetricValue, actualMetrics[i].MetricValue, "Mismatch for value for test %s", tt.name)
assert.Equal(t, expectedMetric.MetricDescription, actualMetrics[i].MetricDescription)
assert.Equal(t, expectedMetric.MetricUnit, actualMetrics[i].MetricUnit)
assert.Equal(t, expectedMetric.MetricAttributes, actualMetrics[i].MetricAttributes)
Expand Down
2 changes: 1 addition & 1 deletion exporter/kafkaexporter/marshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func TestOTLPTracesJsonMarshaling(t *testing.T) {
Encoding: test.encoding,
PartitionTracesByID: test.partitionTracesByID,
})
require.NoError(t, err, fmt.Sprintf("Must have %s marshaler", test.encoding))
require.NoError(t, err, "Must have %s marshaler", test.encoding)

msg, err := marshaler.Marshal(traces, t.Name())
require.NoError(t, err, "Must have marshaled the data without error")
Expand Down
2 changes: 1 addition & 1 deletion exporter/signalfxexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ func TestDefaultSystemCPUTimeExcludedAndTranslated(t *testing.T) {
for _, dp := range dps {
if dp.Metric == "cpu.num_processors" || dp.Metric == "cpu.idle" {
intVal := dp.Value.IntValue
require.NotNil(t, intVal, fmt.Sprintf("unexpected nil IntValue for %q", dp.Metric))
require.NotNil(t, intVal, "unexpected nil IntValue for %q", dp.Metric)
found[dp.Metric] = *intVal
} else {
// account for unexpected w/ test-failing placeholder
Expand Down
3 changes: 1 addition & 2 deletions exporter/signalfxexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package signalfxexporter
import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -520,7 +519,7 @@ func TestDefaultCPUTranslations(t *testing.T) {
cpuStateMetrics := []string{"cpu.idle", "cpu.interrupt", "cpu.system", "cpu.user"}
for _, metric := range cpuStateMetrics {
dps, ok := m[metric]
require.True(t, ok, fmt.Sprintf("%s metrics not found", metric))
require.True(t, ok, "%s metrics not found", metric)
require.Len(t, dps, 9)
}
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/syslogexporter/rfc5424_formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestRFC5424Formatter(t *testing.T) {
assert.NoError(t, err)
matched, err := regexp.MatchString(expectedRegex, actual)
assert.NoError(t, err)
assert.True(t, matched, fmt.Sprintf("unexpected form of formatted message, formatted message: %s, regexp: %s", actual, expectedRegex))
assert.True(t, matched, "unexpected form of formatted message, formatted message: %s, regexp: %s", actual, expectedRegex)
assert.True(t, strings.Contains(actual, "Realm=\"SecureAuth0\""))
assert.True(t, strings.Contains(actual, "UserHostAddress=\"192.168.2.132\""))
assert.True(t, strings.Contains(actual, "UserID=\"Tester2\""))
Expand Down
4 changes: 2 additions & 2 deletions pkg/stanza/fileconsumer/internal/trie/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func get(key string, expect any, why string) testOp {
func put(key string, val any) testOp {
return func(t *testing.T, trie *Trie[any]) {
trie.Put([]byte(key), val)
assert.Equalf(t, val, trie.Get([]byte(key)), "called Put(%s, %d) but HasKey(%s) does not return %d", key, key)
assert.Equalf(t, val, trie.Get([]byte(key)), "called Put(%s, %d) but HasKey(%s) does not return %d", key, val, key, val)
}
}

Expand All @@ -342,7 +342,7 @@ func del(key string, why string) testOp {
assert.Falsef(t, trie.Delete([]byte(key)), why)
} else {
assert.Truef(t, trie.Delete([]byte(key)), why)
assert.Falsef(t, trie.Delete([]byte(key)), "called Del(%s) twice in a row and got true both times")
assert.Falsef(t, trie.Delete([]byte(key)), "called Del(%s) twice in a row and got true both times", key)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions processor/k8sattributesprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1502,14 +1502,14 @@ func TestStartStop(t *testing.T) {

func assertResourceHasStringAttribute(t *testing.T, r pcommon.Resource, k, v string) {
got, ok := r.Attributes().Get(k)
require.True(t, ok, fmt.Sprintf("resource does not contain attribute %s", k))
require.True(t, ok, "resource does not contain attribute %s", k)
assert.EqualValues(t, pcommon.ValueTypeStr, got.Type(), "attribute %s is not of type string", k)
assert.EqualValues(t, v, got.Str(), "attribute %s is not equal to %s", k, v)
}

func assertResourceHasStringSlice(t *testing.T, r pcommon.Resource, k string, v []string) {
got, ok := r.Attributes().Get(k)
require.True(t, ok, fmt.Sprintf("resource does not contain attribute %s", k))
require.True(t, ok, "resource does not contain attribute %s", k)
assert.EqualValues(t, pcommon.ValueTypeSlice, got.Type(), "attribute %s is not of type slice", k)
slice := got.Slice()
for i := 0; i < slice.Len(); i++ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func Test_PerfCounterScraper(t *testing.T) {
break
}
}
assert.Equalf(t, test.includeTotal, includesTotal, "_Total was returned: %v (expected the opposite)", test.includeTotal, includesTotal)
assert.Equalf(t, test.includeTotal, includesTotal, "_Total was returned: %v (expected the opposite)", includesTotal)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,5 @@ service:
// * The first scrape will NOT return stale markers
// * (N-1 / alternatives) = ((10-1) / 2) = ~40% chance of stale markers being emitted.
chance := float64(staleMarkerCount) / float64(totalSamples)
require.GreaterOrEqual(t, chance, 0.4, fmt.Sprintf("Expected at least one stale marker: %.3f", chance))
require.GreaterOrEqual(t, chance, 0.4, "Expected at least one stale marker: %.3f", chance)
}
2 changes: 1 addition & 1 deletion receiver/signalfxreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ func Test_sfxReceiver_TLS(t *testing.T) {

sfxMsg := buildSFxDatapointMsg(msec, 13, 3)
body, err := sfxMsg.Marshal()
require.NoError(t, err, fmt.Sprintf("failed to marshal SFx message: %v", err))
require.NoError(t, err, "failed to marshal SFx message: %v", err)

url := fmt.Sprintf("https://%s/v2/datapoint", addr)

Expand Down
2 changes: 1 addition & 1 deletion receiver/splunkhecreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func Test_splunkhecReceiver_TLS(t *testing.T) {
t.Log("Sending Splunk HEC data Request")

body, err := json.Marshal(buildSplunkHecMsg(sec, 0))
require.NoError(t, err, fmt.Sprintf("failed to marshal Splunk message: %v", err))
require.NoError(t, err, "failed to marshal Splunk message: %v", err)

url := fmt.Sprintf("https://%s", addr)

Expand Down

0 comments on commit a5d9840

Please sign in to comment.