rubocop-graphql 0.14.0 → 0.14.3

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: bf7d97ba00fa1e49f43e15e6dd5ee134169eedff3603dc2fcad6d85d832529f0
4
- data.tar.gz: ea8b222d69f599a1d9b341fadc15306f8a2b2aff17acf2853aa6129a45bdc056
3
+ metadata.gz: c1aef8d25bbcf29e3aac8dd31b10b16341f88a0e27d71a04290ee4c265686db4
4
+ data.tar.gz: 1f8e8a06d5f7c7b1a301c45672634b98fbd748b1904b7e8639bf7377b82d4654
5
5
  SHA512:
6
- metadata.gz: dc4926760bca79b7a6ea7f3cb73b3b035d52b7cdc2a3819a76aefaadf28b11aef232ee6fed961301cdc65467592effa0d02217d6fdbf8c91bf703688b5834f31
7
- data.tar.gz: 6b3bb0304272b6c6ec0b793f698f9139d53da73bbdf2038ab26d4734c754f5b098e075fcf354c361c71f1e82bdaf3be358be1c9b85065d631e5e54fa89b978a1
6
+ metadata.gz: 050f68792f4b7b042994e3bcb9cc9aef1d5d42dc548d91ec7799b7d83211adc4efee756510cdf18c282d99e11e589a4bea1566a1ee2605944da927a7ff10463d
7
+ data.tar.gz: 8ed14cde041d5d10f58f0e0ad9a8fee1c6a73f80e0d5c947af82fba6a5f70b7c72269e585f195f9123cea1a5bc0bebe37969d65e81dd55e49ce60fc89ab36fae
@@ -59,7 +59,7 @@ module RuboCop
59
59
 
60
60
  def register_offense(current)
61
61
  current_field_name = field_name(current)
62
- field_name_message = " in field `#{current_field_name}`" if current_field_name
62
+ field_name_message = " in field #{current_field_name}" if current_field_name
63
63
 
64
64
  message = format(
65
65
  self.class::MSG,
@@ -81,9 +81,16 @@ module RuboCop
81
81
  is_field_block = node.block_type? &&
82
82
  node.respond_to?(:method_name) &&
83
83
  node.method_name == :field
84
- return node.send_node.first_argument.value.to_s if is_field_block
85
84
 
86
- field_name(node.parent)
85
+ return field_name(node.parent) unless is_field_block
86
+
87
+ first_argument = node.send_node.first_argument
88
+ if first_argument.lvar_type?
89
+ variable_name = first_argument.children.first
90
+ return "with name from `#{variable_name}` variable"
91
+ end
92
+
93
+ "`#{first_argument.value}`"
87
94
  end
88
95
 
89
96
  def_node_search :argument_declarations, <<~PATTERN
@@ -52,7 +52,7 @@ module RuboCop
52
52
 
53
53
  def has_description?(node)
54
54
  has_i18n_description?(node) ||
55
- description_kwarg?(node)
55
+ description_method_call?(node)
56
56
  end
57
57
 
58
58
  def child_nodes(node)
@@ -67,10 +67,7 @@ module RuboCop
67
67
 
68
68
  def on_class(node)
69
69
  resolve_method_node = find_resolve_method_node(node)
70
- return if resolve_method_node.nil? ||
71
- resolve_method_node.arguments.any? do |arg|
72
- arg.arg_type? || arg.kwrestarg_type?
73
- end
70
+ return if resolve_method_node.nil? || ignore_arguments_type?(resolve_method_node)
74
71
 
75
72
  declared_arg_nodes = find_declared_arg_nodes(node)
76
73
  return unless declared_arg_nodes.any?
@@ -109,6 +106,12 @@ module RuboCop
109
106
  end
110
107
  end
111
108
 
109
+ def ignore_arguments_type?(resolve_method_node)
110
+ resolve_method_node.arguments.any? do |arg|
111
+ arg.arg_type? || arg.kwrestarg_type? || arg.forward_arg_type?
112
+ end
113
+ end
114
+
112
115
  def register_offense(node, unresolved_args)
113
116
  unresolved_args_source = unresolved_args.map { |v| "#{v}:" }.join(", ")
114
117
 
@@ -10,7 +10,7 @@ module RuboCop
10
10
  def_node_matcher :argument_block, <<~PATTERN
11
11
  (block
12
12
  (send nil? :argument ...)
13
- (args)
13
+ (args ...)
14
14
  $...
15
15
  )
16
16
  PATTERN
@@ -20,13 +20,18 @@ module RuboCop
20
20
  module DescriptionMethod
21
21
  extend RuboCop::NodePattern::Macros
22
22
 
23
- def_node_matcher :description_kwarg?, <<~PATTERN
24
- (send nil? :description
25
- {({str|dstr|const} ...)|(send const ...)|(send ({str|dstr} ...) _)})
23
+ DESCRIPTION_STRING = "{({str|dstr|const} ...)|(send const ...)|(send ({str|dstr} ...) _)}"
24
+
25
+ def_node_matcher :description_method_call?, <<~PATTERN
26
+ (send nil? :description #{DESCRIPTION_STRING})
27
+ PATTERN
28
+
29
+ def_node_matcher :description_with_block_arg?, <<~PATTERN
30
+ (send (lvar _) {:description= :description} #{DESCRIPTION_STRING})
26
31
  PATTERN
27
32
 
28
33
  def find_description_method(nodes)
29
- nodes.find { |kwarg| description_kwarg?(kwarg) }
34
+ nodes.find { |kwarg| description_method_call?(kwarg) || description_with_block_arg?(kwarg) }
30
35
  end
31
36
  end
32
37
  end
@@ -10,7 +10,7 @@ module RuboCop
10
10
  def_node_matcher :field_block, <<~PATTERN
11
11
  (block
12
12
  (send nil? :field ...)
13
- (args)
13
+ (args ...)
14
14
  {(begin $...)|$...}
15
15
  )
16
16
  PATTERN
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module GraphQL
3
- VERSION = "0.14.0".freeze
3
+ VERSION = "0.14.3".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Tsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-23 00:00:00.000000000 Z
11
+ date: 2022-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
- rubygems_version: 3.2.15
145
+ rubygems_version: 3.2.33
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Automatic performance checking tool for Ruby code.