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

Check blank percent literal by Layout/SpaceInsidePercentLiteralDelimiters #11130

Merged

Conversation

r7kamura
Copy link
Contributor

@r7kamura r7kamura commented Oct 27, 2022

Previously, no particular investigation was made for whitespace in blank percent array literals on Layout/SpaceInsideArrayPercentLiteral.

I will change it in this Pull Request so that they are inspected as well.

# bad
%w[ ]
%w[    ]
%w[
]

# good
%w[]

This is a similar change to:


edit: At first I tried to change Layout/SpaceInsideArrayPercentLiteral Cop, but after discussion, it was decided to use Layout/SpaceInsidePercentLiteralDelimiters Cop instead.


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.

@r7kamura
Copy link
Contributor Author

I am wondering if we should offer several styles or if they are unnecessary at this time.

@r7kamura
Copy link
Contributor Author

Perhaps it would be better to implement this in Layout/SpaceInsidePercentLiteralDelimiters cop?

@r7kamura r7kamura changed the title Check space in empty array percent literal on `Layout/SpaceInsideArra… Check space in empty array percent literal on Layout/SpaceInsideArrayPercentLiteral Oct 27, 2022
@r7kamura r7kamura changed the title Check space in empty array percent literal on Layout/SpaceInsideArrayPercentLiteral Check whitespace in empty array percent literal on Layout/SpaceInsideArrayPercentLiteral Oct 27, 2022
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 30, 2022

I am wondering if we should offer several styles or if they are unnecessary at this time.

I don't think so. I haven't seen much usages of spaces in empty literals in general.

Perhaps it would be better to implement this in Layout/SpaceInsidePercentLiteralDelimiters cop?

Well, it can't be an alternative really - it'd be complimentary to the change here.

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 30, 2022

Perhaps it would be better to implement this in Layout/SpaceInsidePercentLiteralDelimiters cop?

My bad - I misread the cop names. 🤦 I agree that would actually be better, as it's more universal. I'd probably mention in the array literals cop that this additional aspect is control by the other cop, so it's clear we're consistent across the board with respect to the empty literals.

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 30, 2022

There it would also make more sense to have some configuration option like EnforcedStyleForEmptyLiteral.

@r7kamura r7kamura force-pushed the feature/space-inside-array-percent branch from 629a974 to de3cdc9 Compare November 3, 2022 03:15
@r7kamura r7kamura changed the title Check whitespace in empty array percent literal on Layout/SpaceInsideArrayPercentLiteral Check blank percent literal by Layout/SpaceInsidePercentLiteralDelimiters Nov 3, 2022
@r7kamura r7kamura force-pushed the feature/space-inside-array-percent branch from de3cdc9 to c3bbc6c Compare November 3, 2022 03:19
@bbatsov bbatsov merged commit b2cf002 into rubocop:master Nov 4, 2022
@bbatsov
Copy link
Collaborator

bbatsov commented Nov 4, 2022

Thanks for tackling this!

@r7kamura r7kamura deleted the feature/space-inside-array-percent branch November 4, 2022 08:04
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

2 participants