rubocop-graphql 1.2.0 → 1.3.0
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: 9cdf5152e0106f86e952fbf5a24a38011914f34b0167a19ef0cf53dd810e4d68
|
4
|
+
data.tar.gz: 9ed0ac94bdc4f323543e1085a612dfb3d02f5e60ee55892da6894b202718865e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 992563e33d74e91766b4917a541ef9361795156f93eb33a95f0944e4968f87a5845681adff07178a30cd11b10c6b2e10ea002e2688b2a501cc6b9e25bb1bc103
|
7
|
+
data.tar.gz: 2cf037f19ca63a512ea00a06601cf49dcc46ed5bb59deec1ede2e45dcd74acfd875b7febf7f703b36354fa4059dd222ca5f37fb59a11572c7cc8d4ffb97389a9
|
data/config/default.yml
CHANGED
@@ -51,6 +51,7 @@ module RuboCop
|
|
51
51
|
|
52
52
|
return if suggested_method_name.nil?
|
53
53
|
return if RuboCop::GraphQL::Field::CONFLICT_FIELD_NAMES.include?(suggested_method_name)
|
54
|
+
return if method_kwarg_set?(field)
|
54
55
|
|
55
56
|
add_offense(node, message: message(suggested_method_name)) do |corrector|
|
56
57
|
autocorrect(corrector, node)
|
@@ -80,6 +81,10 @@ module RuboCop
|
|
80
81
|
method_name = field.resolver_method_name
|
81
82
|
field.schema_member.find_method_definition(method_name)
|
82
83
|
end
|
84
|
+
|
85
|
+
def method_kwarg_set?(field)
|
86
|
+
field.kwargs.method != nil
|
87
|
+
end
|
83
88
|
end
|
84
89
|
end
|
85
90
|
end
|
@@ -7,6 +7,9 @@ module RuboCop
|
|
7
7
|
# Such types can be fetched by ID and therefore should have type level check to
|
8
8
|
# avoid accidental information exposure.
|
9
9
|
#
|
10
|
+
# If `.authorized?` is defined in a parent class, you can add parent to the "SafeBaseClasses"
|
11
|
+
# to avoid offenses in children.
|
12
|
+
#
|
10
13
|
# @example
|
11
14
|
# # good
|
12
15
|
#
|
@@ -45,6 +48,11 @@ module RuboCop
|
|
45
48
|
class NotAuthorizedNodeType < Base
|
46
49
|
MSG = ".authorized? should be defined for types implementing Node interface."
|
47
50
|
|
51
|
+
# @!method class_name(node)
|
52
|
+
def_node_matcher :class_name, <<~PATTERN
|
53
|
+
(const nil? $_)
|
54
|
+
PATTERN
|
55
|
+
|
48
56
|
# @!method implements_node_type?(node)
|
49
57
|
def_node_matcher :implements_node_type?, <<~PATTERN
|
50
58
|
`(send nil? :implements
|
@@ -60,8 +68,20 @@ module RuboCop
|
|
60
68
|
PATTERN
|
61
69
|
|
62
70
|
def on_class(node)
|
71
|
+
return if ignored_class?(parent_class(node))
|
72
|
+
|
63
73
|
add_offense(node) if implements_node_type?(node) && !has_authorized_method?(node)
|
64
74
|
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def parent_class(node)
|
79
|
+
node.child_nodes[1]
|
80
|
+
end
|
81
|
+
|
82
|
+
def ignored_class?(node)
|
83
|
+
cop_config["SafeBaseClasses"].include?(String(class_name(node)))
|
84
|
+
end
|
65
85
|
end
|
66
86
|
end
|
67
87
|
end
|
@@ -10,27 +10,33 @@ module RuboCop
|
|
10
10
|
#
|
11
11
|
# class UserType < BaseType
|
12
12
|
# field :name, String, "Name of the user", null: true do
|
13
|
-
# argument :filter, String, required: false
|
13
|
+
# argument :filter, String, required: false
|
14
14
|
# end
|
15
15
|
# end
|
16
16
|
#
|
17
17
|
# # good
|
18
18
|
#
|
19
19
|
# class UserType < BaseType
|
20
|
-
# argument :filter, String, required: false
|
20
|
+
# argument :filter, String, required: false
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# # good
|
24
|
+
#
|
25
|
+
# class UserType < BaseType
|
26
|
+
# argument :email_filter, String, required: false, camelize: true
|
21
27
|
# end
|
22
28
|
#
|
23
29
|
# # bad
|
24
30
|
#
|
25
31
|
# class UserType < BaseType
|
26
|
-
# argument :filter, String, required: false
|
32
|
+
# argument :filter, String, required: false, camelize: false
|
27
33
|
# end
|
28
34
|
#
|
29
35
|
# # bad
|
30
36
|
#
|
31
37
|
# class UserType < BaseType
|
32
38
|
# field :name, String, "Name of the user", null: true do
|
33
|
-
# argument :filter, String, required: false
|
39
|
+
# argument :filter, String, required: false, camelize: false
|
34
40
|
# end
|
35
41
|
# end
|
36
42
|
#
|
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.
|
4
|
+
version: 1.3.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: 2023-
|
11
|
+
date: 2023-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|