rmosolgo/graphql-ruby

View on GitHub

Showing 473 of 485 total issues

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

Class Warden has 27 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 find_selections has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

          def find_selections(subselections_by_type, selections_on_type, selected_type, ast_selections, arguments)
            ast_selections.each do |ast_selection|
              next if skipped_by_directive?(ast_selection)
    
              case ast_selection
    Severity: Minor
    Found in lib/graphql/execution/lookahead.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 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 public_send_field has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

          def public_send_field(unextended_obj, unextended_ruby_kwargs, query_ctx)
            with_extensions(unextended_obj, unextended_ruby_kwargs, query_ctx) do |obj, ruby_kwargs|
              if @resolver_class
                if obj.is_a?(GraphQL::Schema::Object)
                  obj = obj.object
    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 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

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

      it("Posts to the specified URL", () => {
        var mock = nock("http://example.com")
          .post("/stored_operations/sync")
          .reply(200, { "ok" : "ok" })
    
    
    Severity: Major
    Found in javascript_client/src/sync/__tests__/sendPayloadTest.ts and 1 other location - About 3 hrs to fix
    javascript_client/src/sync/__tests__/sendPayloadTest.ts on lines 16..24

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

    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("Uses HTTPS when provided", () => {
        var mock = nock("https://example2.com")
          .post("/stored_operations/sync")
          .reply(200, { "ok" : "ok" })
    
    
    Severity: Major
    Found in javascript_client/src/sync/__tests__/sendPayloadTest.ts and 1 other location - About 3 hrs to fix
    javascript_client/src/sync/__tests__/sendPayloadTest.ts on lines 6..14

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

    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

    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

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

        Class DocumentFromSchemaDefinition has 26 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 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

            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 parse_type has 73 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 reachable_type_set has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                      def reachable_type_set
                        return @reachable_type_set if defined?(@reachable_type_set)
                
                        @reachable_type_set = Set.new
                
                
                Severity: Minor
                Found in lib/graphql/schema/warden.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 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

                  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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language