bbatsov/rubocop — pull request #330 by edzhelyov (2013-07-03 09:17:59+00:00)
Title: Handle block end alignments in method chains

Hi guys,

Yet another change to the `EndAlignment` Cop. This handles problems like the one described in https://github.com/bbatsov/rubocop/issues/325#issuecomment-20371748.

The cases that we handle in this Cop are growing and we currently have two schemas for block alignment, but I don't think we need the second one - where we align the end under the start of the block command. My vim doesn't align it that way and I think every other editor actually aligns based on the start of the line where the `do` keyword is found.

I propose that we drop the second schema. This will greatly simplify the code and especially the specs. What do you think ?

Second, there are still problems like the one in https://github.com/bbatsov/rubocop/issues/327. It again shows that
the editors just align at the start of the line. We can try to emulate that logic and find the beginning of the line when the `do` keyword is defined and use that for the starting point. This will simplify the actual code and I think the only case that we need to handle is

```
statement; var = test do |v|
```

Maybe there is a way we can detect these cases. In my vim if I write the above code the block's `end` will align with the `statement`, so I'm unsure if we have to handle the case at all. This is kind of a trade of, but I think we need to address the problem in https://github.com/bbatsov/rubocop/issues/327 and I can't think of a better way.
What is your opinion ?