rubocop-graphql 0.14.1 → 0.14.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7a2b9ff95f2f4a0d33cc53dee5f52b4f3953c4f95756ec96d6956908253d95f
|
4
|
+
data.tar.gz: 59dda32afecd9ad67da8dfca3fa044cb38f6a0986f840b4a71934bc1baf3f3cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2bed89e4af7df4fd98dd744c74a9ba9de8f4ef7ea7ce88a7127507c04f2e06ac6f64db0e79fe3c88b0e5b245b51cf220ac59d7d4b2a91d84fa75b5c4f7936da
|
7
|
+
data.tar.gz: bae24c84a5f8933e7a19730074f16a83c4fa1284804cbe3fb177c2814373c2e19e86163f49c1fe8473d3bdddd564f65fc2e0219f1c0db9994216050449bbcfe2
|
@@ -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
|
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
|
@@ -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?
|
@@ -82,9 +79,14 @@ module RuboCop
|
|
82
79
|
private
|
83
80
|
|
84
81
|
def find_declared_arg_nodes(node)
|
85
|
-
|
86
|
-
|
87
|
-
|
82
|
+
node.each_child_node.flat_map do |child|
|
83
|
+
if scoped_node?(child)
|
84
|
+
[]
|
85
|
+
elsif argument_declaration?(child)
|
86
|
+
[child]
|
87
|
+
else
|
88
|
+
find_declared_arg_nodes(child)
|
89
|
+
end
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
@@ -109,6 +111,12 @@ module RuboCop
|
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
114
|
+
def ignore_arguments_type?(resolve_method_node)
|
115
|
+
resolve_method_node.arguments.any? do |arg|
|
116
|
+
arg.arg_type? || arg.kwrestarg_type? || arg.forward_arg_type?
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
112
120
|
def register_offense(node, unresolved_args)
|
113
121
|
unresolved_args_source = unresolved_args.map { |v| "#{v}:" }.join(", ")
|
114
122
|
|
@@ -155,7 +163,19 @@ module RuboCop
|
|
155
163
|
declared_arg.name
|
156
164
|
end
|
157
165
|
|
158
|
-
|
166
|
+
def scoped_node?(node)
|
167
|
+
scope_changing_syntax?(node) || block_or_lambda?(node)
|
168
|
+
end
|
169
|
+
|
170
|
+
def scope_changing_syntax?(node)
|
171
|
+
node.def_type? || node.defs_type? || node.class_type? || node.module_type?
|
172
|
+
end
|
173
|
+
|
174
|
+
def block_or_lambda?(node)
|
175
|
+
node.block_type? || node.lambda_type?
|
176
|
+
end
|
177
|
+
|
178
|
+
def_node_matcher :argument_declaration?, <<~PATTERN
|
159
179
|
(send nil? :argument (:sym _) ...)
|
160
180
|
PATTERN
|
161
181
|
|
@@ -3,22 +3,22 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module GraphQL
|
5
5
|
module SwapRange
|
6
|
+
include RuboCop::Cop::RangeHelp
|
7
|
+
|
6
8
|
def swap_range(corrector, current, previous)
|
7
9
|
current_range = declaration(current)
|
8
10
|
previous_range = declaration(previous)
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
corrector.replace(current_range, src2)
|
14
|
-
corrector.replace(previous_range, src1)
|
12
|
+
corrector.insert_before(previous_range, current_range.source)
|
13
|
+
corrector.remove(current_range)
|
15
14
|
end
|
16
15
|
|
17
16
|
def declaration(node)
|
18
17
|
buffer = processed_source.buffer
|
19
|
-
begin_pos = node.source_range.begin_pos
|
18
|
+
begin_pos = range_by_whole_lines(node.source_range).begin_pos
|
20
19
|
end_line = buffer.line_for_position(node.loc.expression.end_pos)
|
21
|
-
end_pos = buffer.line_range(end_line)
|
20
|
+
end_pos = range_by_whole_lines(buffer.line_range(end_line),
|
21
|
+
include_final_newline: true).end_pos
|
22
22
|
Parser::Source::Range.new(buffer, begin_pos, end_pos)
|
23
23
|
end
|
24
24
|
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.
|
4
|
+
version: 0.14.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: 2022-
|
11
|
+
date: 2022-06-24 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.
|
145
|
+
rubygems_version: 3.3.3
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Automatic performance checking tool for Ruby code.
|