-
-
Notifications
You must be signed in to change notification settings - Fork 497
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
fix: enable formatter.require-f-funcs from testifylint #2836
fix: enable formatter.require-f-funcs from testifylint #2836
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
What is your experience with this rule? I think we are doing good progress in throwing more meaningful error messages, which will be part of the test failure in the case require.Error fails. So I'm not very sure about including this one. Wdyt? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this one, could you clarify why this change is beneficial?
I probably missed something because it's not the intention of the rule to reduce the readability of the test results, on the contrary. The rule reason is explained here There is also more to read |
Yer that's there to eliminate an embedded So its needed for this: assert.Errorf(t, err, fmt.Sprintf("test %s", test.testName)) // Bad
assert.Errorf(t, err, "test %s", test.testName) // Good But not needed for this: assert.Error(t, err, "thing should error") // Not needed as no replaceable variables |
Have look over here, Antonboom/testifylint#177 (comment) |
358566d
to
9509a90
Compare
Signed-off-by: Matthieu MOREL <[email protected]>
9509a90
to
0cbdab1
Compare
Thanks for that context, really useful. Having read the history and looked at the code for assert / require, I believe there's a case which was overlooked. If you trace the calls you'll end up in messageFromMsgAndArgs which has a specific case for a single argument as can be found here. So If that rule doesn't handle that edge case I suggest we leave it disabled as it would cause churn for no real value, I would even suggest that including a reason for things like |
OK, I'll close this PR. require.Error(t, results.FirstErr(), kerr.UnknownTopicOrPartition) //nolint:testifylint In modules/redpanda/redpanda_test.go . Shall it be turned into require.ErrorIs(t, results.FirstErr(), kerr.UnknownTopicOrPartition) or require.ErrorContains(t, results.FirstErr(), kerr.UnknownTopicOrPartition) Or am I missing the understanding of the behavior of that test ? |
Yes @mmorel-35 nice catch, that should be an |
What does this PR do?
Setup formatter.require-f-funcs from testifylint linter and apply it’s recommandations .
Why is it important?
To require f-assertions if format string is used.
Signed-off-by: Matthieu MOREL [email protected]