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 an auto-correction bug in Lint/BooleanSymbol #7871

Merged
merged 1 commit into from Apr 13, 2020

Conversation

knu
Copy link
Contributor

@knu knu commented Apr 13, 2020

It replaces a boolean symbol in a hash value as if it were a key, generating a broken piece of code.

# before
{ null: :false }

# after: wrong (current behavior)
{ null :false => }

# after: correct (fixed behavior)
{ null: false }
# before
{ false: :false }

# after: wrong (current behavior)
{ false => :false => }

# after: correct (fixed behavior)
{ false => false }

Replace this text with a summary of the changes in your PR.
The more detailed you are, the better.


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

koic commented Apr 13, 2020

This looks good to me. Can you squash your commits into one?

@knu
Copy link
Contributor Author

knu commented Apr 13, 2020

@koic I just felt like it would create a time paradox to include a change log update with a PR number in a single commit, but I will if you say so. 😆

@knu knu force-pushed the fix_boolean_symbol_autocorrection branch from 859f7e9 to 2b24253 Compare April 13, 2020 04:25
CHANGELOG.md Outdated
@@ -12,6 +12,7 @@

### Bug fixes

* [#7871](https://github.com/rubocop-hq/rubocop/pull/7871): Fix an auto-correction bug in Lint/BooleanSymbol. ([@knu][])
Copy link
Member

Choose a reason for hiding this comment

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

Oops, I overlooked one. Can you enclose the cop name in backticks?

Suggested change
* [#7871](https://github.com/rubocop-hq/rubocop/pull/7871): Fix an auto-correction bug in Lint/BooleanSymbol. ([@knu][])
* [#7871](https://github.com/rubocop-hq/rubocop/pull/7871): Fix an auto-correction bug in `Lint/BooleanSymbol`. ([@knu][])

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!

It replaces a boolean symbol in a hash value as if it were a key,
generating a broken piece of code.

```ruby
# before
{ null: :false }

# wrong (current behavior)
{ null :false => }

# wrong (fixed behavior)
{ null: false }
```

```ruby
# before
{ false: :false }

# wrong (current behavior)
{ false => :false => }

# wrong (fixed behavior)
{ false => false }
```
@knu knu force-pushed the fix_boolean_symbol_autocorrection branch from 2b24253 to 851784b Compare April 13, 2020 05:48
@koic koic merged commit ba598be into rubocop:master Apr 13, 2020
@koic
Copy link
Member

koic commented Apr 13, 2020

Thank you!

@knu knu deleted the fix_boolean_symbol_autocorrection branch April 13, 2020 07:23
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