rmosolgo/graphql-ruby

View on GitHub

Showing 446 of 458 total issues

Method reachable_type_set has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def reachable_type_set
        return @reachable_type_set if defined?(@reachable_type_set)

        @reachable_type_set = Set.new

Severity: Major
Found in lib/graphql/schema/warden.rb - About 2 hrs to fix

    Class Context has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Context
          module SharedMethods
            # @return [Object] The target for field resolution
            attr_accessor :object
    
    
    Severity: Minor
    Found in lib/graphql/query/context.rb - About 2 hrs to fix

      Method prepare_ast has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def prepare_ast
            @prepared_ast = true
            @warden ||= GraphQL::Schema::Warden.new(@filter, schema: @schema, context: @context)
            parse_error = nil
            @document ||= begin
      Severity: Major
      Found in lib/graphql/query.rb - About 2 hrs to fix

        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 apply has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def apply(input_text)
                  input_text.scan(/(?:input_field|field|return_field|connection|argument) .*$/).each do |field|
                    matches = /(?<field_type>input_field|return_field|field|connection|argument) :(?<name>[a-zA-Z_0-9_]*)?(:?, +(?<return_type>([A-Za-z\[\]\.\!_0-9\(\)]|::|-> ?\{ ?| ?\})+))?(?<remainder>( |,|$).*)/.match(field)
                    if matches
                      name = matches[:name]
          Severity: Major
          Found in lib/graphql/upgrader/member.rb - About 2 hrs to fix

            Method trim_whitespace has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.trim_whitespace(str)
                    lines = str.split("\n")
                    common_indent = nil
            
                    # find the common whitespace
            Severity: Minor
            Found in lib/graphql/language/block_string.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 validate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                  def validate(query, validate: true)
                    query.trace("validate", { validate: validate, query: query }) do
                      can_skip_rewrite = query.context.interpreter? && query.schema.using_ast_analysis? && query.schema.is_a?(Class)
                      errors = if validate == false && can_skip_rewrite
                        []
            Severity: Minor
            Found in lib/graphql/static_validation/validator.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 normalize_arguments has 52 lines of code (exceeds 25 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: Major
            Found in lib/graphql/subscriptions.rb - About 2 hrs to fix

              Method trace has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def trace(key, data)
                      case key
                      when "lex", "parse", "validate", "analyze_query", "analyze_multiplex", "execute_query", "execute_query_lazy", "execute_multiplex"
                        platform_key = @platform_keys.fetch(key)
                        platform_trace(platform_key, key, data) do
              Severity: Major
              Found in lib/graphql/tracing/platform_tracing.rb - About 2 hrs to fix

                File lookahead.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module GraphQL
                  module Execution
                    # Lookahead creates a uniform interface to inspect the forthcoming selections.
                    #
                    # It assumes that the AST it's working with is valid. (So, it's safe to use
                Severity: Minor
                Found in lib/graphql/execution/lookahead.rb - About 2 hrs to fix

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

                    Method to_graphql has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def to_graphql
                            schema_defn = self.new
                            schema_defn.raise_definition_error = true
                            schema_defn.query = query && query.graphql_definition
                            schema_defn.mutation = mutation && mutation.graphql_definition
                    Severity: Minor
                    Found in lib/graphql/schema.rb - About 1 hr to fix

                      Method find_conflicts_between_fragments has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def find_conflicts_between_fragments(fragment_spread1, fragment_spread2, mutually_exclusive:)
                              fragment_name1 = fragment_spread1.name
                              fragment_name2 = fragment_spread2.name
                              return if fragment_name1 == fragment_name2
                      
                      
                      Severity: Minor
                      Found in lib/graphql/static_validation/rules/fields_will_merge.rb - About 1 hr to fix

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

                              def trace(key, data)
                                case key
                                when 'execute_multiplex'
                                  timeout_state = {
                                    timeout_at: Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond) + max_seconds * 1000,
                        Severity: Minor
                        Found in lib/graphql/schema/timeout.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 a Cognitive Complexity of 15 (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
                                  # Apply any `prepare` methods. Not great code organization, can this go somewhere better?
                        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_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 prepare_ast has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def prepare_ast
                              @prepared_ast = true
                              @warden ||= GraphQL::Schema::Warden.new(@filter, schema: @schema, context: @context)
                              parse_error = nil
                              @document ||= begin
                        Severity: Minor
                        Found in lib/graphql/query.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 on_abstract_node has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def on_abstract_node(node, parent)
                                if node == DELETE_NODE
                                  # This might be passed to `super(DELETE_NODE, ...)`
                                  # by a user hook, don't want to keep visiting in that case.
                                  nil
                        Severity: Minor
                        Found in lib/graphql/language/visitor.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 trace has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def trace(key, data)
                                case key
                                when "lex", "parse", "validate", "analyze_query", "analyze_multiplex", "execute_query", "execute_query_lazy", "execute_multiplex"
                                  platform_key = @platform_keys.fetch(key)
                                  platform_trace(platform_key, key, data) do
                        Severity: Minor
                        Found in lib/graphql/tracing/platform_tracing.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 check_resolved_type has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def check_resolved_type(type, object, ctx = :__undefined__)
                              if ctx == :__undefined__
                                # Old method signature
                                ctx = object
                                object = type
                        Severity: Minor
                        Found in lib/graphql/schema.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

                        Severity
                        Category
                        Status
                        Source
                        Language