-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incorrect-assert: add type checks for assert.Regexp
regexp argument
#81
Comments
It's interesting. Could you explain the unexpected behavior you found with this method, especially the "around fmt.Sprint()" Do you have examples of interface value passed to assert.Regexp ? |
I just tried a code search on GitHub of bad usage of But that would be the point of this checker: catch the remaining ones. About |
Side note, if something is implemented it cannot be only about detecting the value is a regexp object or a string. The code use fmt.Sprint, so it relies also in being able to convert into a string. So it should also support fmt.Stringer https://github.com/golang/go/blob/master/src%2Ffmt%2Fprint.go |
Current code of testify is also able to support crazy people doing things like this assert.Regexp(t, 17, " foo 17 bar") https://go.dev/play/p/2usnMRVizun This should be discouraged maybe I didn't test but I think it would be the same for |
@ccoVeille We are discussing about a linter. As a Testify maintainer I can't change the crazy things that are allowed by the current implementation. But I expect the linter to tell the user that the crazy thing he does is most probably just a mistake. |
Yes, I agree that's why I listed the things the linter could raise. I agree with you, it's not about changing testify, but to guide user to use the right asserter |
About this, because I'm unsure about your reply. Your issue was about accepting:
I suggested current implementation also support any struct with a stringer. So something like this: type alpha struct{}
func (*alpha) String() string {
return "[a-z]+"
} (This is pseudo code made on a phone) Would you expect the linter to report sending any object from this type to |
assert.Regexp
regexp argumentassert.Regexp
regexp argument
+ case when order of arguments is invalid assert.Regexp(t, out, `\[.*\] DEBUG \(.*TestNew.*\): message`) |
The signature for
assert.Regexp
(and associated methods) is:However
rx
should only be*regexp.Regexp
orstring
.Related: stretchr/testify#1585
Cc: @kevinburkesegment
The text was updated successfully, but these errors were encountered: