Skip to content

Commit

Permalink
[chore]: enable bool-compare 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 Aug 29, 2024
1 parent 3d5bb5f commit e572976
Show file tree
Hide file tree
Showing 48 changed files with 159 additions and 141 deletions.
18 changes: 18 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ linters-settings:
predeclared:
ignore: copy

testifylint:
disable:
- compares
- empty
- error-is-as
- error-nil
- expected-actual
- float-compare
- go-require
- len
- negative-positive
- nil-compare
- require-error
- suite-dont-use-pkg
- useless-assert
enable-all: true

linters:
enable:
- decorder
Expand All @@ -152,6 +169,7 @@ linters:
- revive
- staticcheck
- tenv
- testifylint
- unconvert
- unparam
- unused
Expand Down
2 changes: 1 addition & 1 deletion connector/routingconnector/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,5 +463,5 @@ func TestLogsConnectorCapabilities(t *testing.T) {
)

require.NoError(t, err)
assert.Equal(t, false, conn.Capabilities().MutatesData)
assert.False(t, conn.Capabilities().MutatesData)
}
2 changes: 1 addition & 1 deletion connector/routingconnector/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,5 @@ func TestMetricsConnectorCapabilities(t *testing.T) {
)

require.NoError(t, err)
assert.Equal(t, false, conn.Capabilities().MutatesData)
assert.False(t, conn.Capabilities().MutatesData)
}
2 changes: 1 addition & 1 deletion connector/routingconnector/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,5 +417,5 @@ func TestTraceConnectorCapabilities(t *testing.T) {
)

require.NoError(t, err)
assert.Equal(t, false, conn.Capabilities().MutatesData)
assert.False(t, conn.Capabilities().MutatesData)
}
12 changes: 6 additions & 6 deletions connector/servicegraphconnector/internal/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestStoreUpsertEdge(t *testing.T) {
e.ClientService = clientService
})
require.NoError(t, err)
require.Equal(t, true, isNew)
require.True(t, isNew)
assert.Equal(t, 1, s.Len())

// Nothing should be evicted as TTL is set to 1h
Expand All @@ -44,7 +44,7 @@ func TestStoreUpsertEdge(t *testing.T) {
e.ServerService = "server"
})
require.NoError(t, err)
require.Equal(t, false, isNew)
require.False(t, isNew)
// Edge is complete and should have been removed
assert.Equal(t, 0, s.Len())

Expand All @@ -57,7 +57,7 @@ func TestStoreUpsertEdge(t *testing.T) {
e.expiration = time.UnixMicro(0)
})
require.NoError(t, err)
require.Equal(t, true, isNew)
require.True(t, isNew)
assert.Equal(t, 1, s.Len())
assert.Equal(t, 1, onCompletedCount)
assert.Equal(t, 0, onExpireCount)
Expand All @@ -80,7 +80,7 @@ func TestStoreUpsertEdge_errTooManyItems(t *testing.T) {
e.ClientService = clientService
})
require.NoError(t, err)
require.Equal(t, true, isNew)
require.True(t, isNew)
assert.Equal(t, 1, s.Len())

_, err = s.UpsertEdge(key2, func(e *Edge) {
Expand All @@ -93,7 +93,7 @@ func TestStoreUpsertEdge_errTooManyItems(t *testing.T) {
e.ClientService = clientService
})
require.NoError(t, err)
require.Equal(t, false, isNew)
require.False(t, isNew)
assert.Equal(t, 1, s.Len())

assert.Equal(t, 0, onCallbackCounter)
Expand All @@ -120,7 +120,7 @@ func TestStoreExpire(t *testing.T) {
for key := range keys {
isNew, err := s.UpsertEdge(key, noopCallback)
require.NoError(t, err)
require.Equal(t, true, isNew)
require.True(t, isNew)
}

s.Expire()
Expand Down
2 changes: 1 addition & 1 deletion connector/spanmetricsconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ func TestConnectorCapabilities(t *testing.T) {

// Verify
assert.NotNil(t, c)
assert.Equal(t, false, caps.MutatesData)
assert.False(t, caps.MutatesData)
}

type errConsumer struct {
Expand Down
4 changes: 2 additions & 2 deletions exporter/alertmanagerexporter/alertmanager_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ func TestAlertManagerExporterEventNameAttributes(t *testing.T) {
// test - count of attributes
assert.Equal(t, 3, got[0].spanEvent.Attributes().Len())
attr, b := got[0].spanEvent.Attributes().Get("attr1")
assert.Equal(t, true, b)
assert.True(t, b)
assert.Equal(t, "unittest-event", got[0].spanEvent.Name())
assert.Equal(t, "unittest-baz", attr.AsString())
attr, b = got[0].spanEvent.Attributes().Get("attr3")
assert.Equal(t, true, b)
assert.True(t, b)
assert.Equal(t, 5.14, attr.Double())
}

Expand Down
8 changes: 4 additions & 4 deletions exporter/awss3exporter/s3_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestS3Key(t *testing.T) {
re := regexp.MustCompile(`keyprefix/year=2022/month=06/day=05/hour=00/minute=00/fileprefixlogs_([0-9]+).json`)
s3Key := getS3Key(tm, "keyprefix", "minute", "fileprefix", "logs", "json", "")
matched := re.MatchString(s3Key)
assert.Equal(t, true, matched)
assert.True(t, matched)
}

func TestS3KeyEmptyFileFormat(t *testing.T) {
Expand All @@ -52,7 +52,7 @@ func TestS3KeyEmptyFileFormat(t *testing.T) {
re := regexp.MustCompile(`keyprefix/year=2022/month=06/day=05/hour=00/minute=00/fileprefixlogs_([0-9]+)`)
s3Key := getS3Key(tm, "keyprefix", "minute", "fileprefix", "logs", "", "")
matched := re.MatchString(s3Key)
assert.Equal(t, true, matched)
assert.True(t, matched)
}

func TestS3KeyOfCompressedFile(t *testing.T) {
Expand All @@ -66,7 +66,7 @@ func TestS3KeyOfCompressedFile(t *testing.T) {
re := regexp.MustCompile(`keyprefix/year=2022/month=06/day=05/hour=00/minute=00/fileprefixlogs_([0-9]+).json.gz`)
s3Key := getS3Key(tm, "keyprefix", "minute", "fileprefix", "logs", "json", "gzip")
matched := re.MatchString(s3Key)
assert.Equal(t, true, matched)
assert.True(t, matched)
}

func TestS3KeyOfCompressedFileEmptyFileFormat(t *testing.T) {
Expand All @@ -80,7 +80,7 @@ func TestS3KeyOfCompressedFileEmptyFileFormat(t *testing.T) {
re := regexp.MustCompile(`keyprefix/year=2022/month=06/day=05/hour=00/minute=00/fileprefixlogs_([0-9]+).gz`)
s3Key := getS3Key(tm, "keyprefix", "minute", "fileprefix", "logs", "", "gzip")
matched := re.MatchString(s3Key)
assert.Equal(t, true, matched)
assert.True(t, matched)
}

func TestGetSessionConfigWithEndpoint(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions exporter/awsxrayexporter/internal/translator/segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ func validateLocalRootDependencySubsegment(t *testing.T, segment *awsxray.Segmen

assert.Equal(t, "MySDK", *segment.AWS.XRay.SDK)
assert.Equal(t, "1.20.0", *segment.AWS.XRay.SDKVersion)
assert.Equal(t, true, *segment.AWS.XRay.AutoInstrumentation)
assert.True(t, *segment.AWS.XRay.AutoInstrumentation)

assert.Equal(t, "UpdateItem", *segment.AWS.Operation)
assert.Equal(t, "AWSAccountAttribute", *segment.AWS.AccountID)
Expand All @@ -1278,7 +1278,7 @@ func validateLocalRootServiceSegment(t *testing.T, segment *awsxray.Segment, spa
assert.Equal(t, "service.name=myTest", segment.Metadata["default"]["otel.resource.attributes"])
assert.Equal(t, "MySDK", *segment.AWS.XRay.SDK)
assert.Equal(t, "1.20.0", *segment.AWS.XRay.SDKVersion)
assert.Equal(t, true, *segment.AWS.XRay.AutoInstrumentation)
assert.True(t, *segment.AWS.XRay.AutoInstrumentation)
assert.Nil(t, segment.AWS.Operation)
assert.Nil(t, segment.AWS.AccountID)
assert.Nil(t, segment.AWS.RemoteRegion)
Expand Down Expand Up @@ -1406,7 +1406,7 @@ func TestNonLocalRootConsumerProcess(t *testing.T) {
assert.Equal(t, "service.name=myTest", segments[0].Metadata["default"]["otel.resource.attributes"])
assert.Equal(t, "MySDK", *segments[0].AWS.XRay.SDK)
assert.Equal(t, "1.20.0", *segments[0].AWS.XRay.SDKVersion)
assert.Equal(t, true, *segments[0].AWS.XRay.AutoInstrumentation)
assert.True(t, *segments[0].AWS.XRay.AutoInstrumentation)
assert.Equal(t, "UpdateItem", *segments[0].AWS.Operation)
assert.Nil(t, segments[0].Namespace)
}
Expand Down Expand Up @@ -1563,7 +1563,7 @@ func validateLocalRootWithoutDependency(t *testing.T, segment *awsxray.Segment,
assert.Equal(t, "service.name=myTest", segment.Metadata["default"]["otel.resource.attributes"])
assert.Equal(t, "MySDK", *segment.AWS.XRay.SDK)
assert.Equal(t, "1.20.0", *segment.AWS.XRay.SDKVersion)
assert.Equal(t, true, *segment.AWS.XRay.AutoInstrumentation)
assert.True(t, *segment.AWS.XRay.AutoInstrumentation)

assert.Equal(t, "UpdateItem", *segment.AWS.Operation)
assert.Equal(t, "AWSAccountAttribute", *segment.AWS.AccountID)
Expand Down
4 changes: 2 additions & 2 deletions exporter/datasetexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestConfigUseProvidedExportResourceInfoValue(t *testing.T) {
})
err := config.Unmarshal(configMap)
assert.NoError(t, err)
assert.Equal(t, true, config.LogsSettings.ExportResourceInfo)
assert.True(t, config.LogsSettings.ExportResourceInfo)
}

func TestConfigUseProvidedExportScopeInfoValue(t *testing.T) {
Expand All @@ -172,5 +172,5 @@ func TestConfigUseProvidedExportScopeInfoValue(t *testing.T) {
})
err := config.Unmarshal(configMap)
assert.NoError(t, err)
assert.Equal(t, false, config.LogsSettings.ExportScopeInfo)
assert.False(t, config.LogsSettings.ExportScopeInfo)
}
8 changes: 4 additions & 4 deletions exporter/fileexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestNewFileWriter(t *testing.T) {
validate: func(t *testing.T, writer *fileWriter) {
assert.Equal(t, 5*time.Second, writer.flushInterval)
_, ok := writer.file.(*bufferedWriteCloser)
assert.Equal(t, true, ok)
assert.True(t, ok)
},
},
{
Expand All @@ -139,7 +139,7 @@ func TestNewFileWriter(t *testing.T) {
},
validate: func(t *testing.T, writer *fileWriter) {
logger, ok := writer.file.(*lumberjack.Logger)
assert.Equal(t, true, ok)
assert.True(t, ok)
assert.Equal(t, defaultMaxBackups, logger.MaxBackups)
},
},
Expand All @@ -158,11 +158,11 @@ func TestNewFileWriter(t *testing.T) {
},
validate: func(t *testing.T, writer *fileWriter) {
logger, ok := writer.file.(*lumberjack.Logger)
assert.Equal(t, true, ok)
assert.True(t, ok)
assert.Equal(t, 3, logger.MaxBackups)
assert.Equal(t, 30, logger.MaxSize)
assert.Equal(t, 100, logger.MaxAge)
assert.Equal(t, true, logger.LocalTime)
assert.True(t, logger.LocalTime)
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/honeycombmarkerexporter/logs_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestExportMarkers(t *testing.T) {

userAgent := req.Header.Get(userAgentHeaderKey)
assert.NotEmpty(t, userAgent)
assert.Equal(t, strings.Contains(userAgent, "OpenTelemetry Collector"), true)
assert.True(t, strings.Contains(userAgent, "OpenTelemetry Collector"))

rw.WriteHeader(http.StatusAccepted)
}))
Expand Down
4 changes: 2 additions & 2 deletions exporter/logicmonitorexporter/internal/logs/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestSendLogs(t *testing.T) {
err = sender.SendLogs(ctx, []model.LogInput{logInput})
cancel()
assert.Error(t, err)
assert.Equal(t, true, consumererror.IsPermanent(err))
assert.True(t, consumererror.IsPermanent(err))
})

t.Run("should not return permanent failure error", func(t *testing.T) {
Expand All @@ -87,7 +87,7 @@ func TestSendLogs(t *testing.T) {
err = sender.SendLogs(ctx, []model.LogInput{logInput})
cancel()
assert.Error(t, err)
assert.Equal(t, false, consumererror.IsPermanent(err))
assert.False(t, consumererror.IsPermanent(err))
})
}

Expand Down
4 changes: 2 additions & 2 deletions exporter/logicmonitorexporter/internal/traces/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestSendTraces(t *testing.T) {
err = sender.SendTraces(ctx, testdata.GenerateTraces(1))
cancel()
assert.Error(t, err)
assert.Equal(t, true, consumererror.IsPermanent(err))
assert.True(t, consumererror.IsPermanent(err))
})

t.Run("should not return permanent failure error", func(t *testing.T) {
Expand All @@ -86,6 +86,6 @@ func TestSendTraces(t *testing.T) {
err = sender.SendTraces(ctx, testdata.GenerateTraces(1))
cancel()
assert.Error(t, err)
assert.Equal(t, false, consumererror.IsPermanent(err))
assert.False(t, consumererror.IsPermanent(err))
})
}
2 changes: 1 addition & 1 deletion exporter/lokiexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func TestLogsToLokiRequestWithGroupingByTenant(t *testing.T) {
assert.Equal(t, len(actualPushRequestPerTenant), len(tC.expected))
for tenant, request := range actualPushRequestPerTenant {
pr, ok := tC.expected[tenant]
assert.Equal(t, ok, true)
assert.True(t, ok)

expectedLabel := pr.label
expectedLine := pr.line
Expand Down
2 changes: 1 addition & 1 deletion exporter/prometheusexporter/accumulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func TestAccumulateDeltaToCumulative(t *testing.T) {
require.Equal(t, mValue, vValue)
require.Equal(t, dataPointValue1+dataPointValue2, vValue)
require.Equal(t, pmetric.AggregationTemporalityCumulative, vTemporality)
require.Equal(t, true, vIsMonotonic)
require.True(t, vIsMonotonic)

require.Equal(t, ts3.Unix(), vTS.Unix())
})
Expand Down
2 changes: 1 addition & 1 deletion exporter/syslogexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestSyslogExportFail(t *testing.T) {
consumerErr := test.exp.pushLogsData(context.Background(), logs)
var consumerErrorLogs consumererror.Logs
ok := errors.As(consumerErr, &consumerErrorLogs)
assert.Equal(t, ok, true)
assert.True(t, ok)
consumerLogs := consumererror.Logs.Data(consumerErrorLogs)
rls := consumerLogs.ResourceLogs()
require.Equal(t, 1, rls.Len())
Expand Down
Loading

0 comments on commit e572976

Please sign in to comment.