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/SpaceAroundBlockParameters bug related to trailing commas #8084

Merged

Conversation

bquorning
Copy link
Contributor

@bquorning bquorning commented Jun 2, 2020

There was a bug in how Layout/SpaceAroundBlockParameters autocorrected block parameters with a trailing comma with both leading and trailing whitespace.


Before submitting the PR make sure the following are checked:

  • 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.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@bquorning bquorning force-pushed the space_around_block_parameters_spec-bug branch from e3150d2 to 8100dec Compare June 2, 2020 11:52
processed_source.buffer.source[pos] == ',' ? pos + 1 : pos
def last_end_pos_inside_pipes(arguments, pos)
num = pos - arguments.source_range.to_a.first
trailing_comma_index = arguments.source[num..-1].index(',')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There must be a smarter way to do this :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so; parser doesn't give out any info about the commas

lib/rubocop/cop/layout/space_around_block_parameters.rb Outdated Show resolved Hide resolved
lib/rubocop/cop/layout/space_around_block_parameters.rb Outdated Show resolved Hide resolved
processed_source.buffer.source[pos] == ',' ? pos + 1 : pos
def last_end_pos_inside_pipes(arguments, pos)
num = pos - arguments.source_range.to_a.first
trailing_comma_index = arguments.source[num..-1].index(',')
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so; parser doesn't give out any info about the commas

@bquorning bquorning force-pushed the space_around_block_parameters_spec-bug branch from c3de612 to 83e5cfd Compare June 3, 2020 08:49
@bquorning bquorning changed the title Failing spec for Layout/SpaceAroundBlockParameters Fix Layout/SpaceAroundBlockParameters bug related to trailing commas Jun 3, 2020
@bquorning bquorning marked this pull request as ready for review June 3, 2020 08:54
@bquorning bquorning force-pushed the space_around_block_parameters_spec-bug branch 2 times, most recently from 2efef3b to 7d26ac8 Compare June 5, 2020 07:53
@bbatsov
Copy link
Collaborator

bbatsov commented Nov 4, 2020

@bquorning Can you rebase this PR?

There was a bug in how Layout/SpaceAroundBlockParameters autocorrected
block parameters with a trailing comma with both leading and trailing
whitespace.
@bquorning bquorning force-pushed the space_around_block_parameters_spec-bug branch from 7d26ac8 to 0f34b08 Compare November 4, 2020 15:38
@bquorning
Copy link
Contributor Author

I had completely forgotten about this PR :-)

It’s rebased now.

@bbatsov bbatsov merged commit 6e47673 into rubocop:master Nov 4, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Nov 4, 2020

Thanks!

I had completely forgotten about this PR :-)

I forget about most PRs, especially if they are not on the first scree. That's why I did a lot of PR pruning today. It's great when you have no more than 25 of them. :-)

@bquorning bquorning deleted the space_around_block_parameters_spec-bug branch November 4, 2020 18:22
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.

3 participants