Skip to content

Commit

Permalink
[chore]: enable bool-compare rule from testifylint (#5829)
Browse files Browse the repository at this point in the history
#### 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>
  • Loading branch information
mmorel-35 and dmathieu authored Sep 20, 2024
1 parent a200e0a commit aef9e4f
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 37 deletions.
14 changes: 14 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ linters:
- revive
- staticcheck
- tenv
- testifylint
- typecheck
- unconvert
- unused
Expand Down Expand Up @@ -302,3 +303,16 @@ linters-settings:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
- name: waitgroup-by-value
disabled: false
testifylint:
enable-all: true
disable:
- empty
- error-is-as
- error-nil
- expected-actual
- float-compare
- go-require
- len
- negative-positive
- require-error
- suite-extra-assert-call
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
assert.Equal(t, "/somepath", c.Metrics.URLPath)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -112,7 +112,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
assert.Equal(t, "/somepath", c.Metrics.URLPath)
assert.Equal(t, false, c.Metrics.Insecure)
assert.False(t, c.Metrics.Insecure)
},
},
{
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -223,7 +223,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -233,7 +233,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
assert.Equal(t, false, c.Metrics.Insecure)
assert.False(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -244,7 +244,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_metrics_endpoint", c.Metrics.Endpoint)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
assert.Equal(t, "/somepath", c.Metrics.URLPath)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -112,7 +112,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
assert.Equal(t, "/somepath", c.Metrics.URLPath)
assert.Equal(t, false, c.Metrics.Insecure)
assert.False(t, c.Metrics.Insecure)
},
},
{
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -223,7 +223,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -233,7 +233,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
assert.Equal(t, false, c.Metrics.Insecure)
assert.False(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -244,7 +244,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_metrics_endpoint", c.Metrics.Endpoint)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
assert.Equal(t, "/somepath", c.Traces.URLPath)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},
{
Expand All @@ -110,7 +110,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
assert.Equal(t, "/somepath", c.Traces.URLPath)
assert.Equal(t, false, c.Traces.Insecure)
assert.False(t, c.Traces.Insecure)
},
},
{
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},
{
Expand All @@ -221,7 +221,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},
{
Expand All @@ -231,7 +231,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
assert.Equal(t, false, c.Traces.Insecure)
assert.False(t, c.Traces.Insecure)
},
},
{
Expand All @@ -242,7 +242,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_traces_endpoint", c.Traces.Endpoint)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
assert.Equal(t, "/somepath", c.Traces.URLPath)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},
{
Expand All @@ -110,7 +110,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
assert.Equal(t, "/somepath", c.Traces.URLPath)
assert.Equal(t, false, c.Traces.Insecure)
assert.False(t, c.Traces.Insecure)
},
},
{
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},
{
Expand All @@ -221,7 +221,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},
{
Expand All @@ -231,7 +231,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
assert.Equal(t, false, c.Traces.Insecure)
assert.False(t, c.Traces.Insecure)
},
},
{
Expand All @@ -242,7 +242,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_traces_endpoint", c.Traces.Endpoint)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},

Expand Down
12 changes: 6 additions & 6 deletions internal/shared/otlp/otlpmetric/oconf/options_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
assert.Equal(t, "/somepath", c.Metrics.URLPath)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -112,7 +112,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
assert.Equal(t, "/somepath", c.Metrics.URLPath)
assert.Equal(t, false, c.Metrics.Insecure)
assert.False(t, c.Metrics.Insecure)
},
},
{
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -223,7 +223,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -233,7 +233,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Metrics.Endpoint)
assert.Equal(t, false, c.Metrics.Insecure)
assert.False(t, c.Metrics.Insecure)
},
},
{
Expand All @@ -244,7 +244,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_metrics_endpoint", c.Metrics.Endpoint)
assert.Equal(t, true, c.Metrics.Insecure)
assert.True(t, c.Metrics.Insecure)
},
},

Expand Down
12 changes: 6 additions & 6 deletions internal/shared/otlp/otlptrace/otlpconfig/options_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
assert.Equal(t, "/somepath", c.Traces.URLPath)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},
{
Expand All @@ -110,7 +110,7 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Traces.Endpoint)
assert.Equal(t, "/somepath", c.Traces.URLPath)
assert.Equal(t, false, c.Traces.Insecure)
assert.False(t, c.Traces.Insecure)
},
},
{
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},
{
Expand All @@ -221,7 +221,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},
{
Expand All @@ -231,7 +231,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_endpoint", c.Traces.Endpoint)
assert.Equal(t, false, c.Traces.Insecure)
assert.False(t, c.Traces.Insecure)
},
},
{
Expand All @@ -242,7 +242,7 @@ func TestConfigs(t *testing.T) {
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "env_traces_endpoint", c.Traces.Endpoint)
assert.Equal(t, true, c.Traces.Insecure)
assert.True(t, c.Traces.Insecure)
},
},

Expand Down
2 changes: 1 addition & 1 deletion log/keyvalue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestSortedValueEqual(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.value.String(), func(t *testing.T) {
assert.Equal(t, true, tc.value.Equal(tc.value2), "%v.Equal(%v)", tc.value, tc.value2)
assert.True(t, tc.value.Equal(tc.value2), "%v.Equal(%v)", tc.value, tc.value2)
})
}
}
Expand Down

0 comments on commit aef9e4f

Please sign in to comment.