Skip to content
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

Option to not switch Ruby blocks to do/end when chained #124

Open
att14 opened this issue Dec 5, 2017 · 3 comments
Open

Option to not switch Ruby blocks to do/end when chained #124

att14 opened this issue Dec 5, 2017 · 3 comments

Comments

@att14
Copy link

att14 commented Dec 5, 2017

Currently when spliting something like this:

expect { ... }.to raise_error StandardError

it produces:

expect do
   ...
end.to raise_error SomeError

Chaining on end is usually considered bad syntax. The expected split would be:

expect {
   ...
}.to raise_error SomeError

In my opinion this should be the default, but if you wanted to keep it how it is for backwards compatibility an options would be nice to toggle this behavior.

@AndrewRadev
Copy link
Owner

While I wouldn't call it "bad syntax", I think you have a point that the curly brace syntax is more common, particularly for rspec expectations. I'd prefer to split like that myself, I think, if there's a chain. It definitely makes sense to open the issue.

That said, it's tricky. Not the splitting thing, that one is easy, but joining complicates things, because it's hard to differentiate between hashes and blocks when they're like this.

I've created a branch, ruby-blocks-in-method-chains, where I've implemented this, with a setting, and a help file. Could you use it for a while, let me know how it works? If there are issues, there's a few more things I can try, but I'd like to have specific examples to work with.

@att14
Copy link
Author

att14 commented Jan 6, 2018

Ya, I've been using it a bit and I haven't seen any problems. I'll keep using it for a week or so and I'll let you know what I find.

@att14
Copy link
Author

att14 commented May 15, 2018

I have been using this for a while, and it does do the correct thing for curly braces that are chained. I have noticed some other bugs, which I'm not sure if they are related to this change. I am working on some ways to reproduce the issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants