rmosolgo/graphql-ruby

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

Summary

Maintainability
D
1 day
Test Coverage

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

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

    class Resolver
      include Schema::Member::GraphQLTypeNames
      # Really we only need description from here, but:
      extend Schema::Member::BaseDSLMethods
      extend GraphQL::Schema::Member::HasArguments
Severity: Minor
Found in lib/graphql/schema/resolver.rb - About 2 hrs to fix

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

      Method load_arguments has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def load_arguments(args)
              prepared_args = {}
              prepare_lazies = []
      
              args.each do |key, value|
      Severity: Minor
      Found in lib/graphql/schema/resolver.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 argument has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def argument(*args, **kwargs, &block)
                loads = kwargs[:loads]
                # Use `from_resolver: true` to short-circuit the InputObject's own `loads:` implementation
                # so that we can support `#load_{x}` methods below.
                arg_defn = super(*args, from_resolver: true, **kwargs)
      Severity: Minor
      Found in lib/graphql/schema/resolver.rb - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                          if loaded_args.any?
                            public_send(self.class.resolve_method, **loaded_args)
                          else
                            public_send(self.class.resolve_method)
                          end
        Severity: Major
        Found in lib/graphql/schema/resolver.rb - About 45 mins to fix

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

                def authorized?(**inputs)
                  self.class.arguments.each_value do |argument|
                    arg_keyword = argument.keyword
                    if inputs.key?(arg_keyword) && !(arg_value = inputs[arg_keyword]).nil? && (arg_value != argument.default_value)
                      arg_auth, err = argument.authorized?(self, arg_value, context)
          Severity: Minor
          Found in lib/graphql/schema/resolver.rb - About 45 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 type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def type(new_type = nil, null: nil)
                    if new_type
                      if null.nil?
                        raise ArgumentError, "required argument `null:` is missing"
                      end
          Severity: Minor
          Found in lib/graphql/schema/resolver.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 null has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def null(allow_null = nil)
                    if !allow_null.nil?
                      @null = allow_null
                    end
          
          
          Severity: Minor
          Found in lib/graphql/schema/resolver.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