/
empty_line_after_hook.rb
52 lines (48 loc) · 1.08 KB
/
empty_line_after_hook.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
# Checks if there is an empty line after hook blocks.
#
# @example
# # bad
# before { do_something }
# it { does_something }
#
# # bad
# after { do_something }
# it { does_something }
#
# # bad
# around { |test| test.run }
# it { does_something }
#
# # good
# before { do_something }
#
# it { does_something }
#
# # good
# after { do_something }
#
# it { does_something }
#
# # good
# around { |test| test.run }
#
# it { does_something }
#
class EmptyLineAfterHook < Cop
extend AutoCorrector
include EmptyLineSeparation
MSG = 'Add an empty line after `%<hook>s`.'
def on_block(node)
return unless hook?(node)
missing_separating_line_offense(node) do |method|
format(MSG, hook: method)
end
end
end
end
end
end