rubocop-grape 0.2.2 → 0.3.0

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
  SHA256:
3
- metadata.gz: 92c8005ffcb25101074781a0e8ef2dde2eec522fe78d8c8a56c2b4bc19f0ecec
4
- data.tar.gz: 91e7e2fa44a245223f72235c9655a9d124232f09ecb27eb32bae8a7d01725294
3
+ metadata.gz: f4f465c44799edf9ecb17a837d1e85bde5b628c29cb15aad03131878f9c46760
4
+ data.tar.gz: 8b788b780a6503f2ee4fd540271221c88d644a3616d8f21f0c3033a151a80e2e
5
5
  SHA512:
6
- metadata.gz: 6becb4f74dcfaa3c922a5c4aab58f4b540286f412c2d4c697aea3bfe69ce16d32ce795b0944b7e1401fd8ed98aa0f779a95d54ce7a1e51b053084cf4bafcd8d9
7
- data.tar.gz: 507a763177ce9a01c1b50fbe067a37c40673c673a469daea3d3c6180dedeac16671e87bbbb3c2b64c625be599dcc020ebacd964804dad6d26f6206915038a864
6
+ metadata.gz: c17941eb7ca48f32fbc0d3f53654a8917c847b00df6b1145aab1093ef86be29e628bec85c3d35400208ebc7c19374dc15f8649568506564d9749202875232539
7
+ data.tar.gz: 0f2163c4f45959cce98ce8682ddc4f188ff642559e62085bcd09fd0b32b764f2d983e1830aae338e1cb510e83923349886d7185e6cf5cb1b0edd61b0b23265e6
@@ -46,18 +46,27 @@ module RuboCop
46
46
  def on_block(node)
47
47
  return unless (body = params_block?(node))
48
48
 
49
- if body.type == :begin
50
- body.children.each(&method(:check_field_name))
51
- else
52
- check_field_name(body)
53
- end
49
+ find_field_node(body)
54
50
  end
55
51
 
56
52
  private
57
53
 
54
+ def find_field_node(node)
55
+ case node.type
56
+ when :begin
57
+ node.each_child_node(&method(:find_field_node))
58
+ when :block
59
+ find_field_node(node.send_node)
60
+ find_field_node(node.body)
61
+ else
62
+ check_field_name(node)
63
+ end
64
+ end
65
+
58
66
  def check_field_name(node)
59
- field = node.children[2]
60
- check_name(node, field_name(node), field.source_range)
67
+ return unless (field_name = field_name(node))
68
+
69
+ check_name(node, field_name, node.first_argument.source_range)
61
70
  end
62
71
 
63
72
  def message(style)
@@ -26,11 +26,11 @@ module RuboCop
26
26
  @config.for_all_cops['GrapeDir']
27
27
  end
28
28
 
29
- def roundup_relevant_cops(filename)
29
+ def roundup_relevant_cops(processed_source)
30
30
  super.select do |cop|
31
31
  next true unless cop.class.name.match?(/RuboCop::Cop::Grape::.+$/)
32
32
 
33
- grape_files.include?(filename)
33
+ grape_files.include?(processed_source.path)
34
34
  end
35
35
  end
36
36
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Grape
5
- VERSION = '0.2.2'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akito Hikasa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-14 00:00:00.000000000 Z
11
+ date: 2023-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop