rubocop-elegant 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/elegant/no_empty_lines_in_blocks.rb +18 -0
- data/rubocop-elegant.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68c6e6f486a9804d01f7be2db7087ed14501cec590250e50b89d32511c3cce97
|
|
4
|
+
data.tar.gz: f654452715b5e92d85fe3d3e410aca24858a9f28ce25ece59103d66bd3f27582
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af01d8551f274a0c56e69f3caed9097d7db6ffe55d7be9519ba7ea8fc169c6a484eba3e5d5af64e0788eb690d5bd4d155034d60d1d473de6a86bfa4baba480d9
|
|
7
|
+
data.tar.gz: f58fb9bbbb83617de532b7ac4712d3089fc61548d43040235cef7bbf46e533a6a5b9d0477b6c2c2124bde2a6b1adcb02eac99f8cec5edcbf0e3831c632e3a620
|
|
@@ -15,6 +15,7 @@ module RuboCop
|
|
|
15
15
|
def on_new_investigation
|
|
16
16
|
super
|
|
17
17
|
@reported = []
|
|
18
|
+
@gaps = scan
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
def on_block(node)
|
|
@@ -71,12 +72,29 @@ module RuboCop
|
|
|
71
72
|
def empty(lines)
|
|
72
73
|
result = []
|
|
73
74
|
lines.each do |num|
|
|
75
|
+
next if @gaps.include?(num)
|
|
74
76
|
line = processed_source.lines[num - 1]
|
|
75
77
|
result << num if line.strip.empty?
|
|
76
78
|
end
|
|
77
79
|
result
|
|
78
80
|
end
|
|
79
81
|
|
|
82
|
+
def scan
|
|
83
|
+
gaps = []
|
|
84
|
+
ast = processed_source.ast
|
|
85
|
+
return gaps if ast.nil?
|
|
86
|
+
ast.each_node(:def, :defs) do |node|
|
|
87
|
+
nxt = node.right_sibling
|
|
88
|
+
next unless nxt.is_a?(RuboCop::AST::Node)
|
|
89
|
+
next unless %i[def defs].include?(nxt.type)
|
|
90
|
+
first = node.last_line + 1
|
|
91
|
+
last = nxt.first_line - 1
|
|
92
|
+
next if first > last
|
|
93
|
+
(first..last).each { |n| gaps << n }
|
|
94
|
+
end
|
|
95
|
+
gaps
|
|
96
|
+
end
|
|
97
|
+
|
|
80
98
|
def register(num)
|
|
81
99
|
return if @reported.include?(num)
|
|
82
100
|
@reported << num
|
data/rubocop-elegant.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
|
|
10
10
|
s.required_ruby_version = '>=2.2'
|
|
11
11
|
s.name = 'rubocop-elegant'
|
|
12
|
-
s.version = '0.0.
|
|
12
|
+
s.version = '0.0.20'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
s.summary = 'Set of custom RuboCop cops for elegant Ruby coding'
|
|
15
15
|
s.description =
|