Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add nakedefer linter#3282
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
base:master
Are you sure you want to change the base?
Conversation
rawen17 commented Oct 7, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Hey, thank you for opening your first Pull Request ! |
CLAassistant commented Oct 7, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
|
ldez commented Oct 7, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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
|
ldez commented Oct 7, 2022
Hello, maybe I have missed something: why only IMO using a function that returns something (not only a function) for a defer is a problem. |
xobotyi commented Oct 10, 2022
@ldez sometimes we're using factory for deferred functions, this linter tracks situation when deferred function returns a function and ensures that returned function is invoked, i.e. |
xobotyi commented Oct 10, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Overall you're right, and maybe we have to make the linter stricter🤔 |
rawen17 commented Oct 11, 2022
Hello! |
ldez commented Oct 11, 2022
@rawen17 you have to sign the CLA #3282 (comment) |
rawen17 commented Oct 11, 2022 • edited by ldez
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by ldez
Uh oh!
There was an error while loading. Please reload this page.
I've signed it already |
ldez commented Oct 11, 2022
The email that you are using to commit is not set up in your GitHub account, so you haven't signed. |
rawen17 commented Oct 11, 2022 • edited by ldez
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by ldez
Uh oh!
There was an error while loading. Please reload this page.
Sorry, now is signed |
Antonboom commented Oct 17, 2022
@rawen17, please, select more specific naming.
Moreover, it would be great to see among the examples something less abstract and closer to real life. Now it raise more questions than answers. E.g., why is it invalid? funcfuncDeferAnonymousReturnIntAndErr(){deferfunc() (int, error){// want "deferred call should not return anything"return1, nil }() }If you explain more clearly the reason of the linter, I can help with the name. Thanks 👍 |
rawen17 commented Oct 18, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@Antonboom, hi!
May be i misunderstood your question |
Antonboom commented Oct 18, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Okay, does the linter ignore I propose something like:
|
bombsimon commented Oct 18, 2022
Curious about this as well. If not, I see a lot of this pattern incoming: deferfunc(){_, _=whatIActuallyWanted() }() |
rawen17 commented Oct 19, 2022
In test/testdata/defer.go there are 2 examples funcReturnErr - can be like
|
rawen17 commented Oct 24, 2022
Change name linter 'defer' to 'nakedefer' |
ldez commented Oct 24, 2022
@rawen17 can you rebase and fix the conflict? |
ldez commented Oct 24, 2022
@rawen17 why did you close the PR? |
rawen17 commented Oct 24, 2022
No, it is my fault, i will try fix it |
ldez commented Oct 24, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
yes you can reopen this PR, but you need to add commits 😉 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
rawen17 commented Nov 11, 2022
@ldez Hello! |
83cada1 to d7e6791Compareldez commented Feb 27, 2023
Sorry for the late reply. I share the point of view of @bombsimon maybe it can be a good idea to add |
Antonboom commented Oct 1, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Could you please add default value for I run linter on large code base and receive warnings about: defert.Stop() // *time.Timerdeferresponse.Body.Close() deferdb.Close() // *pg.DBP.S. It's also cool to not ignore README badges like "Go Report", "CI Build Status", etc. P.P.S. Could be helpful
|
nakedeferis a linter that finds defer functions which return anything.https://github.com/GaijinEntertainment/go-nakedefer