rubocop-mirego 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 092aa7b1f465b752fe8c6416f871767fb643f3ac
4
- data.tar.gz: b836c8a3674b77bf3be615b4cb4016ff13c7900b
3
+ metadata.gz: fbf7f57cdcbd4350c84b2dc8169dab68d71cc012
4
+ data.tar.gz: 1d0eba62dc357fe5ea8261d96188241a533ef98d
5
5
  SHA512:
6
- metadata.gz: e2f3a991ac5820e2a8a46fe545337688bc7f53099fd596584da84a736dc3e83c22493c686701c96948aba823d652e0b1732e3409443db120161ddc5a86aa7fe3
7
- data.tar.gz: faf7cfb1f81200f7b2d24b12af3e121d5fef1b9b7e4d9ec2ea8d864cffb5592b1797a3b7428ed47b67aa30e8b1a413324fddc2149f653b0173ba37d32dee7b4e
6
+ metadata.gz: a8078e6e5435412b24c3b0df36e0ab77a835cbd7a593477d5bb0b80b1aa82529a31b5c9c6d7d14253da18aae3a176e7b61003c6715b83eea6ffd15f9f18bb802
7
+ data.tar.gz: f26636adaf0edd7f0d4f363f820a0cae460e45b76ca254eb334de882ab976c2d394c40e714e013607ae8a067e4643ce68a60b225481fc06eacc86cb5cac7a488
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-mirego (0.0.2)
4
+ rubocop-mirego (0.0.3)
5
5
  rubocop (= 0.39.0)
6
6
 
7
7
  GEM
@@ -49,4 +49,4 @@ DEPENDENCIES
49
49
  rubocop-rspec (~> 1.4, >= 1.4.1)
50
50
 
51
51
  BUNDLED WITH
52
- 1.11.2
52
+ 1.13.7
@@ -20,10 +20,20 @@ module RuboCop
20
20
  expressions = *node
21
21
  return nil unless node
22
22
 
23
- if return_node_type(node: node)
24
- check_return_node(node: node, children: node.children)
25
- elsif expressions.last && return_node_type(node: expressions.last)
26
- check_return_node(node: node, children: expressions.last.to_a)
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
 
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module Mirego
3
- VERSION = '0.0.3'.freeze
3
+ VERSION = '0.0.4'.freeze
4
4
  end
5
5
  end
@@ -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.3
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: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2017-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop