feat: Add TimeEqual checker to enforce proper time comparisons#243
feat: Add TimeEqual checker to enforce proper time comparisons#243semihbkgr wants to merge 1 commit into
Conversation
|
The idea seems legitimate. But then, I wonder whether bool_compare checker will have to be updated |
|
Now, I have read through this I'm unsure about the PR. What do you think @semihbkgr |
|
More context Using assert.WithinDuration seems a better option that could avoid having testifylint rules that may conflicts each other. |
|
It would be better to suggest using Just to clarify, are we all in agreement that there should be a warning when two time values are compared using the |
Yes. So here I would say when we find
I was unsure when I wrote it, and like you, it was worst after reading the threads and discussions I quoted.
For me, yes. Also, I feel like there is a need for a time_compare rule (instead of simply time-equal). That people would enable or disable depending on their needs. This rule should detect:
And suggested WithinDuration(t, t1, t2, 0) |
|
Maybe later, this rule could give ideas for what we do with time.Time and time.Duration, such as:
These are only ideas, that needs to be double checked, depending on how clearer would be the error message that testify would report. |
|
Yes, I know you asked about one specific point and I somehow replied by popping out 3 new ideas, and thus problems that would pops out with it. It's my super power ! 😅 |
fix #242
closes #60
@Antonboom
If you're okay with the new checker, I'll add the corresponding unit tests and refactor the diagnostic messages and fixes.