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 #7675] Fix a false negative for Layout/SpaceBeforeFirstArg #7678

Conversation

koic
Copy link
Member

@koic koic commented Jan 29, 2020

Fixes #7675.

This PR fixes a false negative for Layout/SpaceBeforeFirstArg when a vertical argument positions are aligned.


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.

@koic
Copy link
Member Author

koic commented Jan 29, 2020

CI failure will be resolved by #7679.

@koic koic force-pushed the fix_false_negative_for_layout_space_before_first_arg branch from cd4c29a to 63837bb Compare January 29, 2020 15:34

first_arg = node.first_argument

same_line?(first_arg, node) &&
!(allow_for_alignment? &&
aligned_with_something?(first_arg.source_range))
end

def touch_between_method_name_and_first_argument?(node)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I understand the name of this method. What is touch between supposed to mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I did a confusing naming 💦
I'd like to change the name to def no_space_between_method_name_and_first_argument?

# no space (bad)
do_something'arg' 

# with space (good)
do_something 'arg' 

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for your review. I updated the method name.

Fixes rubocop#7675.

This PR fixes a false negative for `Layout/SpaceBeforeFirstArg`
when a vertical argument positions are aligned.
@koic koic force-pushed the fix_false_negative_for_layout_space_before_first_arg branch from 63837bb to 03cc4f9 Compare January 31, 2020 16:20
@bbatsov bbatsov merged commit 8fd36f0 into rubocop:master Jan 31, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Jan 31, 2020

Thanks!

@koic koic deleted the fix_false_negative_for_layout_space_before_first_arg branch January 31, 2020 23:12
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.

Layout/SpaceBeforeFirstArg doesn't alert when randomly aligning with previous line
2 participants