-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Clothe returns #287
base: master
Are you sure you want to change the base?
Clothe returns #287
Conversation
This is failing to properly adjust the location of comments after inserting the return values. I'll continue working on that. |
See flimzy@64e6495 for what this new transform does on the gofumpt repo itself. I'll do further testing on a larger collection of repos when time permits. |
I've run this change against the stdlib, as well as the repos in this list. I found two panics, which already existed in gofumpt prior to this change. Otherwise, the output appears as expected and, in my subjective opinion, much easier to read. I could share some diffs, but they're bulky and boring to read, honestly. If you'd like me to do any additional investigation, please let me know. |
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.
SGTM, just some thoughts, in particular I'm worried about PathEnclosingInterval :)
i.e. `func() (a, b, c int)`
Anything else before merging this one, @mvdan ? |
Fixes #285
At present, this transformation ignores naked returns in functions with blank-named return values (i.e.
func() (_ int, err error)
) because rewriting them requires a literal zero value, which seemed unnecessary to evaluate the usefulness of this rule. It can be updated if we decide to move forward with this.There's probably also room to improve the algorithm used to determine the nearest function parent to a given return statement. I didn't see any prior art within this project to copy, so I chose an easy option to implement, which I expect is enough to evaluate the usefulness. And we can optimize if deemed necessary.