rubocop-mirego 0.0.3 → 0.0.4
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbf7f57cdcbd4350c84b2dc8169dab68d71cc012
|
4
|
+
data.tar.gz: 1d0eba62dc357fe5ea8261d96188241a533ef98d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8078e6e5435412b24c3b0df36e0ab77a835cbd7a593477d5bb0b80b1aa82529a31b5c9c6d7d14253da18aae3a176e7b61003c6715b83eea6ffd15f9f18bb802
|
7
|
+
data.tar.gz: f26636adaf0edd7f0d4f363f820a0cae460e45b76ca254eb334de882ab976c2d394c40e714e013607ae8a067e4643ce68a60b225481fc06eacc86cb5cac7a488
|
data/Gemfile.lock
CHANGED
@@ -20,10 +20,20 @@ module RuboCop
|
|
20
20
|
expressions = *node
|
21
21
|
return nil unless node
|
22
22
|
|
23
|
-
if
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
if expressions.empty?
|
24
|
+
validate_expression(expression: node)
|
25
|
+
else
|
26
|
+
expressions.compact.each { |expression| validate_expression(expression: expression) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate_expression(expression:)
|
31
|
+
if return_node_type(node: expression)
|
32
|
+
check_return_node(node: expression, children: expression.children)
|
33
|
+
elsif expression.respond_to?(:children)
|
34
|
+
children = expression.children.compact
|
35
|
+
|
36
|
+
check_return_node(node: expression, children: children.last.to_a) if children.last && return_node_type(node: children.last)
|
27
37
|
end
|
28
38
|
end
|
29
39
|
|
@@ -26,7 +26,7 @@ describe RuboCop::Cop::Mirego::ExplicitReturnValue do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe 'with a return missing a value with a conditional' do
|
29
|
+
describe 'with a return missing a value with a `unless` conditional' do
|
30
30
|
let(:source) { 'def test; return unless bool; end' }
|
31
31
|
|
32
32
|
specify do
|
@@ -35,6 +35,24 @@ describe RuboCop::Cop::Mirego::ExplicitReturnValue do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
describe 'with a return missing a value with a `if` conditional' do
|
39
|
+
let(:source) { 'def test; return unless bool; end' }
|
40
|
+
|
41
|
+
specify do
|
42
|
+
expect(cop.offenses.size).to eql(1)
|
43
|
+
expect(cop.offenses.first.cop_name).to eql('Mirego/ExplicitReturnValue')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'with a return missing a value with a expression after the return' do
|
48
|
+
let(:source) { 'def test; return unless bool; foobar end' }
|
49
|
+
|
50
|
+
specify do
|
51
|
+
expect(cop.offenses.size).to eql(1)
|
52
|
+
expect(cop.offenses.first.cop_name).to eql('Mirego/ExplicitReturnValue')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
38
56
|
describe 'with a implicit return' do
|
39
57
|
let(:source) { 'def test; test; end' }
|
40
58
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-mirego
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-François Chaput
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|