rmosolgo/graphql-ruby

View on GitHub
lib/graphql/schema/field.rb

Summary

Maintainability
F
5 days
Test Coverage

File field.rb has 527 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

    Method initialize has a Cognitive Complexity of 34 (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: :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: Minor
    Found in lib/graphql/schema/field.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 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 to_ruby_args has a Cognitive Complexity of 25 (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 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

      Class Field has 27 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Field
            if !String.method_defined?(:-@)
              using GraphQL::StringDedupBackport
            end
      
      
      Severity: Minor
      Found in lib/graphql/schema/field.rb - About 3 hrs to fix

        Method from_options has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.from_options(name = nil, type = nil, desc = nil, resolver: nil, mutation: nil, subscription: nil,**kwargs, &block)
                if kwargs[:field]
                  if kwargs[:field] == GraphQL::Relay::Node.field
                    warn("Legacy-style `GraphQL::Relay::Node.field` is being added to a class-based type. See `GraphQL::Types::Relay::NodeField` for a replacement.")
                    return GraphQL::Types::Relay::NodeField
        Severity: Minor
        Found in lib/graphql/schema/field.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 to_graphql has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def to_graphql
                field_defn = if @field
                  @field.dup
                elsif @function
                  GraphQL::Function.build_field(@function)
        Severity: Major
        Found in lib/graphql/schema/field.rb - About 2 hrs to fix

          Method to_graphql has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def to_graphql
                  field_defn = if @field
                    @field.dup
                  elsif @function
                    GraphQL::Function.build_field(@function)
          Severity: Minor
          Found in lib/graphql/schema/field.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 to_ruby_args has 39 lines of code (exceeds 25 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 1 hr to fix

            Method resolve has 39 lines of code (exceeds 25 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 1 hr to fix

              Method public_send_field has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                    def public_send_field(obj, ruby_kwargs, field_ctx)
                      query_ctx = field_ctx.query.context
                      with_extensions(obj, ruby_kwargs, query_ctx) do |extended_obj, extended_args|
                        if @resolver_class
                          if extended_obj.is_a?(GraphQL::Schema::Object)
              Severity: Minor
              Found in lib/graphql/schema/field.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 from_options has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def self.from_options(name = nil, type = nil, desc = nil, resolver: nil, mutation: nil, subscription: nil,**kwargs, &block)
                      if kwargs[:field]
                        if kwargs[:field] == GraphQL::Relay::Node.field
                          warn("Legacy-style `GraphQL::Relay::Node.field` is being added to a class-based type. See `GraphQL::Types::Relay::NodeField` for a replacement.")
                          return GraphQL::Types::Relay::NodeField
              Severity: Minor
              Found in lib/graphql/schema/field.rb - About 1 hr to fix

                Method resolve_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def resolve_field(obj, args, ctx)
                        ctx.schema.after_lazy(obj) do |after_obj|
                          # First, apply auth ...
                          query_ctx = ctx.query.context
                          # Some legacy fields can have `nil` here, not exactly sure why.
                Severity: Minor
                Found in lib/graphql/schema/field.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 resolve_field_method has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def resolve_field_method(obj, ruby_kwargs, ctx)
                        if obj.object.is_a?(Hash)
                          inner_object = obj.object
                          if inner_object.key?(@method_sym)
                            inner_object[@method_sym]
                Severity: Minor
                Found in lib/graphql/schema/field.rb - About 55 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 from_options has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def self.from_options(name = nil, type = nil, desc = nil, resolver: nil, mutation: nil, subscription: nil,**kwargs, &block)
                Severity: Minor
                Found in lib/graphql/schema/field.rb - About 35 mins to fix

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

                        def connection?
                          if @connection.nil?
                            # Provide default based on type name
                            return_type_name = if (contains_type = @field || @function)
                              Member::BuildType.to_type_name(contains_type.type)
                  Severity: Minor
                  Found in lib/graphql/schema/field.rb - About 35 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 scoped? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def scoped?
                          if !@scope.nil?
                            # The default was overridden
                            @scope
                          else
                  Severity: Minor
                  Found in lib/graphql/schema/field.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

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

                        def extensions(new_extensions = nil)
                          if new_extensions.nil?
                            # Read the value
                            @extensions
                          else
                  Severity: Minor
                  Found in lib/graphql/schema/field.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

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

                        def authorized?(object, args, context)
                          if @resolver_class
                            # The resolver will check itself during `resolve()`
                            @resolver_class.authorized?(object, context)
                          else
                  Severity: Minor
                  Found in lib/graphql/schema/field.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