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 #3426] Fixes Style/RedundantParentheses for indexing with literals. #3592

Merged
merged 1 commit into from
Oct 10, 2016
Merged

[Fix #3426] Fixes Style/RedundantParentheses for indexing with literals. #3592

merged 1 commit into from
Oct 10, 2016

Conversation

thegedge
Copy link
Contributor

@thegedge thegedge commented Oct 9, 2016

Style/RedundantParentheses would not report an offense when parentheses surrounded an indexing operation for a literal, but would work with a regular function call. This PR fixes this issue by also including strings, arrays, and hashes in the node matcher.

I stuck with the a method call offense, but perhaps there's a better wording (even though technically it is a method call to :[])?


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).
  • Used the same coding conventions as the rest of the project.
  • 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.
  • All tests are passing.
  • The new code doesn't generate RuboCop offenses.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.

@@ -31,6 +31,7 @@
* [#3390](https://github.com/bbatsov/rubocop/issues/3390): Fix SaveBang cop for multiple conditional. ([@tejasbubane][])
* [#3577](https://github.com/bbatsov/rubocop/issues/3577): Fix `Style/RaiseArgs` not allowing compact raise with splatted args. ([@savef][])
* [#3578](https://github.com/bbatsov/rubocop/issues/3578): Fix safe navigation method call counting in `Metrics/AbcSize`. ([@savef][])
* [#3592](https://github.com/bbatsov/rubocop/issues/3592): Fix `Style/RedundantParentheses` for indexing with literals ([@thegedge][])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line should have a . before your name. You should also add yourself to the end of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and done!

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 10, 2016

I stuck with the a method call offense, but perhaps there's a better wording (even though technically it is a method call to :[])?

Yeah, that's OK.

Style/RedundantParentheses would not report an offense when parentheses
surrounded an indexing operation for a literal, but would work with a
regular function call.
@bbatsov bbatsov merged commit 25cc3ac into rubocop:master Oct 10, 2016
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 10, 2016

👍

@thegedge thegedge deleted the fix-reundant-parenthesis-for-literals branch October 10, 2016 17:03
Neodelf pushed a commit to Neodelf/rubocop that referenced this pull request Oct 15, 2016
… literals (rubocop#3592)

Style/RedundantParentheses would not report an offense when parentheses
surrounded an indexing operation for a literal, but would work with a
regular function call.
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.

2 participants