Class: Gitlab::Styles::Rubocop::Cop::RSpec::SingleLineHook

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/styles/rubocop/cop/rspec/single_line_hook.rb

Overview

This cop checks for single-line hook blocks

Examples:


# bad
before { do_something }
after(:each) { undo_something }

# good
before do
  do_something
end

after(:each) do
  undo_something
end

Constant Summary collapse

MESSAGE =
"Don't use single-line hook blocks."

Constants included from Rspec::Helpers

Rspec::Helpers::LET

Instance Method Summary collapse

Instance Method Details

#on_block(node) ⇒ Object



34
35
36
37
38
39
# File 'lib/gitlab/styles/rubocop/cop/rspec/single_line_hook.rb', line 34

def on_block(node)
  return unless node.single_line?
  return unless rspec_hook?(node)

  add_offense(node, message: MESSAGE)
end