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 Style/HashAsLastArrayItem with no_braces for empty hash #8681

Merged
merged 2 commits into from Sep 15, 2020
Merged

Fix Style/HashAsLastArrayItem with no_braces for empty hash #8681

merged 2 commits into from Sep 15, 2020

Conversation

fsateler
Copy link
Contributor

@fsateler fsateler commented Sep 9, 2020

When EnforcedStyle is set to no_braces, rubocop was attempting to
correct [1, {}] into [1, ], which is not valid. An empty hash cannot
omit the braces.


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.

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 14, 2020

The change looks good, but for some reason the CI is failing.

@fsateler
Copy link
Contributor Author

I don't understand how the failures can be related to the PR...

CHANGELOG.md Outdated Show resolved Hide resolved
@koic
Copy link
Member

koic commented Sep 14, 2020

I don't understand how the failures can be related to the PR...

The following spec is failing.

Failures:

  1) RuboCop Project changelog has link definitions for all implicit links
     Failure/Error:
       expect(changelog.include?("[#{name}]: http"))
         .to be(true), "CHANGELOG.md is missing a link for #{name}. " \
                       'Please add this link to the bottom of the file.'

       CHANGELOG.md is missing a link for @fsateler. Please add this link to the bottom of the file.
     # ./spec/project_spec.rb:125:in `block (4 levels) in <top (required)>'
     # ./spec/project_spec.rb:124:in `each'
     # ./spec/project_spec.rb:124:in `block (3 levels) in <top (required)>'
     # tasks/spec_runner.rake:32:in `block in run_specs'
     # tasks/spec_runner.rake:44:in `with_encoding'
     # tasks/spec_runner.rake:28:in `run_specs'
     # tasks/spec_runner.rake:116:in `block in <top (required)>'

Finished in 2 minutes 29.1 seconds (files took 3.26 seconds to load)
13875 examples, 1 failure, 10 pending

https://github.com/rubocop-hq/rubocop/pull/8681/checks?check_run_id=1111352141#step:6:158

Can you add your account to the bottom of CHANGELOG.md?

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5936a4678..01b0bb8d8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4856,3 +4856,4 @@
 [@jaimerave]: https://github.com/jaimerave
 [@Skipants]: https://github.com/Skipants
 [@sascha-wolf]: https://github.com/sascha-wolf
+[@fsateler]: https://github.com/fsateler

https://github.com/rubocop-hq/rubocop/blob/v0.90.0/CONTRIBUTING.md#changelog-entry-format

fsateler and others added 2 commits September 14, 2020 12:32
When `EnforcedStyle` is set to `no_braces`, rubocop was attempting to
correct `[1, {}]` into `[1, ]`, which is not valid. An empty hash cannot
omit the braces.
@bbatsov bbatsov merged commit 80e5740 into rubocop:master Sep 15, 2020
@fsateler fsateler deleted the bugfix/empty-hash-last-item branch January 4, 2021 16:46
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

3 participants