-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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 rule from testifylint #18741
base: main
Are you sure you want to change the base?
Conversation
Hi @ghouscht. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files
... and 23 files with indirect coverage changes @@ Coverage Diff @@
## main #18741 +/- ##
==========================================
+ Coverage 68.73% 68.82% +0.08%
==========================================
Files 420 420
Lines 35488 35481 -7
==========================================
+ Hits 24392 24419 +27
+ Misses 9661 9635 -26
+ Partials 1435 1427 -8 Continue to review full report in Codecov by Sentry.
|
@@ -40,12 +40,12 @@ func AssertNotNil(t *testing.T, v any) { | |||
// Deprecated: use github.com/stretchr/testify/assert.True instead. | |||
func AssertTrue(t *testing.T, v bool, msg ...string) { | |||
t.Helper() | |||
assert.True(t, v, msg) | |||
assert.True(t, v, msg) //nolint:testifylint |
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.
Both the AssertTrue
and AssertFalse
functions are part of the public API of the testutils
pkg. It looks like they are no longer used within the etcd codebase but they could be used outside of the etcd codebase. I thought it is best to keep them as they are, thus the nolint
directive. Let me know if you think that is ok.
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.
Until this code is removed, it's better to keep it as is . I agree to disable the linter here
FYI: @mmorel-35 here is the second PR for the |
There are many places where the expected or unexpected error is is printed with I'm wondering if it's not redondant with the behavior of testify which will print it |
Yes, that is true. I can clean them up if you and the maintainers agree on that. |
I feel like it's the best opportunity to do that as most of them are probably modified in this PR. Let's see what the maintainers think. |
|
||
leaderIndex := epc.WaitLeader(t) | ||
_, err = epc.Procs[leaderIndex].Logs().ExpectWithContext(ctx, expect.ExpectedResponse{Value: "finished compaction hash check"}) | ||
require.NoError(t, err, "can't get log indicating finished compaction hash check") | ||
require.NoErrorf(t, err, "can't get log indicating finished compaction hash check") |
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.
Question: there is no variable-length variable in this case, shouldn't require.NoError
be better than require.NoErrorf
?
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.
Note this is a generic question.
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 had the same question and the author of linter directed me to the rule's documentation:
https://github.com/Antonboom/testifylint?tab=readme-ov-file#formatter
And the historical note associated:
https://github.com/Antonboom/testifylint?tab=readme-ov-file#historical-reference
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.
We should always use *f
functions when require-f-funcs: true
no matter there is variable-length variables or not?
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.
That seems to be the recommended way to do indeed
- go-require | ||
- require-error | ||
enable-all: true | ||
formatter: | ||
require-f-funcs: true |
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.
What does this option mean? Could you add a comment to clarify?
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.
https://golangci-lint.run/usage/linters/#testifylint states:
To require f-assertions if format string is used.
I'll add a comment 👍🏻
Yes, testify already prints the error, so we don't need to print it again. But not a big deal. |
4babfc2
to
2d144f0
Compare
2d144f0
to
76e0c60
Compare
Signed-off-by: Thomas Gosteli <thomas.gosteli@protonmail.ch>
76e0c60
to
be02cdb
Compare
👍🏻 I cleaned up the messages and removed redundant information. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ghouscht, mmorel-35 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@ghouscht , |
This PR enables the
formatter
testifylint rule as part of #18719Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.