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

BlockAlignment on chaining methods #393

Closed
lenntt opened this issue Jul 25, 2013 · 4 comments · Fixed by #413
Closed

BlockAlignment on chaining methods #393

lenntt opened this issue Jul 25, 2013 · 4 comments · Fixed by #413
Assignees
Labels

Comments

@lenntt
Copy link

lenntt commented Jul 25, 2013

I have similar code that results in a BlockAlignment failure:

my_object.chaining_this_very_long_method(with_a_parameter)
    .and_one_with_a_block do
  do_something
end

Note, this passes:

my_object.chaining_this_very_long_method(
    with_a_parameter).and_one_with_a_block do
  do_something
end

While I prefer to write down the first.

@ghost ghost assigned jonas054 Aug 2, 2013
@jonas054
Copy link
Collaborator

jonas054 commented Aug 2, 2013

The reason why this is reported as an offence is the implementation from #362, which was a fix for #346. I'm starting to think that it was a mistake to introduce that change. The Style Guide says that "multiline chaining is always ugly" and multiline chaining is exactly what #346 was about.

I propose that we remove the handling introduced in #362. That will solve this issue.

@edzhelyov
Copy link
Collaborator

I also think that multiline chaining should be avoided.

jonas054 added a commit to jonas054/rubocop that referenced this issue Aug 2, 2013
@lenntt
Copy link
Author

lenntt commented Aug 5, 2013

Some Ruby DSLs, like RSpec, are pretty much about chaining. Therefore, I'll probably end up keeping this cop disabled, which is fine by me.

@fuadsaud
Copy link

fuadsaud commented Aug 5, 2013

@SirLenz0rlot had to do the same. But I disagree with the guide. Multi-line chaining, IMO, looks totally ok if you're using {} blocks instead of do/end. But the guide also discourages multi-line {} blocks, which is another silly decision in my opinion - I understand why these decisions were made, but I heavily disagree with them. Disabling theses cops is the way to go.

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

Successfully merging a pull request may close this issue.

4 participants