Rubocop: Style/MutableConstant autocorrect incorrectly wraps %w arrays with another array

Created on 23 Jan 2017  路  2Comments  路  Source: rubocop-hq/rubocop

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)

Most helpful comment

I confirmed this and I'm looking into it.

All 2 comments

I confirmed this and I'm looking into it.

Thank you @mikegee !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aqualon picture Aqualon  路  3Comments

bquorning picture bquorning  路  3Comments

bbugh picture bbugh  路  3Comments

cabello picture cabello  路  3Comments

mlammers picture mlammers  路  3Comments