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 #7517] Layout/WhitespaceAroundKeyword: allow super::const #7518

Merged
merged 1 commit into from Nov 22, 2019

Conversation

ozydingo
Copy link

The Layout/WhitespaceAroundKeyword cop complains when super::MyConst is used. However, in Ruby, modules and classes are normal objects and can be returns by methods including by using super. Therefore, super::MyConst should be considered valid style.

This type of usage is distinct from the intention of this cop, which is to avoid missing space such as around something = 123if test and while(something).

I considered adding a test that verifies that the cop complains when a keyword other than super is used in the same manner (it does). However, I believe this is a syntax error in every other case and so the behavior of this cop is perhaps best left undefined. The alternative would be to suggest that yield :: is the correct form of yield::, which is false; they're both wrong, and it's not the responsibility of this cop to know that.


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.

@@ -212,10 +217,18 @@ def accept_left_square_bracket?(range)
ACCEPT_LEFT_SQUARE_BRACKET.include?(range.source)
end

def accept_namesapce_operator?(range)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: sapce

Copy link
Author

Choose a reason for hiding this comment

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

Fixed. I already squashed and force pushed it; please let me know if the preference is to use separate commits and squash after approval.

@ozydingo ozydingo force-pushed the layout-space_around_keyword-namespace branch from fadbe21 to 89bb28d Compare November 20, 2019 11:50
@ozydingo ozydingo force-pushed the layout-space_around_keyword-namespace branch from 89bb28d to 0a0c442 Compare November 21, 2019 08:01
@koic koic merged commit aa09fd6 into rubocop:master Nov 22, 2019
@koic
Copy link
Member

koic commented Nov 22, 2019

Thanks!

@ozydingo ozydingo deleted the layout-space_around_keyword-namespace branch November 22, 2019 07:18
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

4 participants