Use Layout/BeginEndAlignment style start_of_line #258
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently we disable the Layout/RescueEnsureAlignment in Shopify Core and have a TODO to re-enable it. There used to be a comment saying to renable it when rubocop/rubocop#6433 was fixed but it didn't get renabled after that, I assume because it doesn't have the desired effect.
For instance, it autocorrects with changes like this
which is pretty close to the original issue reported in that issue, with the difference being the presence of the
begin
keyword.Solution
Using the Layout/BeginEndAlignment style of start_of_line avoids the above problem and uses a style that seems consistent with our existing coding style. This style is used by the Layout/RescueEnsureAlignment cop when it is enabled.
If this is too disruptive a change to introduce without a major release, the alternative would be to disable the Layout/RescueEnsureAlignment cop since it doesn't have the desired behaviour without
Layout/BeginEndAlignment
also enabled.