-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New rule(s): Wrong Usage of the
MatchError
gomega Matcher
The `MatchError` gomega matcher asserts an error value (and if it's not nil). There are four valid formats for using this Matcher: * error value; e.g. `Expect(err).To(MatchError(anotherErr))` * string, to be equal to the output of the `Error()` method; e.g. `Expect(err).To(MatchError("Not Found"))` * A gomega matcher that asserts strings; e.g. `Expect(err).To(MatchError(ContainSubstring("Found")))` * [from v0.29.0] a function that receive a single error parameter and returns a single boolean value. In this format, an additional single string parameter, with the function description, is also required; e.g. `Expect(err).To(MatchError(isNotFound, "is the error is a not found error"))` These four format are checked on runtime, but sometimes it's too late. ginkgolinter performs a static analysis and so it will find these issues on build time. ginkgolinter checks the following: * Is the first parameter is one of the four options above. * That there are no additional parameters passed to the matcher; e.g. `MatchError(isNotFoundFunc, "a valid description" , "not used string")`. In this case, the matcher won't fail on run time, but the additional parameters are not in use and ignored. * If the first parameter is a function with the format of `func(error)bool`, ginkgolinter makes sure that the second parameter exists and its type is string.
- Loading branch information
Showing
165 changed files
with
4,901 additions
and
5,045 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/nunnatsa/ginkgolinter | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/go-toolsmith/astcopy v1.1.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.