aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nunnatsa
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2025-01-22 16:07:17 +0100
committerTaras Madan <tarasmadan@google.com>2025-01-23 10:42:36 +0000
commit7b4377ad9d8a7205416df8d6217ef2b010f89481 (patch)
treee6fec4fd12ff807a16d847923f501075bf71d16c /vendor/github.com/nunnatsa
parent475a4c203afb8b7d3af51c4fd32bb170ff32a45e (diff)
vendor: delete
Diffstat (limited to 'vendor/github.com/nunnatsa')
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/.gitignore3
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/.golangci.yml3
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/LICENSE21
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/Makefile33
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/README.md603
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/analyzer.go60
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/doc.go116
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actual.go118
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actualarg.go246
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/asyncactual.go123
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/asyncfuncarg.go38
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/comparisonAsserion.go260
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/expression.go317
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/bematchers.go77
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/benumericmatcher.go128
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/equalmatcher.go124
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/errormatchers.go199
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/lenmatchers.go11
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcher.go86
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcherinfo.go148
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcherwithnest.go66
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/multiplematchers.go62
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/expression/value/value.go221
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/formatter/formatter.go22
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/dothandler.go36
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/ginkgoinfo.go63
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/handler.go48
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/handling.go195
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/namehandler.go49
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/dothandler.go103
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/handler.go48
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/namedhandler.go115
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/gomegainfo/gomegainfo.go113
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/interfaces/interfaces.go76
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/intervals/intervals.go166
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/reports/report-builder.go104
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/reverseassertion/reverse_assertion.go42
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asyncfunccallrule.go41
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asyncsucceedrule.go30
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asynctimeintervalsrule.go79
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/caprule.go128
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/comparepointerrule.go64
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/comparisonrule.go75
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/doublenegativerule.go30
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equalboolrule.go36
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equaldifferenttypesrule.go119
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equalnilrule.go29
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/errorequalnilrule.go42
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/forceexpecttorule.go43
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/havelen0.go23
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/haveoccurredrule.go35
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/lenrule.go119
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/matcheronlyrule.go12
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/matcherrorrule.go110
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/missingassertionrule.go27
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/nilcomparerule.go75
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/rule.go61
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/internal/rules/succeedrule.go41
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/linter/ginkgo_linter.go131
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/types/boolean.go32
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/types/config.go101
-rw-r--r--vendor/github.com/nunnatsa/ginkgolinter/version/version.go14
62 files changed, 0 insertions, 5740 deletions
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/.gitignore b/vendor/github.com/nunnatsa/ginkgolinter/.gitignore
deleted file mode 100644
index 67467b717..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-ginkgolinter
-bin/
-e2e \ No newline at end of file
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/.golangci.yml b/vendor/github.com/nunnatsa/ginkgolinter/.golangci.yml
deleted file mode 100644
index 71ff0d034..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/.golangci.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-linters:
- enable:
- - revive
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/LICENSE b/vendor/github.com/nunnatsa/ginkgolinter/LICENSE
deleted file mode 100644
index 11096c5c8..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2022 Nahshon Unna Tsameret
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/Makefile b/vendor/github.com/nunnatsa/ginkgolinter/Makefile
deleted file mode 100644
index 8ddd8c42c..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-VERSION ?= "unknown"
-VERSION_FLAG := -X github.com/nunnatsa/ginkgolinter/version.version=$(VERSION)
-COMMIT_HASH := $(shell git rev-parse HEAD)
-HASH_FLAG := -X github.com/nunnatsa/ginkgolinter/version.gitHash=$(COMMIT_HASH)
-
-BUILD_ARGS := -ldflags "$(VERSION_FLAG) $(HASH_FLAG)"
-
-build: goimports
- go build $(BUILD_ARGS) -o ginkgolinter ./cmd/ginkgolinter
-
-unit-test:
- go test ./...
-
-build-for-windows:
- GOOS=windows GOARCH=amd64 go build $(BUILD_ARGS) -o bin/ginkgolinter-amd64.exe ./cmd/ginkgolinter
-
-build-for-mac:
- GOOS=darwin GOARCH=amd64 go build $(BUILD_ARGS) -o bin/ginkgolinter-amd64-darwin ./cmd/ginkgolinter
-
-build-for-linux:
- GOOS=linux GOARCH=amd64 go build $(BUILD_ARGS) -o bin/ginkgolinter-amd64-linux ./cmd/ginkgolinter
- GOOS=linux GOARCH=386 go build $(BUILD_ARGS) -o bin/ginkgolinter-386-linux ./cmd/ginkgolinter
-
-build-all: build build-for-linux build-for-mac build-for-windows
-
-test-cli:
- cd tests; go test -v ./
-
-test: unit-test test-cli
-
-goimports:
- go install golang.org/x/tools/cmd/goimports@latest
- goimports -w -local="github.com/nunnatsa/ginkgolinter" $(shell find . -type f -name '*.go' ! -path "*/vendor/*")
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/README.md b/vendor/github.com/nunnatsa/ginkgolinter/README.md
deleted file mode 100644
index 012628ed7..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/README.md
+++ /dev/null
@@ -1,603 +0,0 @@
-[![Go Report Card](https://goreportcard.com/badge/github.com/nunnatsa/ginkgolinter)](https://goreportcard.com/report/github.com/nunnatsa/ginkgolinter)
-[![Coverage Status](https://coveralls.io/repos/github/nunnatsa/ginkgolinter/badge.svg?branch=main)](https://coveralls.io/github/nunnatsa/ginkgolinter?branch=main)
-![Build Status](https://github.com/nunnatsa/ginkgolinter/workflows/CI/badge.svg)
-[![License](https://img.shields.io/github/license/nunnatsa/ginkgolinter)](/LICENSE)
-[![Release](https://img.shields.io/github/release/nunnatsa/ginkgolinter.svg)](https://github.com/nunnatsa/ginkgolinter/releases/latest)
-[![GitHub Releases Stats of ginkgolinter](https://img.shields.io/github/downloads/nunnatsa/ginkgolinter/total.svg?logo=github)](https://somsubhra.github.io/github-release-stats/?username=nunnatsa&repository=ginkgolinter)
-
-# ginkgo-linter
-[ginkgo](https://onsi.github.io/ginkgo/) is a popular testing framework and [gomega](https://onsi.github.io/gomega/) is its assertion package.
-
-This is a golang linter to enforce some standards while using the ginkgo and gomega packages.
-
-## Install the CLI
-Download the right executable from the latest release, according to your OS.
-
-Another option is to use go:
-```shell
-go install github.com/nunnatsa/ginkgolinter/cmd/ginkgolinter@latest
-```
-Then add the new executable to your PATH.
-
-## usage
-```shell
-ginkgolinter [-fix] ./...
-```
-
-Use the `-fix` flag to apply the fix suggestions to the source code.
-
-### Use ginkgolinter with golangci-lint
-The ginkgolinter is now part of the popular [golangci-lint](https://golangci-lint.run/), starting from version `v1.51.1`.
-
-It is not enabled by default, though. There are two ways to run ginkgolinter with golangci-lint:
-
-* From command line:
- ```shell
- golangci-lint run -E ginkgolinter ./...
- ```
-* From configuration:
-
- Add ginkgolinter to the enabled linters list in .golangci.reference.yml file in your project. For more details, see
- the [golangci-lint documentation](https://golangci-lint.run/usage/configuration/); e.g.
- ```yaml
- linters:
- enable:
- - ginkgolinter
- ```
-## Linter Rules
-The linter checks the ginkgo and gomega assertions in golang test code. Gomega may be used together with ginkgo tests,
-For example:
-```go
-It("should test something", func() { // It is ginkgo test case function
- Expect("abcd").To(HaveLen(4), "the string should have a length of 4") // Expect is the gomega assertion
-})
-```
-or within a classic golang test code, like this:
-```go
-func TestWithGomega(t *testing.T) {
- g := NewWithT(t)
- g.Expect("abcd").To(HaveLen(4), "the string should have a length of 4")
-}
-```
-
-In some cases, the gomega will be passed as a variable to function by ginkgo, for example:
-```go
-Eventually(func(g Gomega) error {
- g.Expect("abcd").To(HaveLen(4), "the string should have a length of 4")
- return nil
-}).Should(Succeed())
-```
-
-The linter checks the `Expect`, `ExpectWithOffset` and the `Ω` "actual" functions, with the `Should`, `ShouldNot`, `To`, `ToNot` and `NotTo` assertion functions.
-
-It also supports the embedded `Not()` matcher
-
-Some checks find actual bugs, and some are more for style.
-
-### Using a function call in async assertion [BUG]
-This rule finds an actual bug in tests, where asserting a function call in an async function; e.g. `Eventually`. For
-example:
-```go
-func slowInt(int val) int {
- time.Sleep(time.Second)
- return val
-}
-
-...
-
-It("should test that slowInt returns 42, eventually", func() {
- Eventually(slowInt(42)).WithPolling(time.Millisecond * 100).WithTimeout(time.Second * 2).Equal(42)
-})
-```
-The problem with the above code is that it **should** poll - call the function - until it returns 42, but what actually
-happens is that first the function is called, and we pass `42` to `Eventually` - not the function. This is not what we
-tried to do here.
-
-The linter will suggest replacing this code by:
-```go
-It("should test that slowInt returns 42, eventually", func() {
- Eventually(slowInt).WithArguments(42).WithPolling(time.Millisecond * 100).WithTimeout(time.Second * 2).Equal(42)
-})
-```
-
-The linter suggested replacing the function call by the function name.
-
-If function arguments are used, the linter will add the `WithArguments()` method to pass them.
-
-Please notice that `WithArguments()` is only supported from gomenga v1.22.0.
-
-When using an older version of gomega, change the code manually. For example:
-
-```go
-It("should test that slowInt returns 42, eventually", func() {
- Eventually(func() int {
- slowint(42)
- }).WithPolling(time.Millisecond * 100).WithTimeout(time.Second * 2).Equal(42)
-})
-```
-
-### Comparing a pointer with a value [BUG]
-The linter warns when comparing a pointer with a value.
-These comparisons are always wrong and will always fail.
-
-In case of a positive assertion (`To()` or `Should()`), the test will just fail.
-
-But the main concern is for false positive tests, when using a negative assertion (`NotTo()`, `ToNot()`, `ShouldNot()`,
-`Should(Not())` etc.); e.g.
-```go
-num := 5
-...
-pNum := &num
-...
-Expect(pNum).ShouldNot(Equal(6))
-```
-This assertion will pass, but for the wrong reasons: pNum is not equal 6, not because num == 5, but because pNum is
-a pointer, while `6` is an `int`.
-
-In the case above, the linter will suggest `Expect(pNum).ShouldNot(HaveValue(Equal(6)))`
-
-This is also right for additional matchers: `BeTrue()` and `BeFalse()`, `BeIdenticalTo()`, `BeEquivalentTo()`
-and `BeNumerically`.
-
-### Missing Assertion Method [BUG]
-The linter warns when calling an "actual" method (e.g. `Expect()`, `Eventually()` etc.), without an assertion method (e.g
-`Should()`, `NotTo()` etc.)
-
-For example:
-```go
-// 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.
-
-### Focus Container / Focus individual spec found [BUG]
-This rule finds ginkgo focus containers, or the `Focus` individual spec in the code.
-
-ginkgo supports the `FDescribe`, `FContext`, `FWhen`, `FIt`, `FDescribeTable` and `FEntry`
-containers to allow the developer to focus
-on a specific test or set of tests during test development or debug.
-
-For example:
-```go
-var _ = Describe("checking something", func() {
- FIt("this test is the only one that will run", func(){
- ...
- })
-})
-```
-Alternatively, the `Focus` individual spec may be used for the same purpose, e.g.
-```go
-var _ = Describe("checking something", Focus, func() {
- It("this test is the only one that will run", func(){
- ...
- })
-})
-```
-
-These container, or the `Focus` spec, must not be part of the final source code, and should only be used locally by the
-developer.
-
-***This rule is disabled by default***. Use the `--forbid-focus-container=true` command line flag to enable it.
-
-### Comparing values from different types [BUG]
-
-The `Equal` and the `BeIdentical` matchers also check the type, not only the value.
-
-The following code will fail in runtime:
-```go
-x := 5 // x is int
-Expect(x).Should(Eqaul(uint(5)) // x and uint(5) are with different
-```
-When using negative checks, it's even worse, because we get a false positive:
-```
-x := 5
-Expect(x).ShouldNot(Equal(uint(5))
-```
-
-The linter suggests two options to solve this warning: either compare with the same type, e.g.
-using casting, or use the `BeEquivalentTo` matcher.
-
-The linter can't guess what is the best solution in each case, and so it won't auto-fix this warning.
-
-To suppress this warning entirely, use the `--suppress-type-compare-assertion=true` command line parameter.
-
-To suppress a specific file or line, use the `// ginkgo-linter:ignore-type-compare-warning` comment (see [below](#suppress-warning-from-the-code))
-
-### Wrong Usage of the `MatchError` gomega Matcher [BUG]
-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.
-
-### Async timing interval: timeout is shorter than polling interval [BUG]
-***Note***: Only applied when the `suppress-async-assertion` flag is **not set** *and* the `validate-async-intervals`
-flag **is** set.
-
-***Note***: This rule work with best-effort approach. It can't find many cases, like const defined not in the same
-package, or when using variables.
-
-The timeout and polling intervals may be passed as optional arguments to the `Eventually` or `Constanly` functions, or
-using the `WithTimeout` or , `Within` methods (timeout), and `WithPolling` or `ProbeEvery` methods (polling).
-
-This rule checks if the async (`Eventually` or `Consistently`) timeout duration, is not shorter than the polling interval.
-
-For example:
- ```go
- Eventually(aFunc).WithTimeout(500 * time.Millisecond).WithPolling(10 * time.Second).Should(Succeed())
- ```
-
-This will probably happen when using the old format:
- ```go
- Eventually(aFunc, 500 * time.Millisecond /*timeout*/, 10 * time.Second /*polling*/).Should(Succeed())
- ```
-
-### Prevent Wrong Actual Values with the Succeed() matcher [Bug]
-The `Succeed()` matcher only accepts a single error value. this rule validates that.
-
-For example:
- ```go
- Expect(42).To(Succeed())
- ```
-
-But mostly, we want to avoid using this matcher with functions that return multiple values, even if their last
-returned value is an error, because this is not supported:
- ```go
- Expect(os.Open("myFile.txt")).To(Succeed())
- ```
-
-In async assertions (like `Eventually()`), the `Succeed()` matcher may also been used with functions that accept
-a Gomega object as their first parameter, and returns nothing, e.g. this is a valid usage of `Eventually`
- ```go
- Eventually(func(g Gomega){
- g.Expect(true).To(BeTrue())
- }).WithTimeout(10 * time.Millisecond).WithPolling(time.Millisecond).Should(Succeed())
- ```
-
-***Note***: This rule **does not** support auto-fix.
-
-### Avoid Spec Pollution: Don't Initialize Variables in Container Nodes [BUG/STYLE]:
-***Note***: Only applied when the `--forbid-spec-pollution=true` flag is set (disabled by default).
-
-According to [ginkgo documentation](https://onsi.github.io/ginkgo/#avoid-spec-pollution-dont-initialize-variables-in-container-nodes),
-no variable should be assigned within a container node (`Describe`, `Context`, `When` or their `F`, `P` or `X` forms)
-
-For example:
-```go
-var _ = Describe("description", func(){
- var x = 10
- ...
-})
-```
-
-Instead, use `BeforeEach()`; e.g.
-```go
-var _ = Describe("description", func (){
- var x int
-
- BeforeEach(func (){
- x = 10
- })
- ...
-})
-```
-
-### Wrong Length Assertion [STYLE]
-The linter finds assertion of the golang built-in `len` function, with all kind of matchers, while there are already
-gomega matchers for these usecases; We want to assert the item, rather than its length.
-
-There are several wrong patterns:
-```go
-Expect(len(x)).To(Equal(0)) // should be: Expect(x).To(BeEmpty())
-Expect(len(x)).To(BeZero()) // should be: Expect(x).To(BeEmpty())
-Expect(len(x)).To(BeNumeric(">", 0)) // should be: Expect(x).ToNot(BeEmpty())
-Expect(len(x)).To(BeNumeric(">=", 1)) // should be: Expect(x).ToNot(BeEmpty())
-Expect(len(x)).To(BeNumeric("==", 0)) // should be: Expect(x).To(BeEmpty())
-Expect(len(x)).To(BeNumeric("!=", 0)) // should be: Expect(x).ToNot(BeEmpty())
-
-Expect(len(x)).To(Equal(1)) // should be: Expect(x).To(HaveLen(1))
-Expect(len(x)).To(BeNumeric("==", 2)) // should be: Expect(x).To(HaveLen(2))
-Expect(len(x)).To(BeNumeric("!=", 3)) // should be: Expect(x).ToNot(HaveLen(3))
-```
-
-It also supports the embedded `Not()` matcher; e.g.
-
-`Ω(len(x)).Should(Not(Equal(4)))` => `Ω(x).ShouldNot(HaveLen(4))`
-
-Or even (double negative):
-
-`Ω(len(x)).To(Not(BeNumeric(">", 0)))` => `Ω(x).To(BeEmpty())`
-
-The output of the linter,when finding issues, looks like this:
-```
-./testdata/src/a/a.go:14:5: ginkgo-linter: wrong length assertion; consider using `Expect("abcd").Should(HaveLen(4))` instead
-./testdata/src/a/a.go:18:5: ginkgo-linter: wrong length assertion; consider using `Expect("").Should(BeEmpty())` instead
-./testdata/src/a/a.go:22:5: ginkgo-linter: wrong length assertion; consider using `Expect("").Should(BeEmpty())` instead
-```
-
-### Wrong Cap Assertion [STYLE]
-The linter finds assertion of the golang built-in `cap` function, with all kind of matchers, while there are already
-gomega matchers for these usecases; We want to assert the item, rather than its cap.
-
-There are several wrong patterns:
-```go
-Expect(cap(x)).To(Equal(0)) // should be: Expect(x).To(HaveCap(0))
-Expect(cap(x)).To(BeZero()) // should be: Expect(x).To(HaveCap(0))
-Expect(cap(x)).To(BeNumeric(">", 0)) // should be: Expect(x).ToNot(HaveCap(0))
-Expect(cap(x)).To(BeNumeric("==", 2)) // should be: Expect(x).To(HaveCap(2))
-Expect(cap(x)).To(BeNumeric("!=", 3)) // should be: Expect(x).ToNot(HaveCap(3))
-```
-
-#### use the `HaveLen(0)` matcher. [STYLE]
-The linter will also warn about the `HaveLen(0)` matcher, and will suggest to replace it with `BeEmpty()`
-
-### Wrong `nil` Assertion [STYLE]
-The linter finds assertion of the comparison to nil, with all kind of matchers, instead of using the existing `BeNil()`
-matcher; We want to assert the item, rather than a comparison result.
-
-There are several wrong patterns:
-
-```go
-Expect(x == nil).To(Equal(true)) // should be: Expect(x).To(BeNil())
-Expect(nil == x).To(Equal(true)) // should be: Expect(x).To(BeNil())
-Expect(x != nil).To(Equal(true)) // should be: Expect(x).ToNot(BeNil())
-Expect(nil != nil).To(Equal(true)) // should be: Expect(x).ToNot(BeNil())
-
-Expect(x == nil).To(BeTrue()) // should be: Expect(x).To(BeNil())
-Expect(x == nil).To(BeFalse()) // should be: Expect(x).ToNot(BeNil())
-```
-It also supports the embedded `Not()` matcher; e.g.
-
-`Ω(x == nil).Should(Not(BeTrue()))` => `Ω(x).ShouldNot(BeNil())`
-
-Or even (double negative):
-
-`Ω(x != nil).Should(Not(BeTrue()))` => `Ω(x).Should(BeNil())`
-
-### Wrong boolean Assertion [STYLE]
-The linter finds assertion using the `Equal` method, with the values of to `true` or `false`, instead
-of using the existing `BeTrue()` or `BeFalse()` matcher.
-
-There are several wrong patterns:
-
-```go
-Expect(x).To(Equal(true)) // should be: Expect(x).To(BeTrue())
-Expect(x).To(Equal(false)) // should be: Expect(x).To(BeFalse())
-```
-It also supports the embedded `Not()` matcher; e.g.
-
-`Ω(x).Should(Not(Equal(True)))` => `Ω(x).ShouldNot(BeTrue())`
-
-### Wrong Error Assertion [STYLE]
-The linter finds assertion of errors compared with nil, or to be equal nil, or to be nil. The linter suggests to use `Succeed` for functions or `HaveOccurred` for error values..
-
-There are several wrong patterns:
-
-```go
-Expect(err).To(BeNil()) // should be: Expect(err).ToNot(HaveOccurred())
-Expect(err == nil).To(Equal(true)) // should be: Expect(err).ToNot(HaveOccurred())
-Expect(err == nil).To(BeFalse()) // should be: Expect(err).To(HaveOccurred())
-Expect(err != nil).To(BeTrue()) // should be: Expect(err).To(HaveOccurred())
-Expect(funcReturnsError()).To(BeNil()) // should be: Expect(funcReturnsError()).To(Succeed())
-
-and so on
-```
-It also supports the embedded `Not()` matcher; e.g.
-
-`Ω(err == nil).Should(Not(BeTrue()))` => `Ω(x).Should(HaveOccurred())`
-
-### Wrong Comparison Assertion [STYLE]
-The linter finds assertion of boolean comparisons, which are already supported by existing gomega matchers.
-
-The linter assumes that when compared something to literals or constants, these values should be used for the assertion,
-and it will do its best to suggest the right assertion expression accordingly.
-
-There are several wrong patterns:
-```go
-var x = 10
-var s = "abcd"
-
-...
-
-Expect(x == 10).Should(BeTrue()) // should be Expect(x).Should(Equal(10))
-Expect(10 == x).Should(BeTrue()) // should be Expect(x).Should(Equal(10))
-Expect(x != 5).Should(Equal(true)) // should be Expect(x).ShouldNot(Equal(5))
-Expect(x != 0).Should(Equal(true)) // should be Expect(x).ShouldNot(BeZero())
-
-Expect(s != "abcd").Should(BeFalse()) // should be Expect(s).Should(Equal("abcd"))
-Expect("abcd" != s).Should(BeFalse()) // should be Expect(s).Should(Equal("abcd"))
-```
-Or non-equal comparisons:
-```go
-Expect(x > 10).To(BeTrue()) // ==> Expect(x).To(BeNumerically(">", 10))
-Expect(x >= 15).To(BeTrue()) // ==> Expect(x).To(BeNumerically(">=", 15))
-Expect(3 > y).To(BeTrue()) // ==> Expect(y).To(BeNumerically("<", 3))
-// and so on ...
-```
-
-This check included a limited support in constant values. For example:
-```go
-const c1 = 5
-
-...
-
-Expect(x1 == c1).Should(BeTrue()) // ==> Expect(x1).Should(Equal(c1))
-Expect(c1 == x1).Should(BeTrue()) // ==> Expect(x1).Should(Equal(c1))
-```
-
-### Don't Allow Using `Expect` with `Should` or `ShouldNot` [STYLE]
-This optional rule forces the usage of the `Expect` method only with the `To`, `ToNot` or `NotTo`
-assertion methods; e.g.
-```go
-Expect("abc").Should(HaveLen(3)) // => Expect("abc").To(HaveLen(3))
-Expect("abc").ShouldNot(BeEmpty()) // => Expect("abc").ToNot(BeEmpty())
-```
-This rule support auto fixing.
-
-***This rule is disabled by default***. Use the `--force-expect-to=true` command line flag to enable it.
-
-### Async timing interval: multiple timeout or polling intervals [STYLE]
-***Note***: Only applied when the `suppress-async-assertion` flag is **not set** *and* the `validate-async-intervals`
-flag **is** set.
-
-The timeout and polling intervals may be passed as optional arguments to the `Eventually` or `Constanly` functions, or
-using the `WithTimeout` or , `Within` methods (timeout), and `WithPolling` or `ProbeEvery` methods (polling).
-
-The linter checks that there is up to one polling argument and up to one timeout argument.
-
-For example:
-
-```go
-// both WithTimeout() and Within()
-Eventually(aFunc).WithTimeout(time.Second * 10).Within(time.Second * 10).WithPolling(time.Millisecond * 500).Should(BeTrue())
-// both polling argument, and WithPolling() method
-Eventually(aFunc, time.Second*10, time.Millisecond * 500).WithPolling(time.Millisecond * 500).Should(BeTrue())
-```
-
-### Async timing interval: non-time.Duration intervals [STYLE]
-***Note***: Only applied when the `suppress-async-assertion` flag is **not set** *and* the `validate-async-intervals`
-flag **is** set.
-
-gomega supports a few formats for timeout and polling intervals, when using the old format (the last two parameters of Eventually and Constantly):
-* a `time.Duration` value
-* any kind of numeric value (int(8/16/32/64), uint(8/16/32/64) or float(32/64), as the number of seconds.
-* duration string like `"12s"`
-
-The linter triggers a warning for any duration value that is not of the `time.Duration` type, assuming that this is
-the desired type, given the type of the argument of the newer "WithTimeout", "WithPolling", "Within" and "ProbeEvery"
-methods.
-
-For example:
- ```go
- Eventually(func() bool { return true }, "1s").Should(BeTrue())
- Eventually(context.Background(), func() bool { return true }, time.Second*60, float64(2)).Should(BeTrue())
- ```
-
-This rule offers a limited auto fix: for integer values, or integer consts, the linter will suggest multiply the
-value with `time.Second`; e.g.
-```go
-const polling = 1
-Eventually(aFunc, 5, polling)
-```
-will be changed to:
-```go
-Eventually(aFunc, time.Second*5, time.Second*polling)
-```
-
-### Correct usage of the `Succeed()` and the `HaveOccurred()` matchers
-This rule enforces using the `Success()` matcher only for functions, and the `HaveOccurred()` matcher only for error
-values.
-
-For example:
- ```go
- Expect(err).To(Succeed())
- ```
-will trigger a warning with a suggestion to replace the mather to
- ```go
- Expect(err).ToNot(HaveOccurred())
- ```
-
-and vice versa:
- ```go
- Expect(myErrorFunc()).ToNot(HaveOccurred())
- ```
-will trigger a warning with a suggestion to replace the mather to
- ```go
- Expect(myErrorFunc()).To(Succeed())
- ```
-***This rule is disabled by default***. Use the `--force-succeed=true` command line flag to enable it.
-
-***Note***: This rule **does** support auto-fix, when the `--fix` command line parameter is used.
-
-## Suppress the linter
-### Suppress warning from command line
-* Use the `--suppress-len-assertion=true` flag to suppress the wrong length and cap assertions warning
-* Use the `--suppress-nil-assertion=true` flag to suppress the wrong nil assertion warning
-* Use the `--suppress-err-assertion=true` flag to suppress the wrong error assertion warning
-* Use the `--suppress-compare-assertion=true` flag to suppress the wrong comparison assertion warning
-* Use the `--suppress-async-assertion=true` flag to suppress the function call in async assertion warning
-* Use the `--forbid-focus-container=true` flag to activate the focused container assertion (deactivated by default)
-* Use the `--suppress-type-compare-assertion=true` to suppress the type compare assertion warning
-* Use the `--allow-havelen-0=true` flag to avoid warnings about `HaveLen(0)`; Note: this parameter is only supported from
- command line, and not from a comment.
-
-### Suppress warning from the code
-To suppress the wrong length and cap assertions warning, add a comment with (only)
-
-`ginkgo-linter:ignore-len-assert-warning`.
-
-To suppress the wrong nil assertion warning, add a comment with (only)
-
-`ginkgo-linter:ignore-nil-assert-warning`.
-
-To suppress the wrong error assertion warning, add a comment with (only)
-
-`ginkgo-linter:ignore-err-assert-warning`.
-
-To suppress the wrong comparison assertion warning, add a comment with (only)
-
-`ginkgo-linter:ignore-compare-assert-warning`.
-
-To suppress the wrong async assertion warning, add a comment with (only)
-
-`ginkgo-linter:ignore-async-assert-warning`.
-
-To supress the focus container warning, add a comment with (only)
-
-`ginkgo-linter:ignore-focus-container-warning`
-
-To suppress the different type comparison, add a comment with (only)
-
-`ginkgo-linter:ignore-type-compare-warning`
-
-Notice that this comment will not work for an anonymous variable container like
-```go
-// ginkgo-linter:ignore-focus-container-warning (not working!!)
-var _ = FDescribe(...)
-```
-In this case, use the file comment (see bellow).
-
-There are two options to use these comments:
-1. If the comment is at the top of the file, supress the warning for the whole file; e.g.:
- ```go
- package mypackage
-
- // ginkgo-linter:ignore-len-assert-warning
-
- import (
- . "github.com/onsi/ginkgo/v2"
- . "github.com/onsi/gomega"
- )
-
- var _ = Describe("my test", func() {
- It("should do something", func() {
- Expect(len("abc")).Should(Equal(3)) // nothing in this file will trigger the warning
- })
- })
- ```
-
-2. If the comment is before a wrong length check expression, the warning is suppressed for this expression only; for example:
- ```golang
- It("should test something", func() {
- // ginkgo-linter:ignore-nil-assert-warning
- Expect(x == nil).Should(BeTrue()) // this line will not trigger the warning
- Expect(x == nil).Should(BeTrue()) // this line will trigger the warning
- }
- ```
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/analyzer.go b/vendor/github.com/nunnatsa/ginkgolinter/analyzer.go
deleted file mode 100644
index dbc39aba5..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/analyzer.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package ginkgolinter
-
-import (
- "flag"
- "fmt"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/linter"
- "github.com/nunnatsa/ginkgolinter/types"
- "github.com/nunnatsa/ginkgolinter/version"
-)
-
-// NewAnalyzerWithConfig returns an Analyzer.
-func NewAnalyzerWithConfig(config *types.Config) *analysis.Analyzer {
- theLinter := linter.NewGinkgoLinter(config)
-
- return &analysis.Analyzer{
- Name: "ginkgolinter",
- Doc: fmt.Sprintf(doc, version.Version()),
- Run: theLinter.Run,
- }
-}
-
-// NewAnalyzer returns an Analyzer - the package interface with nogo
-func NewAnalyzer() *analysis.Analyzer {
- config := &types.Config{
- SuppressLen: false,
- SuppressNil: false,
- SuppressErr: false,
- SuppressCompare: false,
- ForbidFocus: false,
- AllowHaveLen0: false,
- ForceExpectTo: false,
- ForceSucceedForFuncs: false,
- }
-
- a := NewAnalyzerWithConfig(config)
-
- var ignored bool
- a.Flags.Init("ginkgolinter", flag.ExitOnError)
- a.Flags.Var(&config.SuppressLen, "suppress-len-assertion", "Suppress warning for wrong length assertions")
- a.Flags.Var(&config.SuppressNil, "suppress-nil-assertion", "Suppress warning for wrong nil assertions")
- a.Flags.Var(&config.SuppressErr, "suppress-err-assertion", "Suppress warning for wrong error assertions")
- a.Flags.Var(&config.SuppressCompare, "suppress-compare-assertion", "Suppress warning for wrong comparison assertions")
- a.Flags.Var(&config.SuppressAsync, "suppress-async-assertion", "Suppress warning for function call in async assertion, like Eventually")
- a.Flags.Var(&config.ValidateAsyncIntervals, "validate-async-intervals", "best effort validation of async intervals (timeout and polling); ignored the suppress-async-assertion flag is true")
- a.Flags.Var(&config.SuppressTypeCompare, "suppress-type-compare-assertion", "Suppress warning for comparing values from different types, like int32 and uint32")
- a.Flags.Var(&config.AllowHaveLen0, "allow-havelen-0", "Do not warn for HaveLen(0); default = false")
- a.Flags.Var(&config.ForceExpectTo, "force-expect-to", "force using `Expect` with `To`, `ToNot` or `NotTo`. reject using `Expect` with `Should` or `ShouldNot`; default = false (not forced)")
- a.Flags.BoolVar(&ignored, "suppress-focus-container", true, "Suppress warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt. Deprecated and ignored: use --forbid-focus-container instead")
- a.Flags.Var(&config.ForbidFocus, "forbid-focus-container", "trigger a warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt; default = false.")
- a.Flags.Var(&config.ForbidSpecPollution, "forbid-spec-pollution", "trigger a warning for variable assignments in ginkgo containers like Describe, Context and When, instead of in BeforeEach(); default = false.")
- a.Flags.Var(&config.ForceSucceedForFuncs, "force-succeed", "force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values")
-
- return a
-}
-
-// Analyzer is the interface to go_vet
-var Analyzer = NewAnalyzer()
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/doc.go b/vendor/github.com/nunnatsa/ginkgolinter/doc.go
deleted file mode 100644
index c07b6a316..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/doc.go
+++ /dev/null
@@ -1,116 +0,0 @@
-package ginkgolinter
-
-const doc = `enforces standards of using ginkgo and gomega
-
-or
- ginkgolinter version
-
-version: %s
-
-currently, the linter searches for following:
-* trigger a warning when using Eventually or Consistently with a function call. This is in order to prevent the case when
- using a function call instead of a function. Function call returns a value only once, and so the original value
- is tested again and again and is never changed. [Bug]
-
-* trigger a warning when comparing a pointer to a value. [Bug]
-
-* trigger a warning for missing assertion method: [Bug]
- Eventually(checkSomething)
-
-* trigger a warning when a ginkgo focus container (FDescribe, FContext, FWhen or FIt) is found. [Bug]
-
-* validate the MatchError gomega matcher [Bug]
-
-* trigger a warning when using the Equal or the BeIdentical matcher with two different types, as these matchers will
- fail in runtime.
-
-* async timing interval: timeout is shorter than polling interval [Bug]
-For example:
- Eventually(aFunc).WithTimeout(500 * time.Millisecond).WithPolling(10 * time.Second).Should(Succeed())
-This will probably happen when using the old format:
- Eventually(aFunc, 500 * time.Millisecond, 10 * time.Second).Should(Succeed())
-
-* Success matcher validation: [BUG]
- The Success matcher expect that the actual argument will be a single error. In async actual assertions, It also allow
- functions with Gomega object as the function first parameter.
-For example:
- Expect(myInt).To(Succeed())
-or
- Eventually(func() int { return 42 }).Should(Succeed())
-
-* reject variable assignments in ginkgo containers [Bug/Style]:
-For example:
- var _ = Describe("description", func(){
- var x = 10
- })
-
-Should use BeforeEach instead; e.g.
- var _ = Describe("description", func(){
- var x int
- BeforeEach(func(){
- x = 10
- })
- })
-
-* wrong length assertions. We want to assert the item rather than its length. [Style]
-For example:
- Expect(len(x)).Should(Equal(1))
-This should be replaced with:
- Expect(x)).Should(HavelLen(1))
-
-* wrong cap assertions. We want to assert the item rather than its cap. [Style]
-For example:
- Expect(cap(x)).Should(Equal(1))
-This should be replaced with:
- Expect(x)).Should(HavelCap(1))
-
-* wrong nil assertions. We want to assert the item rather than a comparison result. [Style]
-For example:
- Expect(x == nil).Should(BeTrue())
-This should be replaced with:
- Expect(x).Should(BeNil())
-
-* wrong error assertions. For example: [Style]
- Expect(err == nil).Should(BeTrue())
-This should be replaced with:
- Expect(err).ShouldNot(HaveOccurred())
-
-* wrong boolean comparison, for example: [Style]
- Expect(x == 8).Should(BeTrue())
-This should be replaced with:
- Expect(x).Should(BeEqual(8))
-
-* replaces Equal(true/false) with BeTrue()/BeFalse() [Style]
-
-* replaces HaveLen(0) with BeEmpty() [Style]
-
-* replaces Expect(...).Should(...) with Expect(...).To() [Style]
-
-* async timing interval: multiple timeout or polling interval [Style]
-For example:
- Eventually(context.Background(), func() bool { return true }, time.Second*10).WithTimeout(time.Second * 10).WithPolling(time.Millisecond * 500).Should(BeTrue())
- Eventually(context.Background(), func() bool { return true }, time.Second*10).Within(time.Second * 10).WithPolling(time.Millisecond * 500).Should(BeTrue())
- Eventually(func() bool { return true }, time.Second*10, 500*time.Millisecond).WithPolling(time.Millisecond * 500).Should(BeTrue())
- Eventually(func() bool { return true }, time.Second*10, 500*time.Millisecond).ProbeEvery(time.Millisecond * 500).Should(BeTrue())
-
-* async timing interval: non-time.Duration intervals [Style]
-gomega supports a few formats for timeout and polling intervals, when using the old format (the last two parameters of Eventually and Constantly):
- * time.Duration
- * any kind of numeric value, as number of seconds
- * duration string like "12s"
-The linter triggers a warning for any duration value that is not of the time.Duration type, assuming that this is
-the desired type, given the type of the argument of the newer "WithTimeout", "WithPolling", "Within" and "ProbeEvery"
-methods.
-For example:
- Eventually(context.Background(), func() bool { return true }, "1s").Should(BeTrue())
- Eventually(context.Background(), func() bool { return true }, time.Second*60, 15).Should(BeTrue())
-
-* Success <=> Eventually usage [Style]
- enforce that the Succeed() matcher will be used for error functions, and the HaveOccurred() matcher will
- be used for error values.
-
-For example:
- Expect(err).ToNot(Succeed())
-or
- Expect(funcRetError().ToNot(HaveOccurred())
-`
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actual.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actual.go
deleted file mode 100644
index c289b24de..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actual.go
+++ /dev/null
@@ -1,118 +0,0 @@
-package actual
-
-import (
- "go/ast"
- gotypes "go/types"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/gomegahandler"
- "github.com/nunnatsa/ginkgolinter/internal/gomegainfo"
-)
-
-type Actual struct {
- Orig *ast.CallExpr
- Clone *ast.CallExpr
- Arg ArgPayload
- argType gotypes.Type
- isTuple bool
- isAsync bool
- asyncArg *AsyncArg
- actualOffset int
-}
-
-func New(origExpr, cloneExpr *ast.CallExpr, orig *ast.CallExpr, clone *ast.CallExpr, pass *analysis.Pass, handler gomegahandler.Handler, timePkg string, errMethodExists bool) (*Actual, bool) {
- funcName, ok := handler.GetActualFuncName(orig)
- if !ok {
- return nil, false
- }
-
- arg, actualOffset := getActualArgPayload(orig, clone, pass, funcName, errMethodExists)
- if arg == nil {
- return nil, false
- }
-
- argType := pass.TypesInfo.TypeOf(orig.Args[actualOffset])
- isTuple := false
-
- if tpl, ok := argType.(*gotypes.Tuple); ok {
- if tpl.Len() > 0 {
- argType = tpl.At(0).Type()
- } else {
- argType = nil
- }
-
- isTuple = tpl.Len() > 1
- }
-
- isAsyncExpr := gomegainfo.IsAsyncActualMethod(funcName)
-
- var asyncArg *AsyncArg
- if isAsyncExpr {
- asyncArg = newAsyncArg(origExpr, cloneExpr, orig, clone, argType, pass, actualOffset, timePkg)
- }
-
- return &Actual{
- Orig: orig,
- Clone: clone,
- Arg: arg,
- argType: argType,
- isTuple: isTuple,
- isAsync: isAsyncExpr,
- asyncArg: asyncArg,
- actualOffset: actualOffset,
- }, true
-}
-
-func (a *Actual) ReplaceActual(newArgs ast.Expr) {
- a.Clone.Args[a.actualOffset] = newArgs
-}
-
-func (a *Actual) ReplaceActualWithItsFirstArg() {
- firstArgOfArg := a.Clone.Args[a.actualOffset].(*ast.CallExpr).Args[0]
- a.ReplaceActual(firstArgOfArg)
-}
-
-func (a *Actual) IsAsync() bool {
- return a.isAsync
-}
-
-func (a *Actual) IsTuple() bool {
- return a.isTuple
-}
-
-func (a *Actual) ArgGOType() gotypes.Type {
- return a.argType
-}
-
-func (a *Actual) GetAsyncArg() *AsyncArg {
- return a.asyncArg
-}
-
-func (a *Actual) AppendWithArgsMethod() {
- if a.asyncArg.fun != nil {
- if len(a.asyncArg.fun.Args) > 0 {
- actualOrigFunc := a.Clone.Fun
- actualOrigArgs := a.Clone.Args
-
- actualOrigArgs[a.actualOffset] = a.asyncArg.fun.Fun
- call := &ast.SelectorExpr{
- Sel: ast.NewIdent("WithArguments"),
- X: &ast.CallExpr{
- Fun: actualOrigFunc,
- Args: actualOrigArgs,
- },
- }
-
- a.Clone.Fun = call
- a.Clone.Args = a.asyncArg.fun.Args
- a.Clone = a.Clone.Fun.(*ast.SelectorExpr).X.(*ast.CallExpr)
- } else {
- a.Clone.Args[a.actualOffset] = a.asyncArg.fun.Fun
- }
- }
-}
-
-func (a *Actual) GetActualArg() ast.Expr {
- return a.Clone.Args[a.actualOffset]
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actualarg.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actualarg.go
deleted file mode 100644
index 541a22330..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/actualarg.go
+++ /dev/null
@@ -1,246 +0,0 @@
-package actual
-
-import (
- "go/ast"
- "go/token"
- gotypes "go/types"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression/value"
- "github.com/nunnatsa/ginkgolinter/internal/gomegainfo"
- "github.com/nunnatsa/ginkgolinter/internal/reverseassertion"
-)
-
-type ArgType uint64
-
-const (
- UnknownActualArgType ArgType = 1 << iota
- ErrActualArgType
- LenFuncActualArgType
- CapFuncActualArgType
- ComparisonActualArgType
- LenComparisonActualArgType
- CapComparisonActualArgType
- NilComparisonActualArgType
- BinaryComparisonActualArgType
- FuncSigArgType
- ErrFuncActualArgType
- GomegaParamArgType
- MultiRetsArgType
- ErrorMethodArgType
-
- ErrorTypeArgType
-
- EqualZero
- GreaterThanZero
-)
-
-func (a ArgType) Is(val ArgType) bool {
- return a&val != 0
-}
-
-func getActualArgPayload(origActualExpr, actualExprClone *ast.CallExpr, pass *analysis.Pass, actualMethodName string, errMethodExists bool) (ArgPayload, int) {
- origArgExpr, argExprClone, actualOffset, isGomegaExpr := getActualArg(origActualExpr, actualExprClone, actualMethodName, pass)
- if !isGomegaExpr {
- return nil, 0
- }
-
- var arg ArgPayload
-
- if errMethodExists {
- arg = &ErrorMethodPayload{}
- } else if value.IsExprError(pass, origArgExpr) {
- arg = newErrPayload(origArgExpr, argExprClone, pass)
- } else {
- switch expr := origArgExpr.(type) {
- case *ast.CallExpr:
- arg = newFuncCallArgPayload(expr, argExprClone.(*ast.CallExpr))
-
- case *ast.BinaryExpr:
- arg = parseBinaryExpr(expr, argExprClone.(*ast.BinaryExpr), pass)
- }
-
- }
-
- if arg != nil {
- return arg, actualOffset
- }
-
- t := pass.TypesInfo.TypeOf(origArgExpr)
- if sig, ok := t.(*gotypes.Signature); ok {
- arg = getAsyncFuncArg(sig)
- if arg != nil {
- return arg, actualOffset
- }
- }
-
- return newRegularArgPayload(origArgExpr, argExprClone, pass), actualOffset
-}
-
-func getActualArg(origActualExpr *ast.CallExpr, actualExprClone *ast.CallExpr, actualMethodName string, pass *analysis.Pass) (ast.Expr, ast.Expr, int, bool) {
- var (
- origArgExpr ast.Expr
- argExprClone ast.Expr
- )
-
- funcOffset := gomegainfo.ActualArgOffset(actualMethodName)
- if funcOffset < 0 {
- return nil, nil, 0, false
- }
-
- if len(origActualExpr.Args) <= funcOffset {
- return nil, nil, 0, false
- }
-
- origArgExpr = origActualExpr.Args[funcOffset]
- argExprClone = actualExprClone.Args[funcOffset]
-
- if gomegainfo.IsAsyncActualMethod(actualMethodName) {
- if pass.TypesInfo.TypeOf(origArgExpr).String() == "context.Context" {
- funcOffset++
- if len(origActualExpr.Args) <= funcOffset {
- return nil, nil, 0, false
- }
-
- origArgExpr = origActualExpr.Args[funcOffset]
- argExprClone = actualExprClone.Args[funcOffset]
- }
- }
-
- return origArgExpr, argExprClone, funcOffset, true
-}
-
-type ArgPayload interface {
- ArgType() ArgType
-}
-
-type RegularArgPayload struct {
- value.Value
-}
-
-func newRegularArgPayload(orig, clone ast.Expr, pass *analysis.Pass) *RegularArgPayload {
- return &RegularArgPayload{
- Value: value.New(orig, clone, pass),
- }
-}
-
-func (*RegularArgPayload) ArgType() ArgType {
- return UnknownActualArgType
-}
-
-type FuncCallArgPayload struct {
- argType ArgType
-
- origFunc *ast.CallExpr
- cloneFunc *ast.CallExpr
-
- origVal ast.Expr
- cloneVal ast.Expr
-}
-
-func newFuncCallArgPayload(orig, clone *ast.CallExpr) ArgPayload {
- funcName, ok := builtinFuncName(orig)
- if !ok {
- return nil
- }
-
- if len(orig.Args) != 1 {
- return nil
- }
-
- var argType ArgType
- switch funcName {
- case "len":
- argType = LenFuncActualArgType
- case "cap":
- argType = CapFuncActualArgType
- default:
- return nil
- }
-
- return &FuncCallArgPayload{
- argType: argType,
- origFunc: orig,
- cloneFunc: clone,
- origVal: orig.Args[0],
- cloneVal: clone.Args[0],
- }
-}
-
-func (f *FuncCallArgPayload) ArgType() ArgType {
- return f.argType
-}
-
-type ErrPayload struct {
- value.Valuer
-}
-
-func newErrPayload(orig, clone ast.Expr, pass *analysis.Pass) *ErrPayload {
- return &ErrPayload{
- Valuer: value.GetValuer(orig, clone, pass),
- }
-}
-
-func (*ErrPayload) ArgType() ArgType {
- return ErrActualArgType | ErrorTypeArgType
-}
-
-type ErrorMethodPayload struct{}
-
-func (ErrorMethodPayload) ArgType() ArgType {
- return ErrorMethodArgType | ErrorTypeArgType
-}
-
-func parseBinaryExpr(origActualExpr, argExprClone *ast.BinaryExpr, pass *analysis.Pass) ArgPayload {
- left, right, op := origActualExpr.X, origActualExpr.Y, origActualExpr.Op
- replace := false
- switch realFirst := left.(type) {
- case *ast.Ident: // check if const
- info, ok := pass.TypesInfo.Types[realFirst]
- if ok {
- if value.Is[*gotypes.Basic](info.Type) && (info.Value != nil || info.IsNil()) {
- replace = true
- }
- }
-
- case *ast.BasicLit:
- replace = true
- }
-
- if replace {
- left, right = right, left
- }
-
- switch op {
- case token.EQL:
- case token.NEQ:
- case token.GTR, token.GEQ, token.LSS, token.LEQ:
- if replace {
- op = reverseassertion.ChangeCompareOperator(op)
- }
- default:
- return nil
- }
-
- leftClone, rightClone := argExprClone.X, argExprClone.Y
- if replace {
- leftClone, rightClone = rightClone, leftClone
- }
-
- leftVal := value.GetValuer(left, leftClone, pass)
- rightVal := value.GetValuer(right, rightClone, pass)
-
- if value.IsNil(right, pass) {
- return newNilComparisonPayload(leftVal, rightVal, op)
- }
-
- leftVal.IsFunc()
- if firstFunc, ok := left.(*ast.CallExpr); ok {
- if payload, ok := newFuncComparisonPayload(firstFunc, leftClone.(*ast.CallExpr), right, rightClone, op, pass); ok {
- return payload
- }
- }
-
- return newComparisonArgPayload(leftVal, rightVal, op)
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/asyncactual.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/asyncactual.go
deleted file mode 100644
index 7c5df2a34..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/asyncactual.go
+++ /dev/null
@@ -1,123 +0,0 @@
-package actual
-
-import (
- "go/ast"
- gotypes "go/types"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/intervals"
-)
-
-type AsyncArg struct {
- valid bool
- fun *ast.CallExpr
-
- timeoutInterval intervals.DurationValue
- pollingInterval intervals.DurationValue
- tooManyTimeouts bool
- tooManyPolling bool
-}
-
-func newAsyncArg(origExpr, cloneExpr, orig, clone *ast.CallExpr, argType gotypes.Type, pass *analysis.Pass, actualOffset int, timePkg string) *AsyncArg {
- var (
- fun *ast.CallExpr
- valid = true
- timeout intervals.DurationValue
- polling intervals.DurationValue
- )
-
- if _, isActualFuncCall := orig.Args[actualOffset].(*ast.CallExpr); isActualFuncCall {
- fun = clone.Args[actualOffset].(*ast.CallExpr)
- valid = isValidAsyncValueType(argType)
- }
-
- timeoutOffset := actualOffset + 1
- //var err error
- tooManyTimeouts := false
- tooManyPolling := false
-
- if len(orig.Args) > timeoutOffset {
- timeout = intervals.GetDuration(pass, timeoutOffset, orig.Args[timeoutOffset], clone.Args[timeoutOffset], timePkg)
- pollingOffset := actualOffset + 2
- if len(orig.Args) > pollingOffset {
- polling = intervals.GetDuration(pass, pollingOffset, orig.Args[pollingOffset], clone.Args[pollingOffset], timePkg)
- }
- }
- selOrig := origExpr.Fun.(*ast.SelectorExpr)
- selClone := cloneExpr.Fun.(*ast.SelectorExpr)
-
- for {
- callOrig, ok := selOrig.X.(*ast.CallExpr)
- if !ok {
- break
- }
- callClone := selClone.X.(*ast.CallExpr)
-
- funOrig, ok := callOrig.Fun.(*ast.SelectorExpr)
- if !ok {
- break
- }
- funClone := callClone.Fun.(*ast.SelectorExpr)
-
- switch funOrig.Sel.Name {
- case "WithTimeout", "Within":
- if timeout != nil {
- tooManyTimeouts = true
- } else if len(callOrig.Args) == 1 {
- timeout = intervals.GetDurationFromValue(pass, callOrig.Args[0], callClone.Args[0])
- }
-
- case "WithPolling", "ProbeEvery":
- if polling != nil {
- tooManyPolling = true
- } else if len(callOrig.Args) == 1 {
- polling = intervals.GetDurationFromValue(pass, callOrig.Args[0], callClone.Args[0])
- }
- }
-
- selOrig = funOrig
- selClone = funClone
- }
-
- return &AsyncArg{
- valid: valid,
- fun: fun,
- timeoutInterval: timeout,
- pollingInterval: polling,
- tooManyTimeouts: tooManyTimeouts,
- tooManyPolling: tooManyPolling,
- }
-}
-
-func (a *AsyncArg) IsValid() bool {
- return a.valid
-}
-
-func (a *AsyncArg) Timeout() intervals.DurationValue {
- return a.timeoutInterval
-}
-
-func (a *AsyncArg) Polling() intervals.DurationValue {
- return a.pollingInterval
-}
-
-func (a *AsyncArg) TooManyTimeouts() bool {
- return a.tooManyTimeouts
-}
-
-func (a *AsyncArg) TooManyPolling() bool {
- return a.tooManyPolling
-}
-
-func isValidAsyncValueType(t gotypes.Type) bool {
- switch t.(type) {
- // allow functions that return function or channel.
- case *gotypes.Signature, *gotypes.Chan, *gotypes.Pointer:
- return true
- case *gotypes.Named:
- return isValidAsyncValueType(t.Underlying())
- }
-
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/asyncfuncarg.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/asyncfuncarg.go
deleted file mode 100644
index c777cd4a7..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/asyncfuncarg.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package actual
-
-import (
- gotypes "go/types"
-
- "github.com/nunnatsa/ginkgolinter/internal/gomegainfo"
- "github.com/nunnatsa/ginkgolinter/internal/interfaces"
-)
-
-func getAsyncFuncArg(sig *gotypes.Signature) ArgPayload {
- argType := FuncSigArgType
- if sig.Results().Len() == 1 {
- if interfaces.ImplementsError(sig.Results().At(0).Type().Underlying()) {
- argType |= ErrFuncActualArgType | ErrorTypeArgType
- }
- }
-
- if sig.Params().Len() > 0 {
- arg := sig.Params().At(0).Type()
- if gomegainfo.IsGomegaType(arg) && sig.Results().Len() == 0 {
- argType |= FuncSigArgType | GomegaParamArgType
- }
- }
-
- if sig.Results().Len() > 1 {
- argType |= FuncSigArgType | MultiRetsArgType
- }
-
- return &FuncSigArgPayload{argType: argType}
-}
-
-type FuncSigArgPayload struct {
- argType ArgType
-}
-
-func (f FuncSigArgPayload) ArgType() ArgType {
- return f.argType
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/comparisonAsserion.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/comparisonAsserion.go
deleted file mode 100644
index 2b16402db..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/actual/comparisonAsserion.go
+++ /dev/null
@@ -1,260 +0,0 @@
-package actual
-
-import (
- "go/ast"
- "go/constant"
- "go/token"
- gotypes "go/types"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression/value"
-)
-
-type ComparisonActualPayload interface {
- GetOp() token.Token
- GetLeft() value.Valuer
- GetRight() value.Valuer
-}
-
-type FuncComparisonPayload struct {
- op token.Token
- argType ArgType
- val value.Valuer
- left value.Valuer
- arg ast.Expr
-}
-
-func newFuncComparisonPayload(origLeft, leftClone *ast.CallExpr, origRight, rightClone ast.Expr, op token.Token, pass *analysis.Pass) (*FuncComparisonPayload, bool) {
-
- funcName, ok := builtinFuncName(origLeft)
- if !ok {
- return nil, false
- }
-
- if len(origLeft.Args) != 1 {
- return nil, false
- }
-
- left := value.GetValuer(origLeft, leftClone, pass)
- val := value.GetValuer(origRight, rightClone, pass)
-
- argType := ComparisonActualArgType
- switch funcName {
- case "len":
- argType |= LenComparisonActualArgType
-
- if val.IsValueNumeric() {
- if val.IsValueZero() {
- switch op {
- case token.EQL:
- argType |= EqualZero
-
- case token.NEQ, token.GTR:
- argType |= GreaterThanZero
- }
- } else if val.GetValue().String() == "1" && op == token.GEQ {
- argType |= GreaterThanZero
- }
- }
-
- if !argType.Is(GreaterThanZero) && op != token.EQL && op != token.NEQ {
- return nil, false
- }
-
- case "cap":
- if op != token.EQL && op != token.NEQ {
- return nil, false
- }
- argType |= CapComparisonActualArgType
-
- default:
- return nil, false
- }
-
- return &FuncComparisonPayload{
- op: op,
- argType: argType,
- val: val,
- left: left,
- arg: leftClone.Args[0],
- }, true
-}
-
-func (f *FuncComparisonPayload) GetLeft() value.Valuer {
- return f.left
-}
-
-func (f *FuncComparisonPayload) GetRight() value.Valuer {
- return f.val
-}
-
-func (f *FuncComparisonPayload) ArgType() ArgType {
- return f.argType
-}
-
-func (f *FuncComparisonPayload) GetOp() token.Token {
- return f.op
-}
-
-func (f *FuncComparisonPayload) GetValue() constant.Value {
- return f.val.GetValue()
-}
-
-func (f *FuncComparisonPayload) GetType() gotypes.Type {
- return f.val.GetType()
-}
-
-func (f *FuncComparisonPayload) GetValueExpr() ast.Expr {
- return f.val.GetValueExpr()
-}
-
-func (f *FuncComparisonPayload) IsError() bool {
- return f.val.IsError()
-}
-
-func (f *FuncComparisonPayload) IsValueZero() bool {
- return f.val.IsValueZero()
-}
-
-func (f *FuncComparisonPayload) IsFunc() bool {
- return true
-}
-
-func (f *FuncComparisonPayload) IsValueNumeric() bool {
- return f.val.IsValueNumeric()
-}
-
-func (f *FuncComparisonPayload) IsValueInt() bool {
- return f.val.IsValueInt()
-}
-
-func (f *FuncComparisonPayload) IsInterface() bool {
- return f.val.IsInterface()
-}
-
-func (f *FuncComparisonPayload) IsPointer() bool {
- return f.val.IsPointer()
-}
-
-func (f *FuncComparisonPayload) GetFuncArg() ast.Expr {
- return f.arg
-}
-
-type ComparisonArgPayload struct {
- left value.Valuer
- right value.Valuer
- op token.Token
-}
-
-func newComparisonArgPayload(left, right value.Valuer, op token.Token) *ComparisonArgPayload {
- return &ComparisonArgPayload{
- left: left,
- right: right,
- op: op,
- }
-}
-
-func (*ComparisonArgPayload) ArgType() ArgType {
- return BinaryComparisonActualArgType | ComparisonActualArgType
-}
-
-func (c *ComparisonArgPayload) GetOp() token.Token {
- return c.op
-}
-
-func (c *ComparisonArgPayload) GetLeft() value.Valuer {
- return c.left
-}
-
-func (c *ComparisonArgPayload) GetRight() value.Valuer {
- return c.right
-}
-
-type NilComparisonPayload struct {
- val value.Valuer
- right value.Valuer
- op token.Token
-}
-
-func newNilComparisonPayload(val, right value.Valuer, op token.Token) *NilComparisonPayload {
- return &NilComparisonPayload{
- val: val,
- right: right,
- op: op,
- }
-}
-
-func (*NilComparisonPayload) ArgType() ArgType {
- return NilComparisonActualArgType
-}
-
-func (n *NilComparisonPayload) GetLeft() value.Valuer {
- return n.val
-}
-
-func (n *NilComparisonPayload) GetRight() value.Valuer {
- return n.right
-}
-
-func (n *NilComparisonPayload) GetType() gotypes.Type {
- return n.val.GetType()
-}
-
-func (n *NilComparisonPayload) GetValue() constant.Value {
- return n.val.GetValue()
-}
-
-func (n *NilComparisonPayload) GetValueExpr() ast.Expr {
- return n.val.GetValueExpr()
-}
-
-func (n *NilComparisonPayload) IsValueInt() bool {
- return n.val.IsValueInt()
-}
-
-func (n *NilComparisonPayload) IsError() bool {
- return n.val.IsError()
-}
-
-func (n *NilComparisonPayload) IsValueNumeric() bool {
- return n.val.IsValueNumeric()
-}
-
-func (n *NilComparisonPayload) IsFunc() bool {
- return n.val.IsFunc()
-}
-
-func (n *NilComparisonPayload) IsValueZero() bool {
- return n.val.IsValueZero()
-}
-
-func (n *NilComparisonPayload) IsInterface() bool {
- return n.val.IsInterface()
-}
-
-func (n *NilComparisonPayload) IsPointer() bool {
- return n.val.IsPointer()
-}
-
-func (n *NilComparisonPayload) GetOp() token.Token {
- return n.op
-}
-
-func builtinFuncName(callExpr *ast.CallExpr) (string, bool) {
- argFunc, ok := callExpr.Fun.(*ast.Ident)
- if !ok {
- return "", false
- }
-
- if len(callExpr.Args) != 1 {
- return "", false
- }
-
- switch name := argFunc.Name; name {
- case "len", "cap", "min", "max":
- return name, true
- default:
- return "", false
- }
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/expression.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/expression.go
deleted file mode 100644
index c2aa702b1..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/expression.go
+++ /dev/null
@@ -1,317 +0,0 @@
-package expression
-
-import (
- "fmt"
- "go/ast"
- "go/token"
- gotypes "go/types"
-
- "github.com/nunnatsa/ginkgolinter/internal/formatter"
-
- "github.com/go-toolsmith/astcopy"
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/expression/value"
- "github.com/nunnatsa/ginkgolinter/internal/gomegahandler"
- "github.com/nunnatsa/ginkgolinter/internal/gomegainfo"
- "github.com/nunnatsa/ginkgolinter/internal/reverseassertion"
-)
-
-type GomegaExpression struct {
- orig *ast.CallExpr
- clone *ast.CallExpr
-
- assertionFuncName string
- origAssertionFuncName string
- actualFuncName string
-
- isAsync bool
-
- actual *actual.Actual
- matcher *matcher.Matcher
-
- handler gomegahandler.Handler
-}
-
-func New(origExpr *ast.CallExpr, pass *analysis.Pass, handler gomegahandler.Handler, timePkg string) (*GomegaExpression, bool) {
- actualMethodName, ok := handler.GetActualFuncName(origExpr)
- if !ok || !gomegainfo.IsActualMethod(actualMethodName) {
- return nil, false
- }
-
- origSel, ok := origExpr.Fun.(*ast.SelectorExpr)
- if !ok || !gomegainfo.IsAssertionFunc(origSel.Sel.Name) {
- return &GomegaExpression{
- orig: origExpr,
- actualFuncName: actualMethodName,
- }, true
- }
-
- exprClone := astcopy.CallExpr(origExpr)
- selClone := exprClone.Fun.(*ast.SelectorExpr)
-
- errMethodExists := false
-
- origActual := handler.GetActualExpr(origSel, &errMethodExists)
- if origActual == nil {
- return nil, false
- }
-
- actualClone := handler.GetActualExprClone(origSel, selClone)
- if actualClone == nil {
- return nil, false
- }
-
- actl, ok := actual.New(origExpr, exprClone, origActual, actualClone, pass, handler, timePkg, errMethodExists)
- if !ok {
- return nil, false
- }
-
- origMatcher, ok := origExpr.Args[0].(*ast.CallExpr)
- if !ok {
- return nil, false
- }
-
- matcherClone := exprClone.Args[0].(*ast.CallExpr)
-
- mtchr, ok := matcher.New(origMatcher, matcherClone, pass, handler)
- if !ok {
- return nil, false
- }
-
- exprClone.Args[0] = mtchr.Clone
-
- gexp := &GomegaExpression{
- orig: origExpr,
- clone: exprClone,
-
- assertionFuncName: origSel.Sel.Name,
- origAssertionFuncName: origSel.Sel.Name,
- actualFuncName: actualMethodName,
-
- isAsync: actl.IsAsync(),
-
- actual: actl,
- matcher: mtchr,
-
- handler: handler,
- }
-
- if mtchr.ShouldReverseLogic() {
- gexp.ReverseAssertionFuncLogic()
- }
-
- return gexp, true
-}
-
-func (e *GomegaExpression) IsMissingAssertion() bool {
- return e.matcher == nil
-}
-
-func (e *GomegaExpression) GetActualFuncName() string {
- if e == nil {
- return ""
- }
- return e.actualFuncName
-}
-
-func (e *GomegaExpression) GetAssertFuncName() string {
- if e == nil {
- return ""
- }
- return e.assertionFuncName
-}
-
-func (e *GomegaExpression) GetOrigAssertFuncName() string {
- if e == nil {
- return ""
- }
- return e.origAssertionFuncName
-}
-
-func (e *GomegaExpression) IsAsync() bool {
- return e.isAsync
-}
-
-func (e *GomegaExpression) ReverseAssertionFuncLogic() {
- assertionFunc := e.clone.Fun.(*ast.SelectorExpr).Sel
- newName := reverseassertion.ChangeAssertionLogic(assertionFunc.Name)
- assertionFunc.Name = newName
- e.assertionFuncName = newName
-}
-
-func (e *GomegaExpression) ReplaceAssertionMethod(name string) {
- e.clone.Fun.(*ast.SelectorExpr).Sel.Name = name
-}
-
-func (e *GomegaExpression) ReplaceMatcherFuncName(name string) {
- e.matcher.ReplaceMatcherFuncName(name)
-}
-
-func (e *GomegaExpression) ReplaceMatcherArgs(newArgs []ast.Expr) {
- e.matcher.ReplaceMatcherArgs(newArgs)
-}
-
-func (e *GomegaExpression) RemoveMatcherArgs() {
- e.matcher.ReplaceMatcherArgs(nil)
-}
-
-func (e *GomegaExpression) ReplaceActual(newArg ast.Expr) {
- e.actual.ReplaceActual(newArg)
-}
-
-func (e *GomegaExpression) ReplaceActualWithItsFirstArg() {
- e.actual.ReplaceActualWithItsFirstArg()
-}
-
-func (e *GomegaExpression) replaceMathcerFuncNoArgs(name string) {
- e.matcher.ReplaceMatcherFuncName(name)
- e.RemoveMatcherArgs()
-}
-
-func (e *GomegaExpression) SetMatcherBeZero() {
- e.replaceMathcerFuncNoArgs("BeZero")
-}
-
-func (e *GomegaExpression) SetMatcherBeEmpty() {
- e.replaceMathcerFuncNoArgs("BeEmpty")
-}
-
-func (e *GomegaExpression) SetLenNumericMatcher() {
- if m, ok := e.matcher.GetMatcherInfo().(value.Valuer); ok && m.IsValueZero() {
- e.SetMatcherBeEmpty()
- } else {
- e.ReplaceMatcherFuncName("HaveLen")
- e.ReplaceMatcherArgs([]ast.Expr{m.GetValueExpr()})
- }
-}
-
-func (e *GomegaExpression) SetLenNumericActual() {
- if m, ok := e.matcher.GetMatcherInfo().(value.Valuer); ok && m.IsValueZero() {
- e.SetMatcherBeEmpty()
- } else {
- e.ReplaceMatcherFuncName("HaveLen")
- e.ReplaceMatcherArgs([]ast.Expr{m.GetValueExpr()})
- }
-}
-
-func (e *GomegaExpression) SetMatcherLen(arg ast.Expr) {
- e.ReplaceMatcherFuncName("HaveLen")
- e.ReplaceMatcherArgs([]ast.Expr{arg})
-}
-
-func (e *GomegaExpression) SetMatcherCap(arg ast.Expr) {
- e.ReplaceMatcherFuncName("HaveCap")
- e.ReplaceMatcherArgs([]ast.Expr{arg})
-}
-
-func (e *GomegaExpression) SetMatcherCapZero() {
- e.ReplaceMatcherFuncName("HaveCap")
- e.ReplaceMatcherArgs([]ast.Expr{&ast.BasicLit{Kind: token.INT, Value: "0"}})
-}
-
-func (e *GomegaExpression) SetMatcherSucceed() {
- e.replaceMathcerFuncNoArgs("Succeed")
-}
-
-func (e *GomegaExpression) SetMatcherHaveOccurred() {
- e.replaceMathcerFuncNoArgs("HaveOccurred")
-}
-
-func (e *GomegaExpression) SetMatcherBeNil() {
- e.replaceMathcerFuncNoArgs("BeNil")
-}
-
-func (e *GomegaExpression) SetMatcherBeTrue() {
- e.replaceMathcerFuncNoArgs("BeTrue")
-}
-
-func (e *GomegaExpression) SetMatcherBeFalse() {
- e.replaceMathcerFuncNoArgs("BeFalse")
-}
-
-func (e *GomegaExpression) SetMatcherHaveValue() {
- newMatcherExp := e.handler.GetNewWrapperMatcher("HaveValue", e.matcher.Clone)
- e.clone.Args[0] = newMatcherExp
- e.matcher.Clone = newMatcherExp
-}
-
-func (e *GomegaExpression) SetMatcherEqual(arg ast.Expr) {
- e.ReplaceMatcherFuncName("Equal")
- e.ReplaceMatcherArgs([]ast.Expr{arg})
-}
-
-func (e *GomegaExpression) SetMatcherBeIdenticalTo(arg ast.Expr) {
- e.ReplaceMatcherFuncName("BeIdenticalTo")
- e.ReplaceMatcherArgs([]ast.Expr{arg})
-}
-
-func (e *GomegaExpression) SetMatcherBeNumerically(op token.Token, arg ast.Expr) {
- e.ReplaceMatcherFuncName("BeNumerically")
- e.ReplaceMatcherArgs([]ast.Expr{
- &ast.BasicLit{Kind: token.STRING, Value: fmt.Sprintf("%q", op.String())},
- arg,
- })
-}
-
-func (e *GomegaExpression) IsNegativeAssertion() bool {
- return reverseassertion.IsNegativeLogic(e.assertionFuncName)
-}
-
-func (e *GomegaExpression) GetClone() *ast.CallExpr {
- return e.clone
-}
-
-// Actual proxies:
-
-func (e *GomegaExpression) GetActualClone() *ast.CallExpr {
- return e.actual.Clone
-}
-
-func (e *GomegaExpression) AppendWithArgsToActual() {
- e.actual.AppendWithArgsMethod()
-}
-
-func (e *GomegaExpression) GetAsyncActualArg() *actual.AsyncArg {
- return e.actual.GetAsyncArg()
-}
-
-func (e *GomegaExpression) GetActualArg() actual.ArgPayload {
- return e.actual.Arg
-}
-
-func (e *GomegaExpression) GetActualArgExpr() ast.Expr {
- return e.actual.GetActualArg()
-}
-
-func (e *GomegaExpression) GetActualArgGOType() gotypes.Type {
- return e.actual.ArgGOType()
-}
-
-func (e *GomegaExpression) ActualArgTypeIs(other actual.ArgType) bool {
- return e.actual.Arg.ArgType().Is(other)
-}
-
-func (e *GomegaExpression) IsActualTuple() bool {
- return e.actual.IsTuple()
-}
-
-// Matcher proxies
-
-func (e *GomegaExpression) GetMatcher() *matcher.Matcher {
- return e.matcher
-}
-
-func (e *GomegaExpression) GetMatcherInfo() matcher.Info {
- return e.matcher.GetMatcherInfo()
-}
-
-func (e *GomegaExpression) MatcherTypeIs(other matcher.Type) bool {
- return e.matcher.GetMatcherInfo().Type().Is(other)
-}
-
-func (e *GomegaExpression) FormatOrig(frm *formatter.GoFmtFormatter) string {
- return frm.Format(e.orig)
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/bematchers.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/bematchers.go
deleted file mode 100644
index 24272535d..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/bematchers.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package matcher
-
-import "github.com/nunnatsa/ginkgolinter/internal/expression/value"
-
-type BeIdenticalToMatcher struct {
- value.Value
-}
-
-func (BeIdenticalToMatcher) Type() Type {
- return BeIdenticalToMatcherType
-}
-
-func (BeIdenticalToMatcher) MatcherName() string {
- return beIdenticalTo
-}
-
-type BeEquivalentToMatcher struct {
- value.Value
-}
-
-func (BeEquivalentToMatcher) Type() Type {
- return BeEquivalentToMatcherType
-}
-
-func (BeEquivalentToMatcher) MatcherName() string {
- return beEquivalentTo
-}
-
-type BeZeroMatcher struct{}
-
-func (BeZeroMatcher) Type() Type {
- return BeZeroMatcherType
-}
-
-func (BeZeroMatcher) MatcherName() string {
- return beZero
-}
-
-type BeEmptyMatcher struct{}
-
-func (BeEmptyMatcher) Type() Type {
- return BeEmptyMatcherType
-}
-
-func (BeEmptyMatcher) MatcherName() string {
- return beEmpty
-}
-
-type BeTrueMatcher struct{}
-
-func (BeTrueMatcher) Type() Type {
- return BeTrueMatcherType | BoolValueTrue
-}
-
-func (BeTrueMatcher) MatcherName() string {
- return beTrue
-}
-
-type BeFalseMatcher struct{}
-
-func (BeFalseMatcher) Type() Type {
- return BeFalseMatcherType | BoolValueFalse
-}
-
-func (BeFalseMatcher) MatcherName() string {
- return beFalse
-}
-
-type BeNilMatcher struct{}
-
-func (BeNilMatcher) Type() Type {
- return BeNilMatcherType
-}
-
-func (BeNilMatcher) MatcherName() string {
- return beNil
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/benumericmatcher.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/benumericmatcher.go
deleted file mode 100644
index 8683f0291..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/benumericmatcher.go
+++ /dev/null
@@ -1,128 +0,0 @@
-package matcher
-
-import (
- "go/ast"
- "go/constant"
- "go/token"
- gotypes "go/types"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression/value"
-)
-
-type BeNumericallyMatcher struct {
- op token.Token
- value value.Valuer
- argType Type
-}
-
-var compareOps = map[string]token.Token{
- `"=="`: token.EQL,
- `"<"`: token.LSS,
- `">"`: token.GTR,
- `"="`: token.ASSIGN,
- `"!="`: token.NEQ,
- `"<="`: token.LEQ,
- `">="`: token.GEQ,
-}
-
-func getCompareOp(opExp ast.Expr) token.Token {
- basic, ok := opExp.(*ast.BasicLit)
- if !ok {
- return token.ILLEGAL
- }
- if basic.Kind != token.STRING {
- return token.ILLEGAL
- }
-
- if tk, ok := compareOps[basic.Value]; ok {
- return tk
- }
-
- return token.ILLEGAL
-}
-
-func newBeNumericallyMatcher(opExp, orig, clone ast.Expr, pass *analysis.Pass) Info {
- op := getCompareOp(opExp)
- if op == token.ILLEGAL {
- return &UnspecifiedMatcher{
- matcherName: beNumerically,
- }
- }
-
- val := value.GetValuer(orig, clone, pass)
- argType := BeNumericallyMatcherType
-
- if val.IsValueNumeric() {
- if v := val.GetValue().String(); v == "0" {
- switch op {
- case token.EQL:
- argType |= EqualZero
-
- case token.NEQ, token.GTR:
- argType |= GreaterThanZero
- }
- } else if v == "1" && op == token.GEQ {
- argType |= GreaterThanZero
- }
- }
-
- return &BeNumericallyMatcher{
- op: op,
- value: val,
- argType: argType,
- }
-}
-
-func (m BeNumericallyMatcher) Type() Type {
- return m.argType
-}
-
-func (BeNumericallyMatcher) MatcherName() string {
- return beNumerically
-}
-
-func (m BeNumericallyMatcher) GetValueExpr() ast.Expr {
- return m.value.GetValueExpr()
-}
-
-func (m BeNumericallyMatcher) GetValue() constant.Value {
- return m.value.GetValue()
-}
-
-func (m BeNumericallyMatcher) GetType() gotypes.Type {
- return m.value.GetType()
-}
-
-func (m BeNumericallyMatcher) GetOp() token.Token {
- return m.op
-}
-
-func (m BeNumericallyMatcher) IsValueZero() bool {
- return m.value.IsValueZero()
-}
-
-func (m BeNumericallyMatcher) IsValueInt() bool {
- return m.value.IsValueInt()
-}
-
-func (m BeNumericallyMatcher) IsValueNumeric() bool {
- return m.value.IsValueNumeric()
-}
-
-func (m BeNumericallyMatcher) IsError() bool {
- return m.value.IsError()
-}
-
-func (m BeNumericallyMatcher) IsFunc() bool {
- return m.value.IsFunc()
-}
-
-func (m BeNumericallyMatcher) IsInterface() bool {
- return m.value.IsInterface()
-}
-
-func (m BeNumericallyMatcher) IsPointer() bool {
- return m.value.IsPointer()
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/equalmatcher.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/equalmatcher.go
deleted file mode 100644
index 8cee8e408..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/equalmatcher.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package matcher
-
-import (
- "go/ast"
- "go/constant"
- gotypes "go/types"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression/value"
-)
-
-func newEqualMatcher(orig, clone ast.Expr, pass *analysis.Pass) Info {
- t := pass.TypesInfo.Types[orig]
-
- if t.Value != nil {
- if t.Value.Kind() == constant.Bool {
- if t.Value.String() == "true" {
- return &EqualTrueMatcher{}
- }
- return &EqualFalseMatcher{}
- }
- }
-
- if value.IsNil(orig, pass) {
- return &EqualNilMatcher{
- gotype: pass.TypesInfo.TypeOf(orig),
- }
- }
-
- val := value.GetValuer(orig, clone, pass)
-
- return &EqualMatcher{
- val: val,
- }
-}
-
-type EqualMatcher struct {
- val value.Valuer
-}
-
-func (EqualMatcher) Type() Type {
- return EqualMatcherType
-}
-
-func (EqualMatcher) MatcherName() string {
- return equal
-}
-
-func (m EqualMatcher) GetValue() constant.Value {
- return m.val.GetValue()
-}
-
-func (m EqualMatcher) GetType() gotypes.Type {
- return m.val.GetType()
-}
-
-func (m EqualMatcher) GetValueExpr() ast.Expr {
- return m.val.GetValueExpr()
-}
-
-func (m EqualMatcher) IsValueZero() bool {
- return m.val.IsValueZero()
-}
-
-func (m EqualMatcher) IsValueInt() bool {
- return m.val.IsValueInt()
-}
-
-func (m EqualMatcher) IsValueNumeric() bool {
- return m.val.IsValueNumeric()
-}
-
-func (m EqualMatcher) IsError() bool {
- return m.val.IsError()
-}
-
-func (m EqualMatcher) IsFunc() bool {
- return m.val.IsFunc()
-}
-
-func (m EqualMatcher) IsInterface() bool {
- return m.val.IsInterface()
-}
-
-func (m EqualMatcher) IsPointer() bool {
- return m.val.IsPointer()
-}
-
-type EqualNilMatcher struct {
- gotype gotypes.Type
-}
-
-func (EqualNilMatcher) Type() Type {
- return EqualNilMatcherType | EqualMatcherType | EqualValueMatcherType
-}
-
-func (EqualNilMatcher) MatcherName() string {
- return equal
-}
-
-func (n EqualNilMatcher) GetType() gotypes.Type {
- return n.gotype
-}
-
-type EqualTrueMatcher struct{}
-
-func (EqualTrueMatcher) Type() Type {
- return EqualMatcherType | EqualBoolValueMatcherType | BoolValueTrue
-}
-
-func (EqualTrueMatcher) MatcherName() string {
- return equal
-}
-
-type EqualFalseMatcher struct{}
-
-func (EqualFalseMatcher) Type() Type {
- return EqualMatcherType | EqualBoolValueMatcherType | BoolValueFalse
-}
-
-func (EqualFalseMatcher) MatcherName() string {
- return equal
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/errormatchers.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/errormatchers.go
deleted file mode 100644
index a493287e0..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/errormatchers.go
+++ /dev/null
@@ -1,199 +0,0 @@
-package matcher
-
-import (
- "go/ast"
- gotypes "go/types"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression/value"
- "github.com/nunnatsa/ginkgolinter/internal/interfaces"
-)
-
-type HaveOccurredMatcher struct{}
-
-func (m *HaveOccurredMatcher) Type() Type {
- return HaveOccurredMatcherType
-}
-func (m *HaveOccurredMatcher) MatcherName() string {
- return haveOccurred
-}
-
-type SucceedMatcher struct{}
-
-func (m *SucceedMatcher) Type() Type {
- return SucceedMatcherType
-}
-func (m *SucceedMatcher) MatcherName() string {
- return succeed
-}
-
-type MatchErrorMatcher interface {
- Info
- AllowedNumArgs() int
- NumArgs() int
-}
-
-type InvalidMatchErrorMatcher struct {
- firstAgr ast.Expr
- numArgs int
-}
-
-func (m *InvalidMatchErrorMatcher) Type() Type {
- return MatchErrorMatcherType
-}
-
-func (m *InvalidMatchErrorMatcher) MatcherName() string {
- return matchError
-}
-
-func (m *InvalidMatchErrorMatcher) AllowedNumArgs() int {
- return 1
-}
-
-func (m *InvalidMatchErrorMatcher) NumArgs() int {
- return m.numArgs
-}
-
-func (m *InvalidMatchErrorMatcher) GetValueExpr() ast.Expr {
- return m.firstAgr
-}
-
-type MatchErrorMatcherWithErr struct {
- numArgs int
-}
-
-func (m *MatchErrorMatcherWithErr) Type() Type {
- return MatchErrorMatcherType | ErrMatchWithErr
-}
-
-func (m *MatchErrorMatcherWithErr) MatcherName() string {
- return matchError
-}
-
-func (m *MatchErrorMatcherWithErr) AllowedNumArgs() int {
- return 1
-}
-
-func (m *MatchErrorMatcherWithErr) NumArgs() int {
- return m.numArgs
-}
-
-type MatchErrorMatcherWithErrFunc struct {
- numArgs int
- secondArgIsString bool
-}
-
-func (m *MatchErrorMatcherWithErrFunc) Type() Type {
- return MatchErrorMatcherType | ErrMatchWithErrFunc
-}
-
-func (m *MatchErrorMatcherWithErrFunc) MatcherName() string {
- return matchError
-}
-
-func (m *MatchErrorMatcherWithErrFunc) AllowedNumArgs() int {
- return 2
-}
-
-func (m *MatchErrorMatcherWithErrFunc) NumArgs() int {
- return m.numArgs
-}
-
-func (m *MatchErrorMatcherWithErrFunc) IsSecondArgString() bool {
- return m.secondArgIsString
-}
-
-type MatchErrorMatcherWithString struct {
- numArgs int
-}
-
-func (m *MatchErrorMatcherWithString) Type() Type {
- return MatchErrorMatcherType | ErrMatchWithString
-}
-
-func (m *MatchErrorMatcherWithString) MatcherName() string {
- return matchError
-}
-
-func (m *MatchErrorMatcherWithString) AllowedNumArgs() int {
- return 1
-}
-
-func (m *MatchErrorMatcherWithString) NumArgs() int {
- return m.numArgs
-}
-
-type MatchErrorMatcherWithMatcher struct {
- numArgs int
-}
-
-func (m *MatchErrorMatcherWithMatcher) Type() Type {
- return MatchErrorMatcherType | ErrMatchWithMatcher
-}
-
-func (m *MatchErrorMatcherWithMatcher) MatcherName() string {
- return matchError
-}
-
-func (m *MatchErrorMatcherWithMatcher) AllowedNumArgs() int {
- return 1
-}
-
-func (m *MatchErrorMatcherWithMatcher) NumArgs() int {
- return m.numArgs
-}
-
-func newMatchErrorMatcher(args []ast.Expr, pass *analysis.Pass) MatchErrorMatcher {
- numArgs := len(args)
- if value.IsExprError(pass, args[0]) {
- return &MatchErrorMatcherWithErr{numArgs: numArgs}
- }
-
- t := pass.TypesInfo.TypeOf(args[0])
- if isString(args[0], pass) {
- return &MatchErrorMatcherWithString{numArgs: numArgs}
- }
-
- if interfaces.ImplementsGomegaMatcher(t) {
- return &MatchErrorMatcherWithMatcher{numArgs: numArgs}
- }
-
- if isFuncErrBool(t) {
- isString := false
- if numArgs > 1 {
- t2 := pass.TypesInfo.TypeOf(args[1])
- isString = gotypes.Identical(t2, gotypes.Typ[gotypes.String])
- }
- return &MatchErrorMatcherWithErrFunc{numArgs: numArgs, secondArgIsString: isString}
- }
-
- return &InvalidMatchErrorMatcher{numArgs: numArgs}
-}
-
-func isString(exp ast.Expr, pass *analysis.Pass) bool {
- t := pass.TypesInfo.TypeOf(exp)
- return gotypes.Identical(t, gotypes.Typ[gotypes.String])
-}
-
-// isFuncErrBool checks if a function is with the signature `func(error) bool`
-func isFuncErrBool(t gotypes.Type) bool {
- sig, ok := t.(*gotypes.Signature)
- if !ok {
- return false
- }
- if sig.Params().Len() != 1 || sig.Results().Len() != 1 {
- return false
- }
-
- if !interfaces.ImplementsError(sig.Params().At(0).Type()) {
- return false
- }
-
- b, ok := sig.Results().At(0).Type().(*gotypes.Basic)
- if ok && b.Name() == "bool" && b.Info() == gotypes.IsBoolean && b.Kind() == gotypes.Bool {
- return true
- }
-
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/lenmatchers.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/lenmatchers.go
deleted file mode 100644
index 8e4f438e8..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/lenmatchers.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package matcher
-
-type HaveLenZeroMatcher struct{}
-
-func (HaveLenZeroMatcher) Type() Type {
- return HaveLenZeroMatcherType
-}
-
-func (HaveLenZeroMatcher) MatcherName() string {
- return haveLen
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcher.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcher.go
deleted file mode 100644
index 0969b9551..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcher.go
+++ /dev/null
@@ -1,86 +0,0 @@
-package matcher
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/gomegahandler"
-)
-
-const ( // gomega matchers
- beEmpty = "BeEmpty"
- beEquivalentTo = "BeEquivalentTo"
- beFalse = "BeFalse"
- beIdenticalTo = "BeIdenticalTo"
- beNil = "BeNil"
- beNumerically = "BeNumerically"
- beTrue = "BeTrue"
- beZero = "BeZero"
- equal = "Equal"
- haveLen = "HaveLen"
- haveValue = "HaveValue"
- and = "And"
- or = "Or"
- withTransform = "WithTransform"
- matchError = "MatchError"
- haveOccurred = "HaveOccurred"
- succeed = "Succeed"
-)
-
-type Matcher struct {
- funcName string
- Orig *ast.CallExpr
- Clone *ast.CallExpr
- info Info
- reverseLogic bool
- handler gomegahandler.Handler
-}
-
-func New(origMatcher, matcherClone *ast.CallExpr, pass *analysis.Pass, handler gomegahandler.Handler) (*Matcher, bool) {
- reverse := false
- var assertFuncName string
- for {
- ok := false
- assertFuncName, ok = handler.GetActualFuncName(origMatcher)
- if !ok {
- return nil, false
- }
-
- if assertFuncName != "Not" {
- break
- }
-
- reverse = !reverse
- origMatcher, ok = origMatcher.Args[0].(*ast.CallExpr)
- if !ok {
- return nil, false
- }
- matcherClone = matcherClone.Args[0].(*ast.CallExpr)
- }
-
- return &Matcher{
- funcName: assertFuncName,
- Orig: origMatcher,
- Clone: matcherClone,
- info: getMatcherInfo(origMatcher, matcherClone, assertFuncName, pass, handler),
- reverseLogic: reverse,
- handler: handler,
- }, true
-}
-
-func (m *Matcher) ShouldReverseLogic() bool {
- return m.reverseLogic
-}
-
-func (m *Matcher) GetMatcherInfo() Info {
- return m.info
-}
-
-func (m *Matcher) ReplaceMatcherFuncName(name string) {
- m.handler.ReplaceFunction(m.Clone, ast.NewIdent(name))
-}
-
-func (m *Matcher) ReplaceMatcherArgs(newArgs []ast.Expr) {
- m.Clone.Args = newArgs
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcherinfo.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcherinfo.go
deleted file mode 100644
index 084226bcc..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcherinfo.go
+++ /dev/null
@@ -1,148 +0,0 @@
-package matcher
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression/value"
- "github.com/nunnatsa/ginkgolinter/internal/gomegahandler"
-)
-
-type Type uint64
-
-const (
- Unspecified Type = 1 << iota
- EqualMatcherType
- BeZeroMatcherType
- BeEmptyMatcherType
- BeTrueMatcherType
- BeFalseMatcherType
- BeNumericallyMatcherType
- HaveLenZeroMatcherType
- BeEquivalentToMatcherType
- BeIdenticalToMatcherType
- BeNilMatcherType
- MatchErrorMatcherType
- MultipleMatcherMatherType
- HaveValueMatherType
- WithTransformMatherType
- EqualBoolValueMatcherType
- EqualValueMatcherType
- HaveOccurredMatcherType
- SucceedMatcherType
- EqualNilMatcherType
-
- BoolValueFalse
- BoolValueTrue
-
- OrMatherType
- AndMatherType
-
- ErrMatchWithErr
- ErrMatchWithErrFunc
- ErrMatchWithString
- ErrMatchWithMatcher
-
- EqualZero
- GreaterThanZero
-)
-
-type Info interface {
- Type() Type
- MatcherName() string
-}
-
-func getMatcherInfo(orig, clone *ast.CallExpr, matcherName string, pass *analysis.Pass, handler gomegahandler.Handler) Info {
- switch matcherName {
- case equal:
- return newEqualMatcher(orig.Args[0], clone.Args[0], pass)
-
- case beZero:
- return &BeZeroMatcher{}
-
- case beEmpty:
- return &BeEmptyMatcher{}
-
- case beTrue:
- return &BeTrueMatcher{}
-
- case beFalse:
- return &BeFalseMatcher{}
-
- case beNil:
- return &BeNilMatcher{}
-
- case beNumerically:
- if len(orig.Args) == 2 {
- return newBeNumericallyMatcher(orig.Args[0], orig.Args[1], clone.Args[1], pass)
- }
-
- case haveLen:
- if value.GetValuer(orig.Args[0], clone.Args[0], pass).IsValueZero() {
- return &HaveLenZeroMatcher{}
- }
-
- case beEquivalentTo:
- return &BeEquivalentToMatcher{
- Value: value.New(orig.Args[0], clone.Args[0], pass),
- }
-
- case beIdenticalTo:
- return &BeIdenticalToMatcher{
- Value: value.New(orig.Args[0], clone.Args[0], pass),
- }
-
- case matchError:
- return newMatchErrorMatcher(orig.Args, pass)
-
- case haveValue:
- if nestedMatcher, ok := getNestedMatcher(orig, clone, 0, pass, handler); ok {
- return &HaveValueMatcher{
- nested: nestedMatcher,
- }
- }
-
- case withTransform:
- if nestedMatcher, ok := getNestedMatcher(orig, clone, 1, pass, handler); ok {
- return newWithTransformMatcher(orig.Args[0], nestedMatcher, pass)
- }
-
- case or, and:
- matcherType := MultipleMatcherMatherType
- if matcherName == or {
- matcherType |= OrMatherType
- } else {
- matcherType |= AndMatherType
- }
-
- if m, ok := newMultipleMatchersMatcher(matcherType, orig.Args, clone.Args, pass, handler); ok {
- return m
- }
-
- case succeed:
- return &SucceedMatcher{}
-
- case haveOccurred:
- return &HaveOccurredMatcher{}
-
- }
-
- return &UnspecifiedMatcher{matcherName: matcherName}
-}
-
-type UnspecifiedMatcher struct {
- matcherName string
-}
-
-func (UnspecifiedMatcher) Type() Type {
- return Unspecified
-}
-
-func (u UnspecifiedMatcher) MatcherName() string {
- return u.matcherName
-}
-
-func (t Type) Is(other Type) bool {
- return t&other != 0
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcherwithnest.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcherwithnest.go
deleted file mode 100644
index cc26e5ac2..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/matcherwithnest.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package matcher
-
-import (
- "go/ast"
- gotypes "go/types"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/gomegahandler"
-)
-
-type HaveValueMatcher struct {
- nested *Matcher
-}
-
-func (m *HaveValueMatcher) Type() Type {
- return HaveValueMatherType
-}
-func (m *HaveValueMatcher) MatcherName() string {
- return haveValue
-}
-
-func (m *HaveValueMatcher) GetNested() *Matcher {
- return m.nested
-}
-
-type WithTransformMatcher struct {
- funcType gotypes.Type
- nested *Matcher
-}
-
-func (m *WithTransformMatcher) Type() Type {
- return WithTransformMatherType
-}
-func (m *WithTransformMatcher) MatcherName() string {
- return withTransform
-}
-
-func (m *WithTransformMatcher) GetNested() *Matcher {
- return m.nested
-}
-
-func (m *WithTransformMatcher) GetFuncType() gotypes.Type {
- return m.funcType
-}
-
-func getNestedMatcher(orig, clone *ast.CallExpr, offset int, pass *analysis.Pass, handler gomegahandler.Handler) (*Matcher, bool) {
- if origNested, ok := orig.Args[offset].(*ast.CallExpr); ok {
- cloneNested := clone.Args[offset].(*ast.CallExpr)
-
- return New(origNested, cloneNested, pass, handler)
- }
-
- return nil, false
-}
-
-func newWithTransformMatcher(fun ast.Expr, nested *Matcher, pass *analysis.Pass) *WithTransformMatcher {
- funcType := pass.TypesInfo.TypeOf(fun)
- if sig, ok := funcType.(*gotypes.Signature); ok && sig.Results().Len() > 0 {
- funcType = sig.Results().At(0).Type()
- }
- return &WithTransformMatcher{
- funcType: funcType,
- nested: nested,
- }
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/multiplematchers.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/multiplematchers.go
deleted file mode 100644
index 9ce0cf5b8..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/matcher/multiplematchers.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package matcher
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/gomegahandler"
-)
-
-type MultipleMatchersMatcher struct {
- matherType Type
- matchers []*Matcher
-}
-
-func (m *MultipleMatchersMatcher) Type() Type {
- return m.matherType
-}
-
-func (m *MultipleMatchersMatcher) MatcherName() string {
- if m.matherType.Is(OrMatherType) {
- return or
- }
- return and
-}
-
-func newMultipleMatchersMatcher(matherType Type, orig, clone []ast.Expr, pass *analysis.Pass, handler gomegahandler.Handler) (*MultipleMatchersMatcher, bool) {
- matchers := make([]*Matcher, len(orig))
-
- for i := range orig {
- nestedOrig, ok := orig[i].(*ast.CallExpr)
- if !ok {
- return nil, false
- }
-
- m, ok := New(nestedOrig, clone[i].(*ast.CallExpr), pass, handler)
- if !ok {
- return nil, false
- }
-
- m.reverseLogic = false
-
- matchers[i] = m
- }
-
- return &MultipleMatchersMatcher{
- matherType: matherType,
- matchers: matchers,
- }, true
-}
-
-func (m *MultipleMatchersMatcher) Len() int {
- return len(m.matchers)
-}
-
-func (m *MultipleMatchersMatcher) At(i int) *Matcher {
- if i >= len(m.matchers) {
- panic("index out of range")
- }
-
- return m.matchers[i]
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/value/value.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/value/value.go
deleted file mode 100644
index dda0dd73b..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/expression/value/value.go
+++ /dev/null
@@ -1,221 +0,0 @@
-package value
-
-import (
- "go/ast"
- "go/constant"
- gotypes "go/types"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/interfaces"
-)
-
-type Valuer interface {
- GetValue() constant.Value
- GetType() gotypes.Type
- GetValueExpr() ast.Expr
- IsValueZero() bool
- IsValueInt() bool
- IsValueNumeric() bool
- IsError() bool
- IsFunc() bool
- IsInterface() bool
- IsPointer() bool
-}
-
-func GetValuer(orig, clone ast.Expr, pass *analysis.Pass) Valuer {
- val := New(orig, clone, pass)
- unspecified := UnspecifiedValue{
- Value: val,
- }
-
- if orig == nil {
- return unspecified
- }
-
- if IsExprError(pass, orig) {
- return &ErrValue{
- Value: val,
- err: clone,
- }
- }
-
- if val.GetValue() == nil || !val.tv.IsValue() {
- return unspecified
- }
-
- if val.GetValue().Kind() == constant.Int {
- num, ok := constant.Int64Val(val.GetValue())
- if !ok {
- return unspecified
- }
- return &IntValue{
- Value: val,
- val: num,
- }
- }
-
- return unspecified
-}
-
-type Value struct {
- expr ast.Expr
- tv gotypes.TypeAndValue
-}
-
-func New(orig, clone ast.Expr, pass *analysis.Pass) Value {
- tv := pass.TypesInfo.Types[orig]
-
- return Value{
- expr: clone,
- tv: tv,
- }
-}
-
-func (v Value) GetValueExpr() ast.Expr {
- return v.expr
-}
-
-func (v Value) GetValue() constant.Value {
- return v.tv.Value
-}
-
-func (v Value) GetType() gotypes.Type {
- return v.tv.Type
-}
-
-func (v Value) IsInterface() bool {
- return gotypes.IsInterface(v.tv.Type)
-}
-
-func (v Value) IsPointer() bool {
- return Is[*gotypes.Pointer](v.tv.Type)
-}
-
-func (v Value) IsNil() bool {
- return v.tv.IsNil()
-}
-
-type UnspecifiedValue struct {
- Value
-}
-
-func (u UnspecifiedValue) IsValueZero() bool {
- return false
-}
-
-func (u UnspecifiedValue) IsValueInt() bool {
- return false
-}
-
-func (u UnspecifiedValue) IsValueNumeric() bool {
- return false
-}
-
-func (u UnspecifiedValue) IsError() bool {
- return false
-}
-
-func (u UnspecifiedValue) IsFunc() bool {
- return isFunc(u.GetValueExpr())
-}
-
-type ErrValue struct {
- Value
- err ast.Expr
-}
-
-func (e ErrValue) IsValueZero() bool {
- return false
-}
-
-func (e ErrValue) IsValueInt() bool {
- return false
-}
-
-func (e ErrValue) IsValueNumeric() bool {
- return false
-}
-
-func (e ErrValue) IsError() bool {
- return true
-}
-
-func (e ErrValue) IsFunc() bool {
- return isFunc(e.GetValueExpr())
-}
-
-type IntValuer interface {
- GetIntValue() int64
-}
-
-type IntValue struct {
- Value
- val int64
-}
-
-func (i IntValue) IsValueZero() bool {
- return i.val == 0
-}
-
-func (i IntValue) IsValueInt() bool {
- return i.val == 0
-}
-
-func (i IntValue) IsValueNumeric() bool {
- return true
-}
-
-func (i IntValue) IsError() bool {
- return false
-}
-
-func (i IntValue) IsFunc() bool {
- return false
-}
-
-func (i IntValue) GetIntValue() int64 {
- return i.val
-}
-
-func isFunc(exp ast.Expr) bool {
- return Is[*ast.CallExpr](exp)
-}
-
-func Is[T any](x any) bool {
- _, matchType := x.(T)
- return matchType
-}
-
-func IsExprError(pass *analysis.Pass, expr ast.Expr) bool {
- actualArgType := pass.TypesInfo.TypeOf(expr)
- switch t := actualArgType.(type) {
- case *gotypes.Named:
- return interfaces.ImplementsError(actualArgType)
-
- case *gotypes.Pointer:
- if tt, ok := t.Elem().(*gotypes.Named); ok {
- return interfaces.ImplementsError(tt)
- }
-
- case *gotypes.Tuple:
- if t.Len() > 0 {
- switch t0 := t.At(0).Type().(type) {
- case *gotypes.Named, *gotypes.Pointer:
- if interfaces.ImplementsError(t0) {
- return true
- }
- }
- }
- }
- return false
-}
-
-func IsNil(exp ast.Expr, pass *analysis.Pass) bool {
- id, ok := exp.(*ast.Ident)
- if !ok {
- return false
- }
-
- return pass.TypesInfo.Types[id].IsNil()
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/formatter/formatter.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/formatter/formatter.go
deleted file mode 100644
index 64f3d99ad..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/formatter/formatter.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package formatter
-
-import (
- "bytes"
- "go/ast"
- "go/printer"
- "go/token"
-)
-
-type GoFmtFormatter struct {
- fset *token.FileSet
-}
-
-func NewGoFmtFormatter(fset *token.FileSet) *GoFmtFormatter {
- return &GoFmtFormatter{fset: fset}
-}
-
-func (f GoFmtFormatter) Format(exp ast.Expr) string {
- var buf bytes.Buffer
- _ = printer.Fprint(&buf, f.fset, exp)
- return buf.String()
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/dothandler.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/dothandler.go
deleted file mode 100644
index 9c54b4334..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/dothandler.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package ginkgohandler
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-// dotHandler is used when importing ginkgo with dot; i.e.
-// import . "github.com/onsi/ginkgo"
-type dotHandler struct{}
-
-func (h dotHandler) HandleGinkgoSpecs(expr ast.Expr, config types.Config, pass *analysis.Pass) bool {
- return handleGinkgoSpecs(expr, config, pass, h)
-}
-
-func (h dotHandler) getFocusContainerName(exp *ast.CallExpr) (bool, *ast.Ident) {
- if fun, ok := exp.Fun.(*ast.Ident); ok {
- return isFocusContainer(fun.Name), fun
- }
- return false, nil
-}
-
-func (h dotHandler) isWrapContainer(exp *ast.CallExpr) bool {
- if fun, ok := exp.Fun.(*ast.Ident); ok {
- return isWrapContainer(fun.Name)
- }
- return false
-}
-
-func (h dotHandler) isFocusSpec(exp ast.Expr) bool {
- id, ok := exp.(*ast.Ident)
- return ok && id.Name == focusSpec
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/ginkgoinfo.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/ginkgoinfo.go
deleted file mode 100644
index d8bb75399..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/ginkgoinfo.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package ginkgohandler
-
-const ( // container names
- describe = "Describe"
- pdescribe = "PDescribe"
- xdescribe = "XDescribe"
- fdescribe = "FDescribe"
-
- when = "When"
- pwhen = "PWhen"
- xwhen = "XWhen"
- fwhen = "FWhen"
-
- contextContainer = "Context"
- pcontext = "PContext"
- xcontext = "XContext"
- fcontext = "FContext"
-
- it = "It"
- pit = "PIt"
- xit = "XIt"
- fit = "FIt"
-
- describeTable = "DescribeTable"
- pdescribeTable = "PDescribeTable"
- xdescribeTable = "XDescribeTable"
- fdescribeTable = "FDescribeTable"
-
- entry = "Entry"
- pentry = "PEntry"
- xentry = "XEntry"
- fentry = "FEntry"
-)
-
-func isFocusContainer(name string) bool {
- switch name {
- case fdescribe, fcontext, fwhen, fit, fdescribeTable, fentry:
- return true
- }
- return false
-}
-
-func isContainer(name string) bool {
- switch name {
- case it, when, contextContainer, describe, describeTable, entry,
- pit, pwhen, pcontext, pdescribe, pdescribeTable, pentry,
- xit, xwhen, xcontext, xdescribe, xdescribeTable, xentry:
- return true
- }
- return isFocusContainer(name)
-}
-
-func isWrapContainer(name string) bool {
- switch name {
- case when, contextContainer, describe,
- fwhen, fcontext, fdescribe,
- pwhen, pcontext, pdescribe,
- xwhen, xcontext, xdescribe:
- return true
- }
-
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/handler.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/handler.go
deleted file mode 100644
index c44e3e8d8..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/handler.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package ginkgohandler
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const (
- importPath = `"github.com/onsi/ginkgo"`
- importPathV2 = `"github.com/onsi/ginkgo/v2"`
-
- focusSpec = "Focus"
-)
-
-// Handler provide different handling, depend on the way ginkgo was imported, whether
-// in imported with "." name, custom name or without any name.
-type Handler interface {
- HandleGinkgoSpecs(ast.Expr, types.Config, *analysis.Pass) bool
- getFocusContainerName(*ast.CallExpr) (bool, *ast.Ident)
- isWrapContainer(*ast.CallExpr) bool
- isFocusSpec(ident ast.Expr) bool
-}
-
-// GetGinkgoHandler returns a ginkgor handler according to the way ginkgo was imported in the specific file
-func GetGinkgoHandler(file *ast.File) Handler {
- for _, imp := range file.Imports {
- switch imp.Path.Value {
-
- case importPath, importPathV2:
- switch name := imp.Name.String(); {
- case name == ".":
- return dotHandler{}
- case name == "<nil>": // import with no local name
- return nameHandler("ginkgo")
- default:
- return nameHandler(name)
- }
-
- default:
- continue
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/handling.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/handling.go
deleted file mode 100644
index 4b6de5767..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/handling.go
+++ /dev/null
@@ -1,195 +0,0 @@
-package ginkgohandler
-
-import (
- "fmt"
- "go/ast"
- "go/token"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const (
- linterName = "ginkgo-linter"
- focusContainerFound = linterName + ": Focus container found. This is used only for local debug and should not be part of the actual source code. Consider to replace with %q"
- focusSpecFound = linterName + ": Focus spec found. This is used only for local debug and should not be part of the actual source code. Consider to remove it"
- useBeforeEachTemplate = "use BeforeEach() to assign variable %s"
-)
-
-func handleGinkgoSpecs(expr ast.Expr, config types.Config, pass *analysis.Pass, ginkgoHndlr Handler) bool {
- goDeeper := false
- if exp, ok := expr.(*ast.CallExpr); ok {
- if bool(config.ForbidFocus) && checkFocusContainer(pass, ginkgoHndlr, exp) {
- goDeeper = true
- }
-
- if bool(config.ForbidSpecPollution) && checkAssignmentsInContainer(pass, ginkgoHndlr, exp) {
- goDeeper = true
- }
- }
- return goDeeper
-}
-
-func checkAssignmentsInContainer(pass *analysis.Pass, ginkgoHndlr Handler, exp *ast.CallExpr) bool {
- foundSomething := false
- if ginkgoHndlr.isWrapContainer(exp) {
- for _, arg := range exp.Args {
- if fn, ok := arg.(*ast.FuncLit); ok {
- if fn.Body != nil {
- if checkAssignments(pass, fn.Body.List) {
- foundSomething = true
- }
- break
- }
- }
- }
- }
-
- return foundSomething
-}
-
-func checkAssignments(pass *analysis.Pass, list []ast.Stmt) bool {
- foundSomething := false
- for _, stmt := range list {
- switch st := stmt.(type) {
- case *ast.DeclStmt:
- if checkAssignmentDecl(pass, st) {
- foundSomething = true
- }
-
- case *ast.AssignStmt:
- if checkAssignmentAssign(pass, st) {
- foundSomething = true
- }
-
- case *ast.IfStmt:
- if checkAssignmentIf(pass, st) {
- foundSomething = true
- }
- }
- }
-
- return foundSomething
-}
-
-func checkAssignmentsValues(pass *analysis.Pass, names []*ast.Ident, values []ast.Expr) bool {
- foundSomething := false
- for i, val := range values {
- if !is[*ast.FuncLit](val) {
- reportNoFix(pass, names[i].Pos(), useBeforeEachTemplate, names[i].Name)
- foundSomething = true
- }
- }
-
- return foundSomething
-}
-
-func checkAssignmentDecl(pass *analysis.Pass, ds *ast.DeclStmt) bool {
- foundSomething := false
- if gen, ok := ds.Decl.(*ast.GenDecl); ok {
- if gen.Tok != token.VAR {
- return false
- }
- for _, spec := range gen.Specs {
- if valSpec, ok := spec.(*ast.ValueSpec); ok {
- if checkAssignmentsValues(pass, valSpec.Names, valSpec.Values) {
- foundSomething = true
- }
- }
- }
- }
-
- return foundSomething
-}
-
-func checkAssignmentAssign(pass *analysis.Pass, as *ast.AssignStmt) bool {
- foundSomething := false
- for i, val := range as.Rhs {
- if !is[*ast.FuncLit](val) {
- if id, isIdent := as.Lhs[i].(*ast.Ident); isIdent && id.Name != "_" {
- reportNoFix(pass, id.Pos(), useBeforeEachTemplate, id.Name)
- foundSomething = true
- }
- }
- }
- return foundSomething
-}
-
-func checkAssignmentIf(pass *analysis.Pass, is *ast.IfStmt) bool {
- foundSomething := false
-
- if is.Body != nil {
- if checkAssignments(pass, is.Body.List) {
- foundSomething = true
- }
- }
- if is.Else != nil {
- if block, isBlock := is.Else.(*ast.BlockStmt); isBlock {
- if checkAssignments(pass, block.List) {
- foundSomething = true
- }
- }
- }
-
- return foundSomething
-}
-
-func checkFocusContainer(pass *analysis.Pass, handler Handler, exp *ast.CallExpr) bool {
- foundFocus := false
- isFocus, id := handler.getFocusContainerName(exp)
- if isFocus {
- reportNewName(pass, id, id.Name[1:], id.Name)
- foundFocus = true
- }
-
- if id != nil && isContainer(id.Name) {
- for _, arg := range exp.Args {
- if handler.isFocusSpec(arg) {
- reportNoFix(pass, arg.Pos(), focusSpecFound)
- foundFocus = true
- } else if callExp, ok := arg.(*ast.CallExpr); ok {
- if checkFocusContainer(pass, handler, callExp) { // handle table entries
- foundFocus = true
- }
- }
- }
- }
-
- return foundFocus
-}
-
-func reportNewName(pass *analysis.Pass, id *ast.Ident, newName string, oldExpr string) {
- pass.Report(analysis.Diagnostic{
- Pos: id.Pos(),
- Message: fmt.Sprintf(focusContainerFound, newName),
- SuggestedFixes: []analysis.SuggestedFix{
- {
- Message: fmt.Sprintf("should replace %s with %s", oldExpr, newName),
- TextEdits: []analysis.TextEdit{
- {
- Pos: id.Pos(),
- End: id.End(),
- NewText: []byte(newName),
- },
- },
- },
- },
- })
-}
-
-func reportNoFix(pass *analysis.Pass, pos token.Pos, message string, args ...any) {
- if len(args) > 0 {
- message = fmt.Sprintf(message, args...)
- }
-
- pass.Report(analysis.Diagnostic{
- Pos: pos,
- Message: message,
- })
-}
-
-func is[T any](x any) bool {
- _, matchType := x.(T)
- return matchType
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/namehandler.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/namehandler.go
deleted file mode 100644
index 2ef9fe703..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/ginkgohandler/namehandler.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package ginkgohandler
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-// nameHandler is used when importing ginkgo without name; i.e.
-// import "github.com/onsi/ginkgo"
-//
-// or with a custom name; e.g.
-// import customname "github.com/onsi/ginkgo"
-type nameHandler string
-
-func (h nameHandler) HandleGinkgoSpecs(expr ast.Expr, config types.Config, pass *analysis.Pass) bool {
- return handleGinkgoSpecs(expr, config, pass, h)
-}
-
-func (h nameHandler) getFocusContainerName(exp *ast.CallExpr) (bool, *ast.Ident) {
- if sel, ok := exp.Fun.(*ast.SelectorExpr); ok {
- if id, ok := sel.X.(*ast.Ident); ok && id.Name == string(h) {
- return isFocusContainer(sel.Sel.Name), sel.Sel
- }
- }
- return false, nil
-}
-
-func (h nameHandler) isWrapContainer(exp *ast.CallExpr) bool {
- if sel, ok := exp.Fun.(*ast.SelectorExpr); ok {
- if id, ok := sel.X.(*ast.Ident); ok && id.Name == string(h) {
- return isWrapContainer(sel.Sel.Name)
- }
- }
- return false
-
-}
-
-func (h nameHandler) isFocusSpec(exp ast.Expr) bool {
- if selExp, ok := exp.(*ast.SelectorExpr); ok {
- if x, ok := selExp.X.(*ast.Ident); ok && x.Name == string(h) {
- return selExp.Sel.Name == focusSpec
- }
- }
-
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/dothandler.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/dothandler.go
deleted file mode 100644
index c853ca906..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/dothandler.go
+++ /dev/null
@@ -1,103 +0,0 @@
-package gomegahandler
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/gomegainfo"
-)
-
-// dotHandler is used when importing gomega with dot; i.e.
-// import . "github.com/onsi/gomega"
-type dotHandler struct {
- pass *analysis.Pass
-}
-
-// GetActualFuncName returns the name of the gomega function, e.g. `Expect`
-func (h dotHandler) GetActualFuncName(expr *ast.CallExpr) (string, bool) {
- switch actualFunc := expr.Fun.(type) {
- case *ast.Ident:
- return actualFunc.Name, true
- case *ast.SelectorExpr:
- if h.isGomegaVar(actualFunc.X) {
- return actualFunc.Sel.Name, true
- }
-
- if x, ok := actualFunc.X.(*ast.CallExpr); ok {
- return h.GetActualFuncName(x)
- }
-
- case *ast.CallExpr:
- return h.GetActualFuncName(actualFunc)
- }
- return "", false
-}
-
-// ReplaceFunction replaces the function with another one, for fix suggestions
-func (dotHandler) ReplaceFunction(caller *ast.CallExpr, newExpr *ast.Ident) {
- switch f := caller.Fun.(type) {
- case *ast.Ident:
- caller.Fun = newExpr
- case *ast.SelectorExpr:
- f.Sel = newExpr
- }
-}
-
-func (dotHandler) GetNewWrapperMatcher(name string, existing *ast.CallExpr) *ast.CallExpr {
- return &ast.CallExpr{
- Fun: ast.NewIdent(name),
- Args: []ast.Expr{existing},
- }
-}
-
-func (h dotHandler) GetActualExpr(assertionFunc *ast.SelectorExpr, errMethodExists *bool) *ast.CallExpr {
- actualExpr, ok := assertionFunc.X.(*ast.CallExpr)
- if !ok {
- return nil
- }
-
- switch fun := actualExpr.Fun.(type) {
- case *ast.Ident:
- return actualExpr
- case *ast.SelectorExpr:
- if gomegainfo.IsActualMethod(fun.Sel.Name) {
- if h.isGomegaVar(fun.X) {
- return actualExpr
- }
- } else {
- if fun.Sel.Name == "Error" {
- *errMethodExists = true
- }
-
- return h.GetActualExpr(fun, errMethodExists)
- }
- }
- return nil
-}
-
-func (h dotHandler) GetActualExprClone(origFunc, funcClone *ast.SelectorExpr) *ast.CallExpr {
- actualExpr, ok := funcClone.X.(*ast.CallExpr)
- if !ok {
- return nil
- }
-
- switch funClone := actualExpr.Fun.(type) {
- case *ast.Ident:
- return actualExpr
- case *ast.SelectorExpr:
- origFun := origFunc.X.(*ast.CallExpr).Fun.(*ast.SelectorExpr)
- if gomegainfo.IsActualMethod(funClone.Sel.Name) {
- if h.isGomegaVar(origFun.X) {
- return actualExpr
- }
- } else {
- return h.GetActualExprClone(origFun, funClone)
- }
- }
- return nil
-}
-
-func (h dotHandler) isGomegaVar(x ast.Expr) bool {
- return gomegainfo.IsGomegaVar(x, h.pass)
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/handler.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/handler.go
deleted file mode 100644
index 414438ba6..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/handler.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package gomegahandler
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
-)
-
-const (
- importPath = `"github.com/onsi/gomega"`
-)
-
-// Handler provide different handling, depend on the way gomega was imported, whether
-// in imported with "." name, custom name or without any name.
-type Handler interface {
- // GetActualFuncName returns the name of the gomega function, e.g. `Expect`
- GetActualFuncName(*ast.CallExpr) (string, bool)
- // ReplaceFunction replaces the function with another one, for fix suggestions
- ReplaceFunction(*ast.CallExpr, *ast.Ident)
-
- GetActualExpr(assertionFunc *ast.SelectorExpr, errMethodExists *bool) *ast.CallExpr
-
- GetActualExprClone(origFunc, funcClone *ast.SelectorExpr) *ast.CallExpr
-
- GetNewWrapperMatcher(name string, existing *ast.CallExpr) *ast.CallExpr
-}
-
-// GetGomegaHandler returns a gomegar handler according to the way gomega was imported in the specific file
-func GetGomegaHandler(file *ast.File, pass *analysis.Pass) Handler {
- for _, imp := range file.Imports {
- if imp.Path.Value != importPath {
- continue
- }
-
- switch name := imp.Name.String(); {
- case name == ".":
- return &dotHandler{
- pass: pass,
- }
- case name == "<nil>": // import with no local name
- return &nameHandler{name: "gomega", pass: pass}
- default:
- return &nameHandler{name: name, pass: pass}
- }
- }
-
- return nil // no gomega import; this file does not use gomega
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/namedhandler.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/namedhandler.go
deleted file mode 100644
index 66d563311..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegahandler/namedhandler.go
+++ /dev/null
@@ -1,115 +0,0 @@
-package gomegahandler
-
-import (
- "go/ast"
-
- "github.com/nunnatsa/ginkgolinter/internal/gomegainfo"
-
- "golang.org/x/tools/go/analysis"
-)
-
-// nameHandler is used when importing gomega without name; i.e.
-// import "github.com/onsi/gomega"
-//
-// or with a custom name; e.g.
-// import customname "github.com/onsi/gomega"
-type nameHandler struct {
- name string
- pass *analysis.Pass
-}
-
-// GetActualFuncName returns the name of the gomega function, e.g. `Expect`
-func (g nameHandler) GetActualFuncName(expr *ast.CallExpr) (string, bool) {
- selector, ok := expr.Fun.(*ast.SelectorExpr)
- if !ok {
- return "", false
- }
-
- switch x := selector.X.(type) {
- case *ast.Ident:
- if x.Name != g.name {
- if !g.isGomegaVar(x) {
- return "", false
- }
- }
-
- return selector.Sel.Name, true
-
- case *ast.CallExpr:
- return g.GetActualFuncName(x)
- }
-
- return "", false
-}
-
-// ReplaceFunction replaces the function with another one, for fix suggestions
-func (nameHandler) ReplaceFunction(caller *ast.CallExpr, newExpr *ast.Ident) {
- caller.Fun.(*ast.SelectorExpr).Sel = newExpr
-}
-
-func (g nameHandler) isGomegaVar(x ast.Expr) bool {
- return gomegainfo.IsGomegaVar(x, g.pass)
-}
-
-func (g nameHandler) GetActualExpr(assertionFunc *ast.SelectorExpr, errMethodExists *bool) *ast.CallExpr {
- actualExpr, ok := assertionFunc.X.(*ast.CallExpr)
- if !ok {
- return nil
- }
-
- switch fun := actualExpr.Fun.(type) {
- case *ast.Ident:
- return actualExpr
- case *ast.SelectorExpr:
- if x, ok := fun.X.(*ast.Ident); ok && x.Name == g.name {
- return actualExpr
- }
- if gomegainfo.IsActualMethod(fun.Sel.Name) {
- if g.isGomegaVar(fun.X) {
- return actualExpr
- }
- } else {
- if fun.Sel.Name == "Error" {
- *errMethodExists = true
- }
- return g.GetActualExpr(fun, errMethodExists)
- }
- }
- return nil
-}
-
-func (g nameHandler) GetActualExprClone(origFunc, funcClone *ast.SelectorExpr) *ast.CallExpr {
- actualExpr, ok := funcClone.X.(*ast.CallExpr)
- if !ok {
- return nil
- }
-
- switch funClone := actualExpr.Fun.(type) {
- case *ast.Ident:
- return actualExpr
- case *ast.SelectorExpr:
- if x, ok := funClone.X.(*ast.Ident); ok && x.Name == g.name {
- return actualExpr
- }
- origFun := origFunc.X.(*ast.CallExpr).Fun.(*ast.SelectorExpr)
- if gomegainfo.IsActualMethod(funClone.Sel.Name) {
- if g.isGomegaVar(origFun.X) {
- return actualExpr
- }
- } else {
- return g.GetActualExprClone(origFun, funClone)
- }
-
- }
- return nil
-}
-
-func (g nameHandler) GetNewWrapperMatcher(name string, existing *ast.CallExpr) *ast.CallExpr {
- return &ast.CallExpr{
- Fun: &ast.SelectorExpr{
- X: ast.NewIdent(g.name),
- Sel: ast.NewIdent(name),
- },
- Args: []ast.Expr{existing},
- }
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegainfo/gomegainfo.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegainfo/gomegainfo.go
deleted file mode 100644
index ca45a34b2..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/gomegainfo/gomegainfo.go
+++ /dev/null
@@ -1,113 +0,0 @@
-package gomegainfo
-
-import (
- "go/ast"
- gotypes "go/types"
- "regexp"
-
- "golang.org/x/tools/go/analysis"
-)
-
-const ( // gomega actual method names
- expect = "Expect"
- expectWithOffset = "ExpectWithOffset"
- omega = "Ω"
- eventually = "Eventually"
- eventuallyWithOffset = "EventuallyWithOffset"
- consistently = "Consistently"
- consistentlyWithOffset = "ConsistentlyWithOffset"
-)
-
-const ( // assertion methods
- to = "To"
- toNot = "ToNot"
- notTo = "NotTo"
- should = "Should"
- shouldNot = "ShouldNot"
-)
-
-var funcOffsetMap = map[string]int{
- expect: 0,
- expectWithOffset: 1,
- omega: 0,
- eventually: 0,
- eventuallyWithOffset: 1,
- consistently: 0,
- consistentlyWithOffset: 1,
-}
-
-func IsActualMethod(name string) bool {
- _, found := funcOffsetMap[name]
- return found
-}
-
-func ActualArgOffset(methodName string) int {
- funcOffset, ok := funcOffsetMap[methodName]
- if !ok {
- return -1
- }
- return funcOffset
-}
-
-func GetAllowedAssertionMethods(actualMethodName string) string {
- switch actualMethodName {
- case expect, expectWithOffset:
- return `"To()", "ToNot()" or "NotTo()"`
-
- case eventually, eventuallyWithOffset, consistently, consistentlyWithOffset:
- return `"Should()" or "ShouldNot()"`
-
- case omega:
- return `"Should()", "To()", "ShouldNot()", "ToNot()" or "NotTo()"`
-
- default:
- return ""
- }
-}
-
-var asyncFuncSet = map[string]struct{}{
- eventually: {},
- eventuallyWithOffset: {},
- consistently: {},
- consistentlyWithOffset: {},
-}
-
-func IsAsyncActualMethod(name string) bool {
- _, ok := asyncFuncSet[name]
- return ok
-}
-
-func IsAssertionFunc(name string) bool {
- switch name {
- case to, toNot, notTo, should, shouldNot:
- return true
- }
- return false
-}
-
-var gomegaTypeRegex = regexp.MustCompile(`github\.com/onsi/gomega/(?:internal|types)\.Gomega`)
-
-func IsGomegaVar(x ast.Expr, pass *analysis.Pass) bool {
- if tx, ok := pass.TypesInfo.Types[x]; ok {
- return IsGomegaType(tx.Type)
- }
-
- return false
-}
-
-func IsGomegaType(t gotypes.Type) bool {
- var typeStr string
- switch ttx := t.(type) {
- case *gotypes.Pointer:
- tp := ttx.Elem()
- typeStr = tp.String()
-
- case *gotypes.Named:
- typeStr = ttx.String()
-
- default:
- return false
- }
-
- return gomegaTypeRegex.MatchString(typeStr)
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/interfaces/interfaces.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/interfaces/interfaces.go
deleted file mode 100644
index 91849ca56..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/interfaces/interfaces.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package interfaces
-
-import (
- "go/token"
- gotypes "go/types"
-)
-
-var (
- errorType *gotypes.Interface
- gomegaMatcherType *gotypes.Interface
-)
-
-func init() {
- errorType = gotypes.Universe.Lookup("error").Type().Underlying().(*gotypes.Interface)
- gomegaMatcherType = generateTheGomegaMatcherInfType()
-}
-
-// generateTheGomegaMatcherInfType generates a types.Interface instance that represents the
-// GomegaMatcher interface.
-// The original code is (copied from https://github.com/nunnatsa/ginkgolinter/blob/8fdd05eee922578d4699f49d267001c01e0b9f1e/testdata/src/a/vendor/github.com/onsi/gomega/types/types.go)
-//
-// type GomegaMatcher interface {
-// Match(actual interface{}) (success bool, err error)
-// FailureMessage(actual interface{}) (message string)
-// NegatedFailureMessage(actual interface{}) (message string)
-// }
-func generateTheGomegaMatcherInfType() *gotypes.Interface {
- err := gotypes.Universe.Lookup("error").Type()
- bl := gotypes.Typ[gotypes.Bool]
- str := gotypes.Typ[gotypes.String]
- anyType := gotypes.Universe.Lookup("any").Type()
-
- return gotypes.NewInterfaceType([]*gotypes.Func{
- // Match(actual interface{}) (success bool, err error)
- gotypes.NewFunc(token.NoPos, nil, "Match", gotypes.NewSignatureType(
- nil, nil, nil,
- gotypes.NewTuple(
- gotypes.NewVar(token.NoPos, nil, "actual", anyType),
- ),
- gotypes.NewTuple(
- gotypes.NewVar(token.NoPos, nil, "", bl),
- gotypes.NewVar(token.NoPos, nil, "", err),
- ), false),
- ),
- // FailureMessage(actual interface{}) (message string)
- gotypes.NewFunc(token.NoPos, nil, "FailureMessage", gotypes.NewSignatureType(
- nil, nil, nil,
- gotypes.NewTuple(
- gotypes.NewVar(token.NoPos, nil, "", anyType),
- ),
- gotypes.NewTuple(
- gotypes.NewVar(token.NoPos, nil, "", str),
- ),
- false),
- ),
- //NegatedFailureMessage(actual interface{}) (message string)
- gotypes.NewFunc(token.NoPos, nil, "NegatedFailureMessage", gotypes.NewSignatureType(
- nil, nil, nil,
- gotypes.NewTuple(
- gotypes.NewVar(token.NoPos, nil, "", anyType),
- ),
- gotypes.NewTuple(
- gotypes.NewVar(token.NoPos, nil, "", str),
- ),
- false),
- ),
- }, nil)
-}
-
-func ImplementsError(t gotypes.Type) bool {
- return gotypes.Implements(t, errorType)
-}
-
-func ImplementsGomegaMatcher(t gotypes.Type) bool {
- return t != nil && gotypes.Implements(t, gomegaMatcherType)
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/intervals/intervals.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/intervals/intervals.go
deleted file mode 100644
index 51d55166d..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/intervals/intervals.go
+++ /dev/null
@@ -1,166 +0,0 @@
-package intervals
-
-import (
- "go/ast"
- "go/constant"
- "go/token"
- gotypes "go/types"
- "time"
-
- "golang.org/x/tools/go/analysis"
-)
-
-func GetDuration(pass *analysis.Pass, argOffset int, origInterval, intervalClone ast.Expr, timePkg string) DurationValue {
- tv := pass.TypesInfo.Types[origInterval]
- argType := tv.Type
- if durType, ok := argType.(*gotypes.Named); ok {
- if durType.String() == "time.Duration" {
- if tv.Value != nil {
- if val, ok := constant.Int64Val(tv.Value); ok {
- return &RealDurationValue{
- dur: time.Duration(val),
- expr: intervalClone,
- }
- }
- }
- return &UnknownDurationTypeValue{
- expr: intervalClone,
- }
- }
- }
-
- if basic, ok := argType.(*gotypes.Basic); ok && tv.Value != nil {
- if basic.Info()&gotypes.IsInteger != 0 {
- if num, ok := constant.Int64Val(tv.Value); ok {
- return &NumericDurationValue{
- timePkg: timePkg,
- numSeconds: num,
- offset: argOffset,
- dur: time.Duration(num) * time.Second,
- expr: intervalClone,
- }
- }
- }
-
- if basic.Info()&gotypes.IsFloat != 0 {
- if num, ok := constant.Float64Val(tv.Value); ok {
- return &NumericDurationValue{
- timePkg: timePkg,
- numSeconds: int64(num),
- offset: argOffset,
- dur: time.Duration(num) * time.Second,
- expr: intervalClone,
- }
- }
- }
- }
-
- return &UnknownDurationValue{expr: intervalClone}
-}
-
-func GetDurationFromValue(pass *analysis.Pass, orig, clone ast.Expr) DurationValue {
- tv := pass.TypesInfo.Types[orig]
- interval := tv.Value
- if interval != nil {
- if val, ok := constant.Int64Val(interval); ok {
- return RealDurationValue{
- dur: time.Duration(val),
- expr: orig,
- }
- }
- }
- return UnknownDurationTypeValue{expr: clone}
-}
-
-type DurationValue interface {
- Duration() time.Duration
-}
-
-type NumericValue interface {
- GetOffset() int
- GetDurationExpr() ast.Expr
-}
-type RealDurationValue struct {
- dur time.Duration
- expr ast.Expr
-}
-
-func (r RealDurationValue) Duration() time.Duration {
- return r.dur
-}
-
-type NumericDurationValue struct {
- timePkg string
- numSeconds int64
- offset int
- dur time.Duration
- expr ast.Expr
-}
-
-func (r *NumericDurationValue) Duration() time.Duration {
- return r.dur
-}
-
-func (r *NumericDurationValue) GetOffset() int {
- return r.offset
-}
-
-func (r *NumericDurationValue) GetDurationExpr() ast.Expr {
- var newArg ast.Expr
- second := &ast.SelectorExpr{
- Sel: ast.NewIdent("Second"),
- X: ast.NewIdent(r.timePkg),
- }
-
- if r.numSeconds == 1 {
- newArg = second
- } else {
- newArg = &ast.BinaryExpr{
- X: second,
- Op: token.MUL,
- Y: r.expr,
- }
- }
-
- return newArg
-}
-
-type UnknownDurationValue struct {
- expr ast.Expr
-}
-
-func (r UnknownDurationValue) Duration() time.Duration {
- return 0
-}
-
-type UnknownNumericValue struct {
- expr ast.Expr
- offset int
-}
-
-func (r UnknownNumericValue) Duration() time.Duration {
- return 0
-}
-
-func (r UnknownNumericValue) GetDurationExpr() ast.Expr {
- return &ast.BinaryExpr{
- X: &ast.SelectorExpr{
- Sel: ast.NewIdent("Second"),
- X: ast.NewIdent("time"),
- },
- Op: token.MUL,
- Y: r.expr,
- }
-}
-
-func (r UnknownNumericValue) GetOffset() int {
- return r.offset
-}
-
-type UnknownDurationTypeValue struct {
- expr ast.Expr
-}
-
-func (r UnknownDurationTypeValue) Duration() time.Duration {
- return 0
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/reports/report-builder.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/reports/report-builder.go
deleted file mode 100644
index dee88bd2c..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/reports/report-builder.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package reports
-
-import (
- "fmt"
- "go/ast"
- "go/token"
- "strings"
-
- "github.com/nunnatsa/ginkgolinter/internal/formatter"
-
- "golang.org/x/tools/go/analysis"
-)
-
-type Builder struct {
- pos token.Pos
- end token.Pos
- oldExpr string
- issues []string
- fixOffer string
- suggestFix bool
- formatter *formatter.GoFmtFormatter
-}
-
-func NewBuilder(oldExpr ast.Expr, expFormatter *formatter.GoFmtFormatter) *Builder {
- b := &Builder{
- pos: oldExpr.Pos(),
- end: oldExpr.End(),
- oldExpr: expFormatter.Format(oldExpr),
- suggestFix: false,
- formatter: expFormatter,
- }
-
- return b
-}
-
-func (b *Builder) OldExp() string {
- return b.oldExpr
-}
-
-func (b *Builder) AddIssue(suggestFix bool, issue string, args ...any) {
- if len(args) > 0 {
- issue = fmt.Sprintf(issue, args...)
- }
- b.issues = append(b.issues, issue)
-
- if suggestFix {
- b.suggestFix = true
- }
-}
-
-func (b *Builder) SetFixOffer(fixOffer ast.Expr) {
- if b.suggestFix {
- if offer := b.formatter.Format(fixOffer); offer != b.oldExpr {
- b.fixOffer = offer
- }
- }
-}
-
-func (b *Builder) HasReport() bool {
- return len(b.issues) > 0
-}
-
-func (b *Builder) Build() analysis.Diagnostic {
- diagnostic := analysis.Diagnostic{
- Pos: b.pos,
- Message: b.getMessage(),
- }
-
- if b.suggestFix && len(b.fixOffer) > 0 {
- diagnostic.SuggestedFixes = []analysis.SuggestedFix{
- {
- Message: fmt.Sprintf("should replace %s with %s", b.oldExpr, b.fixOffer),
- TextEdits: []analysis.TextEdit{
- {
- Pos: b.pos,
- End: b.end,
- NewText: []byte(b.fixOffer),
- },
- },
- },
- }
- }
-
- return diagnostic
-}
-
-func (b *Builder) FormatExpr(expr ast.Expr) string {
- return b.formatter.Format(expr)
-}
-
-func (b *Builder) getMessage() string {
- sb := strings.Builder{}
- sb.WriteString("ginkgo-linter: ")
- if len(b.issues) > 1 {
- sb.WriteString("multiple issues: ")
- }
- sb.WriteString(strings.Join(b.issues, "; "))
-
- if b.suggestFix && len(b.fixOffer) != 0 {
- sb.WriteString(fmt.Sprintf(". Consider using `%s` instead", b.fixOffer))
- }
-
- return sb.String()
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/reverseassertion/reverse_assertion.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/reverseassertion/reverse_assertion.go
deleted file mode 100644
index 1dbd89810..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/reverseassertion/reverse_assertion.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package reverseassertion
-
-import "go/token"
-
-var reverseLogicAssertions = map[string]string{
- "To": "ToNot",
- "ToNot": "To",
- "NotTo": "To",
- "Should": "ShouldNot",
- "ShouldNot": "Should",
-}
-
-// ChangeAssertionLogic get gomega assertion function name, and returns the reverse logic function name
-func ChangeAssertionLogic(funcName string) string {
- if revFunc, ok := reverseLogicAssertions[funcName]; ok {
- return revFunc
- }
- return funcName
-}
-
-func IsNegativeLogic(funcName string) bool {
- switch funcName {
- case "ToNot", "NotTo", "ShouldNot":
- return true
- }
- return false
-}
-
-var reverseCompareOperators = map[token.Token]token.Token{
- token.LSS: token.GTR,
- token.GTR: token.LSS,
- token.LEQ: token.GEQ,
- token.GEQ: token.LEQ,
-}
-
-// ChangeCompareOperator return the reversed comparison operator
-func ChangeCompareOperator(op token.Token) token.Token {
- if revOp, ok := reverseCompareOperators[op]; ok {
- return revOp
- }
- return op
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asyncfunccallrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asyncfunccallrule.go
deleted file mode 100644
index e4eda7f6c..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asyncfunccallrule.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const valueInEventually = "use a function call in %[1]s. This actually checks nothing, because %[1]s receives the function returned value, instead of function itself, and this value is never changed"
-
-// AsyncFuncCallRule checks that there is no function call actual parameter,
-// in an async actual method (e.g. Eventually).
-//
-// Async actual methods should get the function itself, not a function call, because
-// then there is no async operation at all, and we're waiting for the function to be
-// returned before calling the assertion.
-//
-// We do allow functions that return a function, a channel or a pointer.
-type AsyncFuncCallRule struct{}
-
-func (r AsyncFuncCallRule) isApplied(gexp *expression.GomegaExpression, config types.Config) bool {
- if bool(config.SuppressAsync) || !gexp.IsAsync() {
- return false
- }
-
- if asyncArg := gexp.GetAsyncActualArg(); asyncRules != nil {
- return !asyncArg.IsValid()
- }
-
- return false
-}
-
-func (r AsyncFuncCallRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if r.isApplied(gexp, config) {
-
- gexp.AppendWithArgsToActual()
-
- reportBuilder.AddIssue(true, valueInEventually, gexp.GetActualFuncName())
- }
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asyncsucceedrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asyncsucceedrule.go
deleted file mode 100644
index 803c705de..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asyncsucceedrule.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-type AsyncSucceedRule struct{}
-
-func (AsyncSucceedRule) isApply(gexp *expression.GomegaExpression) bool {
- return gexp.IsAsync() &&
- gexp.MatcherTypeIs(matcher.SucceedMatcherType) &&
- gexp.ActualArgTypeIs(actual.FuncSigArgType) &&
- !gexp.ActualArgTypeIs(actual.ErrorTypeArgType|actual.GomegaParamArgType)
-}
-
-func (r AsyncSucceedRule) Apply(gexp *expression.GomegaExpression, _ types.Config, reportBuilder *reports.Builder) bool {
- if r.isApply(gexp) {
- if gexp.ActualArgTypeIs(actual.MultiRetsArgType) {
- reportBuilder.AddIssue(false, "Success matcher does not support multiple values")
- } else {
- reportBuilder.AddIssue(false, "Success matcher only support a single error value, or function with Gomega as its first parameter")
- }
- }
-
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asynctimeintervalsrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asynctimeintervalsrule.go
deleted file mode 100644
index 45953ec01..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/asynctimeintervalsrule.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package rules
-
-import (
- "go/ast"
- "time"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/intervals"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const (
- multipleTimeouts = "timeout defined more than once"
- multiplePolling = "polling defined more than once"
- onlyUseTimeDurationForInterval = "only use time.Duration for timeout and polling in Eventually() or Consistently()"
- pollingGreaterThanTimeout = "timeout must not be shorter than the polling interval"
-)
-
-type AsyncTimeIntervalsRule struct{}
-
-func (r AsyncTimeIntervalsRule) isApplied(gexp *expression.GomegaExpression, config types.Config) bool {
- return !bool(config.SuppressAsync) && bool(config.ValidateAsyncIntervals) && gexp.IsAsync()
-}
-
-func (r AsyncTimeIntervalsRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if r.isApplied(gexp, config) {
- asyncArg := gexp.GetAsyncActualArg()
- if asyncArg.TooManyTimeouts() {
- reportBuilder.AddIssue(false, multipleTimeouts)
- }
-
- if asyncArg.TooManyPolling() {
- reportBuilder.AddIssue(false, multiplePolling)
- }
-
- timeoutDuration := checkInterval(gexp, asyncArg.Timeout(), reportBuilder)
- pollingDuration := checkInterval(gexp, asyncArg.Polling(), reportBuilder)
-
- if timeoutDuration > 0 && pollingDuration > 0 && pollingDuration > timeoutDuration {
- reportBuilder.AddIssue(false, pollingGreaterThanTimeout)
- }
- }
-
- return false
-}
-
-func checkInterval(gexp *expression.GomegaExpression, durVal intervals.DurationValue, reportBuilder *reports.Builder) time.Duration {
- if durVal != nil {
- switch to := durVal.(type) {
- case *intervals.RealDurationValue, *intervals.UnknownDurationTypeValue:
-
- case *intervals.NumericDurationValue:
- if checkNumericInterval(gexp.GetActualClone(), to) {
- reportBuilder.AddIssue(true, onlyUseTimeDurationForInterval)
- }
-
- case *intervals.UnknownDurationValue:
- reportBuilder.AddIssue(true, onlyUseTimeDurationForInterval)
- }
-
- return durVal.Duration()
- }
-
- return 0
-}
-
-func checkNumericInterval(intervalMethod *ast.CallExpr, interval intervals.DurationValue) bool {
- if interval != nil {
- if numVal, ok := interval.(intervals.NumericValue); ok {
- if offset := numVal.GetOffset(); offset > 0 {
- intervalMethod.Args[offset] = numVal.GetDurationExpr()
- return true
- }
- }
- }
-
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/caprule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/caprule.go
deleted file mode 100644
index e3ad45d96..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/caprule.go
+++ /dev/null
@@ -1,128 +0,0 @@
-package rules
-
-import (
- "go/token"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const wrongCapWarningTemplate = "wrong cap assertion"
-
-// CapRule does not allow using the cap() function in actual with numeric comparison.
-// it suggests to use the HaveLen matcher, instead.
-type CapRule struct{}
-
-func (r *CapRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
-
- if !r.isApplied(gexp, config) {
- return false
- }
-
- if r.fixExpression(gexp) {
- reportBuilder.AddIssue(true, wrongCapWarningTemplate)
- return true
- }
- return false
-}
-
-func (r *CapRule) isApplied(gexp *expression.GomegaExpression, config types.Config) bool {
- if config.SuppressLen {
- return false
- }
-
- //matcherType := gexp.matcher.GetMatcherInfo().Type()
- if gexp.ActualArgTypeIs(actual.CapFuncActualArgType) {
- if gexp.MatcherTypeIs(matcher.EqualMatcherType | matcher.BeZeroMatcherType) {
- return true
- }
-
- if gexp.MatcherTypeIs(matcher.BeNumericallyMatcherType) {
- mtchr := gexp.GetMatcherInfo().(*matcher.BeNumericallyMatcher)
- return mtchr.GetOp() == token.EQL || mtchr.GetOp() == token.NEQ || gexp.MatcherTypeIs(matcher.EqualZero|matcher.GreaterThanZero)
- }
- }
-
- if gexp.ActualArgTypeIs(actual.CapComparisonActualArgType) && gexp.MatcherTypeIs(matcher.BeTrueMatcherType|matcher.BeFalseMatcherType|matcher.EqualBoolValueMatcherType) {
- return true
- }
-
- return false
-}
-
-func (r *CapRule) fixExpression(gexp *expression.GomegaExpression) bool {
- if gexp.ActualArgTypeIs(actual.CapFuncActualArgType) {
- return r.fixEqual(gexp)
- }
-
- if gexp.ActualArgTypeIs(actual.CapComparisonActualArgType) {
- return r.fixComparison(gexp)
- }
-
- return false
-}
-
-func (r *CapRule) fixEqual(gexp *expression.GomegaExpression) bool {
- matcherInfo := gexp.GetMatcherInfo()
- switch mtchr := matcherInfo.(type) {
- case *matcher.EqualMatcher:
- gexp.SetMatcherCap(mtchr.GetValueExpr())
-
- case *matcher.BeZeroMatcher:
- gexp.SetMatcherCapZero()
-
- case *matcher.BeNumericallyMatcher:
- if !r.handleBeNumerically(gexp, mtchr) {
- return false
- }
-
- default:
- return false
- }
-
- gexp.ReplaceActualWithItsFirstArg()
-
- return true
-}
-
-func (r *CapRule) fixComparison(gexp *expression.GomegaExpression) bool {
- actl := gexp.GetActualArg().(*actual.FuncComparisonPayload)
- if op := actl.GetOp(); op == token.NEQ {
- gexp.ReverseAssertionFuncLogic()
- } else if op != token.EQL {
- return false
- }
-
- gexp.SetMatcherCap(actl.GetValueExpr())
- gexp.ReplaceActual(actl.GetFuncArg())
-
- if gexp.MatcherTypeIs(matcher.BoolValueFalse) {
- gexp.ReverseAssertionFuncLogic()
- }
-
- return true
-}
-
-func (r *CapRule) handleBeNumerically(gexp *expression.GomegaExpression, matcher *matcher.BeNumericallyMatcher) bool {
- op := matcher.GetOp()
- val := matcher.GetValue()
- isValZero := val.String() == "0"
- isValOne := val.String() == "1"
-
- if (op == token.GTR && isValZero) || (op == token.GEQ && isValOne) {
- gexp.ReverseAssertionFuncLogic()
- gexp.SetMatcherCapZero()
- } else if op == token.EQL {
- gexp.SetMatcherCap(matcher.GetValueExpr())
- } else if op == token.NEQ {
- gexp.ReverseAssertionFuncLogic()
- gexp.SetMatcherCap(matcher.GetValueExpr())
- } else {
- return false
- }
-
- return true
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/comparepointerrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/comparepointerrule.go
deleted file mode 100644
index dcbea1bc9..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/comparepointerrule.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const comparePointerToValue = "comparing a pointer to a value will always fail"
-
-type ComparePointRule struct{}
-
-func (r ComparePointRule) isApplied(gexp *expression.GomegaExpression) bool {
- actl, ok := gexp.GetActualArg().(*actual.RegularArgPayload)
- if !ok {
- return false
- }
-
- return actl.IsPointer()
-}
-
-func (r ComparePointRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp) {
- return false
- }
-
- switch mtchr := gexp.GetMatcherInfo().(type) {
- case *matcher.EqualMatcher:
- if mtchr.IsPointer() || mtchr.IsInterface() {
- return false
- }
-
- case *matcher.BeEquivalentToMatcher:
- if mtchr.IsPointer() || mtchr.IsInterface() || mtchr.IsNil() {
- return false
- }
-
- case *matcher.BeIdenticalToMatcher:
- if mtchr.IsPointer() || mtchr.IsInterface() || mtchr.IsNil() {
- return false
- }
-
- case *matcher.EqualNilMatcher:
- return false
-
- case *matcher.BeTrueMatcher,
- *matcher.BeFalseMatcher,
- *matcher.BeNumericallyMatcher,
- *matcher.EqualTrueMatcher,
- *matcher.EqualFalseMatcher:
-
- default:
- return false
- }
-
- getMatcherOnlyRules().Apply(gexp, config, reportBuilder)
-
- gexp.SetMatcherHaveValue()
- reportBuilder.AddIssue(true, comparePointerToValue)
-
- return true
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/comparisonrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/comparisonrule.go
deleted file mode 100644
index fb38529e0..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/comparisonrule.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package rules
-
-import (
- "go/token"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const wrongCompareWarningTemplate = "wrong comparison assertion"
-
-type ComparisonRule struct{}
-
-func (r ComparisonRule) isApplied(gexp *expression.GomegaExpression, config types.Config) bool {
- if config.SuppressCompare {
- return false
- }
-
- return gexp.ActualArgTypeIs(actual.ComparisonActualArgType)
-}
-
-func (r ComparisonRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp, config) {
- return false
- }
-
- actl, ok := gexp.GetActualArg().(actual.ComparisonActualPayload)
- if !ok {
- return false
- }
-
- switch actl.GetOp() {
- case token.EQL:
- r.handleEqualComparison(gexp, actl)
-
- case token.NEQ:
- gexp.ReverseAssertionFuncLogic()
- r.handleEqualComparison(gexp, actl)
- case token.GTR, token.GEQ, token.LSS, token.LEQ:
- if !actl.GetRight().IsValueNumeric() {
- return false
- }
-
- gexp.SetMatcherBeNumerically(actl.GetOp(), actl.GetRight().GetValueExpr())
-
- default:
- return false
- }
-
- if gexp.MatcherTypeIs(matcher.BoolValueFalse) {
- gexp.ReverseAssertionFuncLogic()
- }
-
- gexp.ReplaceActual(actl.GetLeft().GetValueExpr())
-
- reportBuilder.AddIssue(true, wrongCompareWarningTemplate)
- return true
-}
-
-func (r ComparisonRule) handleEqualComparison(gexp *expression.GomegaExpression, actual actual.ComparisonActualPayload) {
- if actual.GetRight().IsValueZero() {
- gexp.SetMatcherBeZero()
- } else {
- left := actual.GetLeft()
- arg := actual.GetRight().GetValueExpr()
- if left.IsInterface() || left.IsPointer() {
- gexp.SetMatcherBeIdenticalTo(arg)
- } else {
- gexp.SetMatcherEqual(arg)
- }
- }
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/doublenegativerule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/doublenegativerule.go
deleted file mode 100644
index 6ce7be5a5..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/doublenegativerule.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const doubleNegativeWarningTemplate = "avoid double negative assertion"
-
-type DoubleNegativeRule struct{}
-
-func (DoubleNegativeRule) isApplied(gexp *expression.GomegaExpression) bool {
- return gexp.MatcherTypeIs(matcher.BeFalseMatcherType) &&
- gexp.IsNegativeAssertion()
-}
-
-func (r DoubleNegativeRule) Apply(gexp *expression.GomegaExpression, _ types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp) {
- return false
- }
-
- gexp.ReverseAssertionFuncLogic()
- gexp.SetMatcherBeTrue()
-
- reportBuilder.AddIssue(true, doubleNegativeWarningTemplate)
-
- return true
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equalboolrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equalboolrule.go
deleted file mode 100644
index e9eaa1b80..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equalboolrule.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const wrongBoolWarningTemplate = "wrong boolean assertion"
-
-type EqualBoolRule struct{}
-
-func (r EqualBoolRule) isApplied(gexp *expression.GomegaExpression) bool {
- return gexp.MatcherTypeIs(matcher.EqualBoolValueMatcherType)
-}
-
-func (r EqualBoolRule) Apply(gexp *expression.GomegaExpression, _ types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp) {
- return false
- }
-
- if gexp.MatcherTypeIs(matcher.BoolValueTrue) {
- gexp.SetMatcherBeTrue()
- } else {
- if gexp.IsNegativeAssertion() {
- gexp.ReverseAssertionFuncLogic()
- gexp.SetMatcherBeTrue()
- } else {
- gexp.SetMatcherBeFalse()
- }
- }
-
- reportBuilder.AddIssue(true, wrongBoolWarningTemplate)
- return true
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equaldifferenttypesrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equaldifferenttypesrule.go
deleted file mode 100644
index 81d703bb8..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equaldifferenttypesrule.go
+++ /dev/null
@@ -1,119 +0,0 @@
-package rules
-
-import (
- gotypes "go/types"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const compareDifferentTypes = "use %[1]s with different types: Comparing %[2]s with %[3]s; either change the expected value type if possible, or use the BeEquivalentTo() matcher, instead of %[1]s()"
-
-type EqualDifferentTypesRule struct{}
-
-func (r EqualDifferentTypesRule) isApplied(config types.Config) bool {
- return !bool(config.SuppressTypeCompare)
-}
-
-func (r EqualDifferentTypesRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(config) {
- return false
- }
-
- return r.checkEqualDifferentTypes(gexp, gexp.GetMatcher(), false, reportBuilder)
-}
-
-func (r EqualDifferentTypesRule) checkEqualDifferentTypes(gexp *expression.GomegaExpression, mtchr *matcher.Matcher, parentPointer bool, reportBuilder *reports.Builder) bool {
- actualType := gexp.GetActualArgGOType()
-
- if parentPointer {
- if t, ok := actualType.(*gotypes.Pointer); ok {
- actualType = t.Elem()
- }
- }
-
- var (
- matcherType gotypes.Type
- matcherName string
- )
-
- switch specificMatcher := mtchr.GetMatcherInfo().(type) {
- case *matcher.EqualMatcher:
- matcherType = specificMatcher.GetType()
- matcherName = specificMatcher.MatcherName()
-
- case *matcher.BeIdenticalToMatcher:
- matcherType = specificMatcher.GetType()
- matcherName = specificMatcher.MatcherName()
-
- case *matcher.HaveValueMatcher:
- return r.checkEqualDifferentTypes(gexp, specificMatcher.GetNested(), true, reportBuilder)
-
- case *matcher.MultipleMatchersMatcher:
- foundIssue := false
- for i := range specificMatcher.Len() {
- if r.checkEqualDifferentTypes(gexp, specificMatcher.At(i), parentPointer, reportBuilder) {
- foundIssue = true
- }
-
- }
- return foundIssue
-
- case *matcher.EqualNilMatcher:
- matcherType = specificMatcher.GetType()
- matcherName = specificMatcher.MatcherName()
-
- case *matcher.WithTransformMatcher:
- nested := specificMatcher.GetNested()
- switch specificNested := nested.GetMatcherInfo().(type) {
- case *matcher.EqualMatcher:
- matcherType = specificNested.GetType()
- matcherName = specificNested.MatcherName()
-
- case *matcher.BeIdenticalToMatcher:
- matcherType = specificNested.GetType()
- matcherName = specificNested.MatcherName()
-
- default:
- return false
- }
-
- actualType = specificMatcher.GetFuncType()
- default:
- return false
- }
-
- if !gotypes.Identical(matcherType, actualType) {
- if r.isImplementing(matcherType, actualType) || r.isImplementing(actualType, matcherType) {
- return false
- }
-
- reportBuilder.AddIssue(false, compareDifferentTypes, matcherName, actualType, matcherType)
- return true
- }
-
- return false
-}
-
-func (r EqualDifferentTypesRule) isImplementing(ifs, impl gotypes.Type) bool {
- if gotypes.IsInterface(ifs) {
-
- var (
- theIfs *gotypes.Interface
- ok bool
- )
-
- for {
- theIfs, ok = ifs.(*gotypes.Interface)
- if ok {
- break
- }
- ifs = ifs.Underlying()
- }
-
- return gotypes.Implements(impl, theIfs)
- }
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equalnilrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equalnilrule.go
deleted file mode 100644
index 5b28e7d9b..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/equalnilrule.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-// EqualNilRule validate that there is no use of Equal(nil) in the code
-// It is part of assertion only rules
-type EqualNilRule struct{}
-
-func (r EqualNilRule) isApplied(gexp *expression.GomegaExpression, config types.Config) bool {
- return !bool(config.SuppressNil) &&
- gexp.MatcherTypeIs(matcher.EqualValueMatcherType)
-}
-
-func (r EqualNilRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp, config) {
- return false
- }
-
- gexp.SetMatcherBeNil()
-
- reportBuilder.AddIssue(true, wrongNilWarningTemplate)
-
- return true
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/errorequalnilrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/errorequalnilrule.go
deleted file mode 100644
index 81932cc2c..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/errorequalnilrule.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/expression/value"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-type ErrorEqualNilRule struct{}
-
-func (ErrorEqualNilRule) isApplied(gexp *expression.GomegaExpression, config types.Config) bool {
- if config.SuppressErr {
- return false
- }
-
- if !gexp.IsAsync() && gexp.ActualArgTypeIs(actual.FuncSigArgType) {
- return false
- }
-
- return gexp.ActualArgTypeIs(actual.ErrorTypeArgType) &&
- gexp.MatcherTypeIs(matcher.BeNilMatcherType|matcher.EqualNilMatcherType)
-}
-
-func (r ErrorEqualNilRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp, config) {
- return false
- }
-
- if v, ok := gexp.GetActualArg().(value.Valuer); ok && v.IsFunc() || gexp.ActualArgTypeIs(actual.ErrFuncActualArgType) {
- gexp.SetMatcherSucceed()
- } else {
- gexp.ReverseAssertionFuncLogic()
- gexp.SetMatcherHaveOccurred()
- }
-
- reportBuilder.AddIssue(true, wrongErrWarningTemplate)
-
- return true
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/forceexpecttorule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/forceexpecttorule.go
deleted file mode 100644
index 391d1d449..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/forceexpecttorule.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const forceExpectToTemplate = "must not use %s with %s"
-
-type ForceExpectToRule struct{}
-
-func (ForceExpectToRule) isApplied(gexp *expression.GomegaExpression, config types.Config) bool {
- if !config.ForceExpectTo {
- return false
- }
-
- actlName := gexp.GetActualFuncName()
- return actlName == "Expect" || actlName == "ExpectWithOffset"
-}
-
-func (r ForceExpectToRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp, config) {
- return false
- }
-
- var newName string
-
- switch gexp.GetAssertFuncName() {
- case "Should":
- newName = "To"
- case "ShouldNot":
- newName = "ToNot"
- default:
- return false
- }
-
- gexp.ReplaceAssertionMethod(newName)
- reportBuilder.AddIssue(true, forceExpectToTemplate, gexp.GetActualFuncName(), gexp.GetOrigAssertFuncName())
-
- // always return false, to keep checking another rules.
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/havelen0.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/havelen0.go
deleted file mode 100644
index 20bcb7211..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/havelen0.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-type HaveLen0 struct{}
-
-func (r *HaveLen0) isApplied(gexp *expression.GomegaExpression, config types.Config) bool {
- return gexp.MatcherTypeIs(matcher.HaveLenZeroMatcherType) && !bool(config.AllowHaveLen0)
-}
-
-func (r *HaveLen0) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp, config) {
- return false
- }
- gexp.SetMatcherBeEmpty()
- reportBuilder.AddIssue(true, wrongLengthWarningTemplate)
- return true
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/haveoccurredrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/haveoccurredrule.go
deleted file mode 100644
index 437d3ee23..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/haveoccurredrule.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-type HaveOccurredRule struct{}
-
-func (r HaveOccurredRule) isApplied(gexp *expression.GomegaExpression) bool {
- return gexp.MatcherTypeIs(matcher.HaveOccurredMatcherType)
-}
-
-func (r HaveOccurredRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp) {
- return false
- }
-
- if !gexp.ActualArgTypeIs(actual.ErrorTypeArgType) {
- reportBuilder.AddIssue(false, "asserting a non-error type with HaveOccurred matcher")
- return true
- }
-
- if bool(config.ForceSucceedForFuncs) && gexp.GetActualArg().(*actual.ErrPayload).IsFunc() {
- gexp.ReverseAssertionFuncLogic()
- gexp.SetMatcherSucceed()
- reportBuilder.AddIssue(true, "prefer using the Succeed matcher for error function, instead of HaveOccurred")
- return true
- }
-
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/lenrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/lenrule.go
deleted file mode 100644
index 06d6f2c68..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/lenrule.go
+++ /dev/null
@@ -1,119 +0,0 @@
-package rules
-
-import (
- "go/token"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const wrongLengthWarningTemplate = "wrong length assertion"
-
-// LenRule does not allow using the len() function in actual with numeric comparison. Instead,
-// it suggests to use the HaveLen matcher, or the BeEmpty matcher, if comparing to zero.
-type LenRule struct{}
-
-func (r *LenRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
-
- if !r.isApplied(gexp, config) {
- return false
- }
-
- if r.fixExpression(gexp) {
- reportBuilder.AddIssue(true, wrongLengthWarningTemplate)
- return true
- }
- return false
-}
-
-func (r *LenRule) isApplied(gexp *expression.GomegaExpression, config types.Config) bool {
- if config.SuppressLen {
- return false
- }
-
- if gexp.ActualArgTypeIs(actual.LenFuncActualArgType) {
- if gexp.MatcherTypeIs(matcher.EqualMatcherType | matcher.BeZeroMatcherType) {
- return true
- }
-
- if gexp.MatcherTypeIs(matcher.BeNumericallyMatcherType) {
- mtchr := gexp.GetMatcherInfo().(*matcher.BeNumericallyMatcher)
- return mtchr.GetOp() == token.EQL || mtchr.GetOp() == token.NEQ || gexp.MatcherTypeIs(matcher.EqualZero|matcher.GreaterThanZero)
- }
- }
-
- if gexp.ActualArgTypeIs(actual.LenComparisonActualArgType) && gexp.MatcherTypeIs(matcher.BeTrueMatcherType|matcher.BeFalseMatcherType|matcher.EqualBoolValueMatcherType) {
- return true
- }
-
- return false
-}
-
-func (r *LenRule) fixExpression(gexp *expression.GomegaExpression) bool {
- if gexp.ActualArgTypeIs(actual.LenFuncActualArgType) {
- return r.fixEqual(gexp)
- }
-
- if gexp.ActualArgTypeIs(actual.LenComparisonActualArgType) {
- return r.fixComparison(gexp)
- }
-
- return false
-}
-
-func (r *LenRule) fixEqual(gexp *expression.GomegaExpression) bool {
-
- if gexp.MatcherTypeIs(matcher.EqualMatcherType) {
- gexp.SetLenNumericMatcher()
-
- } else if gexp.MatcherTypeIs(matcher.BeZeroMatcherType) {
- gexp.SetMatcherBeEmpty()
-
- } else if gexp.MatcherTypeIs(matcher.BeNumericallyMatcherType) {
- mtchr := gexp.GetMatcherInfo().(*matcher.BeNumericallyMatcher)
- op := mtchr.GetOp()
-
- if op == token.EQL {
- gexp.SetLenNumericMatcher()
- } else if op == token.NEQ {
- gexp.ReverseAssertionFuncLogic()
- gexp.SetLenNumericMatcher()
- } else if gexp.MatcherTypeIs(matcher.GreaterThanZero) {
- gexp.ReverseAssertionFuncLogic()
- gexp.SetMatcherBeEmpty()
- } else {
- return false
- }
- } else {
- return false
- }
-
- gexp.ReplaceActualWithItsFirstArg()
- return true
-}
-
-func (r *LenRule) fixComparison(gexp *expression.GomegaExpression) bool {
- actl := gexp.GetActualArg().(*actual.FuncComparisonPayload)
- if op := actl.GetOp(); op == token.NEQ {
- gexp.ReverseAssertionFuncLogic()
- } else if op != token.EQL {
- return false
- }
-
- if gexp.MatcherTypeIs(matcher.BoolValueFalse) {
- gexp.ReverseAssertionFuncLogic()
- }
-
- if actl.IsValueZero() {
- gexp.SetMatcherBeEmpty()
- } else {
- gexp.SetMatcherLen(actl.GetValueExpr())
- }
-
- gexp.ReplaceActual(actl.GetFuncArg())
-
- return true
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/matcheronlyrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/matcheronlyrule.go
deleted file mode 100644
index 1174393c6..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/matcheronlyrule.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package rules
-
-var matcherOnlyRules = Rules{
- &HaveLen0{},
- &EqualBoolRule{},
- &EqualNilRule{},
- &DoubleNegativeRule{},
-}
-
-func getMatcherOnlyRules() Rules {
- return matcherOnlyRules
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/matcherrorrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/matcherrorrule.go
deleted file mode 100644
index 767b4b621..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/matcherrorrule.go
+++ /dev/null
@@ -1,110 +0,0 @@
-package rules
-
-import (
- "go/ast"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const (
- matchErrorArgWrongType = "the MatchError matcher used to assert a non error type (%s)"
- matchErrorWrongTypeAssertion = "MatchError first parameter (%s) must be error, string, GomegaMatcher or func(error)bool are allowed"
- matchErrorMissingDescription = "missing function description as second parameter of MatchError"
- matchErrorRedundantArg = "redundant MatchError arguments; consider removing them"
- matchErrorNoFuncDescription = "The second parameter of MatchError must be the function description (string)"
-)
-
-// MatchErrorRule validates the usage of the MatchError matcher.
-//
-// # First, it checks that the actual value is actually an error
-//
-// Then, it checks the matcher itself: this matcher can be used in 3 different ways:
-// 1. With error type variable
-// 2. With another gomega matcher, to check the actual err.Error() value
-// 3. With function with a signature of func(error) bool. In this case, additional description
-// string variable is required.
-type MatchErrorRule struct{}
-
-func (r MatchErrorRule) isApplied(gexp *expression.GomegaExpression) bool {
- return gexp.MatcherTypeIs(matcher.MatchErrorMatcherType | matcher.MultipleMatcherMatherType)
-}
-
-func (r MatchErrorRule) Apply(gexp *expression.GomegaExpression, _ types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp) {
- return false
- }
-
- return checkMatchError(gexp, reportBuilder)
-}
-
-func checkMatchError(gexp *expression.GomegaExpression, reportBuilder *reports.Builder) bool {
- mtchr := gexp.GetMatcherInfo()
- switch m := mtchr.(type) {
- case matcher.MatchErrorMatcher:
- return checkMatchErrorMatcher(gexp, gexp.GetMatcher(), m, reportBuilder)
-
- case *matcher.MultipleMatchersMatcher:
- res := false
- for i := range m.Len() {
- nested := m.At(i)
- if specific, ok := nested.GetMatcherInfo().(matcher.MatchErrorMatcher); ok {
- if valid := checkMatchErrorMatcher(gexp, gexp.GetMatcher(), specific, reportBuilder); valid {
- res = true
- }
- }
- }
- return res
- default:
- return false
- }
-}
-
-func checkMatchErrorMatcher(gexp *expression.GomegaExpression, mtchr *matcher.Matcher, mtchrInfo matcher.MatchErrorMatcher, reportBuilder *reports.Builder) bool {
- if !gexp.ActualArgTypeIs(actual.ErrorTypeArgType) {
- reportBuilder.AddIssue(false, matchErrorArgWrongType, reportBuilder.FormatExpr(gexp.GetActualArgExpr()))
- }
-
- switch m := mtchrInfo.(type) {
- case *matcher.InvalidMatchErrorMatcher:
- reportBuilder.AddIssue(false, matchErrorWrongTypeAssertion, reportBuilder.FormatExpr(mtchr.Clone.Args[0]))
-
- case *matcher.MatchErrorMatcherWithErrFunc:
- if m.NumArgs() == m.AllowedNumArgs() {
- if !m.IsSecondArgString() {
- reportBuilder.AddIssue(false, matchErrorNoFuncDescription)
- }
- return true
- }
-
- if m.NumArgs() == 1 {
- reportBuilder.AddIssue(false, matchErrorMissingDescription)
- return true
- }
-
- case *matcher.MatchErrorMatcherWithErr,
- *matcher.MatchErrorMatcherWithMatcher,
- *matcher.MatchErrorMatcherWithString:
- // continue
- default:
- return false
- }
-
- if mtchrInfo.NumArgs() == mtchrInfo.AllowedNumArgs() {
- return true
- }
-
- if mtchrInfo.NumArgs() > mtchrInfo.AllowedNumArgs() {
- var newArgsSuggestion []ast.Expr
- for i := 0; i < mtchrInfo.AllowedNumArgs(); i++ {
- newArgsSuggestion = append(newArgsSuggestion, mtchr.Clone.Args[i])
- }
- mtchr.Clone.Args = newArgsSuggestion
- reportBuilder.AddIssue(false, matchErrorRedundantArg)
- return true
- }
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/missingassertionrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/missingassertionrule.go
deleted file mode 100644
index 43fc58bf6..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/missingassertionrule.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/gomegainfo"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const missingAssertionMessage = `%q: missing assertion method. Expected %s`
-
-type MissingAssertionRule struct{}
-
-func (r MissingAssertionRule) isApplied(gexp *expression.GomegaExpression) bool {
- return gexp.IsMissingAssertion()
-}
-
-func (r MissingAssertionRule) Apply(gexp *expression.GomegaExpression, _ types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp) {
- return false
- }
-
- actualMethodName := gexp.GetActualFuncName()
- reportBuilder.AddIssue(false, missingAssertionMessage, actualMethodName, gomegainfo.GetAllowedAssertionMethods(actualMethodName))
-
- return true
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/nilcomparerule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/nilcomparerule.go
deleted file mode 100644
index fc3cd49e5..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/nilcomparerule.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package rules
-
-import (
- "go/token"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-const (
- wrongNilWarningTemplate = "wrong nil assertion"
- wrongErrWarningTemplate = "wrong error assertion"
-)
-
-type NilCompareRule struct{}
-
-func (r NilCompareRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- isErr, ruleApplied := r.isApplied(gexp, config)
- if !ruleApplied {
- return false
- }
-
- if gexp.MatcherTypeIs(matcher.BoolValueFalse) {
- gexp.ReverseAssertionFuncLogic()
- }
-
- r.handleNilBeBoolMatcher(gexp, gexp.GetActualArg().(*actual.NilComparisonPayload), reportBuilder, isErr)
-
- return true
-}
-
-func (r NilCompareRule) isApplied(gexp *expression.GomegaExpression, config types.Config) (bool, bool) {
- if !gexp.MatcherTypeIs(matcher.EqualBoolValueMatcherType | matcher.BeTrueMatcherType | matcher.BeFalseMatcherType) {
- return false, false
- }
-
- actl, ok := gexp.GetActualArg().(*actual.NilComparisonPayload)
- if !ok {
- return false, false
- }
-
- isErr := actl.IsError() && !bool(config.SuppressErr)
-
- if !isErr && bool(config.SuppressNil) {
- return isErr, false
- }
-
- return isErr, true
-}
-
-func (r NilCompareRule) handleNilBeBoolMatcher(gexp *expression.GomegaExpression, actl *actual.NilComparisonPayload, reportBuilder *reports.Builder, isErr bool) {
- template := wrongNilWarningTemplate
- if isErr {
- template = wrongErrWarningTemplate
- if actl.IsFunc() {
- gexp.SetMatcherSucceed()
- } else {
- gexp.ReverseAssertionFuncLogic()
- gexp.SetMatcherHaveOccurred()
- }
- } else {
- gexp.SetMatcherBeNil()
- }
-
- gexp.ReplaceActual(actl.GetValueExpr())
-
- if actl.GetOp() == token.NEQ {
- gexp.ReverseAssertionFuncLogic()
- }
-
- reportBuilder.AddIssue(true, template)
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/rule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/rule.go
deleted file mode 100644
index cf331c21c..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/rule.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-type Rule interface {
- Apply(*expression.GomegaExpression, types.Config, *reports.Builder) bool
-}
-
-var rules = Rules{
- &ForceExpectToRule{},
- &LenRule{},
- &CapRule{},
- &ComparisonRule{},
- &NilCompareRule{},
- &ComparePointRule{},
- &ErrorEqualNilRule{},
- &MatchErrorRule{},
- getMatcherOnlyRules(),
- &EqualDifferentTypesRule{},
- &HaveOccurredRule{},
- &SucceedRule{},
-}
-
-var asyncRules = Rules{
- &AsyncFuncCallRule{},
- &AsyncTimeIntervalsRule{},
- &ErrorEqualNilRule{},
- &MatchErrorRule{},
- &AsyncSucceedRule{},
- getMatcherOnlyRules(),
-}
-
-func GetRules() Rules {
- return rules
-}
-
-func GetAsyncRules() Rules {
- return asyncRules
-}
-
-type Rules []Rule
-
-func (r Rules) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- for _, rule := range r {
- if rule.Apply(gexp, config, reportBuilder) {
- return true
- }
- }
-
- return false
-}
-
-var missingAssertionRule = MissingAssertionRule{}
-
-func GetMissingAssertionRule() Rule {
- return missingAssertionRule
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/succeedrule.go b/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/succeedrule.go
deleted file mode 100644
index 6a5167a8a..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/internal/rules/succeedrule.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package rules
-
-import (
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/expression/actual"
- "github.com/nunnatsa/ginkgolinter/internal/expression/matcher"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-type SucceedRule struct{}
-
-func (r SucceedRule) isApplied(gexp *expression.GomegaExpression) bool {
- return !gexp.IsAsync() && gexp.MatcherTypeIs(matcher.SucceedMatcherType)
-}
-
-func (r SucceedRule) Apply(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder) bool {
- if !r.isApplied(gexp) {
- return false
- }
-
- if !gexp.ActualArgTypeIs(actual.ErrorTypeArgType) {
- if gexp.IsActualTuple() {
- reportBuilder.AddIssue(false, "the Success matcher does not support multiple values")
- } else {
- reportBuilder.AddIssue(false, "asserting a non-error type with Succeed matcher")
- }
- return true
- }
-
- if bool(config.ForceSucceedForFuncs) && !gexp.GetActualArg().(*actual.ErrPayload).IsFunc() {
- gexp.ReverseAssertionFuncLogic()
- gexp.SetMatcherHaveOccurred()
-
- reportBuilder.AddIssue(true, "prefer using the HaveOccurred matcher for non-function error value, instead of Succeed")
-
- return true
- }
-
- return false
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/linter/ginkgo_linter.go b/vendor/github.com/nunnatsa/ginkgolinter/linter/ginkgo_linter.go
deleted file mode 100644
index 188b2b5f9..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/linter/ginkgo_linter.go
+++ /dev/null
@@ -1,131 +0,0 @@
-package linter
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
-
- "github.com/nunnatsa/ginkgolinter/internal/expression"
- "github.com/nunnatsa/ginkgolinter/internal/formatter"
- "github.com/nunnatsa/ginkgolinter/internal/ginkgohandler"
- "github.com/nunnatsa/ginkgolinter/internal/gomegahandler"
- "github.com/nunnatsa/ginkgolinter/internal/reports"
- "github.com/nunnatsa/ginkgolinter/internal/rules"
- "github.com/nunnatsa/ginkgolinter/types"
-)
-
-// The ginkgolinter enforces standards of using ginkgo and gomega.
-//
-// For more details, look at the README.md file
-
-type GinkgoLinter struct {
- config *types.Config
-}
-
-// NewGinkgoLinter return new ginkgolinter object
-func NewGinkgoLinter(config *types.Config) *GinkgoLinter {
- return &GinkgoLinter{
- config: config,
- }
-}
-
-// Run is the main assertion function
-func (l *GinkgoLinter) Run(pass *analysis.Pass) (any, error) {
- for _, file := range pass.Files {
- fileConfig := l.config.Clone()
-
- cm := ast.NewCommentMap(pass.Fset, file, file.Comments)
-
- fileConfig.UpdateFromFile(cm)
-
- gomegaHndlr := gomegahandler.GetGomegaHandler(file, pass)
- ginkgoHndlr := ginkgohandler.GetGinkgoHandler(file)
-
- if gomegaHndlr == nil && ginkgoHndlr == nil { // no gomega or ginkgo imports => no use in gomega in this file; nothing to do here
- continue
- }
-
- ast.Inspect(file, func(n ast.Node) bool {
- if ginkgoHndlr != nil {
- goDeeper := false
- spec, ok := n.(*ast.ValueSpec)
- if ok {
- for _, val := range spec.Values {
- goDeeper = ginkgoHndlr.HandleGinkgoSpecs(val, fileConfig, pass) || goDeeper
- }
- }
- if goDeeper {
- return true
- }
- }
-
- stmt, ok := n.(*ast.ExprStmt)
- if !ok {
- return true
- }
-
- // search for function calls
- assertionExp, ok := stmt.X.(*ast.CallExpr)
- if !ok {
- return true
- }
-
- config := fileConfig.Clone()
- if comments, ok := cm[stmt]; ok {
- config.UpdateFromComment(comments)
- }
-
- if ginkgoHndlr != nil {
- if ginkgoHndlr.HandleGinkgoSpecs(assertionExp, config, pass) {
- return true
- }
- }
-
- // no more ginkgo checks. From here it's only gomega. So if there is no gomega handler, exit here.
- if gomegaHndlr == nil {
- return true
- }
-
- gexp, ok := expression.New(assertionExp, pass, gomegaHndlr, getTimePkg(file))
- if !ok || gexp == nil {
- return true
- }
-
- reportBuilder := reports.NewBuilder(assertionExp, formatter.NewGoFmtFormatter(pass.Fset))
- return checkGomegaExpression(gexp, config, reportBuilder, pass)
- })
- }
- return nil, nil
-}
-
-func checkGomegaExpression(gexp *expression.GomegaExpression, config types.Config, reportBuilder *reports.Builder, pass *analysis.Pass) bool {
- goNested := false
- if rules.GetMissingAssertionRule().Apply(gexp, config, reportBuilder) {
- goNested = true
- } else {
- if gexp.IsAsync() {
- rules.GetAsyncRules().Apply(gexp, config, reportBuilder)
- goNested = true
- } else {
- rules.GetRules().Apply(gexp, config, reportBuilder)
- }
- }
-
- if reportBuilder.HasReport() {
- reportBuilder.SetFixOffer(gexp.GetClone())
- pass.Report(reportBuilder.Build())
- }
-
- return goNested
-}
-
-func getTimePkg(file *ast.File) string {
- timePkg := "time"
- for _, imp := range file.Imports {
- if imp.Path.Value == `"time"` && imp.Name != nil {
- timePkg = imp.Name.Name
- }
- }
-
- return timePkg
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/types/boolean.go b/vendor/github.com/nunnatsa/ginkgolinter/types/boolean.go
deleted file mode 100644
index be510c4e9..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/types/boolean.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package types
-
-import (
- "errors"
- "strings"
-)
-
-// Boolean is a bool, implementing the flag.Value interface, to be used as a flag var.
-type Boolean bool
-
-func (b *Boolean) Set(value string) error {
- if b == nil {
- return errors.New("trying to set nil parameter")
- }
- switch strings.ToLower(value) {
- case "true":
- *b = true
- case "false":
- *b = false
- default:
- return errors.New(value + " is not a Boolean value")
-
- }
- return nil
-}
-
-func (b Boolean) String() string {
- if b {
- return "true"
- }
- return "false"
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/types/config.go b/vendor/github.com/nunnatsa/ginkgolinter/types/config.go
deleted file mode 100644
index 0aadd3416..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/types/config.go
+++ /dev/null
@@ -1,101 +0,0 @@
-package types
-
-import (
- "go/ast"
- "strings"
-)
-
-const (
- suppressPrefix = "ginkgo-linter:"
- suppressLengthAssertionWarning = suppressPrefix + "ignore-len-assert-warning"
- suppressNilAssertionWarning = suppressPrefix + "ignore-nil-assert-warning"
- suppressErrAssertionWarning = suppressPrefix + "ignore-err-assert-warning"
- suppressCompareAssertionWarning = suppressPrefix + "ignore-compare-assert-warning"
- suppressAsyncAsertWarning = suppressPrefix + "ignore-async-assert-warning"
- suppressFocusContainerWarning = suppressPrefix + "ignore-focus-container-warning"
- suppressTypeCompareWarning = suppressPrefix + "ignore-type-compare-warning"
-)
-
-type Config struct {
- SuppressLen Boolean
- SuppressNil Boolean
- SuppressErr Boolean
- SuppressCompare Boolean
- SuppressAsync Boolean
- ForbidFocus Boolean
- SuppressTypeCompare Boolean
- AllowHaveLen0 Boolean
- ForceExpectTo Boolean
- ValidateAsyncIntervals Boolean
- ForbidSpecPollution Boolean
- ForceSucceedForFuncs Boolean
-}
-
-func (s *Config) AllTrue() bool {
- return bool(s.SuppressLen && s.SuppressNil && s.SuppressErr && s.SuppressCompare && s.SuppressAsync && !s.ForbidFocus)
-}
-
-func (s *Config) Clone() Config {
- return Config{
- SuppressLen: s.SuppressLen,
- SuppressNil: s.SuppressNil,
- SuppressErr: s.SuppressErr,
- SuppressCompare: s.SuppressCompare,
- SuppressAsync: s.SuppressAsync,
- ForbidFocus: s.ForbidFocus,
- SuppressTypeCompare: s.SuppressTypeCompare,
- AllowHaveLen0: s.AllowHaveLen0,
- ForceExpectTo: s.ForceExpectTo,
- ValidateAsyncIntervals: s.ValidateAsyncIntervals,
- ForbidSpecPollution: s.ForbidSpecPollution,
- ForceSucceedForFuncs: s.ForceSucceedForFuncs,
- }
-}
-
-func (s *Config) UpdateFromComment(commentGroup []*ast.CommentGroup) {
- for _, cmntList := range commentGroup {
- if s.AllTrue() {
- break
- }
-
- for _, cmnt := range cmntList.List {
- commentLines := strings.Split(cmnt.Text, "\n")
- for _, comment := range commentLines {
- comment = strings.TrimPrefix(comment, "//")
- comment = strings.TrimPrefix(comment, "/*")
- comment = strings.TrimSuffix(comment, "*/")
- comment = strings.TrimSpace(comment)
-
- switch comment {
- case suppressLengthAssertionWarning:
- s.SuppressLen = true
- case suppressNilAssertionWarning:
- s.SuppressNil = true
- case suppressErrAssertionWarning:
- s.SuppressErr = true
- case suppressCompareAssertionWarning:
- s.SuppressCompare = true
- case suppressAsyncAsertWarning:
- s.SuppressAsync = true
- case suppressFocusContainerWarning:
- s.ForbidFocus = false
- case suppressTypeCompareWarning:
- s.SuppressTypeCompare = true
- }
- }
- }
- }
-}
-
-func (s *Config) UpdateFromFile(cm ast.CommentMap) {
-
- for key, commentGroup := range cm {
- if s.AllTrue() {
- break
- }
-
- if _, ok := key.(*ast.GenDecl); ok {
- s.UpdateFromComment(commentGroup)
- }
- }
-}
diff --git a/vendor/github.com/nunnatsa/ginkgolinter/version/version.go b/vendor/github.com/nunnatsa/ginkgolinter/version/version.go
deleted file mode 100644
index 7bf181a8e..000000000
--- a/vendor/github.com/nunnatsa/ginkgolinter/version/version.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package version
-
-var (
- version = "unknown"
- gitHash = "unknown"
-)
-
-func Version() string {
- return version
-}
-
-func GitHash() string {
- return gitHash
-}