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.
- checksums.yaml +4 -4
 - data/config/default.yml +86 -41
 - data/lib/rubocop/cop/graphql/argument_description.rb +1 -0
 - data/lib/rubocop/cop/graphql/argument_name.rb +1 -0
 - data/lib/rubocop/cop/graphql/field_definitions.rb +21 -5
 - data/lib/rubocop/cop/graphql/field_description.rb +1 -0
 - data/lib/rubocop/cop/graphql/field_hash_key.rb +3 -2
 - data/lib/rubocop/cop/graphql/field_method.rb +8 -2
 - data/lib/rubocop/cop/graphql/field_name.rb +1 -0
 - data/lib/rubocop/cop/graphql/field_uniqueness.rb +8 -1
 - data/lib/rubocop/cop/graphql/graphql_name.rb +70 -0
 - data/lib/rubocop/cop/graphql/legacy_dsl.rb +1 -0
 - data/lib/rubocop/cop/graphql/max_complexity_schema.rb +31 -0
 - data/lib/rubocop/cop/graphql/max_depth_schema.rb +31 -0
 - data/lib/rubocop/cop/graphql/multiple_field_definitions.rb +2 -0
 - data/lib/rubocop/cop/graphql/not_authorized_node_type.rb +134 -0
 - data/lib/rubocop/cop/graphql/ordered_arguments.rb +15 -21
 - data/lib/rubocop/cop/graphql/ordered_fields.rb +20 -15
 - data/lib/rubocop/cop/graphql/prepare_method.rb +95 -0
 - data/lib/rubocop/cop/graphql/resolver_method_length.rb +4 -7
 - data/lib/rubocop/cop/graphql/unnecessary_argument_camelize.rb +11 -4
 - data/lib/rubocop/cop/graphql/unnecessary_field_alias.rb +33 -9
 - data/lib/rubocop/cop/graphql/unnecessary_field_camelize.rb +1 -0
 - data/lib/rubocop/cop/graphql/unused_argument.rb +4 -5
 - data/lib/rubocop/cop/graphql_cops.rb +5 -0
 - data/lib/rubocop/graphql/argument/block.rb +1 -1
 - data/lib/rubocop/graphql/compare_order.rb +51 -0
 - data/lib/rubocop/graphql/ext/snake_case.rb +1 -1
 - data/lib/rubocop/graphql/field.rb +5 -2
 - data/lib/rubocop/graphql/heredoc.rb +12 -5
 - data/lib/rubocop/graphql/schema_member.rb +1 -1
 - data/lib/rubocop/graphql/sorbet.rb +2 -10
 - data/lib/rubocop/graphql/version.rb +1 -1
 - data/lib/rubocop-graphql.rb +1 -0
 - metadata +11 -5
 
| 
         @@ -8,16 +8,23 @@ module RuboCop 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  def range_including_heredoc(node)
         
     | 
| 
       11 
     | 
    
         
            -
                     
     | 
| 
       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. 
     | 
| 
      
 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
         
     | 
| 
         @@ -15,16 +15,8 @@ module RuboCop 
     | 
|
| 
       15 
15 
     | 
    
         
             
                  end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                  def sorbet_signature_for(node)
         
     | 
| 
       18 
     | 
    
         
            -
                    node. 
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       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
         
     | 
    
        data/lib/rubocop-graphql.rb
    CHANGED
    
    | 
         @@ -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:  
     | 
| 
      
 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:  
     | 
| 
      
 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: ' 
     | 
| 
      
 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: ' 
     | 
| 
      
 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: ' 
     | 
| 
      
 148 
     | 
    
         
            +
                  version: '3.0'
         
     | 
| 
       143 
149 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       144 
150 
     | 
    
         
             
              requirements:
         
     | 
| 
       145 
151 
     | 
    
         
             
              - - ">="
         
     |