Skip to content

Simple linter for idiomatic usage of gomega matchers and assertions

License

Notifications You must be signed in to change notification settings

krdln/gomegalint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gomegalint

Linter for gomega assertions.

  1. Checks whether you're not mixing Ω-notation with Expect-notation (which compiles, but looks weird).
  2. Recommends most appropriate matcher for checking nilness (BeNil/Succeed/HaveOccurred), depending on context.

Uses standard linter interface based on golang.org/x/tools/go/analysis.

Example

$ gomegalint -c 0 github.com/xxx/yyy/pkg/...
…/zzz.go:25:3: unidiomatic matcher: consider using HaveOccurred instead of BeNil in this assertion
25			Expect(err).Should(BeNil())
…/zzz.go:25:3: inconsistent assertion style (Expect + Should)
25			Expect(err).Should(BeNil())

All warnings are auto-fixable with the -fix flag!

$ gomegalint -fix github.com/xxx/yyy/pkg/...

This applies the following suggestion:

-               Expect(err).Should(BeNil())
+               Expect(err).NotTo(HaveOccurred())

Installation

go install github.com/krdln/gomegalint@latest

About

Simple linter for idiomatic usage of gomega matchers and assertions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages