rubocop-graphql 0.14.5 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +4 -2
- data/lib/rubocop/cop/graphql/argument_uniqueness.rb +2 -1
- data/lib/rubocop/cop/graphql/extract_input_type.rb +1 -1
- data/lib/rubocop/cop/graphql/extract_type.rb +1 -1
- data/lib/rubocop/cop/graphql/field_definitions.rb +24 -8
- data/lib/rubocop/cop/graphql/field_hash_key.rb +6 -1
- data/lib/rubocop/cop/graphql/field_method.rb +1 -0
- data/lib/rubocop/cop/graphql/field_uniqueness.rb +2 -1
- data/lib/rubocop/cop/graphql/legacy_dsl.rb +2 -1
- data/lib/rubocop/cop/graphql/multiple_field_definitions.rb +105 -0
- data/lib/rubocop/cop/graphql/object_description.rb +2 -0
- data/lib/rubocop/cop/graphql/ordered_arguments.rb +2 -0
- data/lib/rubocop/cop/graphql/ordered_fields.rb +1 -0
- data/lib/rubocop/cop/graphql/resolver_method_length.rb +2 -1
- data/lib/rubocop/cop/graphql/unused_argument.rb +2 -0
- data/lib/rubocop/cop/graphql_cops.rb +1 -0
- data/lib/rubocop/graphql/argument/block.rb +1 -0
- data/lib/rubocop/graphql/argument/kwargs.rb +4 -0
- data/lib/rubocop/graphql/argument.rb +3 -0
- data/lib/rubocop/graphql/description_method.rb +2 -0
- data/lib/rubocop/graphql/field/block.rb +1 -0
- data/lib/rubocop/graphql/field/kwargs.rb +6 -0
- data/lib/rubocop/graphql/field.rb +3 -0
- data/lib/rubocop/graphql/node_pattern.rb +3 -0
- data/lib/rubocop/graphql/schema_member.rb +2 -1
- data/lib/rubocop/graphql/sorbet.rb +1 -0
- data/lib/rubocop/graphql/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07b20077b6c0a6ec0ff0aa58528140efd701a90c3059c2483b213ea9039dfe35
|
4
|
+
data.tar.gz: 7f2e405ea2241a8f6d918577e75bfe523125700ed48441d434a1e671d1a93e56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ac7dc1b72346ef4f42d6739b1c0c9a10b35a80ab5b9421c937a3673d755384a15d06f5e358e88f1a4a29e426e7e2eea41e6e54634a76b8cf8dfeb34ea3a84ca
|
7
|
+
data.tar.gz: 68aa6accd90828a337828ba69f7e7d42bd5034644762cf83021a71352cfd3a8c7292934a3da2d30b1522a7055502ee49cd7c6ed7abcf6590a6a7b00062847eb7
|
data/config/default.yml
CHANGED
@@ -38,6 +38,10 @@ GraphQL/FieldDefinitions:
|
|
38
38
|
- group_definitions
|
39
39
|
- define_resolver_after_definition
|
40
40
|
|
41
|
+
GraphQL/MultipleFieldDefinitions:
|
42
|
+
Enabled: true
|
43
|
+
Description: 'Ensures that fields with multiple definitions are grouped together'
|
44
|
+
|
41
45
|
GraphQL/FieldDescription:
|
42
46
|
Enabled: true
|
43
47
|
VersionAdded: '0.80'
|
@@ -109,5 +113,3 @@ GraphQL/OrderedFields:
|
|
109
113
|
GraphQL/UnusedArgument:
|
110
114
|
Enabled: true
|
111
115
|
Description: 'Arguments should either be listed explicitly or **rest should be in the resolve signature'
|
112
|
-
|
113
|
-
|
@@ -80,7 +80,7 @@ module RuboCop
|
|
80
80
|
|
81
81
|
is_field_block = node.block_type? &&
|
82
82
|
node.respond_to?(:method_name) &&
|
83
|
-
node.
|
83
|
+
node.method?(:field)
|
84
84
|
|
85
85
|
return field_name(node.parent) unless is_field_block
|
86
86
|
|
@@ -93,6 +93,7 @@ module RuboCop
|
|
93
93
|
"`#{first_argument.value}`"
|
94
94
|
end
|
95
95
|
|
96
|
+
# @!method argument_declarations(node)
|
96
97
|
def_node_search :argument_declarations, <<~PATTERN
|
97
98
|
(send nil? :argument (:sym _) ...)
|
98
99
|
PATTERN
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module GraphQL
|
6
|
-
#
|
6
|
+
# Checks consistency of field definitions
|
7
7
|
#
|
8
8
|
# EnforcedStyle supports two modes:
|
9
9
|
#
|
@@ -52,6 +52,7 @@ module RuboCop
|
|
52
52
|
include RuboCop::GraphQL::Sorbet
|
53
53
|
include RuboCop::GraphQL::Heredoc
|
54
54
|
|
55
|
+
# @!method field_kwargs(node)
|
55
56
|
def_node_matcher :field_kwargs, <<~PATTERN
|
56
57
|
(send nil? :field
|
57
58
|
...
|
@@ -62,8 +63,9 @@ module RuboCop
|
|
62
63
|
PATTERN
|
63
64
|
|
64
65
|
def on_send(node)
|
65
|
-
return if !
|
66
|
+
return if !field?(node) || style != :define_resolver_after_definition
|
66
67
|
|
68
|
+
node = node.parent if field_definition_with_body?(node.parent)
|
67
69
|
field = RuboCop::GraphQL::Field.new(node)
|
68
70
|
check_resolver_is_defined_after_definition(field)
|
69
71
|
end
|
@@ -113,7 +115,10 @@ module RuboCop
|
|
113
115
|
"sharing resolver method."
|
114
116
|
|
115
117
|
def check_resolver_is_defined_after_definition(field)
|
116
|
-
|
118
|
+
multiple_definitions = multiple_definitions(field)
|
119
|
+
return if field.node != multiple_definitions.last
|
120
|
+
|
121
|
+
return if field_has_no_resolver_method(field)
|
117
122
|
|
118
123
|
method_definition = field.schema_member.find_method_definition(field.resolver_method_name)
|
119
124
|
return unless method_definition
|
@@ -124,11 +129,25 @@ module RuboCop
|
|
124
129
|
return if resolver_defined_after_definition?(field, method_definition)
|
125
130
|
|
126
131
|
add_offense(field.node,
|
127
|
-
message: offense_message(
|
132
|
+
message: offense_message(
|
133
|
+
fields_with_same_resolver.one? && multiple_definitions.size == 1
|
134
|
+
)) do |corrector|
|
128
135
|
place_resolver_after_field_definition(corrector, field.node)
|
129
136
|
end
|
130
137
|
end
|
131
138
|
|
139
|
+
def field_has_no_resolver_method(field)
|
140
|
+
field.kwargs.resolver || field.kwargs.method || field.kwargs.hash_key
|
141
|
+
end
|
142
|
+
|
143
|
+
def multiple_definitions(field)
|
144
|
+
field.schema_member.body.select { |node| field?(node) && field_name(node) == field.name }
|
145
|
+
end
|
146
|
+
|
147
|
+
def field_name(node)
|
148
|
+
RuboCop::GraphQL::Field.new(node).name
|
149
|
+
end
|
150
|
+
|
132
151
|
def offense_message(single_field_using_resolver)
|
133
152
|
single_field_using_resolver ? RESOLVER_AFTER_FIELD_MSG : RESOLVER_AFTER_LAST_FIELD_MSG
|
134
153
|
end
|
@@ -156,10 +175,7 @@ module RuboCop
|
|
156
175
|
def fields_with_same_resolver(field, resolver)
|
157
176
|
fields = field.schema_member.body
|
158
177
|
.select { |node| field?(node) }
|
159
|
-
.map
|
160
|
-
field = field_definition_with_body?(node) ? node.children.first : node
|
161
|
-
RuboCop::GraphQL::Field.new(field)
|
162
|
-
end
|
178
|
+
.map { |node| RuboCop::GraphQL::Field.new(node) }
|
163
179
|
|
164
180
|
[].tap do |fields_with_same_resolver|
|
165
181
|
fields.each do |field|
|
@@ -28,6 +28,7 @@ module RuboCop
|
|
28
28
|
include RuboCop::GraphQL::NodePattern
|
29
29
|
include RuboCop::Cop::RangeHelp
|
30
30
|
|
31
|
+
# @!method hash_key_to_use(node)
|
31
32
|
def_node_matcher :hash_key_to_use, <<~PATTERN
|
32
33
|
(def
|
33
34
|
_
|
@@ -50,7 +51,7 @@ module RuboCop
|
|
50
51
|
suggested_hash_key_name = hash_key_to_use(method_definition)
|
51
52
|
|
52
53
|
return if suggested_hash_key_name.nil?
|
53
|
-
return if
|
54
|
+
return if conflict?(suggested_hash_key_name)
|
54
55
|
|
55
56
|
add_offense(node, message: message(suggested_hash_key_name)) do |corrector|
|
56
57
|
autocorrect(corrector, node)
|
@@ -59,6 +60,10 @@ module RuboCop
|
|
59
60
|
|
60
61
|
private
|
61
62
|
|
63
|
+
def conflict?(suggested_hash_key_name)
|
64
|
+
RuboCop::GraphQL::Field::CONFLICT_FIELD_NAMES.include?(suggested_hash_key_name.to_sym)
|
65
|
+
end
|
66
|
+
|
62
67
|
def message(hash_key)
|
63
68
|
format(MSG, hash_key: hash_key)
|
64
69
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module GraphQL
|
6
|
-
#
|
6
|
+
# Detects duplicate field definitions within
|
7
7
|
# the same type
|
8
8
|
#
|
9
9
|
# @example
|
@@ -66,6 +66,7 @@ module RuboCop
|
|
66
66
|
node.first_argument.value.to_s
|
67
67
|
end
|
68
68
|
|
69
|
+
# @!method field_declarations(node)
|
69
70
|
def_node_search :field_declarations, <<~PATTERN
|
70
71
|
{
|
71
72
|
(send nil? :field (:sym _) ...)
|
@@ -20,6 +20,7 @@ module RuboCop
|
|
20
20
|
#
|
21
21
|
module GraphQL
|
22
22
|
class LegacyDsl < Base
|
23
|
+
# @!method legacy_dsl?(node)
|
23
24
|
def_node_matcher :legacy_dsl?, <<~PATTERN
|
24
25
|
(block
|
25
26
|
(send
|
@@ -33,7 +34,7 @@ module RuboCop
|
|
33
34
|
"Use class-based definitions instead."
|
34
35
|
|
35
36
|
def on_send(node)
|
36
|
-
return unless node.parent.
|
37
|
+
return unless node.parent.block_type?
|
37
38
|
|
38
39
|
add_offense(node.parent) if legacy_dsl?(node.parent)
|
39
40
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module GraphQL
|
6
|
+
# Checks whether fields with multiple definitions are grouped together.
|
7
|
+
# @example
|
8
|
+
# # good
|
9
|
+
#
|
10
|
+
# class UserType < BaseType
|
11
|
+
# field :first_name, String, null: true
|
12
|
+
# field :first_name, Name, null: true
|
13
|
+
#
|
14
|
+
# def first_name
|
15
|
+
# object.contact_data.first_name
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# # bad
|
20
|
+
#
|
21
|
+
# class UserType < BaseType
|
22
|
+
# field :first_name, String, null: true
|
23
|
+
#
|
24
|
+
# def first_name
|
25
|
+
# object.contact_data.first_name
|
26
|
+
# end
|
27
|
+
# field :first_name, Name, null: true
|
28
|
+
# end
|
29
|
+
class MultipleFieldDefinitions < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
include RuboCop::GraphQL::NodePattern
|
32
|
+
include RuboCop::Cop::RangeHelp
|
33
|
+
include RuboCop::GraphQL::Heredoc
|
34
|
+
|
35
|
+
def on_send(node)
|
36
|
+
return unless field?(node)
|
37
|
+
|
38
|
+
node = node.parent if field_definition_with_body?(node.parent)
|
39
|
+
|
40
|
+
field = RuboCop::GraphQL::Field.new(node)
|
41
|
+
|
42
|
+
multiple_definitions = multiple_definitions(field)
|
43
|
+
|
44
|
+
return if multiple_definitions.size == 1 || node != multiple_definitions.last
|
45
|
+
|
46
|
+
if has_ungrouped_definitions?(multiple_definitions)
|
47
|
+
add_offense(node, message: MULTIPLE_DEFINITIONS_MSG) do |corrector|
|
48
|
+
group_multiple_definitions(corrector, multiple_definitions)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
MULTIPLE_DEFINITIONS_MSG = "Group multiple field definitions together."
|
56
|
+
|
57
|
+
def multiple_definitions(field)
|
58
|
+
field.schema_member.body.select { |node| field?(node) && field_name(node) == field.name }
|
59
|
+
end
|
60
|
+
|
61
|
+
def field_name(node)
|
62
|
+
RuboCop::GraphQL::Field.new(node).name
|
63
|
+
end
|
64
|
+
|
65
|
+
def group_multiple_definitions(corrector, multiple_definitions)
|
66
|
+
multiple_definitions.each_cons(2) do |first, second|
|
67
|
+
next unless field_sibling_index(second) - field_sibling_index(first) > 1
|
68
|
+
|
69
|
+
insert_new_field(corrector, first, second)
|
70
|
+
remove_old_field(corrector, second)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def insert_new_field(corrector, first, second)
|
75
|
+
source_to_insert = "\n#{range_including_heredoc(second).source}"
|
76
|
+
field_definition_range = range_including_heredoc(first)
|
77
|
+
corrector.insert_after(field_definition_range, source_to_insert)
|
78
|
+
end
|
79
|
+
|
80
|
+
def remove_old_field(corrector, second)
|
81
|
+
range_to_remove = range_with_surrounding_space(
|
82
|
+
range: range_including_heredoc(second), side: :left
|
83
|
+
)
|
84
|
+
corrector.remove(range_to_remove)
|
85
|
+
end
|
86
|
+
|
87
|
+
def has_ungrouped_definitions?(multiple_definitions)
|
88
|
+
sibling_indices = multiple_definitions.map do |field|
|
89
|
+
field_sibling_index(field)
|
90
|
+
end
|
91
|
+
|
92
|
+
sibling_indices.each_cons(2).any? { |index1, index2| index2 - index1 > 1 }
|
93
|
+
end
|
94
|
+
|
95
|
+
def field_sibling_index(field)
|
96
|
+
if field_definition_with_body?(field.parent)
|
97
|
+
field.parent.sibling_index
|
98
|
+
else
|
99
|
+
field.sibling_index
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -26,10 +26,12 @@ module RuboCop
|
|
26
26
|
|
27
27
|
MSG = "Missing type description"
|
28
28
|
|
29
|
+
# @!method has_i18n_description?(node)
|
29
30
|
def_node_matcher :has_i18n_description?, <<~PATTERN
|
30
31
|
(send nil? :description (send (const nil? :I18n) :t ...))
|
31
32
|
PATTERN
|
32
33
|
|
34
|
+
# @!method interface?(node)
|
33
35
|
def_node_matcher :interface?, <<~PATTERN
|
34
36
|
(send nil? :include (const ...))
|
35
37
|
PATTERN
|
@@ -101,10 +101,12 @@ module RuboCop
|
|
101
101
|
previous.source_range.last_line == current.source_range.first_line - 1
|
102
102
|
end
|
103
103
|
|
104
|
+
# @!method argument_declarations_without_blocks(node)
|
104
105
|
def_node_search :argument_declarations_without_blocks, <<~PATTERN
|
105
106
|
(send nil? :argument (:sym _) ...)
|
106
107
|
PATTERN
|
107
108
|
|
109
|
+
# @!method argument_declarations_with_blocks(node)
|
108
110
|
def_node_search :argument_declarations_with_blocks, <<~PATTERN
|
109
111
|
(block
|
110
112
|
(send nil? :argument
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module GraphQL
|
6
|
-
#
|
6
|
+
# Checks if the length of a resolver method exceeds some maximum value.
|
7
7
|
# Comment lines can optionally be ignored.
|
8
8
|
#
|
9
9
|
# The maximum allowed length is configurable using the Max option.
|
@@ -13,6 +13,7 @@ module RuboCop
|
|
13
13
|
|
14
14
|
MSG = "ResolverMethod has too many lines. [%<total>d/%<max>d]"
|
15
15
|
|
16
|
+
# @!method field_definition(node)
|
16
17
|
def_node_matcher :field_definition, <<~PATTERN
|
17
18
|
(send nil? :field (sym $...) ...)
|
18
19
|
PATTERN
|
@@ -175,10 +175,12 @@ module RuboCop
|
|
175
175
|
node.block_type? || node.lambda_type?
|
176
176
|
end
|
177
177
|
|
178
|
+
# @!method argument_declaration?(node)
|
178
179
|
def_node_matcher :argument_declaration?, <<~PATTERN
|
179
180
|
(send nil? :argument (:sym _) ...)
|
180
181
|
PATTERN
|
181
182
|
|
183
|
+
# @!method resolve_method_definition(node)
|
182
184
|
def_node_search :resolve_method_definition, <<~PATTERN
|
183
185
|
(def :resolve
|
184
186
|
(args ...) ...)
|
@@ -12,6 +12,7 @@ require_relative "graphql/field_method"
|
|
12
12
|
require_relative "graphql/field_name"
|
13
13
|
require_relative "graphql/field_uniqueness"
|
14
14
|
require_relative "graphql/legacy_dsl"
|
15
|
+
require_relative "graphql/multiple_field_definitions"
|
15
16
|
require_relative "graphql/resolver_method_length"
|
16
17
|
require_relative "graphql/object_description"
|
17
18
|
require_relative "graphql/ordered_arguments"
|
@@ -6,6 +6,7 @@ module RuboCop
|
|
6
6
|
class Kwargs
|
7
7
|
extend RuboCop::NodePattern::Macros
|
8
8
|
|
9
|
+
# @!method argument_kwargs(node)
|
9
10
|
def_node_matcher :argument_kwargs, <<~PATTERN
|
10
11
|
(send nil? :argument
|
11
12
|
...
|
@@ -15,14 +16,17 @@ module RuboCop
|
|
15
16
|
)
|
16
17
|
PATTERN
|
17
18
|
|
19
|
+
# @!method description_kwarg?(node)
|
18
20
|
def_node_matcher :description_kwarg?, <<~PATTERN
|
19
21
|
(pair (sym :description) ...)
|
20
22
|
PATTERN
|
21
23
|
|
24
|
+
# @!method loads_kwarg?(node)
|
22
25
|
def_node_matcher :loads_kwarg?, <<~PATTERN
|
23
26
|
(pair (sym :loads) ...)
|
24
27
|
PATTERN
|
25
28
|
|
29
|
+
# @!method as_kwarg?(node)
|
26
30
|
def_node_matcher :as_kwarg?, <<~PATTERN
|
27
31
|
(pair (sym :as) ...)
|
28
32
|
PATTERN
|
@@ -5,14 +5,17 @@ module RuboCop
|
|
5
5
|
class Argument
|
6
6
|
extend RuboCop::NodePattern::Macros
|
7
7
|
|
8
|
+
# @!method argument_description(node)
|
8
9
|
def_node_matcher :argument_description, <<~PATTERN
|
9
10
|
(send nil? :argument _ _ (:str $_) ...)
|
10
11
|
PATTERN
|
11
12
|
|
13
|
+
# @!method argument_name(node)
|
12
14
|
def_node_matcher :argument_name, <<~PATTERN
|
13
15
|
(send nil? :argument (:sym $_) ...)
|
14
16
|
PATTERN
|
15
17
|
|
18
|
+
# @!method argument_as(node)
|
16
19
|
def_node_matcher :argument_as, <<~PATTERN
|
17
20
|
(pair (sym :as) (sym $_))
|
18
21
|
PATTERN
|
@@ -22,10 +22,12 @@ module RuboCop
|
|
22
22
|
|
23
23
|
DESCRIPTION_STRING = "{({str|dstr|const} ...)|(send const ...)|(send ({str|dstr} ...) _)}"
|
24
24
|
|
25
|
+
# @!method description_method_call?(node)
|
25
26
|
def_node_matcher :description_method_call?, <<~PATTERN
|
26
27
|
(send nil? :description #{DESCRIPTION_STRING})
|
27
28
|
PATTERN
|
28
29
|
|
30
|
+
# @!method description_with_block_arg?(node)
|
29
31
|
def_node_matcher :description_with_block_arg?, <<~PATTERN
|
30
32
|
(send (lvar _) {:description= :description} #{DESCRIPTION_STRING})
|
31
33
|
PATTERN
|
@@ -6,6 +6,7 @@ module RuboCop
|
|
6
6
|
class Kwargs
|
7
7
|
extend RuboCop::NodePattern::Macros
|
8
8
|
|
9
|
+
# @!method field_kwargs(node)
|
9
10
|
def_node_matcher :field_kwargs, <<~PATTERN
|
10
11
|
(send nil? :field
|
11
12
|
...
|
@@ -15,22 +16,27 @@ module RuboCop
|
|
15
16
|
)
|
16
17
|
PATTERN
|
17
18
|
|
19
|
+
# @!method resolver_kwarg?(node)
|
18
20
|
def_node_matcher :resolver_kwarg?, <<~PATTERN
|
19
21
|
(pair (sym :resolver) ...)
|
20
22
|
PATTERN
|
21
23
|
|
24
|
+
# @!method method_kwarg?(node)
|
22
25
|
def_node_matcher :method_kwarg?, <<~PATTERN
|
23
26
|
(pair (sym :method) ...)
|
24
27
|
PATTERN
|
25
28
|
|
29
|
+
# @!method hash_key_kwarg?(node)
|
26
30
|
def_node_matcher :hash_key_kwarg?, <<~PATTERN
|
27
31
|
(pair (sym :hash_key) ...)
|
28
32
|
PATTERN
|
29
33
|
|
34
|
+
# @!method description_kwarg?(node)
|
30
35
|
def_node_matcher :description_kwarg?, <<~PATTERN
|
31
36
|
(pair (sym :description) ...)
|
32
37
|
PATTERN
|
33
38
|
|
39
|
+
# @!method resolver_method_option(node)
|
34
40
|
def_node_matcher :resolver_method_option, <<~PATTERN
|
35
41
|
(pair (sym :resolver_method) (sym $...))
|
36
42
|
PATTERN
|
@@ -20,15 +20,18 @@ module RuboCop
|
|
20
20
|
|
21
21
|
def_delegators :@node, :sibling_index, :parent
|
22
22
|
|
23
|
+
# @!method field_name(node)
|
23
24
|
def_node_matcher :field_name, <<~PATTERN
|
24
25
|
(send nil? :field (:sym $_) ...)
|
25
26
|
PATTERN
|
26
27
|
|
28
|
+
# @!method field_with_body_name(node)
|
27
29
|
def_node_matcher :field_with_body_name, <<~PATTERN
|
28
30
|
(block
|
29
31
|
(send nil? :field (:sym $_) ...)...)
|
30
32
|
PATTERN
|
31
33
|
|
34
|
+
# @!method field_description(node)
|
32
35
|
def_node_matcher :field_description, <<~PATTERN
|
33
36
|
(send nil? :field _ _ (:str $_) ...)
|
34
37
|
PATTERN
|
@@ -5,10 +5,12 @@ module RuboCop
|
|
5
5
|
module NodePattern
|
6
6
|
extend RuboCop::NodePattern::Macros
|
7
7
|
|
8
|
+
# @!method field_definition?(node)
|
8
9
|
def_node_matcher :field_definition?, <<~PATTERN
|
9
10
|
(send nil? :field (:sym _) ...)
|
10
11
|
PATTERN
|
11
12
|
|
13
|
+
# @!method field_definition_with_body?(node)
|
12
14
|
def_node_matcher :field_definition_with_body?, <<~PATTERN
|
13
15
|
(block
|
14
16
|
(send nil? :field (:sym _) ...)
|
@@ -16,6 +18,7 @@ module RuboCop
|
|
16
18
|
)
|
17
19
|
PATTERN
|
18
20
|
|
21
|
+
# @!method argument?(node)
|
19
22
|
def_node_matcher :argument?, <<~PATTERN
|
20
23
|
(send nil? :argument (:sym _) ...)
|
21
24
|
PATTERN
|
@@ -5,6 +5,7 @@ module RuboCop
|
|
5
5
|
class SchemaMember
|
6
6
|
extend RuboCop::NodePattern::Macros
|
7
7
|
|
8
|
+
# @!method class_contents(node)
|
8
9
|
def_node_matcher :class_contents, <<~PATTERN
|
9
10
|
(class _ _ $_)
|
10
11
|
PATTERN
|
@@ -16,7 +17,7 @@ module RuboCop
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def find_method_definition(method_name)
|
19
|
-
body.find { |node| node.def_type? && node.method_name
|
20
|
+
body.find { |node| node.def_type? && node.method?(method_name) }
|
20
21
|
end
|
21
22
|
|
22
23
|
def body
|
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.
|
4
|
+
version: 0.15.0
|
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-
|
11
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/rubocop/cop/graphql/field_name.rb
|
97
97
|
- lib/rubocop/cop/graphql/field_uniqueness.rb
|
98
98
|
- lib/rubocop/cop/graphql/legacy_dsl.rb
|
99
|
+
- lib/rubocop/cop/graphql/multiple_field_definitions.rb
|
99
100
|
- lib/rubocop/cop/graphql/object_description.rb
|
100
101
|
- lib/rubocop/cop/graphql/ordered_arguments.rb
|
101
102
|
- lib/rubocop/cop/graphql/ordered_fields.rb
|
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
143
|
- !ruby/object:Gem::Version
|
143
144
|
version: '0'
|
144
145
|
requirements: []
|
145
|
-
rubygems_version: 3.3.
|
146
|
+
rubygems_version: 3.3.7
|
146
147
|
signing_key:
|
147
148
|
specification_version: 4
|
148
149
|
summary: Automatic performance checking tool for Ruby code.
|