rmosolgo/graphql-ruby

View on GitHub

Showing 476 of 488 total issues

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

      return sync(options).then(function() {
        var generatedCode = fs.readFileSync("./__crazy_outfile.js", "utf8")
        expect(generatedCode).toMatch('"GetStuff": "5f0da489cf508a7c65ff5fa144e50545"')
        expect(generatedCode).toMatch('module.exports = OperationStoreClient')
        expect(generatedCode).toMatch('var _client = "test-2"')
Severity: Major
Found in javascript_client/src/__tests__/syncTest.ts and 1 other location - About 2 hrs to fix
javascript_client/src/__tests__/syncTest.ts on lines 216..222

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 92.

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

      return sync(options).then(function() {
        var generatedCode = fs.readFileSync("./src/OperationStoreClient.js", "utf8")
        expect(generatedCode).toMatch('"GetStuff": "5f0da489cf508a7c65ff5fa144e50545"')
        expect(generatedCode).toMatch('module.exports = OperationStoreClient')
        expect(generatedCode).toMatch('var _client = "test-1"')
Severity: Major
Found in javascript_client/src/__tests__/syncTest.ts and 1 other location - About 2 hrs to fix
javascript_client/src/__tests__/syncTest.ts on lines 234..240

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 92.

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

        def continue_field(path, value, field, type, ast_node, next_selections, is_non_null, owner_object, arguments) # rubocop:disable Metrics/ParameterLists
          case type.kind.name
          when "SCALAR", "ENUM"
            r = type.coerce_result(value, context)
            write_in_response(path, r)
Severity: Major
Found in lib/graphql/execution/interpreter/runtime.rb - About 2 hrs to fix

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

            def implements(*new_interfaces, **options)
              new_memberships = []
              new_interfaces.each do |int|
                if int.is_a?(Module)
                  unless int.include?(GraphQL::Schema::Interface)
    Severity: Minor
    Found in lib/graphql/schema/object.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 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 visit has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def visit(schema, member, context_description)
            case member
            when GraphQL::Schema
              member.directives.each { |name, directive| visit(schema, directive, "Directive #{name}") }
              # Find the starting points, then visit them
    Severity: Major
    Found in lib/graphql/schema/traversal.rb - About 2 hrs to fix

      Function prepareProject has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function prepareProject(filenames: string[], addTypename: boolean) {
        if(!filenames.length) { return []; }
        var allGraphQL = ""
        filenames.forEach(function(filename) {
          allGraphQL += fs.readFileSync(filename)
      Severity: Major
      Found in javascript_client/src/sync/prepareProject.ts - About 2 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 accepts_definition has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

                  def accepts_definition(name)
                    own_accepts_definition_methods << name
        
                    ivar_name = "@#{name}_args"
                    if self.is_a?(Class)
        Severity: Minor
        Found in lib/graphql/schema/member/accepts_definition.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 trace has a Cognitive Complexity of 19 (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 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 build_rows has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_rows(context_entry, rows:, top: false)
                case context_entry
                when GraphQL::Query::Context::FieldResolutionContext
                  ctx = context_entry
                  field_name = "#{ctx.irep_node.owner_type.name}.#{ctx.field.name}"
        Severity: Minor
        Found in lib/graphql/backtrace/table.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 coerce_arguments has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

                def coerce_arguments(parent_object, values, context)
                  argument_values = {}
                  kwarg_arguments = {}
                  # Cache this hash to avoid re-merging it
                  arg_defns = self.arguments
        Severity: Minor
        Found in lib/graphql/schema/member/has_arguments.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_type_expression has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.normalize_type_expression(type_expression, mode:, null: true)
                if type_expression.start_with?("!")
                  normalize_type_expression(type_expression[1..-1], mode: mode, null: false)
                elsif type_expression.end_with?("!")
                  normalize_type_expression(type_expression[0..-2], mode: mode, null: false)
        Severity: Minor
        Found in lib/generators/graphql/type_generator.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 on_variable_definition has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

              def on_variable_definition(node, parent)
                if !node.default_value.nil?
                  value = node.default_value
                  if node.type.is_a?(GraphQL::Language::Nodes::NonNullType)
                    add_error(GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTypedError.new(

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

              def print_node(node, indent: "")
                case node
                when Nodes::Document
                  print_document(node)
                when Nodes::Argument
        Severity: Major
        Found in lib/graphql/language/printer.rb - About 2 hrs to fix

          Method resolve has a Cognitive Complexity of 18 (exceeds 5 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: Minor
          Found in lib/graphql/query/serial_execution/value_resolution.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 proxy_to_depth has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

                    def proxy_to_depth(inner_obj, depth, ctx)
                      if depth > 0
                        inner_obj.map { |i| proxy_to_depth(i, depth - 1, ctx) }
                      else
                        ctx.schema.after_lazy(inner_obj) do |inner_obj|
          Severity: Minor
          Found in lib/graphql/schema/member/instrumentation.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

          Function sendPayload has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function sendPayload(payload: any, options: SendPayloadOptions) {
            var syncUrl = options.url
            var key = options.secret
            var clientName = options.client
            var verbose = options.verbose
          Severity: Major
          Found in javascript_client/src/sync/sendPayload.ts - About 2 hrs to fix

            Class Runtime has 22 methods (exceeds 20 allowed). Consider refactoring.
            Open

                  class Runtime
                    # @return [GraphQL::Query]
                    attr_reader :query
            
                    # @return [Class<GraphQL::Schema>]
            Severity: Minor
            Found in lib/graphql/execution/interpreter/runtime.rb - About 2 hrs to fix

              Method from_arguments has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def self.from_arguments(ast_arguments, argument_owner, variables)
                      context = variables ? variables.context : nil
                      values_hash = {}
                      defaults_used = Set.new
              
              
              Severity: Major
              Found in lib/graphql/query/literal_input.rb - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language