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/SymbolArray autocorrects without respecting Style/PercentLiteralDelimiters #4199

Closed
brandonweiss opened this issue Mar 29, 2017 · 2 comments
Labels

Comments

@brandonweiss
Copy link
Contributor

Style/PercentLiteralDelimiters:
  PreferredDelimiters:
    "%i": "[]"

Will autocorrect [:foo, :bar] to %i(foo bar).

@bbatsov bbatsov added the bug label Mar 29, 2017
@Drenmi
Copy link
Collaborator

Drenmi commented Mar 29, 2017

Looks like the PercentLiteral mixin doesn't care for delimiter configuration at all at this point. Fixing it will likely also impact Style/WordArray (hopefully for the better.) 🙂

@pocke
Copy link
Collaborator

pocke commented Mar 30, 2017

I'll fix this bug.

pocke added a commit to pocke/rubocop that referenced this issue Mar 30, 2017
…y` cop

See rubocop#4199

If `PreferredDelimiters` option is specified, `Style/SymbolArray` and `Style/WordArray` cops auto correct to not expected code.
The option is ignored.

For example

```ruby
 # PreferredDelimiters is []

 # Before
 [:a, :b, :c]
 ['a', 'b', 'c']

 # Corrected
 %i(a b c) # Not %i[]
 %w(a b c) # Not %w[]
```

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

No branches or pull requests

4 participants