Skip to content

Releases: nunnatsa/ginkgolinter

v0.15.1

10 Dec 13:15
Compare
Choose a tag to compare

Downgrade to golang v1.20, because golangci-lint needs to be built with go1.20, as go1.20 and go1.21 are the current versions of Go supported by the Go team. So, for now, golangci-lint should not depend on go1.21.

v0.15.0

04 Dec 09:58
Compare
Choose a tag to compare

What's Changed

New rule(s): Wrong Usage of the MatchError gomega Matcher

The MatchError gomega matcher asserts an error value (and if it's not nil).

There are four valid formats for using this Matcher:

  • error value; e.g. Expect(err).To(MatchError(anotherErr))
  • string, to be equal to the output of the Error() method; e.g. Expect(err).To(MatchError("Not Found"))
  • A gomega matcher that asserts strings; e.g. Expect(err).To(MatchError(ContainSubstring("Found")))
  • [from v0.29.0] a function that receive a single error parameter and returns a single boolean value. In this format, an additional single string parameter, with the function description, is also required; e.g. Expect(err).To(MatchError(isNotFound, "is the error is a not found error"))

These four format are checked on runtime, but sometimes it's too late. ginkgolinter performs a static analysis and so it will find these issues on build time.

ginkgolinter checks the following:

  • Is the first parameter is one of the four options above.
  • That there are no additional parameters passed to the matcher; e.g. MatchError(isNotFoundFunc, "a valid description" , "not used string"). In this case, the matcher won't fail on run time, but the additional parameters are not in use and ignored.
  • If the first parameter is a function with the format of func(error)bool, ginkgolinter makes sure that the second parameter exists and its type is string.

Full Changelog: v0.14.1...v0.15.0

v0.14.1

29 Oct 06:17
Compare
Choose a tag to compare

Bug fixes

Type checker gives false positive for WithTransform + ContainElement (#115 )

ginkgolinter now only trigger warning for WithTransform with Equal or BeIdentical matchers.

Full Changelog: v0.14.0...v0.14.1

v0.14.0

03 Oct 11:54
Compare
Choose a tag to compare

New Rule: Prevent comparing of value from different types

The Equal and the BeIdentical gomega matchers check not only the value, but also the type.

For example:

x := uint(5)
Expect(x).Should(Equal(5))

This assertion will fail in runtime (when running the test). This is not too bad for unit tests, that can be easily run locally and be fixed, but for complex functional or e2e test, it could be hard to debug and it's not always simple to run.

In addition, it can create fals positive tests, for example:

x := uint(5)
Expect(x).ShouldNot(Equal(5))

This test will pass. The value itself is never checked, but only the type.

ginkgolinter now finds these cases and trigger warnings for them.

command line arguments

The new --suppress-type-compare-assertion=true command line argument will suppress this new rule.

Full Changelog: v0.13.5...v0.14.0

v0.13.5

14 Aug 06:20
Compare
Choose a tag to compare

What's Changed

Improve the focus rule

  1. forbid also the FDescribeTable and the FEntry focused containers.
  2. forbid the Focus individual spec, as in
    It("test something", Focus, func(){
        Expect(...)...
    })

Full Changelog: v0.13.3...v0.13.5

v0.13.3

24 Jul 12:52
Compare
Choose a tag to compare

Bug Fixes

Optimize focus-container validation to opt-in

Make the focused container rule to be opt-in. It is now disabled by default and should be enabled by the user.

CLI Flags

  • The --suppress-focus-container flag is now depracated and ignored.
  • The new --forbid-focus-container=true flag enables the focused container rule.

Full Changelog: v0.13.0...v0.13.3

v0.13.0

18 Jul 05:31
Compare
Choose a tag to compare

New Rule: disallow focus containers

This new rule prevent the leaking of a local debug code to the repo, by forbidding the usage of the ginkgo focus container (FDescribe, FContext, FWhen and FIt).

new suppress comment

in order to locally suppress this new rule, use the following comment (see more details at the README.md

// ginkgo-linter:ignore-focus-container-warning

new command line flag

--suppress-focus-container=true - to suppress the new rule

Misc

Docs

fix the version of golangci-lint in the README.md by @chetan-rns

bump golang to 1.20

New Contributors - thank you so much! 🥇

Full Changelog: v0.12.2...v0.13.0

v0.12.2

27 Jun 15:08
Compare
Choose a tag to compare

Bug Fixes

  • false positive warning for typed function calls #92

Full Changelog: v0.12.1...v0.12.2

v0.12.1

06 Jun 09:38
Compare
Choose a tag to compare

Bug Fixes

allow function calls in async checks for functions that return a pointer #88

v0.12.0

07 May 09:36
Compare
Choose a tag to compare

New Rules

Missing Assertion Method

The linter warns when calling an "actual" method (e.g. Expect(), Eventually() etc.), without an assertion method (e.g Should(), NotTo() etc.)

For example:

// no assertion for the result
Eventually(doSomething).WithTimeout(time.Seconds * 5).WithPolling(time.Milliseconds * 100)

The linter will not suggest a fix for this warning.

This rule cannot be suppressed.

Full Changelog: v0.11.2...v0.12.0