nunnatsa / ginkgolinter

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

[Enhancement] boolean check of comparison #64

Closed pohly closed 1 year ago

pohly commented 1 year ago

Is your feature request related to a problem? Please describe.

This is sub-optimal:

gomega.Expect(batchLag <= podBatchStartupLimit).To(gomega.BeTrue(), "Batch creation startup time exceed limit")

Describe the solution you'd like

The linter should detect this and suggest:

gomega.Expect(batchLag).To(gomega.BeNumerically("<=", podBatchStartupLimit), "Batch creation startup time exceed limit")

Additional context

With the original Expect it is not clear which value is the actual value. I would just keep the order of the comparison operands.

pohly commented 1 year ago

This is just one example - there could be plenty of variants of this, including those with To(gomega.BeFalse()) or even worse, ToNot(gomega.BeFalse()). Test developers are creative...