rmosolgo/graphql-ruby

View on GitHub

Showing 476 of 488 total issues

Class Query has 33 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 4 hrs to fix

    Method resolve_value has a Cognitive Complexity of 28 (exceeds 5 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: Minor
    Found in lib/graphql/execution/execute.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 gather_selections has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

            def gather_selections(owner_object, owner_type, selections, selections_by_name)
              selections.each do |node|
                # Skip gathering this if the directive says so
                if !directives_include?(node, owner_object, owner_type)
                  next
    Severity: Minor
    Found in lib/graphql/execution/interpreter/runtime.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 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

    File createAblyHandlerTest.ts has 333 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { createAblyHandler } from "../createAblyHandler"
    import { Realtime, Types } from "ably"
    
    const dummyOperation = { text: "", name: "" }
    
    

      File syncTest.ts has 326 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import sync from "../sync"
      var fs = require("fs")
      var nock = require("nock")
      
      interface MockOperation {
      Severity: Minor
      Found in javascript_client/src/__tests__/syncTest.ts - About 3 hrs to fix

        Method build has 95 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 update_type_owner has a Cognitive Complexity of 26 (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 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 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

          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

          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 initialize has 85 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, broadcastable: nil, 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  it("Skips outfile generation when using --apollo-android-operation-output artifact", () => {
                    var options = {
                      client: "test-2",
                      apolloAndroidOperationOutput: "./src/__tests__/example-apollo-android-operation-output.json",
                      url: "bogus",
              Severity: Major
              Found in javascript_client/src/__tests__/syncTest.ts and 1 other location - About 3 hrs to fix
              javascript_client/src/__tests__/syncTest.ts on lines 243..256

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 103.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  it("Skips outfile generation when using --persist-output artifact", () => {
                    var options = {
                      client: "test-2",
                      relayPersistedOutput: "./src/__tests__/example-relay-persisted-queries.json",
                      url: "bogus",
              Severity: Major
              Found in javascript_client/src/__tests__/syncTest.ts and 1 other location - About 3 hrs to fix
              javascript_client/src/__tests__/syncTest.ts on lines 258..271

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 103.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              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

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

                  Class Warden has 28 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                      class Warden
                        # @param filter [<#call(member)>] Objects are hidden when `.call(member, ctx)` returns true
                        # @param context [GraphQL::Query::Context]
                        # @param schema [GraphQL::Schema]
                        # @param deep_check [Boolean]
                  Severity: Minor
                  Found in lib/graphql/schema/warden.rb - About 3 hrs to fix

                    Method add_type has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def add_type(type, owner:, late_types:, path:)
                            if type.respond_to?(:metadata) && type.metadata.is_a?(Hash)
                              type_class = type.metadata[:type_class]
                              if type_class.nil?
                                raise ArgumentError, "Can't add legacy type: #{type} (#{type.class})"
                    Severity: Major
                    Found in lib/graphql/schema.rb - About 3 hrs to fix

                      File query.rb has 304 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/fingerprint"
                      Severity: Minor
                      Found in lib/graphql/query.rb - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language