forked from rubocop/rubocop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
empty_lines_around_class_body.rb
85 lines (80 loc) · 1.62 KB
/
empty_lines_around_class_body.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# frozen_string_literal: true
module RuboCop
module Cop
module Layout
# Checks if empty lines around the bodies of classes match
# the configuration.
#
# @example EnforcedStyle: empty_lines
# # good
#
# class Foo
#
# def bar
# # ...
# end
#
# end
#
# @example EnforcedStyle: empty_lines_except_namespace
# # good
#
# class Foo
# class Bar
#
# # ...
#
# end
# end
#
# @example EnforcedStyle: empty_lines_special
# # good
# class Foo
#
# def bar; end
#
# end
#
# @example EnforcedStyle: beginning_only
# # good
#
# class Foo
#
# def bar
# # ...
# end
# end
#
# @example EnforcedStyle: ending_only
# # good
#
# class Foo
# def bar
# # ...
# end
#
# end
#
# @example EnforcedStyle: no_empty_lines (default)
# # good
#
# class Foo
# def bar
# # ...
# end
# end
class EmptyLinesAroundClassBody < Base
include EmptyLinesAroundBody
extend AutoCorrector
KIND = 'class'
def on_class(node)
first_line = node.parent_class.first_line if node.parent_class
check(node, node.body, adjusted_first_line: first_line)
end
def on_sclass(node)
check(node, node.body)
end
end
end
end
end