nunnatsa / ginkgolinter

golang linter for ginkgo and gomega
MIT License
24 stars 6 forks source link

[BUG] Custom GomegaMatcher Incorrectly Compares to MatchError #125

Closed sam-heilbron closed 6 months ago

sam-heilbron commented 6 months ago

Describe the bug When I define a custom GomegaMatcher in a test, and then run the linter against that code, I see:

ginkgo-linter: the MatchError matcher used to assert a non error type (<type>)

To Reproduce Option 1:

  1. Write a test that relies on a custom GomegaMatcher
  2. Run the linter against that file

Option 2:

  1. Run the linter agains the code in https://github.com/solo-io/gloo

When I use option 2, I see a bunch of errors, like:

string, GomegaMatcher or func(error)bool are allowed
/Users/samheilbron/go/src/github.com/solo-io/gloo/test/kube2e/gateway/gateway_test.go:2119:6: ginkgo-linter: the MatchError matcher used to assert a non error type (err.Error())
/Users/samheilbron/go/src/github.com/solo-io/gloo/test/kube2e/gateway/gateway_test.go:2119:29: ginkgo-linter: MatchError first parameter (matchers2.ContainSubstrings([]string{"admission webhook", "SSL secret not found", secretName})) must be error, string, GomegaMatcher or func(error)bool are allowed
/Users/samheilbron/go/src/github.com/solo-io/gloo/test/kube2e/gateway/gateway_test.go:2281:7: ginkgo-linter: the MatchError matcher used to assert a non error type (vs.GetVirtualHost().GetOptions().GetTransformations())
/Users/samheilbron/go/src/github.com/solo-io/gloo/test/kube2e/gateway/gateway_test.go:2281:74: ginkgo-linter: MatchError first parameter (gloo_matchers.MatchProto(invalidTransformation)) must be error, string, GomegaMatcher or func(error)bool are allowed

Expected behavior Custom GomegaMatchers, which are built correctly, should not trip a lint error

Additional context

nunnatsa commented 6 months ago

Thanks @sam-heilbron - this is actually the same bug as #124

Closing.