Skip to content

Change Layout/LineEndStringConcatenationIndentation

Chad Woolley requested to merge caw-change-continuation-indent into master

What does this MR do and why?

Makes changes proposed and discussed in Change rubocop Layout/LineEndStringConcatenatio... (gitlab-org/gitlab#442626)

Change

Style/LineEndStringConcatenationIndentation:
  Enabled: true
  EnforcedStyle: indented

Documentation and example

See the EnforcedStyle: indented section in https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Layout/LineEndStringConcatenationIndentation for documentation and examples:

# bad
result = 'x' \
         'y'

my_hash = {
  first: 'a message' \
         'in two parts'
}

# good
result = 'x' \
  'y'

my_hash = {
  first: 'a message' \
    'in two parts'
}

Reasons

More consistent with other indentation rules (or lack thereof).

Specifically, no other known rule prevents a standard 2-character indentation of multi-line expressions. See examples here:

Any other example I can think of all accepts a standard 2-character indentation for multi-line expressions without any complaints from rubocop:

Screenshot_2024-02-23_at_8.28.43_AM

So, this one definitely seems like the odd one out.


Also, there is a closely related issue [Proposal] Use `EnforcedStyle: consistent` for ... (#42 - closed)

Skimming that issue, it seems to be trying to achieve the same goals as this one, and this rule maybe just got missed.

TODOs which would be introduced to gitlab repo

$ bundle exec rubocop -P -f o --only Layout/LineEndStringConcatenationIndentation

1258  Layout/LineEndStringConcatenationIndentation
--
1258  Total in 755 files

Refs [Proposal] Use `EnforcedStyle: consistent` for ... (#42 - closed)

Edited by Chad Woolley

Merge request reports