rubocop-graphql 0.14.5 → 0.14.6

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: 5c4b8fdbb39f5e0bea2bbcce54cdd520480f1e412a2b3c5ce549b7c37a5e2cbb
4
- data.tar.gz: 5e6065465cad8df870476977d0b9e4ac64869c27a4247570c5d6d6d56bb32577
3
+ metadata.gz: a7832bf74fe37877eee6544f83cc7625cfa874df93f6b141c07a2c1a628a927f
4
+ data.tar.gz: c764f2caaf3cbbb685eb944b1a206c4904a484fe000f39a41c40b33846eecc1b
5
5
  SHA512:
6
- metadata.gz: 267c257092e56d804772fa9f58e0e657151348758d80b7b453b07c00e0aa33651b61f326424822f2fcc272dacff45a245820c3a9eea8bbe00e344ed6ff17bc83
7
- data.tar.gz: badf0bbcdefc806c43cdc60defadf002cfc645dfb6c2f6bf6609b444c18cd9c13bb81b4a4c48eebf3ae25ffbdaf477678d6807349133866098736387d483df90
6
+ metadata.gz: 9bdb7f16d1b31c795e8d624030e774c3c92ebb1481e4459f229fe135557eb072dbe2920c1cfc2600bb0d768756b338846da6db1b396def061d95ad4d0628e5b0
7
+ data.tar.gz: d506eade963151227cfa3bf55f7ddf320b281111083ac784807c7c6aa6534a0899a01474d2c80f35c2460d1817b18f033d05ce880be59f477b5fe75cf85ce0e8
data/config/default.yml CHANGED
@@ -109,5 +109,3 @@ GraphQL/OrderedFields:
109
109
  GraphQL/UnusedArgument:
110
110
  Enabled: true
111
111
  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.method_name == :field
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
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Cop
5
5
  module GraphQL
6
6
  class ExtractInputType < Base
7
- # This cop checks fields on common prefix groups
7
+ # Checks fields on common prefix groups
8
8
  #
9
9
  # # @example
10
10
  # # good
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Cop
5
5
  module GraphQL
6
6
  class ExtractType < Base
7
- # This cop checks fields on common prefix groups
7
+ # Checks fields on common prefix groups
8
8
  #
9
9
  # # @example
10
10
  # # good
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module GraphQL
6
- # This cop checks consistency of field definitions
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
  ...
@@ -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 RuboCop::GraphQL::Field::CONFLICT_FIELD_NAMES.include?(suggested_hash_key_name)
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
@@ -28,6 +28,7 @@ module RuboCop
28
28
  include RuboCop::GraphQL::NodePattern
29
29
  include RuboCop::Cop::RangeHelp
30
30
 
31
+ # @!method method_to_use(node)
31
32
  def_node_matcher :method_to_use, <<~PATTERN
32
33
  (def
33
34
  _
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module GraphQL
6
- # This cop detects duplicate field definitions within
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.type == :block
37
+ return unless node.parent.block_type?
37
38
 
38
39
  add_offense(node.parent) if legacy_dsl?(node.parent)
39
40
  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
@@ -74,6 +74,7 @@ module RuboCop
74
74
  previous.source_range.last_line == current.source_range.first_line - 1
75
75
  end
76
76
 
77
+ # @!method field_declarations(node)
77
78
  def_node_search :field_declarations, <<~PATTERN
78
79
  {
79
80
  (send nil? :field (:sym _) ...)
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module GraphQL
6
- # This cop checks if the length of a resolver method exceeds some maximum value.
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 ...) ...)
@@ -7,6 +7,7 @@ module RuboCop
7
7
  extend RuboCop::NodePattern::Macros
8
8
  include DescriptionMethod
9
9
 
10
+ # @!method argument_block(node)
10
11
  def_node_matcher :argument_block, <<~PATTERN
11
12
  (block
12
13
  (send nil? :argument ...)
@@ -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
@@ -7,6 +7,7 @@ module RuboCop
7
7
  extend RuboCop::NodePattern::Macros
8
8
  include DescriptionMethod
9
9
 
10
+ # @!method field_block(node)
10
11
  def_node_matcher :field_block, <<~PATTERN
11
12
  (block
12
13
  (send nil? :field ...)
@@ -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 == method_name }
20
+ body.find { |node| node.def_type? && node.method?(method_name) }
20
21
  end
21
22
 
22
23
  def body
@@ -5,6 +5,7 @@ module RuboCop
5
5
  module Sorbet
6
6
  extend RuboCop::NodePattern::Macros
7
7
 
8
+ # @!method sorbet_signature(node)
8
9
  def_node_matcher(:sorbet_signature, <<~PATTERN)
9
10
  (block (send nil? :sig) (args) ...)
10
11
  PATTERN
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module GraphQL
3
- VERSION = "0.14.5".freeze
3
+ VERSION = "0.14.6".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: 0.14.5
4
+ version: 0.14.6
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: 2022-08-02 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,7 +127,7 @@ metadata:
127
127
  homepage_uri: https://github.com/DmitryTsepelev/rubocop-graphql
128
128
  source_code_uri: https://github.com/DmitryTsepelev/rubocop-graphql
129
129
  changelog_uri: https://github.com/DmitryTsepelev/rubocop-graphql/blob/master/CHANGELOG.md
130
- post_install_message:
130
+ post_install_message:
131
131
  rdoc_options: []
132
132
  require_paths:
133
133
  - lib
@@ -142,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
- rubygems_version: 3.3.3
146
- signing_key:
145
+ rubygems_version: 3.1.6
146
+ signing_key:
147
147
  specification_version: 4
148
148
  summary: Automatic performance checking tool for Ruby code.
149
149
  test_files: []