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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a46226de426fa7b76116750fea759a20d48125a0d44a546accb374f5ba91da57
4
- data.tar.gz: 85e3592cd2395049c4ce3f228d4a60b43dcdcb3a8a7d7eb909cead9abcd87a5c
3
+ metadata.gz: 68c6e6f486a9804d01f7be2db7087ed14501cec590250e50b89d32511c3cce97
4
+ data.tar.gz: f654452715b5e92d85fe3d3e410aca24858a9f28ce25ece59103d66bd3f27582
5
5
  SHA512:
6
- metadata.gz: 72f1dc5fccc9a27c3c8cbd7a39aabf4d71e8577bb6149879a2213546e0c6010a0bed1ae8035f0fdb55bc0609db38582db4737043d3db2b75783dab83e2fb8d13
7
- data.tar.gz: 7e430e58ecec3d31bdfdd03895117d1e4cb18e02028e0a9156680f68d9c9caaf16653eab3a07b25eac44531956b02648f54b8d830ef761c804cc65dd8b3a2f2e
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
@@ -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.19'
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 =
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-elegant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko