Class: RuboCop::Cop::Capybara::FindAllFirst
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Capybara::FindAllFirst
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/capybara/find_all_first.rb
Overview
Enforces use of ‘first` instead of `all` with `first` or `[0]`.
Constant Summary collapse
- MSG =
'Use `first(%<selector>s)`.'
- RESTRICT_ON_SEND =
%i[all find].freeze
Instance Method Summary collapse
Instance Method Details
permalink #find_all_first?(node) ⇒ Object
[View source]
27 28 29 30 31 32 |
# File 'lib/rubocop/cop/capybara/find_all_first.rb', line 27 def_node_matcher :find_all_first?, <<~PATTERN { (send (send _ :all _ ...) :first) (send (send _ :all _ ...) :[] (int 0)) } PATTERN |
permalink #include_match_first?(node) ⇒ Object
[View source]
35 36 37 |
# File 'lib/rubocop/cop/capybara/find_all_first.rb', line 35 def_node_matcher :include_match_first?, <<~PATTERN (send _ {:find :all} _ $(hash <(pair (sym :match) (sym :first)) ...>)) PATTERN |
permalink #on_send(node) ⇒ Object
[View source]
39 40 41 42 |
# File 'lib/rubocop/cop/capybara/find_all_first.rb', line 39 def on_send(node) on_all_first(node) on_match_first(node) end |