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

Cop to check "Deprecate defining enums with keywords args" #1322

Closed
guillaumebriday opened this issue Aug 7, 2024 · 1 comment
Closed

Cop to check "Deprecate defining enums with keywords args" #1322

guillaumebriday opened this issue Aug 7, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@guillaumebriday
Copy link

Is your feature request related to a problem? Please describe.

When upgrading my app to Rails 7.2.0rc1, I got this deprecation warning:

DEPRECATION WARNING: Defining enums with keyword arguments is deprecated and will be removed
in Rails 8.0. Positional arguments should be used instead:

See: https://sparkrails.com/rails-7/2024/02/13/rails-7-deprecated-enum-with-keywords-args.html
And: rails/rails#50987

Describe the solution you'd like

That would be cool to have a cop that ensure the new syntax is used:

class Function > ApplicationRecord
  # BAD
  enum color: [:red, :blue],
       type: [:instance, :class]

  # GOOD
  enum :color, [:red, :blue]
  enum :type, [:instance, :class]
end

Thank you in advance!
And thanks a lot for your awesome work on Rubocop 🙏

@koic
Copy link
Member

koic commented Aug 7, 2024

This feature request is a dup with #1238. Thank you.

@koic koic closed this as completed Aug 7, 2024
@koic koic added the duplicate This issue or pull request already exists label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants