Class: RuboCop::Cop::RailsAccessibility::NoPositiveTabindex

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/rails_accessibility/no_positive_tabindex.rb

Constant Summary collapse

MSG =
"Positive tabindex is error-prone and often inaccessible."

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubocop/cop/rails_accessibility/no_positive_tabindex.rb', line 11

def on_send(node)
  receiver, _method_name, *args = *node

  return unless receiver.nil?

  args_each = args.select do |arg|
    arg.type == :hash
  end
  args_each.each do |hash|
    hash.each_pair do |key, value|
      next if key.type == :dsym
      next unless key.respond_to?(:value)
      break unless key.value == :tabindex && value.source.to_i.positive?

      add_offense(hash)
    end
  end
end