rmosolgo/graphql-ruby

View on GitHub

Showing 446 of 458 total issues

File field.rb has 505 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "graphql/schema/field/connection_extension"
require "graphql/schema/field/scope_extension"

module GraphQL
  class Schema
Severity: Major
Found in lib/graphql/schema/field.rb - About 1 day to fix

    File runtime.rb has 484 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

      File nodes.rb has 476 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module GraphQL
        module Language
          module Nodes
            # {AbstractNode} is the base class for all nodes in a GraphQL AST.
            #
      Severity: Minor
      Found in lib/graphql/language/nodes.rb - About 7 hrs to fix

        Method build has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
        Open

                def build(document, default_resolve: DefaultResolve, using: {}, interpreter: true)
                  raise InvalidDocumentError.new('Must provide a document ast.') if !document || !document.is_a?(GraphQL::Language::Nodes::Document)
        
                  if default_resolve.is_a?(Hash)
                    default_resolve = ResolveMap.new(default_resolve)
        Severity: Minor
        Found in lib/graphql/schema/build_from_definition.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

        Method from_arguments has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.from_arguments(ast_arguments, argument_owner, variables)
                context = variables ? variables.context : nil
                values_hash = {}
                defaults_used = Set.new
        
        
        Severity: Minor
        Found in lib/graphql/query/literal_input.rb - About 6 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 a Cognitive Complexity of 39 (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 5 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 on_argument has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

              def on_argument(node, parent)
                parent_defn = case parent
                when GraphQL::Language::Nodes::InputObject
                  arg_defn = context.argument_definition
                  if arg_defn.nil?

        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

        Function sync has 135 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function sync(options: SyncOptions) {
          var logger = new Logger(!!options.quiet)
          var verbose = !!options.verbose
          var url = options.url
          if (!url) {
        Severity: Major
        Found in javascript_client/src/sync/index.ts - About 5 hrs to fix

          Method resolve_with_support has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

                def resolve_with_support(**args)
                  # First call the ready? hook which may raise
                  ready_val = if args.any?
                    ready?(**args)
                  else
          Severity: Minor
          Found in lib/graphql/schema/resolver.rb - About 5 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 add_type has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

                def add_type(type, owner:, late_types:)
                  if type.respond_to?(:metadata) && type.metadata.is_a?(Hash)
                    type_class = type.metadata[:type_class]
                    if type_class.nil?
                      raise ArgumentError, "Can't add legacy type: #{type} (#{type.class})"
          Severity: Minor
          Found in lib/graphql/schema.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 resolve has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

                def resolve(object, args, ctx)
                  if @resolve_proc
                    raise "Can't run resolve proc for #{path} when using GraphQL::Execution::Interpreter"
                  end
                  begin
          Severity: Minor
          Found in lib/graphql/schema/field.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 initialize has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(type: nil, name: nil, owner: nil, null: nil, field: nil, function: nil, description: nil, deprecation_reason: nil, method: nil, hash_key: nil, resolver_method: nil, resolve: nil, connection: nil, max_page_size: nil, scope: nil, introspection: false, camelize: true, trace: nil, complexity: 1, ast_node: nil, extras: [], extensions: EMPTY_ARRAY, resolver_class: nil, subscription_scope: nil, relay_node_field: false, relay_nodes_field: false, method_conflict_warning: true, arguments: EMPTY_HASH, &definition_block)
                  if name.nil?
                    raise ArgumentError, "missing first `name` argument or keyword `name:`"
                  end
                  if !(field || function || resolver_class)
          Severity: Minor
          Found in lib/graphql/schema/field.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 normalize_arguments has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

              def normalize_arguments(event_name, arg_owner, args)
                case arg_owner
                when GraphQL::Field, GraphQL::InputObjectType, GraphQL::Schema::Field, Class
                  if arg_owner.is_a?(Class) && !arg_owner.kind.input_object?
                    # it's a type, but not an input object
          Severity: Minor
          Found in lib/graphql/subscriptions.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

          File execution_specification.rb has 355 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "graphql/compatibility/execution_specification/counter_schema"
          require "graphql/compatibility/execution_specification/specification_schema"
          
          module GraphQL
            module Compatibility
          Severity: Minor
          Found in lib/graphql/compatibility/execution_specification.rb - About 4 hrs to fix

            Method initialize has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
            Open

                  def initialize(ctx, ast_variables, provided_variables)
                    schema = ctx.schema
                    @context = ctx
            
                    @provided_variables = GraphQL::Argument.deep_stringify(provided_variables)
            Severity: Minor
            Found in lib/graphql/query/variables.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

            Class Printer has 34 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class Printer
                  # Turn an arbitrary AST node back into a string.
                  #
                  # @example Turning a document into a query string
                  #    document = GraphQL.parse(query_string)
            Severity: Minor
            Found in lib/graphql/language/printer.rb - About 4 hrs to fix

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

                    def visit(schema, member, context_description)
                      case member
                      when GraphQL::Schema
                        member.directives.each { |name, directive| visit(schema, directive, "Directive #{name}") }
                        # Find the starting points, then visit them
              Severity: Minor
              Found in lib/graphql/schema/traversal.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 parse_type has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
              Open

                      def parse_type(type_expr, null:)
                        list_type = false
              
                        return_type = case type_expr
                        when String
              Severity: Minor
              Found in lib/graphql/schema/member/build_type.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 resolve_value has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                      def resolve_value(value, field_type, field_ctx)
                        field_defn = field_ctx.field
              
                        if value.nil?
                          if field_type.kind.non_null?
              Severity: Minor
              Found in lib/graphql/execution/execute.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 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

              Severity
              Category
              Status
              Source
              Language