Skip to content

Commit

Permalink
testifylint: enable bool-compare (jaegertracing#5032)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Apply bool-compare rule of testifylint 

## Description of the changes
- Apply testifylint --disable-all -fix --enable=bool-compare ./...

## How was this change tested?
- CI

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [ ] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 authored Dec 24, 2023
1 parent 286997c commit 9bd8317
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ linters-settings:
- shadow
testifylint:
disable:
- bool-compare
- compares
- float-compare
- go-require
- require-error
enable:
- bool-compare
- empty
- error-is-as
- error-nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/app/reporter/grpc/collector_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestMultipleCollectors(t *testing.T) {
c, g := mFactory.Snapshot()
assert.True(t, len(g) > 0)
assert.True(t, len(c) > 0)
assert.Equal(t, true, bothServers)
assert.True(t, bothServers)
require.NoError(t, proxy.Close())
}

Expand Down
16 changes: 8 additions & 8 deletions cmd/anonymizer/app/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ func TestOptionsWithDefaultFlags(t *testing.T) {

assert.Equal(t, "localhost:16686", o.QueryGRPCHostPort)
assert.Equal(t, "/tmp", o.OutputDir)
assert.Equal(t, false, o.HashStandardTags)
assert.Equal(t, false, o.HashCustomTags)
assert.Equal(t, false, o.HashLogs)
assert.Equal(t, false, o.HashProcess)
assert.False(t, o.HashStandardTags)
assert.False(t, o.HashCustomTags)
assert.False(t, o.HashLogs)
assert.False(t, o.HashProcess)
assert.Equal(t, -1, o.MaxSpansCount)
}

Expand All @@ -55,10 +55,10 @@ func TestOptionsWithFlags(t *testing.T) {
assert.Equal(t, "192.168.1.10:16686", o.QueryGRPCHostPort)
assert.Equal(t, "/data", o.OutputDir)
assert.Equal(t, "6ef2debb698f2f7c", o.TraceID)
assert.Equal(t, true, o.HashStandardTags)
assert.Equal(t, true, o.HashCustomTags)
assert.Equal(t, true, o.HashLogs)
assert.Equal(t, true, o.HashProcess)
assert.True(t, o.HashStandardTags)
assert.True(t, o.HashCustomTags)
assert.True(t, o.HashLogs)
assert.True(t, o.HashProcess)
assert.Equal(t, 100, o.MaxSpansCount)
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/anonymizer/app/uiconv/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ func TestReaderTraceSuccess(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "a071653098f9250d", s1.OperationName)
assert.Equal(t, 1, r.spansRead)
assert.Equal(t, false, r.eofReached)
assert.False(t, r.eofReached)

r.spansRead = 999

s2, err := r.NextSpan()
require.NoError(t, err)
assert.Equal(t, "471418097747d04a", s2.OperationName)
assert.Equal(t, 1000, r.spansRead)
assert.Equal(t, true, r.eofReached)
assert.True(t, r.eofReached)

_, err = r.NextSpan()
require.Equal(t, errNoMoreSpans, err)
assert.Equal(t, 1000, r.spansRead)
assert.Equal(t, true, r.eofReached)
assert.True(t, r.eofReached)
}

func TestReaderTraceNonExistent(t *testing.T) {
Expand All @@ -61,7 +61,7 @@ func TestReaderTraceEmpty(t *testing.T) {
_, err = r.NextSpan()
require.Contains(t, err.Error(), "cannot read file")
assert.Equal(t, 0, r.spansRead)
assert.Equal(t, true, r.eofReached)
assert.True(t, r.eofReached)
}

func TestReaderTraceWrongFormat(t *testing.T) {
Expand All @@ -72,7 +72,7 @@ func TestReaderTraceWrongFormat(t *testing.T) {
_, err = r.NextSpan()
require.Equal(t, "file must begin with '['", err.Error())
assert.Equal(t, 0, r.spansRead)
assert.Equal(t, true, r.eofReached)
assert.True(t, r.eofReached)
}

func TestReaderTraceInvalidJson(t *testing.T) {
Expand All @@ -83,5 +83,5 @@ func TestReaderTraceInvalidJson(t *testing.T) {
_, err = r.NextSpan()
require.Contains(t, err.Error(), "cannot unmarshal span")
assert.Equal(t, 0, r.spansRead)
assert.Equal(t, true, r.eofReached)
assert.True(t, r.eofReached)
}
8 changes: 4 additions & 4 deletions cmd/collector/app/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestCollectorOptionsWithFlags_CheckNoTenancy(t *testing.T) {
command.ParseFlags([]string{})
c.InitFromViper(v, zap.NewNop())

assert.Equal(t, false, c.GRPC.Tenancy.Enabled)
assert.False(t, c.GRPC.Tenancy.Enabled)
}

func TestCollectorOptionsWithFlags_CheckSimpleTenancy(t *testing.T) {
Expand All @@ -160,7 +160,7 @@ func TestCollectorOptionsWithFlags_CheckSimpleTenancy(t *testing.T) {
})
c.InitFromViper(v, zap.NewNop())

assert.Equal(t, true, c.GRPC.Tenancy.Enabled)
assert.True(t, c.GRPC.Tenancy.Enabled)
assert.Equal(t, "x-tenant", c.GRPC.Tenancy.Header)
}

Expand All @@ -174,7 +174,7 @@ func TestCollectorOptionsWithFlags_CheckFullTenancy(t *testing.T) {
})
c.InitFromViper(v, zap.NewNop())

assert.Equal(t, true, c.GRPC.Tenancy.Enabled)
assert.True(t, c.GRPC.Tenancy.Enabled)
assert.Equal(t, "custom-tenant-header", c.GRPC.Tenancy.Header)
assert.Equal(t, []string{"acme", "hardware-store"}, c.GRPC.Tenancy.Tenants)
}
Expand All @@ -187,7 +187,7 @@ func TestCollectorOptionsWithFlags_CheckZipkinKeepAlive(t *testing.T) {
})
c.InitFromViper(v, zap.NewNop())

assert.Equal(t, false, c.Zipkin.KeepAlive)
assert.False(t, c.Zipkin.KeepAlive)
}

func TestMain(m *testing.M) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ func TestSpanProcessorContextPropagation(t *testing.T) {
assert.NoError(t, p.Close())

// Verify that the dummy tenant from SpansOptions context made it to writer
assert.Equal(t, true, w.tenants[dummyTenant])
assert.True(t, w.tenants[dummyTenant])
// Verify no other tenantKey context values made it to writer
assert.True(t, reflect.DeepEqual(w.tenants, map[string]bool{dummyTenant: true}))
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/zipkin/zipkindeser/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestUnmarshalSpan(t *testing.T) {
assert.NotNil(t, spans)
assert.Len(t, spans, 1)
assert.Equal(t, "bar", spans[0].Name)
assert.Equal(t, false, spans[0].Debug)
assert.False(t, spans[0].Debug)
assert.Equal(t, "1234567891234567", spans[0].ParentID)
assert.Equal(t, "1234567891234567", spans[0].TraceID)
assert.Equal(t, "1234567891234567", spans[0].ID)
Expand Down
4 changes: 2 additions & 2 deletions cmd/es-index-cleaner/app/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func TestBindFlags(t *testing.T) {

c.InitFromViper(v)
assert.Equal(t, "tenant1-", c.IndexPrefix)
assert.Equal(t, true, c.Rollover)
assert.Equal(t, true, c.Archive)
assert.True(t, c.Rollover)
assert.True(t, c.Archive)
assert.Equal(t, 150, c.MasterNodeTimeoutSeconds)
assert.Equal(t, "@", c.IndexDateSeparator)
assert.Equal(t, "admin", c.Username)
Expand Down
2 changes: 1 addition & 1 deletion cmd/es-rollover/app/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestExecuteAction(t *testing.T) {
assert.Equal(t, "https://localhost:9300", c.Endpoint)
transport, ok := c.Client.Transport.(*http.Transport)
require.True(t, ok)
assert.Equal(t, true, transport.TLSClientConfig.InsecureSkipVerify)
assert.True(t, transport.TLSClientConfig.InsecureSkipVerify)
return &dummyAction{
TestFn: func() error {
executedAction = true
Expand Down
4 changes: 2 additions & 2 deletions cmd/es-rollover/app/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func TestBindFlags(t *testing.T) {

c.InitFromViper(v)
assert.Equal(t, "tenant1-", c.IndexPrefix)
assert.Equal(t, true, c.Archive)
assert.True(t, c.Archive)
assert.Equal(t, 150, c.Timeout)
assert.Equal(t, "admin", c.Username)
assert.Equal(t, "qwerty123", c.Password)
assert.Equal(t, "jaeger-ilm", c.ILMPolicyName)
assert.Equal(t, true, c.SkipDependencies)
assert.True(t, c.SkipDependencies)
}
4 changes: 2 additions & 2 deletions model/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ func TestGetSpanKind(t *testing.T) {
span := makeSpan(model.String("sampler.type", "lowerbound"))
spanKind, found := span.GetSpanKind()
assert.Equal(t, "unspecified", spanKind.String())
assert.Equal(t, false, found)
assert.False(t, found)

span = makeSpan(model.String("span.kind", "client"))
spanKind, found = span.GetSpanKind()
assert.Equal(t, "client", spanKind.String())
assert.Equal(t, true, found)
assert.True(t, found)
}

func TestSamplerType(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/lru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestCompareAndSwap(t *testing.T) {
cache := NewLRU(2)

item, ok := cache.CompareAndSwap("A", nil, "Foo")
assert.Equal(t, true, ok)
assert.True(t, ok)
assert.Equal(t, "Foo", item)
assert.Equal(t, "Foo", cache.Get("A"))
assert.Nil(t, cache.Get("B"))
Expand Down
2 changes: 1 addition & 1 deletion plugin/metrics/prometheus/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestWithConfiguration(t *testing.T) {
assert.Equal(t, "http://localhost:1234", f.options.Primary.ServerURL)
assert.Equal(t, 5*time.Second, f.options.Primary.ConnectTimeout)
assert.Equal(t, "test/test_file.txt", f.options.Primary.TokenFilePath)
assert.Equal(t, false, f.options.Primary.TokenOverrideFromContext)
assert.False(t, f.options.Primary.TokenOverrideFromContext)
})
t.Run("with space in token file path", func(t *testing.T) {
f := NewFactory()
Expand Down
8 changes: 4 additions & 4 deletions plugin/storage/cassandra/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ func TestOptionsWithFlags(t *testing.T) {
assert.Equal(t, "ONE", primary.Consistency)
assert.Equal(t, []string{"blerg", "blarg", "blorg"}, opts.TagIndexBlacklist())
assert.Equal(t, []string{"flerg", "flarg", "florg"}, opts.TagIndexWhitelist())
assert.Equal(t, true, opts.Index.Tags)
assert.Equal(t, false, opts.Index.ProcessTags)
assert.Equal(t, true, opts.Index.Logs)
assert.True(t, opts.Index.Tags)
assert.False(t, opts.Index.ProcessTags)
assert.True(t, opts.Index.Logs)

aux := opts.Get("cas-aux")
require.NotNil(t, aux)
Expand All @@ -105,7 +105,7 @@ func TestDefaultTlsHostVerify(t *testing.T) {
opts.InitFromViper(v)

primary := opts.GetPrimary()
assert.Equal(t, false, primary.TLS.SkipHostVerify)
assert.False(t, primary.TLS.SkipHostVerify)
}

func TestEmptyBlackWhiteLists(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions plugin/storage/es/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func TestOptionsWithFlags(t *testing.T) {
assert.Equal(t, 48*time.Hour, primary.MaxSpanAge)
assert.True(t, primary.Sniffer)
assert.True(t, primary.SnifferTLSEnabled)
assert.Equal(t, true, primary.TLS.Enabled)
assert.Equal(t, true, primary.TLS.SkipHostVerify)
assert.True(t, primary.TLS.Enabled)
assert.True(t, primary.TLS.SkipHostVerify)
assert.True(t, primary.Tags.AllAsFields)
assert.Equal(t, "!", primary.Tags.DotReplacement)
assert.Equal(t, "./file.txt", primary.Tags.File)
Expand Down
6 changes: 3 additions & 3 deletions plugin/storage/grpc/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestOptionsWithFlags(t *testing.T) {
assert.Equal(t, "noop-grpc-plugin", opts.Configuration.PluginBinary)
assert.Equal(t, "config.json", opts.Configuration.PluginConfigurationFile)
assert.Equal(t, "debug", opts.Configuration.PluginLogLevel)
assert.Equal(t, false, opts.Configuration.TenancyOpts.Enabled)
assert.False(t, opts.Configuration.TenancyOpts.Enabled)
assert.Equal(t, "x-scope-orgid", opts.Configuration.TenancyOpts.Header)
}

Expand All @@ -57,7 +57,7 @@ func TestRemoteOptionsWithFlags(t *testing.T) {

assert.Equal(t, "", opts.Configuration.PluginBinary)
assert.Equal(t, "localhost:2001", opts.Configuration.RemoteServerAddr)
assert.Equal(t, true, opts.Configuration.RemoteTLS.Enabled)
assert.True(t, opts.Configuration.RemoteTLS.Enabled)
assert.Equal(t, 60*time.Second, opts.Configuration.RemoteConnectTimeout)
}

Expand All @@ -74,7 +74,7 @@ func TestRemoteOptionsNoTLSWithFlags(t *testing.T) {

assert.Equal(t, "", opts.Configuration.PluginBinary)
assert.Equal(t, "localhost:2001", opts.Configuration.RemoteServerAddr)
assert.Equal(t, false, opts.Configuration.RemoteTLS.Enabled)
assert.False(t, opts.Configuration.RemoteTLS.Enabled)
assert.Equal(t, 60*time.Second, opts.Configuration.RemoteConnectTimeout)
}

Expand Down

0 comments on commit 9bd8317

Please sign in to comment.