rmosolgo/graphql-ruby

View on GitHub
lib/graphql/execution/interpreter/runtime.rb

Summary

Maintainability
F
5 days
Test Coverage

Method evaluate_selections has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

        def evaluate_selections(path, scoped_context, owner_object, owner_type, selections, root_operation_type: nil)
          @interpreter_context[:current_object] = owner_object
          @interpreter_context[:current_path] = path
          selections_by_name = {}
          gather_selections(owner_object, owner_type, selections, selections_by_name)
Severity: Minor
Found in lib/graphql/execution/interpreter/runtime.rb - About 7 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File runtime.rb has 465 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module GraphQL
  module Execution
    class Interpreter
      # I think it would be even better if we could somehow make
      # `continue_field` not recursive. "Trampolining" it somehow.
Severity: Minor
Found in lib/graphql/execution/interpreter/runtime.rb - About 7 hrs to fix

    Method continue_field has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

            def continue_field(path, value, field, type, ast_node, next_selections, is_non_null, owner_object, arguments) # rubocop:disable Metrics/ParameterLists
              case type.kind.name
              when "SCALAR", "ENUM"
                r = type.coerce_result(value, context)
                write_in_response(path, r)
    Severity: Minor
    Found in lib/graphql/execution/interpreter/runtime.rb - About 4 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method evaluate_selections has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def evaluate_selections(path, scoped_context, owner_object, owner_type, selections, root_operation_type: nil)
              @interpreter_context[:current_object] = owner_object
              @interpreter_context[:current_path] = path
              selections_by_name = {}
              gather_selections(owner_object, owner_type, selections, selections_by_name)
    Severity: Major
    Found in lib/graphql/execution/interpreter/runtime.rb - About 4 hrs to fix

      Method gather_selections has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

              def gather_selections(owner_object, owner_type, selections, selections_by_name)
                selections.each do |node|
                  # Skip gathering this if the directive says so
                  if !directives_include?(node, owner_object, owner_type)
                    next
      Severity: Minor
      Found in lib/graphql/execution/interpreter/runtime.rb - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method continue_field has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def continue_field(path, value, field, type, ast_node, next_selections, is_non_null, owner_object, arguments) # rubocop:disable Metrics/ParameterLists
                case type.kind.name
                when "SCALAR", "ENUM"
                  r = type.coerce_result(value, context)
                  write_in_response(path, r)
      Severity: Major
      Found in lib/graphql/execution/interpreter/runtime.rb - About 2 hrs to fix

        Class Runtime has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

              class Runtime
                # @return [GraphQL::Query]
                attr_reader :query
        
                # @return [Class<GraphQL::Schema>]
        Severity: Minor
        Found in lib/graphql/execution/interpreter/runtime.rb - About 2 hrs to fix

          Method continue_value has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                  def continue_value(path, value, field, is_non_null, ast_node)
                    if value.nil?
                      if is_non_null
                        err = field.owner::InvalidNullError.new(field.owner, field, value)
                        write_invalid_null_in_response(path, err)
          Severity: Minor
          Found in lib/graphql/execution/interpreter/runtime.rb - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method after_lazy has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                  def after_lazy(lazy_obj, owner:, field:, path:, scoped_context:, owner_object:, arguments:, eager: false, trace: true, &block)
                    @interpreter_context[:current_object] = owner_object
                    @interpreter_context[:current_arguments] = arguments
                    @interpreter_context[:current_path] = path
                    @interpreter_context[:current_field] = field
          Severity: Minor
          Found in lib/graphql/execution/interpreter/runtime.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method gather_selections has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def gather_selections(owner_object, owner_type, selections, selections_by_name)
                    selections.each do |node|
                      # Skip gathering this if the directive says so
                      if !directives_include?(node, owner_object, owner_type)
                        next
          Severity: Minor
          Found in lib/graphql/execution/interpreter/runtime.rb - About 1 hr to fix

            Method after_lazy has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def after_lazy(lazy_obj, owner:, field:, path:, scoped_context:, owner_object:, arguments:, eager: false, trace: true, &block)
                      @interpreter_context[:current_object] = owner_object
                      @interpreter_context[:current_arguments] = arguments
                      @interpreter_context[:current_path] = path
                      @interpreter_context[:current_field] = field
            Severity: Minor
            Found in lib/graphql/execution/interpreter/runtime.rb - About 1 hr to fix

              Method continue_value has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def continue_value(path, value, field, is_non_null, ast_node)
                        if value.nil?
                          if is_non_null
                            err = field.owner::InvalidNullError.new(field.owner, field, value)
                            write_invalid_null_in_response(path, err)
              Severity: Minor
              Found in lib/graphql/execution/interpreter/runtime.rb - About 1 hr to fix

                Method continue_field has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        def continue_field(path, value, field, type, ast_node, next_selections, is_non_null, owner_object, arguments) # rubocop:disable Metrics/ParameterLists
                Severity: Major
                Found in lib/graphql/execution/interpreter/runtime.rb - About 1 hr to fix

                  Method dead_path? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def dead_path?(path)
                            res = @dead_paths
                            path.each do |part|
                              if res
                                if res[:__dead]
                  Severity: Minor
                  Found in lib/graphql/execution/interpreter/runtime.rb - About 45 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method continue_value has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          def continue_value(path, value, field, is_non_null, ast_node)
                  Severity: Minor
                  Found in lib/graphql/execution/interpreter/runtime.rb - About 35 mins to fix

                    Method evaluate_selections has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            def evaluate_selections(path, scoped_context, owner_object, owner_type, selections, root_operation_type: nil)
                    Severity: Minor
                    Found in lib/graphql/execution/interpreter/runtime.rb - About 35 mins to fix

                      Method run_directive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def run_directive(object, ast_node, idx, &block)
                                dir_node = ast_node.directives[idx]
                                if !dir_node
                                  yield
                                else
                      Severity: Minor
                      Found in lib/graphql/execution/interpreter/runtime.rb - About 25 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      There are no issues that match your filters.

                      Category
                      Status