rubocop-graphql 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/graphql/field_uniqueness.rb +13 -1
- data/lib/rubocop/graphql/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffc9fa90011bdaddbf2d485a5948ede1e7bf2ade1c91c3a960799a1e0cd47bb3
|
4
|
+
data.tar.gz: 4dcbb755ed55538cfb8539b86f0c186e13b201bbfd0bbf3201d3091b8058c0fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25cf86cd5e3e3942eafed3383df445c3f71296bc63a617ba4a0a9e597f6c355a1f5f94b1f2718439cd5606c50573758b8d3381a40af59937ba20cba150a9fe3d
|
7
|
+
data.tar.gz: 745057b345ba218c88b5a21addced87fc6bd972147ac72281efa0e1c1db005694f3ec44d33dc6760bdff68edddf8fedaff1d23f270ca3fc5162b5f01652da902
|
@@ -31,9 +31,13 @@ module RuboCop
|
|
31
31
|
"Field `%<current>s` is duplicated."
|
32
32
|
|
33
33
|
def on_class(node)
|
34
|
-
|
34
|
+
return if nested_class?(node)
|
35
|
+
|
36
|
+
field_names_by_class = Hash.new { |h, k| h[k] = Set.new }
|
35
37
|
|
36
38
|
field_declarations(node).each do |current|
|
39
|
+
current_class = current_class_name(current)
|
40
|
+
field_names = field_names_by_class[current_class]
|
37
41
|
current_field_name = field_name(current)
|
38
42
|
|
39
43
|
unless field_names.include?(current_field_name)
|
@@ -47,6 +51,10 @@ module RuboCop
|
|
47
51
|
|
48
52
|
private
|
49
53
|
|
54
|
+
def nested_class?(node)
|
55
|
+
node.each_ancestor(:class).any?
|
56
|
+
end
|
57
|
+
|
50
58
|
def register_offense(current)
|
51
59
|
message = format(
|
52
60
|
self.class::MSG,
|
@@ -60,6 +68,10 @@ module RuboCop
|
|
60
68
|
node.first_argument.value.to_s
|
61
69
|
end
|
62
70
|
|
71
|
+
def current_class_name(node)
|
72
|
+
node.each_ancestor(:class).first.defined_module_name
|
73
|
+
end
|
74
|
+
|
63
75
|
def_node_search :field_declarations, <<~PATTERN
|
64
76
|
{
|
65
77
|
(send nil? :field (:sym _) ...)
|
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.11.
|
4
|
+
version: 0.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Tsepelev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,7 +122,7 @@ metadata:
|
|
122
122
|
homepage_uri: https://github.com/DmitryTsepelev/rubocop-graphql
|
123
123
|
source_code_uri: https://github.com/DmitryTsepelev/rubocop-graphql
|
124
124
|
changelog_uri: https://github.com/DmitryTsepelev/rubocop-graphql/CHANGELOG.md
|
125
|
-
post_install_message:
|
125
|
+
post_install_message:
|
126
126
|
rdoc_options: []
|
127
127
|
require_paths:
|
128
128
|
- lib
|
@@ -137,8 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
141
|
-
signing_key:
|
140
|
+
rubygems_version: 3.0.3.1
|
141
|
+
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Automatic performance checking tool for Ruby code.
|
144
144
|
test_files: []
|