rmosolgo/graphql-ruby

View on GitHub

Showing 450 of 462 total issues

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

        def self.build(execution_strategy)
          organization_type = nil

          timestamp_type = GraphQL::ScalarType.define do
            name "Timestamp"

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 99 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 3 hrs to fix

    Method update_type_owner has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

          def update_type_owner(owner, type)
            case owner
            when Class
              if owner.kind.union?
                # It's a union with possible_types
    Severity: Minor
    Found in lib/graphql/schema.rb - About 3 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 build has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def build(document, default_resolve:, using: {}, interpreter: true, relay:)
              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: Major
    Found in lib/graphql/schema/build_from_definition.rb - About 3 hrs to fix

      Method define_type has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def define_type(type, type_resolver)
                case type.fetch("kind")
                when "ENUM"
                  EnumType.define(
                    name: type["name"],
      Severity: Major
      Found in lib/graphql/schema/loader.rb - About 3 hrs to fix

        Class Query has 30 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Query
            include Tracing::Traceable
            extend Forwardable
        
            class OperationNameMissingError < GraphQL::ExecutionError
        Severity: Minor
        Found in lib/graphql/query.rb - About 3 hrs to fix

          Method recursively_validate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

                def recursively_validate(ast_value, type)
                  if type.nil?
                    # this means we're an undefined argument, see #present_input_field_values_are_valid
                    maybe_raise_if_invalid(ast_value) do
                      @invalid_response
          Severity: Minor
          Found in lib/graphql/static_validation/literal_validator.rb - About 3 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 constantize has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

                  def constantize(string)
                    names = string.split('::')
          
                    # Trigger a built-in NameError exception including the ill-formed constant in the message.
                    Object.const_get(string) if names.empty?
          Severity: Minor
          Found in lib/graphql/schema/member/build_type.rb - About 3 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 BaseType has 29 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class BaseType
              include GraphQL::Define::NonNullWithBang
              include GraphQL::Define::InstanceDefinable
              include GraphQL::Relay::TypeExtensions
          
          
          Severity: Minor
          Found in lib/graphql/base_type.rb - About 3 hrs to fix

            Method to_ruby_args has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                  def to_ruby_args(obj, graphql_args, field_ctx)
                    if graphql_args.any? || @extras.any?
                      # Splat the GraphQL::Arguments to Ruby keyword arguments
                      ruby_kwargs = graphql_args.to_kwargs
                      maybe_lazies = []
            Severity: Minor
            Found in lib/graphql/schema/field.rb - About 3 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 84 lines of code (exceeds 25 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: Major
            Found in lib/graphql/execution/execute.rb - About 3 hrs to fix

              Method initialize has 84 lines of code (exceeds 25 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: :not_given, scope: nil, introspection: false, camelize: true, trace: nil, complexity: 1, ast_node: nil, extras: [], extensions: EMPTY_ARRAY, connection_extension: self.class.connection_extension, 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: Major
              Found in lib/graphql/schema/field.rb - About 3 hrs to fix

                Method coerce has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                      def self.coerce(type, ast_node, variables)
                        case ast_node
                        when nil
                          nil
                        when Language::Nodes::NullValue
                Severity: Minor
                Found in lib/graphql/query/literal_input.rb - About 3 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 validate_field_selections has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                      def validate_field_selections(ast_node, resolved_type)
                        msg = if resolved_type.nil?
                          nil
                        elsif resolved_type.kind.scalar? && ast_node.selections.any?
                          if ast_node.selections.first.is_a?(GraphQL::Language::Nodes::InlineFragment)

                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 find_selections has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                      def find_selections(subselections_by_type, selections_on_type, selected_type, ast_selections, arguments)
                        ast_selections.each do |ast_selection|
                          next if skipped_by_directive?(ast_selection)
                
                          case ast_selection
                Severity: Minor
                Found in lib/graphql/execution/lookahead.rb - About 3 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 build_analyzers has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                      def build_analyzers(schema, max_depth, max_complexity)
                        qa = schema.query_analyzers.dup
                
                        # Filter out the built in authorization analyzer.
                        # It is deprecated and does not have an AST analyzer alternative.
                Severity: Minor
                Found in lib/graphql/query/validation_pipeline.rb - About 3 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 call has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                      def call(memo, visit_type, irep_node)
                        if visit_type == :enter
                          field = irep_node.definition
                          if field
                            schema = memo[:schema]
                Severity: Minor
                Found in lib/graphql/authorization.rb - About 3 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 find_returned_hashes has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                        def find_returned_hashes(node, returning:)
                          if node.is_a?(Array)
                            *possible_returns, last_expression = *node
                            return possible_returns.map { |c| find_returned_hashes(c, returning: false) }.flatten +
                              # Check the last expression of a method body
                Severity: Minor
                Found in lib/graphql/upgrader/member.rb - About 3 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 build_from_definition.rb has 294 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require "graphql/schema/build_from_definition/resolve_map"
                
                module GraphQL
                  class Schema
                    module BuildFromDefinition
                Severity: Minor
                Found in lib/graphql/schema/build_from_definition.rb - About 3 hrs to fix

                  File query.rb has 294 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require "graphql/query/arguments"
                  require "graphql/query/arguments_cache"
                  require "graphql/query/context"
                  require "graphql/query/executor"
                  require "graphql/query/literal_input"
                  Severity: Minor
                  Found in lib/graphql/query.rb - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language