rubocop-graphql 0.8.0 → 0.8.1

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: c68112dd907111859f0c8ca78ad31c6bea918c11411d9d89a4a4ae289fc3630d
4
- data.tar.gz: cfeed828552dcdc4509b476f4d6a9672c111ef2e11001fad01f52b3699d26bc9
3
+ metadata.gz: 62d96a424a721e274ada4265af5482248fd8786a07c9d533dadf368d39b0e142
4
+ data.tar.gz: b0e1877a97532a0190036b71c5068d95b3572a728b7eb2e2c51ee9b3c35869ce
5
5
  SHA512:
6
- metadata.gz: 7a20bb455185e7eb0ceeffb6da3f33438a416f003ce6fd7287483a34aab61301051a72e0b6b13967ead0c2b14c5ce31d28f4c9c864ed24ab627b34e7f322e40c
7
- data.tar.gz: e3badf19ec0a0ec03fe7be4d71324cb65e70f64c2ed3919334836f5d532e10fd16b3f54f58f2e909c987b72957027a13fa27fedf35f1bba2d2cceb6c9e66ca69
6
+ metadata.gz: 7cbf14cb18196ed2ec0cbf75299f867674c2ac47a716f55b335cfb258377e4fd0d00968d51d28890fdb81d07211d2e4d6192efabf56bd349d0436c58c3c1e8e0
7
+ data.tar.gz: 4fb8ff31d9f3a500ed58118945c41451fa1178d3ace5635242861e176ec2fae4f1b31512dca2135d639a7d74e61d9c98d6fca4912fcd3609e033fc8241efba56
@@ -7,6 +7,7 @@ require_relative "rubocop/graphql/ext/snake_case"
7
7
  require_relative "rubocop/graphql"
8
8
  require_relative "rubocop/graphql/version"
9
9
  require_relative "rubocop/graphql/inject"
10
+ require_relative "rubocop/graphql/description_method"
10
11
  require_relative "rubocop/graphql/node_pattern"
11
12
 
12
13
  require_relative "rubocop/graphql/argument"
@@ -22,6 +22,7 @@ module RuboCop
22
22
  #
23
23
  class ObjectDescription < Cop
24
24
  include RuboCop::GraphQL::NodePattern
25
+ include RuboCop::GraphQL::DescriptionMethod
25
26
 
26
27
  MSG = "Missing type description"
27
28
 
@@ -29,14 +30,6 @@ module RuboCop
29
30
  (send nil? :description (send (const nil? :I18n) :t ...))
30
31
  PATTERN
31
32
 
32
- def_node_matcher :has_string_description?, <<~PATTERN
33
- (send nil? :description (:str $_))
34
- PATTERN
35
-
36
- def_node_matcher :has_multiline_string_description?, <<~PATTERN
37
- (send nil? :description (:dstr ...))
38
- PATTERN
39
-
40
33
  def_node_matcher :interface?, <<~PATTERN
41
34
  (send nil? :include (const ...))
42
35
  PATTERN
@@ -59,8 +52,7 @@ module RuboCop
59
52
 
60
53
  def has_description?(node)
61
54
  has_i18n_description?(node) ||
62
- has_string_description?(node) ||
63
- has_multiline_string_description?(node)
55
+ description_kwarg?(node)
64
56
  end
65
57
 
66
58
  def child_nodes(node)
@@ -5,6 +5,7 @@ module RuboCop
5
5
  class Argument
6
6
  class Block
7
7
  extend RuboCop::NodePattern::Macros
8
+ include DescriptionMethod
8
9
 
9
10
  def_node_matcher :argument_block, <<~PATTERN
10
11
  (block
@@ -14,16 +15,12 @@ module RuboCop
14
15
  )
15
16
  PATTERN
16
17
 
17
- def_node_matcher :description_kwarg?, <<~PATTERN
18
- (send nil? :description (str ...))
19
- PATTERN
20
-
21
18
  def initialize(argument_node)
22
19
  @nodes = argument_block(argument_node) || []
23
20
  end
24
21
 
25
22
  def description
26
- @nodes.find { |kwarg| description_kwarg?(kwarg) }
23
+ find_description_method(@nodes)
27
24
  end
28
25
  end
29
26
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module GraphQL
5
+ # Matches a variety of description formats commonly seen in Rails applications
6
+ #
7
+ # description 'blah'
8
+ #
9
+ # description "blah"
10
+ #
11
+ # description <<~EOT
12
+ # blah
13
+ # bloop
14
+ # EOT
15
+ #
16
+ # description <<-EOT.squish
17
+ # blah
18
+ # bloop
19
+ # EOT
20
+ module DescriptionMethod
21
+ extend RuboCop::NodePattern::Macros
22
+
23
+ def_node_matcher :description_kwarg?, <<~PATTERN
24
+ (send nil? :description {({str|dstr} ...)|(send ({str|dstr} ...) _)})
25
+ PATTERN
26
+
27
+ def find_description_method(nodes)
28
+ nodes.find { |kwarg| description_kwarg?(kwarg) }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -5,6 +5,7 @@ module RuboCop
5
5
  class Field
6
6
  class Block
7
7
  extend RuboCop::NodePattern::Macros
8
+ include DescriptionMethod
8
9
 
9
10
  def_node_matcher :field_block, <<~PATTERN
10
11
  (block
@@ -14,16 +15,12 @@ module RuboCop
14
15
  )
15
16
  PATTERN
16
17
 
17
- def_node_matcher :description_kwarg?, <<~PATTERN
18
- (send nil? :description (str ...))
19
- PATTERN
20
-
21
18
  def initialize(field_node)
22
19
  @nodes = field_block(field_node) || []
23
20
  end
24
21
 
25
22
  def description
26
- @nodes.find { |kwarg| description_kwarg?(kwarg) }
23
+ find_description_method(@nodes)
27
24
  end
28
25
  end
29
26
  end
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module GraphQL
3
- VERSION = "0.8.0".freeze
3
+ VERSION = "0.8.1".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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Tsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-08 00:00:00.000000000 Z
11
+ date: 2021-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,6 +102,7 @@ files:
102
102
  - lib/rubocop/graphql/argument.rb
103
103
  - lib/rubocop/graphql/argument/block.rb
104
104
  - lib/rubocop/graphql/argument/kwargs.rb
105
+ - lib/rubocop/graphql/description_method.rb
105
106
  - lib/rubocop/graphql/ext/snake_case.rb
106
107
  - lib/rubocop/graphql/field.rb
107
108
  - lib/rubocop/graphql/field/block.rb