Skip to content

Commit aef9e4f

Browse files
mmorel-35dmathieu
andauthored
[chore]: enable bool-compare rule from testifylint (#5829)
#### Description Testifylint is a linter that provides best practices with the use of testify. This PR enables [bool-compare](https://github.com/Antonboom/testifylint?tab=readme-ov-file#bool-compare) rule from [testifylint](https://github.com/Antonboom/testifylint) It's linter provided by golangci-lint. Here all available rules are activated except those who require to be fixed. This PR only fixes bool-compare so the quantity of changes stays reasonnable for reviewers. Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: Damien Mathieu <42@dmathieu.com>
1 parent a200e0a commit aef9e4f

8 files changed

Lines changed: 51 additions & 37 deletions

File tree

.golangci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ linters:
2525
- revive
2626
- staticcheck
2727
- tenv
28+
- testifylint
2829
- typecheck
2930
- unconvert
3031
- unused
@@ -302,3 +303,16 @@ linters-settings:
302303
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
303304
- name: waitgroup-by-value
304305
disabled: false
306+
testifylint:
307+
enable-all: true
308+
disable:
309+
- empty
310+
- error-is-as
311+
- error-nil
312+
- expected-actual
313+
- float-compare
314+
- go-require
315+
- len
316+
- negative-positive
317+
- require-error
318+
- suite-extra-assert-call

exporters/otlp/otlpmetric/otlpmetricgrpc/internal/oconf/options_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestConfigs(t *testing.T) {
101101
asserts: func(t *testing.T, c *Config, grpcOption bool) {
102102
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
103103
assert.Equal(t, "/somepath", c.Metrics.URLPath)
104-
assert.Equal(t, true, c.Metrics.Insecure)
104+
assert.True(t, c.Metrics.Insecure)
105105
},
106106
},
107107
{
@@ -112,7 +112,7 @@ func TestConfigs(t *testing.T) {
112112
asserts: func(t *testing.T, c *Config, grpcOption bool) {
113113
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
114114
assert.Equal(t, "/somepath", c.Metrics.URLPath)
115-
assert.Equal(t, false, c.Metrics.Insecure)
115+
assert.False(t, c.Metrics.Insecure)
116116
},
117117
},
118118
{
@@ -213,7 +213,7 @@ func TestConfigs(t *testing.T) {
213213
},
214214
asserts: func(t *testing.T, c *Config, grpcOption bool) {
215215
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
216-
assert.Equal(t, true, c.Metrics.Insecure)
216+
assert.True(t, c.Metrics.Insecure)
217217
},
218218
},
219219
{
@@ -223,7 +223,7 @@ func TestConfigs(t *testing.T) {
223223
},
224224
asserts: func(t *testing.T, c *Config, grpcOption bool) {
225225
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
226-
assert.Equal(t, true, c.Metrics.Insecure)
226+
assert.True(t, c.Metrics.Insecure)
227227
},
228228
},
229229
{
@@ -233,7 +233,7 @@ func TestConfigs(t *testing.T) {
233233
},
234234
asserts: func(t *testing.T, c *Config, grpcOption bool) {
235235
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
236-
assert.Equal(t, false, c.Metrics.Insecure)
236+
assert.False(t, c.Metrics.Insecure)
237237
},
238238
},
239239
{
@@ -244,7 +244,7 @@ func TestConfigs(t *testing.T) {
244244
},
245245
asserts: func(t *testing.T, c *Config, grpcOption bool) {
246246
assert.Equal(t, "env_metrics_endpoint", c.Metrics.Endpoint)
247-
assert.Equal(t, true, c.Metrics.Insecure)
247+
assert.True(t, c.Metrics.Insecure)
248248
},
249249
},
250250

exporters/otlp/otlpmetric/otlpmetrichttp/internal/oconf/options_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestConfigs(t *testing.T) {
101101
asserts: func(t *testing.T, c *Config, grpcOption bool) {
102102
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
103103
assert.Equal(t, "/somepath", c.Metrics.URLPath)
104-
assert.Equal(t, true, c.Metrics.Insecure)
104+
assert.True(t, c.Metrics.Insecure)
105105
},
106106
},
107107
{
@@ -112,7 +112,7 @@ func TestConfigs(t *testing.T) {
112112
asserts: func(t *testing.T, c *Config, grpcOption bool) {
113113
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
114114
assert.Equal(t, "/somepath", c.Metrics.URLPath)
115-
assert.Equal(t, false, c.Metrics.Insecure)
115+
assert.False(t, c.Metrics.Insecure)
116116
},
117117
},
118118
{
@@ -213,7 +213,7 @@ func TestConfigs(t *testing.T) {
213213
},
214214
asserts: func(t *testing.T, c *Config, grpcOption bool) {
215215
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
216-
assert.Equal(t, true, c.Metrics.Insecure)
216+
assert.True(t, c.Metrics.Insecure)
217217
},
218218
},
219219
{
@@ -223,7 +223,7 @@ func TestConfigs(t *testing.T) {
223223
},
224224
asserts: func(t *testing.T, c *Config, grpcOption bool) {
225225
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
226-
assert.Equal(t, true, c.Metrics.Insecure)
226+
assert.True(t, c.Metrics.Insecure)
227227
},
228228
},
229229
{
@@ -233,7 +233,7 @@ func TestConfigs(t *testing.T) {
233233
},
234234
asserts: func(t *testing.T, c *Config, grpcOption bool) {
235235
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
236-
assert.Equal(t, false, c.Metrics.Insecure)
236+
assert.False(t, c.Metrics.Insecure)
237237
},
238238
},
239239
{
@@ -244,7 +244,7 @@ func TestConfigs(t *testing.T) {
244244
},
245245
asserts: func(t *testing.T, c *Config, grpcOption bool) {
246246
assert.Equal(t, "env_metrics_endpoint", c.Metrics.Endpoint)
247-
assert.Equal(t, true, c.Metrics.Insecure)
247+
assert.True(t, c.Metrics.Insecure)
248248
},
249249
},
250250

exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/options_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestConfigs(t *testing.T) {
9999
asserts: func(t *testing.T, c *Config, grpcOption bool) {
100100
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
101101
assert.Equal(t, "/somepath", c.Traces.URLPath)
102-
assert.Equal(t, true, c.Traces.Insecure)
102+
assert.True(t, c.Traces.Insecure)
103103
},
104104
},
105105
{
@@ -110,7 +110,7 @@ func TestConfigs(t *testing.T) {
110110
asserts: func(t *testing.T, c *Config, grpcOption bool) {
111111
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
112112
assert.Equal(t, "/somepath", c.Traces.URLPath)
113-
assert.Equal(t, false, c.Traces.Insecure)
113+
assert.False(t, c.Traces.Insecure)
114114
},
115115
},
116116
{
@@ -211,7 +211,7 @@ func TestConfigs(t *testing.T) {
211211
},
212212
asserts: func(t *testing.T, c *Config, grpcOption bool) {
213213
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
214-
assert.Equal(t, true, c.Traces.Insecure)
214+
assert.True(t, c.Traces.Insecure)
215215
},
216216
},
217217
{
@@ -221,7 +221,7 @@ func TestConfigs(t *testing.T) {
221221
},
222222
asserts: func(t *testing.T, c *Config, grpcOption bool) {
223223
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
224-
assert.Equal(t, true, c.Traces.Insecure)
224+
assert.True(t, c.Traces.Insecure)
225225
},
226226
},
227227
{
@@ -231,7 +231,7 @@ func TestConfigs(t *testing.T) {
231231
},
232232
asserts: func(t *testing.T, c *Config, grpcOption bool) {
233233
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
234-
assert.Equal(t, false, c.Traces.Insecure)
234+
assert.False(t, c.Traces.Insecure)
235235
},
236236
},
237237
{
@@ -242,7 +242,7 @@ func TestConfigs(t *testing.T) {
242242
},
243243
asserts: func(t *testing.T, c *Config, grpcOption bool) {
244244
assert.Equal(t, "env_traces_endpoint", c.Traces.Endpoint)
245-
assert.Equal(t, true, c.Traces.Insecure)
245+
assert.True(t, c.Traces.Insecure)
246246
},
247247
},
248248

exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestConfigs(t *testing.T) {
9999
asserts: func(t *testing.T, c *Config, grpcOption bool) {
100100
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
101101
assert.Equal(t, "/somepath", c.Traces.URLPath)
102-
assert.Equal(t, true, c.Traces.Insecure)
102+
assert.True(t, c.Traces.Insecure)
103103
},
104104
},
105105
{
@@ -110,7 +110,7 @@ func TestConfigs(t *testing.T) {
110110
asserts: func(t *testing.T, c *Config, grpcOption bool) {
111111
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
112112
assert.Equal(t, "/somepath", c.Traces.URLPath)
113-
assert.Equal(t, false, c.Traces.Insecure)
113+
assert.False(t, c.Traces.Insecure)
114114
},
115115
},
116116
{
@@ -211,7 +211,7 @@ func TestConfigs(t *testing.T) {
211211
},
212212
asserts: func(t *testing.T, c *Config, grpcOption bool) {
213213
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
214-
assert.Equal(t, true, c.Traces.Insecure)
214+
assert.True(t, c.Traces.Insecure)
215215
},
216216
},
217217
{
@@ -221,7 +221,7 @@ func TestConfigs(t *testing.T) {
221221
},
222222
asserts: func(t *testing.T, c *Config, grpcOption bool) {
223223
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
224-
assert.Equal(t, true, c.Traces.Insecure)
224+
assert.True(t, c.Traces.Insecure)
225225
},
226226
},
227227
{
@@ -231,7 +231,7 @@ func TestConfigs(t *testing.T) {
231231
},
232232
asserts: func(t *testing.T, c *Config, grpcOption bool) {
233233
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
234-
assert.Equal(t, false, c.Traces.Insecure)
234+
assert.False(t, c.Traces.Insecure)
235235
},
236236
},
237237
{
@@ -242,7 +242,7 @@ func TestConfigs(t *testing.T) {
242242
},
243243
asserts: func(t *testing.T, c *Config, grpcOption bool) {
244244
assert.Equal(t, "env_traces_endpoint", c.Traces.Endpoint)
245-
assert.Equal(t, true, c.Traces.Insecure)
245+
assert.True(t, c.Traces.Insecure)
246246
},
247247
},
248248

internal/shared/otlp/otlpmetric/oconf/options_test.go.tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestConfigs(t *testing.T) {
101101
asserts: func(t *testing.T, c *Config, grpcOption bool) {
102102
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
103103
assert.Equal(t, "/somepath", c.Metrics.URLPath)
104-
assert.Equal(t, true, c.Metrics.Insecure)
104+
assert.True(t, c.Metrics.Insecure)
105105
},
106106
},
107107
{
@@ -112,7 +112,7 @@ func TestConfigs(t *testing.T) {
112112
asserts: func(t *testing.T, c *Config, grpcOption bool) {
113113
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
114114
assert.Equal(t, "/somepath", c.Metrics.URLPath)
115-
assert.Equal(t, false, c.Metrics.Insecure)
115+
assert.False(t, c.Metrics.Insecure)
116116
},
117117
},
118118
{
@@ -213,7 +213,7 @@ func TestConfigs(t *testing.T) {
213213
},
214214
asserts: func(t *testing.T, c *Config, grpcOption bool) {
215215
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
216-
assert.Equal(t, true, c.Metrics.Insecure)
216+
assert.True(t, c.Metrics.Insecure)
217217
},
218218
},
219219
{
@@ -223,7 +223,7 @@ func TestConfigs(t *testing.T) {
223223
},
224224
asserts: func(t *testing.T, c *Config, grpcOption bool) {
225225
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
226-
assert.Equal(t, true, c.Metrics.Insecure)
226+
assert.True(t, c.Metrics.Insecure)
227227
},
228228
},
229229
{
@@ -233,7 +233,7 @@ func TestConfigs(t *testing.T) {
233233
},
234234
asserts: func(t *testing.T, c *Config, grpcOption bool) {
235235
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
236-
assert.Equal(t, false, c.Metrics.Insecure)
236+
assert.False(t, c.Metrics.Insecure)
237237
},
238238
},
239239
{
@@ -244,7 +244,7 @@ func TestConfigs(t *testing.T) {
244244
},
245245
asserts: func(t *testing.T, c *Config, grpcOption bool) {
246246
assert.Equal(t, "env_metrics_endpoint", c.Metrics.Endpoint)
247-
assert.Equal(t, true, c.Metrics.Insecure)
247+
assert.True(t, c.Metrics.Insecure)
248248
},
249249
},
250250

internal/shared/otlp/otlptrace/otlpconfig/options_test.go.tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestConfigs(t *testing.T) {
9999
asserts: func(t *testing.T, c *Config, grpcOption bool) {
100100
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
101101
assert.Equal(t, "/somepath", c.Traces.URLPath)
102-
assert.Equal(t, true, c.Traces.Insecure)
102+
assert.True(t, c.Traces.Insecure)
103103
},
104104
},
105105
{
@@ -110,7 +110,7 @@ func TestConfigs(t *testing.T) {
110110
asserts: func(t *testing.T, c *Config, grpcOption bool) {
111111
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
112112
assert.Equal(t, "/somepath", c.Traces.URLPath)
113-
assert.Equal(t, false, c.Traces.Insecure)
113+
assert.False(t, c.Traces.Insecure)
114114
},
115115
},
116116
{
@@ -211,7 +211,7 @@ func TestConfigs(t *testing.T) {
211211
},
212212
asserts: func(t *testing.T, c *Config, grpcOption bool) {
213213
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
214-
assert.Equal(t, true, c.Traces.Insecure)
214+
assert.True(t, c.Traces.Insecure)
215215
},
216216
},
217217
{
@@ -221,7 +221,7 @@ func TestConfigs(t *testing.T) {
221221
},
222222
asserts: func(t *testing.T, c *Config, grpcOption bool) {
223223
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
224-
assert.Equal(t, true, c.Traces.Insecure)
224+
assert.True(t, c.Traces.Insecure)
225225
},
226226
},
227227
{
@@ -231,7 +231,7 @@ func TestConfigs(t *testing.T) {
231231
},
232232
asserts: func(t *testing.T, c *Config, grpcOption bool) {
233233
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
234-
assert.Equal(t, false, c.Traces.Insecure)
234+
assert.False(t, c.Traces.Insecure)
235235
},
236236
},
237237
{
@@ -242,7 +242,7 @@ func TestConfigs(t *testing.T) {
242242
},
243243
asserts: func(t *testing.T, c *Config, grpcOption bool) {
244244
assert.Equal(t, "env_traces_endpoint", c.Traces.Endpoint)
245-
assert.Equal(t, true, c.Traces.Insecure)
245+
assert.True(t, c.Traces.Insecure)
246246
},
247247
},
248248

log/keyvalue_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestSortedValueEqual(t *testing.T) {
9191
}
9292
for _, tc := range testCases {
9393
t.Run(tc.value.String(), func(t *testing.T) {
94-
assert.Equal(t, true, tc.value.Equal(tc.value2), "%v.Equal(%v)", tc.value, tc.value2)
94+
assert.True(t, tc.value.Equal(tc.value2), "%v.Equal(%v)", tc.value, tc.value2)
9595
})
9696
}
9797
}

0 commit comments

Comments
 (0)