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

auto correct Rails/EnumHash fails on wordArray enum #159

Closed
ngouy opened this issue Nov 29, 2019 · 7 comments
Closed

auto correct Rails/EnumHash fails on wordArray enum #159

ngouy opened this issue Nov 29, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@ngouy
Copy link
Contributor

ngouy commented Nov 29, 2019

For wordArray, autocorrect should add missings "

Base to auto correct :

MyModel < ActiveRecord::Base
  enum my_enum: %w[value1 value2 value3]
end
$<--- rubocop --auto-correct app/models/my_model.rb
>>
>> app/models/my_model.rb:x:x: C: [Corrected] Rails/EnumHash: Enum defined as an 
>> array found in state enum declaration. Use hash syntax instead.
>>  enum state: %w[value0 value1 value2]

Expected behavior

MyModel < ActiveRecord::Base
  enum my_enum: { "value1" => 0, "value2" => 1, "value3" => 2 }
end

Actual behavior

MyModel < ActiveRecord::Base
  enum my_enum: { value1 => 0, value2 => 1, value3 => 2 }
end

RuboCop version

0.77.0

@ngouy
Copy link
Contributor Author

ngouy commented Nov 29, 2019

I will try to fix it within next week when I wiill have some time

@Knack
Copy link
Contributor

Knack commented Dec 2, 2019

It fails with %i too

@fakenine
Copy link

fakenine commented Dec 2, 2019

Same issue here with a %i enum array

@ngouy
Copy link
Contributor Author

ngouy commented Dec 2, 2019

I'll try to takle it this week, I'll keep you updated

ngouy added a commit to ngouy/rubocop-rails that referenced this issue Dec 3, 2019
ngouy added a commit to ngouy/rubocop-rails that referenced this issue Dec 3, 2019
ngouy added a commit to ngouy/rubocop-rails that referenced this issue Dec 3, 2019
ngouy added a commit to ngouy/rubocop-rails that referenced this issue Dec 3, 2019
@koic koic added the bug Something isn't working label Dec 3, 2019
ngouy added a commit to ngouy/rubocop-rails that referenced this issue Dec 3, 2019
ngouy added a commit to ngouy/rubocop-rails that referenced this issue Dec 3, 2019
@koic koic closed this as completed in 4d79291 Dec 3, 2019
koic added a commit that referenced this issue Dec 3, 2019
…cent-literals

FIX #159 enum hash auto correct for % arrays
@malikusman
Copy link

This issue still persists.

@ngouy
Copy link
Contributor Author

ngouy commented Feb 7, 2023

@malikusman could it be another variation of this?
There is a non-regression test for the exact example I've given above here

@malikusman
Copy link

malikusman commented Feb 7, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants