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 <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 committed Sep 18, 2024
1 parent 7bd1c85 commit 851cf74
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 39 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
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ $(GORELEASE): PACKAGE=golang.org/x/exp/cmd/gorelease
GOVULNCHECK = $(TOOLS)/govulncheck
$(TOOLS)/govulncheck: PACKAGE=golang.org/x/vuln/cmd/govulncheck

TESTIFYLINT = $(TOOLS)/testifylint
$(TOOLS)/testifylint: PACKAGE=github.com/Antonboom/testifylint

.PHONY: tools
tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(GOJQ) $(SEMCONVGEN) $(MULTIMOD) $(SEMCONVKIT) $(GOTMPL) $(GORELEASE)
tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(GOJQ) $(SEMCONVGEN) $(MULTIMOD) $(SEMCONVKIT) $(GOTMPL) $(GORELEASE) $(TESTIFYLINT)

# Virtualized python tools via docker

Expand Down Expand Up @@ -199,6 +202,14 @@ golangci-lint/%: $(GOLANGCI_LINT)
&& cd $(DIR) \
&& $(GOLANGCI_LINT) run --allow-serial-runners $(ARGS)

.PHONY: testifylint
testifylint: $(OTEL_GO_MOD_DIRS:%=testifylint/%)
testifylint/%: DIR=$*
testifylint/%: $(TESTIFYLINT)
@echo 'testifylint -fix ./... in $(DIR)' \
&& cd $(DIR) \
&& $(TESTIFYLINT) --enable-all --disable=empty,error-is-as,error-nil,expected-actual,float-compare,go-require,len,negative-positive,require-error,suite-extra-assert-call -fix ./...

.PHONY: crosslink
crosslink: $(CROSSLINK)
@echo "Updating intra-repository dependencies in all go modules" \
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 @@ -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 internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module go.opentelemetry.io/otel/internal/tools
go 1.22.1

require (
github.com/Antonboom/testifylint v1.4.3
github.com/client9/misspell v0.3.4
github.com/gogo/protobuf v1.3.2
github.com/golangci/golangci-lint v1.61.0
Expand All @@ -26,7 +27,6 @@ require (
github.com/Abirdcfly/dupword v0.1.1 // indirect
github.com/Antonboom/errname v0.1.13 // indirect
github.com/Antonboom/nilnil v0.1.9 // indirect
github.com/Antonboom/testifylint v1.4.3 // indirect
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
github.com/Crocmagnon/fatcontext v0.5.2 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
Expand Down
Loading

0 comments on commit 851cf74

Please sign in to comment.