rubocop-graphql 1.5.2 → 1.5.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
  SHA256:
3
- metadata.gz: 54137ed6106e3d8c0d2c675ea02e41989aef1d4480edf875071c9c7918a96fba
4
- data.tar.gz: a1a0b7d307854a39d4b4761d77cc829569dd9e97453a329d027886331407aae0
3
+ metadata.gz: e0d8efee42cd1c4f7443f6d83ffcf7f0aeb030de07573486bbf12bc9f758e0a2
4
+ data.tar.gz: 4bc42c5823b8dceca37a2ca48b086478c7fa360817f864ce4ee2c420e103fba0
5
5
  SHA512:
6
- metadata.gz: 9e1fc8711b226bd656ca33d8409949a40667e9eabf31ca55a3536ae5f4f54f3af4e7254cbaa589e406172c724afdeb6772ffe5dd689909ebeb09608c7c94b848
7
- data.tar.gz: 392b99c409b0e2b8247fff232d35fab529c1abf5eb3f7b648f40eb9020b07a5c56f074d88538626e564872a4a13f1cb59ee20a5ddc0c982099a2aa3edc596289
6
+ metadata.gz: addcc849a825b94134f1d19743a10a7c6784d984831b41f3b9e0292c2aca6a2ab1d055bd97fae7fed9a918d4edf865f8c4d81684f43d0b9b981dab782669b476
7
+ data.tar.gz: c7958b6e456137e98f4116954b6982d417eab63202ce4da778fd154a70620159e44ce69da7cac078a25d983a917ebfbc02f9acfcf11681f90399be911307df2b
@@ -47,6 +47,7 @@ module RuboCop
47
47
  class FieldDefinitions < Base # rubocop:disable Metrics/ClassLength
48
48
  extend AutoCorrector
49
49
  include ConfigurableEnforcedStyle
50
+ include CommentsHelp
50
51
  include RuboCop::GraphQL::NodePattern
51
52
  include RuboCop::Cop::RangeHelp
52
53
  include RuboCop::GraphQL::Sorbet
@@ -212,17 +213,19 @@ module RuboCop
212
213
  end
213
214
 
214
215
  def insert_new_resolver(corrector, field_definition, resolver_definition)
216
+ resolver_definition_range = source_range_with_comment(resolver_definition)
215
217
  source_to_insert =
216
218
  "\n#{signature_to_insert(resolver_definition)}\n" \
217
- "#{indent(resolver_definition)}#{resolver_definition.source}\n"
219
+ "#{indent(resolver_definition)}#{resolver_definition_range.source.strip}\n"
218
220
 
219
221
  field_definition_range = range_including_heredoc(field_definition)
220
222
  corrector.insert_after(field_definition_range, source_to_insert)
221
223
  end
222
224
 
223
225
  def remove_old_resolver(corrector, resolver_definition)
226
+ resolver_definition_range = source_range_with_comment(resolver_definition)
224
227
  range_to_remove = range_with_surrounding_space(
225
- range: resolver_definition.source_range, side: :left
228
+ range: resolver_definition_range, side: :left
226
229
  )
227
230
  corrector.remove(range_to_remove)
228
231
 
@@ -230,8 +233,9 @@ module RuboCop
230
233
 
231
234
  return unless resolver_signature
232
235
 
236
+ resolver_signature_range = source_range_with_comment(resolver_signature)
233
237
  range_to_remove = range_with_surrounding_space(
234
- range: resolver_signature.source_range, side: :left
238
+ range: resolver_signature_range, side: :left
235
239
  )
236
240
  corrector.remove(range_to_remove)
237
241
  end
@@ -241,7 +245,8 @@ module RuboCop
241
245
 
242
246
  return unless signature
243
247
 
244
- "\n#{indent(signature)}#{signature.source}"
248
+ range = source_range_with_comment(signature)
249
+ "\n#{indent(signature)}#{range.source.strip}"
245
250
  end
246
251
 
247
252
  def indent(node)
@@ -8,7 +8,6 @@ module RuboCop
8
8
  #
9
9
  # The maximum allowed length is configurable using the Max option.
10
10
  class ResolverMethodLength < Base
11
- include RuboCop::Cop::ConfigurableMax
12
11
  include RuboCop::Cop::CodeLength
13
12
 
14
13
  MSG = "ResolverMethod has too many lines. [%<total>d/%<max>d]"
@@ -156,7 +156,7 @@ module RuboCop
156
156
  .sub(/([^s])$/, "\\1s")
157
157
  .to_sym
158
158
  else
159
- name
159
+ name_as_string.to_sym
160
160
  end
161
161
  end
162
162
 
@@ -186,8 +186,7 @@ module RuboCop
186
186
 
187
187
  # @!method resolve_method_definition(node)
188
188
  def_node_search :resolve_method_definition, <<~PATTERN
189
- (def {:resolve | :authorized?}
190
- (args ...) ...)
189
+ (def {:resolve | :authorized?} (args ...) ...)
191
190
  PATTERN
192
191
  end
193
192
  end
@@ -8,16 +8,23 @@ module RuboCop
8
8
  end
9
9
 
10
10
  def range_including_heredoc(node)
11
- field = RuboCop::GraphQL::Field.new(node)
12
- last_heredoc = field.kwargs.instance_variable_get(:@nodes).reverse.find do |kwarg|
13
- heredoc?(kwarg.value)
14
- end&.value
11
+ last_heredoc = find_last_heredoc(node)
15
12
 
16
13
  range = node.source_range
17
14
  range = range.join(last_heredoc.loc.heredoc_end) if last_heredoc
18
15
 
19
16
  range_by_whole_lines(range)
20
17
  end
18
+
19
+ private
20
+
21
+ def find_last_heredoc(node)
22
+ # Do a cheap check first.
23
+ return nil unless node.source.include?("<<")
24
+
25
+ heredocs = node.descendants.select { |descendant| heredoc?(descendant) }
26
+ heredocs.max_by { |heredoc| heredoc.loc.heredoc_end }
27
+ end
21
28
  end
22
29
  end
23
30
  end
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module GraphQL
3
- VERSION = "1.5.2".freeze
3
+ VERSION = "1.5.4".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: 1.5.2
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Tsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-01 00:00:00.000000000 Z
11
+ date: 2024-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0.90'
61
+ version: '1.50'
62
62
  - - "<"
63
63
  - !ruby/object:Gem::Version
64
64
  version: '2'
@@ -68,7 +68,7 @@ dependencies:
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: '0.90'
71
+ version: '1.50'
72
72
  - - "<"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '2'