Class: RuboCop::Cop::Rails::EnumUniqueness
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::EnumUniqueness
- Includes:
- Duplication
- Defined in:
- lib/rubocop/cop/rails/enum_uniqueness.rb
Overview
Looks for duplicate values in enum declarations.
Constant Summary collapse
- MSG =
'Duplicate value `%<value>s` found in `%<enum>s` enum declaration.'
- RESTRICT_ON_SEND =
%i[enum].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rubocop/cop/rails/enum_uniqueness.rb', line 50 def on_send(node) enum?(node) do |key, args| consecutive_duplicates(args.values).each do |item| add_offense(item, message: (key, item)) end end enum_with_old_syntax?(node) do |pairs| pairs.each do |pair| enum_values(pair) do |key, args| consecutive_duplicates(args.values).each do |item| add_offense(item, message: (key, item)) end end end end end |