rmosolgo/graphql-ruby

View on GitHub

Showing 391 of 408 total issues

Class Query has 29 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 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

      Class BaseType has 28 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 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

        File build_from_definition.rb has 302 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

          Method initialize has 81 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: nil, scope: nil, introspection: false, camelize: true, trace: nil, complexity: 1, extras: [], extensions: [], resolver_class: nil, subscription_scope: nil, relay_node_field: false, relay_nodes_field: false, arguments: {}, &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 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 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

            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

            File printer.rb has 293 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module GraphQL
              module Language
                class Printer
                  # Turn an arbitrary AST node back into a string.
                  #
            Severity: Minor
            Found in lib/graphql/language/printer.rb - About 3 hrs to fix

              Class Visitor has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

                    class Visitor < GraphQL::Language::Visitor
                      def initialize(query:, analyzers:)
                        @analyzers = analyzers
                        @path = []
                        @object_types = []
              Severity: Minor
              Found in lib/graphql/analysis/ast/visitor.rb - About 3 hrs to fix

                File syncTest.js has 290 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                var sync = require("../sync")
                var fs = require("fs")
                var nock = require("nock")
                var Logger = require("../sync/logger")
                var logger = new Logger
                Severity: Minor
                Found in javascript_client/__tests__/syncTest.js - About 2 hrs to fix

                  Method resolve has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def self.resolve(parent_type, field_defn, field_type, value, selection, query_ctx)
                            if value.nil? || value.is_a?(GraphQL::ExecutionError)
                              if field_type.kind.non_null?
                                if value.nil?
                                  type_error = GraphQL::InvalidNullError.new(parent_type, field_defn, value)
                  Severity: Major
                  Found in lib/graphql/query/serial_execution/value_resolution.rb - About 2 hrs to fix

                    Method platform_trace has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def platform_trace(platform_key, key, data)
                            if key == "execute_query"
                              query = data[:query]
                              title = query.selected_operation_name || "<anonymous>"
                              category = platform_key
                    Severity: Minor
                    Found in lib/graphql/tracing/skylight_tracing.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

                    File fields_will_merge.rb has 287 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    module GraphQL
                      module StaticValidation
                        module FieldsWillMerge
                          # Validates that a selection set is valid if all fields (including spreading any
                          # fragments) either correspond to distinct response names or can be merged
                    Severity: Minor
                    Found in lib/graphql/static_validation/rules/fields_will_merge.rb - About 2 hrs to fix

                      Class DocumentFromSchemaDefinition has 25 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                          class DocumentFromSchemaDefinition
                            def initialize(
                              schema, context: nil, only: nil, except: nil, include_introspection_types: false,
                              include_built_in_directives: false, include_built_in_scalars: false, always_include_schema: false
                            )
                      Severity: Minor
                      Found in lib/graphql/language/document_from_schema_definition.rb - About 2 hrs to fix

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

                                def parse_type(type_expr, null:)
                                  list_type = false
                        
                                  return_type = case type_expr
                                  when String
                        Severity: Major
                        Found in lib/graphql/schema/member/build_type.rb - About 2 hrs to fix

                          Method resolve_dependencies has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def resolve_dependencies
                                  dependency_map = DependencyMap.new
                                  # Don't allow the loop to run more times
                                  # than the number of fragments in the document
                                  max_loops = 0
                          Severity: Minor
                          Found in lib/graphql/static_validation/definition_dependencies.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 load_value has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def load_value(value)
                                    if value.is_a?(Array)
                                      value.map{|item| load_value(item)}
                                    elsif value.is_a?(Hash)
                                      if value.size == 1 && value.key?(GLOBALID_KEY)
                          Severity: Minor
                          Found in lib/graphql/subscriptions/serialize.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

                          Severity
                          Category
                          Status
                          Source
                          Language