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

Fix Layout/RedundantLineBreak adding extra space within method chains #10124

Merged
merged 2 commits into from Sep 28, 2021

Conversation

dvandersluis
Copy link
Member

@dvandersluis dvandersluis commented Sep 24, 2021

When Layout/RedundantLineBreak finds a multiline method chain that can be collapsed to a single line, it adds an extra space between each method. Although the spaces could also be detected by Layout/SpaceAroundMethodCallOperator, this change allows the cop to calculate if a correction will fit on the line better (as demonstrated by the fixes in the 2nd commit).

foo.
  bar.
  baz

Before:

foo. bar. baz

After:

foo.bar.baz

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

Copy link
Collaborator

@jonas054 jonas054 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a potential problem. Looks fine otherwise.

spec/rubocop/cop/layout/redundant_line_break_spec.rb Outdated Show resolved Hide resolved
@jonas054 jonas054 self-requested a review September 26, 2021 10:40
@koic koic merged commit 9d534e2 into rubocop:master Sep 28, 2021
@koic
Copy link
Member

koic commented Sep 28, 2021

Thanks!

@jonas054
Copy link
Collaborator

Nice!

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

Successfully merging this pull request may close these issues.

None yet

3 participants