rmosolgo/graphql-ruby

View on GitHub

Showing 244 of 436 total issues

File build_from_definition_spec.rb has 842 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "spec_helper"

describe GraphQL::Schema::BuildFromDefinition do
  # Build a schema from `definition` and assert that it
  # prints out the same string.
Severity: Major
Found in spec/graphql/schema/build_from_definition_spec.rb - About 2 days to fix

    Method build_suite has 345 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.build_suite(execution_strategy)
            Class.new(Minitest::Test) do
              class << self
                attr_accessor :counter_schema, :specification_schema
              end
    Severity: Major
    Found in lib/graphql/compatibility/execution_specification.rb - About 1 day to fix

      File warden_spec.rb has 721 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "spec_helper"
      
      module MaskHelpers
        PhonemeType = GraphQL::ObjectType.define do
          name "Phoneme"
      Severity: Major
      Found in spec/graphql/schema/warden_spec.rb - About 1 day to fix

        Class Schema has 86 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Schema
            extend Forwardable
            extend GraphQL::Schema::Member::AcceptsDefinition
            include GraphQL::Define::InstanceDefinable
            accepts_definitions \
        Severity: Major
        Found in lib/graphql/schema.rb - About 1 day to fix

          File schema.rb has 701 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "graphql/schema/base_64_encoder"
          require "graphql/schema/catchall_middleware"
          require "graphql/schema/default_parse_error"
          require "graphql/schema/default_type_error"
          require "graphql/schema/finder"
          Severity: Major
          Found in lib/graphql/schema.rb - About 1 day to fix

            File query_spec.rb has 678 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require "spec_helper"
            
            describe GraphQL::Query do
              let(:query_string) { %|
                query getFlavor($cheeseId: Int!) {
            Severity: Major
            Found in spec/graphql/query_spec.rb - About 1 day to fix

              File member.rb has 660 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              begin
                require 'parser/current'
              rescue LoadError
                raise LoadError, "GraphQL::Upgrader requires the 'parser' gem, please install it and/or add it to your Gemfile"
              end
              Severity: Major
              Found in lib/graphql/upgrader/member.rb - About 1 day to fix

                File relation_connection_spec.rb has 646 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require 'spec_helper'
                
                describe GraphQL::Relay::RelationConnection do
                  def get_names(result)
                    ships = result["data"]["empire"]["bases"]["edges"]
                Severity: Major
                Found in spec/graphql/relay/relation_connection_spec.rb - About 1 day to fix

                  File authorization_spec.rb has 573 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require "spec_helper"
                  
                  describe GraphQL::Authorization do
                    module AuthTest
                      class Box
                  Severity: Major
                  Found in spec/graphql/authorization_spec.rb - About 1 day to fix

                    File fields_will_merge_spec.rb has 535 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require "spec_helper"
                    
                    describe GraphQL::StaticValidation::FieldsWillMerge do
                      include StaticValidationHelpers
                    
                    
                    Severity: Major
                    Found in spec/graphql/static_validation/rules/fields_will_merge_spec.rb - About 1 day to fix

                      File document_from_schema_definition_spec.rb has 518 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require "spec_helper"
                      
                      describe GraphQL::Language::DocumentFromSchemaDefinition do
                        let(:subject) { GraphQL::Language::DocumentFromSchemaDefinition }
                      
                      
                      Severity: Major
                      Found in spec/graphql/language/document_from_schema_definition_spec.rb - About 1 day to fix

                        File printer_spec.rb has 480 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        require "spec_helper"
                        
                        describe GraphQL::Schema::Printer do
                          let(:schema) {
                            node_type = GraphQL::InterfaceType.define do
                        Severity: Minor
                        Found in spec/graphql/schema/printer_spec.rb - About 7 hrs to fix

                          Method build_suite has 186 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                def self.build_suite(execution_strategy)
                                  Class.new(Minitest::Test) do
                                    class << self
                                      attr_accessor :lazy_schema
                                    end
                          Severity: Major
                          Found in lib/graphql/compatibility/lazy_execution_specification.rb - About 7 hrs to fix

                            Method build_suite has 178 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                  def self.build_suite(&block)
                                    Class.new(Minitest::Test) do
                                      @@parse_fn = block
                            
                                      def parse(query_string)
                            Severity: Major
                            Found in lib/graphql/compatibility/schema_parser_specification.rb - About 7 hrs to fix

                              File jazz.rb has 446 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              module Jazz
                                module Models
                                  Instrument = Struct.new(:name, :family)
                                  Ensemble = Struct.new(:name)
                                  Musician = Struct.new(:name, :favorite_key)
                              Severity: Minor
                              Found in spec/support/jazz.rb - About 6 hrs to fix

                                File member_spec.rb has 440 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                require "spec_helper"
                                require './lib/graphql/upgrader/member.rb'
                                
                                describe GraphQL::Upgrader::Member do
                                  def upgrade(old)
                                Severity: Minor
                                Found in spec/graphql/upgrader/member_spec.rb - About 6 hrs to fix

                                  Method apply has a Cognitive Complexity of 40 (exceeds 5 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: Minor
                                  Found in lib/graphql/upgrader/member.rb - About 6 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 37 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                          def build(document, default_resolve: DefaultResolve)
                                            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: Minor
                                  Found in lib/graphql/schema/build_from_definition.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

                                  File schema_spec.rb has 399 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  require "spec_helper"
                                  
                                  describe GraphQL::Schema do
                                    let(:schema) { Dummy::Schema }
                                    let(:relay_schema)  { StarWars::Schema }
                                  Severity: Minor
                                  Found in spec/graphql/schema_spec.rb - About 5 hrs to fix

                                    File mongo_relation_connection_spec.rb has 398 lines of code (exceeds 250 allowed). Consider refactoring.
                                    Open

                                    require 'spec_helper'
                                    
                                    if MONGO_DETECTED
                                      require "support/star_trek/data"
                                      require "support/star_trek/schema"
                                    Severity: Minor
                                    Found in spec/graphql/relay/mongo_relation_connection_spec.rb - About 5 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language