rubocop-graphql 0.19.0 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +86 -41
  3. data/lib/rubocop/cop/graphql/argument_description.rb +1 -0
  4. data/lib/rubocop/cop/graphql/argument_name.rb +1 -0
  5. data/lib/rubocop/cop/graphql/field_definitions.rb +21 -5
  6. data/lib/rubocop/cop/graphql/field_description.rb +1 -0
  7. data/lib/rubocop/cop/graphql/field_hash_key.rb +3 -2
  8. data/lib/rubocop/cop/graphql/field_method.rb +8 -2
  9. data/lib/rubocop/cop/graphql/field_name.rb +1 -0
  10. data/lib/rubocop/cop/graphql/field_uniqueness.rb +8 -1
  11. data/lib/rubocop/cop/graphql/graphql_name.rb +70 -0
  12. data/lib/rubocop/cop/graphql/legacy_dsl.rb +1 -0
  13. data/lib/rubocop/cop/graphql/max_complexity_schema.rb +31 -0
  14. data/lib/rubocop/cop/graphql/max_depth_schema.rb +31 -0
  15. data/lib/rubocop/cop/graphql/multiple_field_definitions.rb +2 -0
  16. data/lib/rubocop/cop/graphql/not_authorized_node_type.rb +134 -0
  17. data/lib/rubocop/cop/graphql/ordered_arguments.rb +15 -21
  18. data/lib/rubocop/cop/graphql/ordered_fields.rb +20 -15
  19. data/lib/rubocop/cop/graphql/prepare_method.rb +95 -0
  20. data/lib/rubocop/cop/graphql/resolver_method_length.rb +4 -7
  21. data/lib/rubocop/cop/graphql/unnecessary_argument_camelize.rb +11 -4
  22. data/lib/rubocop/cop/graphql/unnecessary_field_alias.rb +33 -9
  23. data/lib/rubocop/cop/graphql/unnecessary_field_camelize.rb +1 -0
  24. data/lib/rubocop/cop/graphql/unused_argument.rb +4 -5
  25. data/lib/rubocop/cop/graphql_cops.rb +5 -0
  26. data/lib/rubocop/graphql/argument/block.rb +1 -1
  27. data/lib/rubocop/graphql/compare_order.rb +51 -0
  28. data/lib/rubocop/graphql/ext/snake_case.rb +1 -1
  29. data/lib/rubocop/graphql/field.rb +5 -2
  30. data/lib/rubocop/graphql/heredoc.rb +12 -5
  31. data/lib/rubocop/graphql/schema_member.rb +1 -1
  32. data/lib/rubocop/graphql/sorbet.rb +2 -10
  33. data/lib/rubocop/graphql/version.rb +1 -1
  34. data/lib/rubocop-graphql.rb +1 -0
  35. metadata +11 -5
@@ -8,16 +8,23 @@ module RuboCop
8
8
  end
9
9
 
10
10
  def range_including_heredoc(node)
11
- field = RuboCop::GraphQL::Field.new(node)
12
- last_heredoc = field.kwargs.instance_variable_get(:@nodes).reverse.find do |kwarg|
13
- heredoc?(kwarg.value)
14
- end&.value
11
+ last_heredoc = find_last_heredoc(node)
15
12
 
16
- range = node.loc.expression
13
+ range = node.source_range
17
14
  range = range.join(last_heredoc.loc.heredoc_end) if last_heredoc
18
15
 
19
16
  range_by_whole_lines(range)
20
17
  end
18
+
19
+ private
20
+
21
+ def find_last_heredoc(node)
22
+ # Do a cheap check first.
23
+ return nil unless node.source.include?("<<")
24
+
25
+ heredocs = node.descendants.select { |descendant| heredoc?(descendant) }
26
+ heredocs.max_by { |heredoc| heredoc.loc.heredoc_end }
27
+ end
21
28
  end
22
29
  end
23
30
  end
@@ -7,7 +7,7 @@ module RuboCop
7
7
 
8
8
  # @!method class_contents(node)
9
9
  def_node_matcher :class_contents, <<~PATTERN
10
- (class _ _ $_)
10
+ {(class _ _ $_) | (module _ $_)}
11
11
  PATTERN
12
12
 
13
13
  attr_reader :node
@@ -15,16 +15,8 @@ module RuboCop
15
15
  end
16
16
 
17
17
  def sorbet_signature_for(node)
18
- node.parent.each_descendant.find do |sibling|
19
- siblings_in_sequence?(sibling, node) &&
20
- sorbet_signature(sibling)
21
- end
22
- end
23
-
24
- private
25
-
26
- def siblings_in_sequence?(first_node, second_node)
27
- first_node.sibling_index - second_node.sibling_index == - 1
18
+ sibling = node.left_sibling
19
+ sibling if sibling && sorbet_signature(sibling)
28
20
  end
29
21
  end
30
22
  end
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module GraphQL
3
- VERSION = "0.19.0".freeze
3
+ VERSION = "1.5.4".freeze
4
4
  end
5
5
  end
@@ -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/compare_order"
10
11
  require_relative "rubocop/graphql/description_method"
11
12
  require_relative "rubocop/graphql/heredoc"
12
13
  require_relative "rubocop/graphql/node_pattern"
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.19.0
4
+ version: 1.5.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: 2023-01-15 00:00:00.000000000 Z
11
+ date: 2024-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0.87'
61
+ version: '1.50'
62
62
  - - "<"
63
63
  - !ruby/object:Gem::Version
64
64
  version: '2'
@@ -68,7 +68,7 @@ dependencies:
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: '0.87'
71
+ version: '1.50'
72
72
  - - "<"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '2'
@@ -95,11 +95,16 @@ files:
95
95
  - lib/rubocop/cop/graphql/field_method.rb
96
96
  - lib/rubocop/cop/graphql/field_name.rb
97
97
  - lib/rubocop/cop/graphql/field_uniqueness.rb
98
+ - lib/rubocop/cop/graphql/graphql_name.rb
98
99
  - lib/rubocop/cop/graphql/legacy_dsl.rb
100
+ - lib/rubocop/cop/graphql/max_complexity_schema.rb
101
+ - lib/rubocop/cop/graphql/max_depth_schema.rb
99
102
  - lib/rubocop/cop/graphql/multiple_field_definitions.rb
103
+ - lib/rubocop/cop/graphql/not_authorized_node_type.rb
100
104
  - lib/rubocop/cop/graphql/object_description.rb
101
105
  - lib/rubocop/cop/graphql/ordered_arguments.rb
102
106
  - lib/rubocop/cop/graphql/ordered_fields.rb
107
+ - lib/rubocop/cop/graphql/prepare_method.rb
103
108
  - lib/rubocop/cop/graphql/resolver_method_length.rb
104
109
  - lib/rubocop/cop/graphql/unnecessary_argument_camelize.rb
105
110
  - lib/rubocop/cop/graphql/unnecessary_field_alias.rb
@@ -111,6 +116,7 @@ files:
111
116
  - lib/rubocop/graphql/argument/block.rb
112
117
  - lib/rubocop/graphql/argument/kwargs.rb
113
118
  - lib/rubocop/graphql/class.rb
119
+ - lib/rubocop/graphql/compare_order.rb
114
120
  - lib/rubocop/graphql/description_method.rb
115
121
  - lib/rubocop/graphql/ext/snake_case.rb
116
122
  - lib/rubocop/graphql/field.rb
@@ -139,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
145
  requirements:
140
146
  - - ">="
141
147
  - !ruby/object:Gem::Version
142
- version: '2.5'
148
+ version: '3.0'
143
149
  required_rubygems_version: !ruby/object:Gem::Requirement
144
150
  requirements:
145
151
  - - ">="