-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add new linter gomockcontrollerfinish #4202
Add new linter gomockcontrollerfinish #4202
Conversation
In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.
Pull Request Description
Linter
The Linter Tests Inside Golangci-lint
|
@hendrywiranto, hello! I don't want to belittle your work, but before a review there is a simple question – what is the profit from such kind of linters? 1.
You ignored my comment, but instead of linter I suppose just make contribution in uber-go/mock. |
Hi @Antonboom , thanks for the comment! I think the main benefit is we can have less code in the tests, not only just 1 less line, but also we can completely remove the usage of e.g. Also a little background, I recently saw lots of my coworker still calling
Thank you for the reference, I'm also aware that
For your comment I actually saw it, sorry it's just I don't know what to respond to it. For the linter itself, it works as long as the controller object is a All in all, thank you for the review, I'm still new at go linters and I'm open for feedbacks on this. It's okay if this ends up to look not really useful, I can still use it on my org codebase. I just think it's better if I'm able to add it into this awesome project :) |
Imho,
As I said before I just affected by different situation, when people used to call
Nice point!
I meant that you can offer them to return the deleted line with the log, but instead of the log, for example, fail the test. This is the way of the Go std func (t *T) Run(name string, f func(t *T)) bool {
if t.cleanupStarted.Load() {
panic("testing: t.Run called during t.Cleanup")
}
// ...
func (c *common) checkFuzzFn(name string) {
if c.inFuzzFn {
panic(fmt.Sprintf("testing: f.%s was called inside the fuzz target, use t.%s instead", name, name))
}
}
// ...
func (t *T) Parallel() {
if t.isParallel {
panic("testing: t.Parallel called multiple times")
}
// .... P.S.Also it is better to remove this filter if !isTestFile(pass.Fset.Position(callExpr.Pos()).Filename) {
|
Yes it's still possible, I will look for another way of checking this. thanks
Ah I see, appreciate the explanation
Also the deprecation of the method itself is reverted uber-go/mock#85. I'm thinking that the users of the framework that still require to call
Noted on the PS. I will adjust it. Thanks |
adjusted based on both of your comments @Antonboom
If the linter is good to go, I will update this PR with the updated version. Thanks. |
I'm not sure if we really need this linter. A few months ago I pushed changes that deprecated |
Hi @alexandear, yes I noticed your PR and the discussions around it. I think other than those test frameworks that you mentioned, people can completely omits it. And on my case, it's quite useful e.g. as I mentioned here
What do you think? |
@hendrywiranto Perhaps we should consider adding a new rule to the existing linters such as go-critic, revive, or staticcheck? |
Ah I see... Thanks for the recommendation, I will take a look on those linters 😃 |
also I wonder how many rules does it take for a linter to be considered worth it? @alexandear just curious, no pressure intended my plan was to make the linter more general (maybe can be about mocking rules (?) ), but still no other rules in mind, so maybe I'll come back later when it has more rules |
This rule doesn't really exist, a linter doesn't have to handle several elements/rules. Your linter is focused on a tiny rule, it's not a major blocker but this questions the relevance of your linter.
If you plan that do it now, because the name of your linter is not really open to changes. |
It's possible to prevent the usage of
|
so it's already possible with another linter, we will decline this PR. |
Hello,
I'd like to add new linter
https://github.com/hendrywiranto/gomockcontrollerfinish
Closes #3223
Currently, it's only checks whether an unnecessary call to
.Finish()
ongomock.Controller
existsNote: I'm open to renaming for more general use such as
gomocklint
to support another linting rule forgomock
in the future