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/MutableConstant autocorrect incorrectly wraps %w arrays with another array #3959

Closed
shepmaster opened this issue Jan 23, 2017 · 2 comments · Fixed by #3962
Closed

Style/MutableConstant autocorrect incorrectly wraps %w arrays with another array #3959

shepmaster opened this issue Jan 23, 2017 · 2 comments · Fixed by #3962

Comments

@shepmaster
Copy link

Expected behavior

# frozen_string_literal: true
FOO = %w(one two three).freeze

Actual behavior

# frozen_string_literal: true
FOO = [%w(one two three)].freeze

Note the extra array.

Steps to reproduce the problem

Save this as foo.rb:

# frozen_string_literal: true
FOO = %w(one two three)
rubocop -c /dev/null -a foo.rb

RuboCop version

$ rubocop -V
0.47.1 (using Parser 2.3.3.1, running on ruby 2.3.3 x86_64-darwin16)
@mikegee
Copy link
Contributor

mikegee commented Jan 23, 2017

I confirmed this and I'm looking into it.

mikegee added a commit to mikegee/rubocop that referenced this issue Jan 23, 2017
`Style/MutableConstant` shouldn't wrap "percent arrays" (`%w`, `%W`,
`%i`, etc.) with extra brackets when autocorrecting
bbatsov pushed a commit that referenced this issue Jan 24, 2017
`Style/MutableConstant` shouldn't wrap "percent arrays" (`%w`, `%W`,
`%i`, etc.) with extra brackets when autocorrecting
@shepmaster
Copy link
Author

Thank you @mikegee !

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 a pull request may close this issue.

2 participants