Closed nunnatsa closed 1 year ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
types/config.go | 2 | 3 | 66.67% | ||
reverseassertion/reverse_assertion.go | 0 | 5 | 0.0% | ||
ginkgo_linter.go | 121 | 137 | 88.32% | ||
gomegahandler/handler.go | 2 | 37 | 5.41% | ||
<!-- | Total: | 125 | 182 | 68.68% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
types/config.go | 1 | 33.33% | ||
ginkgo_linter.go | 6 | 88.55% | ||
<!-- | Total: | 7 | --> |
Totals | |
---|---|
Change from base Build 4401338548: | -3.5% |
Covered Lines: | 740 |
Relevant Lines: | 889 |
closing in order to split to smaller PRs
Added New linter Rule: asserting a function call with async method
The linter now warns about using
Eventually
orConsistently
with a function call. This is because when doing that,Eventually
checks the same returned value again and again, instead of polling by calling the function.For example:
In the above code,
Eventually
receives42
as its argument. Then it polls this value to check if it equal 42. What we really wanted here is:Now,
Eventually
calls the function until it returns the required value.To suppress this warning entirely, add the
--suppress-async-assertion=true
command line flag, or theginkgo-linter:ignore-async-assert-warning
comment.Additional Improvements
support WithOffset
add support in the WithOffset method. The linter previously missed the wrong pattern when WithOffset was used, e.g.
Now the linter checks these patterns as well.
len() comparison bug
Fix a bug, where comparing a len() result, triggers the wrong warning and replacement; e.g.
Expect(len(x) == 5).Should(BeTrue())
was changed intoExpect(len(x)).Should(Equal(5))
. This pattern is also wrong (wrong length assertion).The linter now suggests
Expect(x).Should(HaveLen(5))
in this case.avoiding double negative assertion
The linter now tries avoiding double negative assertion in some cases. For example, for this patter:
The linter used to change to
Now, the linter changes it to:
How Has This Been Tested?
Checklist: