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

Style/HashSyntax reports errors with string interpolated Symbol names #6778

Closed
arbox opened this issue Feb 19, 2019 · 0 comments · Fixed by #6948
Closed

Style/HashSyntax reports errors with string interpolated Symbol names #6778

arbox opened this issue Feb 19, 2019 · 0 comments · Fixed by #6948
Labels

Comments

@arbox
Copy link
Contributor

arbox commented Feb 19, 2019

Rubocop reports style check violation while processing hashes with symbol keys coming from string interpolation. See examples below.

Expected behavior

No errors reported.

Actual behavior

Error reported (in FlyCheck/Emacs notation):

Don't mix style in the same hash. [Style/HashSyntax]

Steps to reproduce the problem

Having the following Rubocop configuration:

Style/HashSyntax:
  EnforcedStyle: ruby19_no_mixed_keys

try to write:

{"#{accountant.id}": {number: "4711", name: "Test"}}
{"#{@accountant.id}": {number: "4711", name: "Test"}}
{"#@accountant.id": {number: "4711", name: "Test"}}

RuboCop version

We're using the latest Rubocop for these examples:

$ bundle exec rubocop -V
0.65.0 (using Parser 2.5.0.3, running on ruby 2.4.3 x86_64-linux)
@Drenmi Drenmi added the bug label Feb 21, 2019
tatsuyafw added a commit to tatsuyafw/rubocop that referenced this issue Apr 19, 2019
The `Style/HashSyntax` cop would register an offense when `EnforcedStyle` was
`ruby19_no_mixed_keys` and a hash key was an interpolated string
like the following code:

```
{"#{foo}": 1}
```

This change fixes that.
bbatsov pushed a commit that referenced this issue Apr 19, 2019
The `Style/HashSyntax` cop would register an offense when `EnforcedStyle` was
`ruby19_no_mixed_keys` and a hash key was an interpolated string
like the following code:

```
{"#{foo}": 1}
```

This change fixes that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants