gomegalint

command module
v0.0.0-...-98766ad Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 5 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL