Class: Rubocop::Cop::RSpec::SingleLineHook
- Defined in:
- lib/rubocop/cop/rspec/single_line_hook.rb
Overview
Checks for single-line hook blocks
Constant Summary collapse
- MESSAGE =
"Don't use single-line hook blocks."
Instance Method Summary collapse
- #on_block(node) ⇒ Object (also: #on_numblock)
- #rspec_hook?(node) ⇒ Object
Instance Method Details
#on_block(node) ⇒ Object Also known as: on_numblock
33 34 35 36 37 38 |
# File 'lib/rubocop/cop/rspec/single_line_hook.rb', line 33 def on_block(node) return unless node.single_line? return unless rspec_hook?(node) add_offense(node, message: MESSAGE) end |
#rspec_hook?(node) ⇒ Object
29 30 31 |
# File 'lib/rubocop/cop/rspec/single_line_hook.rb', line 29 def_node_search :rspec_hook?, <<~PATTERN (send nil? {:after :around :before} ...) PATTERN |