rmosolgo/graphql-ruby

View on GitHub

Showing 436 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

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

                                    describe "applying a max_page_size bigger than the results" do
                                      let(:query_string) {%|
                                        query getBases($first: Int, $after: String, $last: Int, $before: String){
                                          federation {
                                            bases: basesWithLargeMaxLimitRelation(first: $first, after: $after, last: $last, before: $before) {
                                  Severity: Major
                                  Found in spec/graphql/relay/mongo_relation_connection_spec.rb and 1 other location - About 5 hrs to fix
                                  spec/graphql/relay/relation_connection_spec.rb on lines 360..418

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

                                  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

                                    describe "applying a max_page_size bigger than the results" do
                                      let(:query_string) {%|
                                        query getBases($first: Int, $after: String, $last: Int, $before: String){
                                          empire {
                                            bases: basesWithLargeMaxLimitRelation(first: $first, after: $after, last: $last, before: $before) {
                                  Severity: Major
                                  Found in spec/graphql/relay/relation_connection_spec.rb and 1 other location - About 5 hrs to fix
                                  spec/graphql/relay/mongo_relation_connection_spec.rb on lines 342..400

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

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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language