datamapper/dm-core

View on GitHub

Showing 115 of 115 total issues

Class Collection has 79 methods (exceeds 20 allowed). Consider refactoring.

  class Collection < LazyArray

    # Returns the Query the Collection is scoped with
    #
    # @return [Query]
Severity: Major
Found in lib/dm-core/collection.rb - About 1 day to fix

    File query.rb has 620 lines of code (exceeds 250 allowed). Consider refactoring.

    module DataMapper
    
      # Query class represents a query which will be run against the data-store.
      # Generally Query objects can be found inside Collection objects.
      #
    Severity: Major
    Found in lib/dm-core/query.rb - About 1 day to fix

      Class Query has 68 methods (exceeds 20 allowed). Consider refactoring.

        class Query
          include DataMapper::Assertions
          extend Equalizer
      
          OPTIONS = [ :fields, :links, :conditions, :offset, :limit, :order, :unique, :add_reversed, :reload ].to_set.freeze
      Severity: Major
      Found in lib/dm-core/query.rb - About 1 day to fix

        File collection.rb has 529 lines of code (exceeds 250 allowed). Consider refactoring.

        module DataMapper
          # The Collection class represents a list of resources persisted in
          # a repository and identified by a query.
          #
          # A Collection should act like an Array in every way, except that
        Severity: Major
        Found in lib/dm-core/collection.rb - About 1 day to fix

          File resource.rb has 461 lines of code (exceeds 250 allowed). Consider refactoring.

          module DataMapper
            module Resource
              include DataMapper::Assertions
          
              # Return if Resource#save should raise an exception on save failures (per-resource)
          Severity: Minor
          Found in lib/dm-core/resource.rb - About 7 hrs to fix

            Class LazyArray has 43 methods (exceeds 20 allowed). Consider refactoring.

            class LazyArray  # borrowed partially from StrokeDB
              include Enumerable
            
              attr_reader :head, :tail
            
            
            Severity: Minor
            Found in lib/dm-core/support/lazy_array.rb - About 5 hrs to fix

              Class Relationship has 40 methods (exceeds 20 allowed). Consider refactoring.

                  class Relationship
                    include DataMapper::Assertions
                    include Subject
              
                    OPTIONS = [ :child_repository_name, :parent_repository_name, :child_key, :parent_key, :min, :max, :inverse, :reader_visibility, :writer_visibility, :default ].to_set
              Severity: Minor
              Found in lib/dm-core/associations/relationship.rb - About 5 hrs to fix

                Method load has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.

                    def load(records, query)
                      repository      = query.repository
                      repository_name = repository.name
                      fields          = query.fields
                      discriminator   = properties(repository_name).discriminator
                Severity: Minor
                Found in lib/dm-core/model.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

                Class Property has 38 methods (exceeds 20 allowed). Consider refactoring.

                  class Property
                    include DataMapper::Assertions
                    include Subject
                    extend Equalizer
                
                
                Severity: Minor
                Found in lib/dm-core/property.rb - About 5 hrs to fix

                  File comparison.rb has 364 lines of code (exceeds 250 allowed). Consider refactoring.

                  module DataMapper
                    class Query
                      # The Conditions module contains classes used as part of a Query when
                      # filtering collections of resources.
                      #
                  Severity: Minor
                  Found in lib/dm-core/query/conditions/comparison.rb - About 4 hrs to fix

                    File lazy_array.rb has 361 lines of code (exceeds 250 allowed). Consider refactoring.

                    class LazyArray  # borrowed partially from StrokeDB
                      include Enumerable
                    
                      attr_reader :head, :tail
                    
                    
                    Severity: Minor
                    Found in lib/dm-core/support/lazy_array.rb - About 4 hrs to fix

                      File model.rb has 348 lines of code (exceeds 250 allowed). Consider refactoring.

                      module DataMapper
                        module Model
                          include Enumerable
                      
                          WRITER_METHOD_REGEXP   = /=\z/.freeze
                      Severity: Minor
                      Found in lib/dm-core/model.rb - About 4 hrs to fix

                        Method assert_valid_options has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.

                            def assert_valid_options(options)
                              keys = options.keys
                        
                              if (unknown_keys = keys - self.class.accepted_options).any?
                                raise ArgumentError, "options #{unknown_keys.map { |key| key.inspect }.join(' and ')} are unknown"
                        Severity: Minor
                        Found in lib/dm-core/property.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 PropertySet has 27 methods (exceeds 20 allowed). Consider refactoring.

                          class PropertySet < SubjectSet
                            include Enumerable
                        
                            def <<(property)
                              clear_cache
                        Severity: Minor
                        Found in lib/dm-core/property_set.rb - About 3 hrs to fix

                          File relationship.rb has 296 lines of code (exceeds 250 allowed). Consider refactoring.

                          module DataMapper
                            module Associations
                              # Base class for relationships. Each type of relationship
                              # (1 to 1, 1 to n, n to m) implements a subclass of this class
                              # with methods like get and set overridden.
                          Severity: Minor
                          Found in lib/dm-core/associations/relationship.rb - About 3 hrs to fix

                            Method assert_valid_options has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.

                                  def assert_valid_options(options)
                                    # TODO: update to match Query#assert_valid_options
                                    #   - perform options normalization elsewhere
                            
                                    if options.key?(:min) && options.key?(:max)
                            Severity: Minor
                            Found in lib/dm-core/model/relationship.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 AbstractOperation has 26 methods (exceeds 20 allowed). Consider refactoring.

                                  class AbstractOperation
                                    include DataMapper::Assertions
                                    include Enumerable
                                    extend Equalizer
                            
                            
                            Severity: Minor
                            Found in lib/dm-core/query/conditions/operation.rb - About 3 hrs to fix

                              File many_to_many.rb has 286 lines of code (exceeds 250 allowed). Consider refactoring.

                              module DataMapper
                                module Associations
                                  module ManyToMany #:nodoc:
                                    class Relationship < Associations::OneToMany::Relationship
                                      extend Chainable
                              Severity: Minor
                              Found in lib/dm-core/associations/many_to_many.rb - About 2 hrs to fix

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

                                    def self.nested_const_lookup(mod, const_name)
                                      unless mod.equal?(::Object)
                                        constants = []
                                
                                        mod.name.split('::').each do |part|
                                Severity: Minor
                                Found in lib/dm-core/support/ext/module.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

                                Class AbstractComparison has 23 methods (exceeds 20 allowed). Consider refactoring.

                                      class AbstractComparison
                                        extend Equalizer
                                
                                        equalize :subject, :value
                                
                                
                                Severity: Minor
                                Found in lib/dm-core/query/conditions/comparison.rb - About 2 hrs to fix

                                  File property.rb has 269 lines of code (exceeds 250 allowed). Consider refactoring.

                                  module DataMapper
                                    # = Properties
                                    # Properties for a model are not derived from a database structure, but
                                    # instead explicitly declared inside your model class definitions. These
                                    # properties then map (or, if using automigrate, generate) fields in your
                                  Severity: Minor
                                  Found in lib/dm-core/property.rb - About 2 hrs to fix

                                    Method install_hook has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.

                                          def install_hook(type, target_method, method_sym, scope, &block)
                                            assert_kind_of 'target_method', target_method, Symbol
                                            assert_kind_of 'method_sym',    method_sym,    Symbol unless method_sym.nil?
                                            assert_kind_of 'scope',         scope,         Symbol
                                    
                                    
                                    Severity: Minor
                                    Found in lib/dm-core/support/hook.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

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

                                          class Relationship < Associations::Relationship
                                            OPTIONS = superclass::OPTIONS.dup << :required << :key << :unique
                                    
                                            # @api semipublic
                                            alias_method :source_repository_name, :child_repository_name
                                    Severity: Minor
                                    Found in lib/dm-core/associations/many_to_one.rb - About 2 hrs to fix

                                      Method target_conditions has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.

                                          def self.target_conditions(source, source_key, target_key)
                                            target_key_size = target_key.size
                                            source_values   = []
                                      
                                            if source.nil?
                                      Severity: Minor
                                      Found in lib/dm-core/query.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

                                      Class Relationship has 21 methods (exceeds 20 allowed). Consider refactoring.

                                            class Relationship < Associations::OneToMany::Relationship
                                              extend Chainable
                                      
                                              OPTIONS = superclass::OPTIONS.dup << :through << :via
                                      
                                      
                                      Severity: Minor
                                      Found in lib/dm-core/associations/many_to_many.rb - About 2 hrs to fix

                                        Method assert_valid_conditions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.

                                            def assert_valid_conditions(conditions)
                                              case conditions
                                                when Hash
                                                  conditions.each do |subject, bind_value|
                                                    case subject
                                        Severity: Minor
                                        Found in lib/dm-core/query.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 default_attributes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.

                                            def default_attributes
                                              return @default_attributes if @default_attributes
                                        
                                              default_attributes = {}
                                        
                                        
                                        Severity: Minor
                                        Found in lib/dm-core/collection.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 last has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.

                                            def last(*args)
                                              first_arg = args.first
                                              last_arg  = args.last
                                        
                                              limit_specified = first_arg.kind_of?(Integer)
                                        Severity: Minor
                                        Found in lib/dm-core/collection.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 install_hook has 49 lines of code (exceeds 25 allowed). Consider refactoring.

                                              def install_hook(type, target_method, method_sym, scope, &block)
                                                assert_kind_of 'target_method', target_method, Symbol
                                                assert_kind_of 'method_sym',    method_sym,    Symbol unless method_sym.nil?
                                                assert_kind_of 'scope',         scope,         Symbol
                                        
                                        
                                        Severity: Minor
                                        Found in lib/dm-core/support/hook.rb - About 1 hr to fix

                                          Method load has 49 lines of code (exceeds 25 allowed). Consider refactoring.

                                              def load(records, query)
                                                repository      = query.repository
                                                repository_name = repository.name
                                                fields          = query.fields
                                                discriminator   = properties(repository_name).discriminator
                                          Severity: Minor
                                          Found in lib/dm-core/model.rb - About 1 hr to fix

                                            Method first has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.

                                                def first(*args)
                                                  first_arg = args.first
                                                  last_arg  = args.last
                                            
                                                  limit_specified = first_arg.kind_of?(Integer)
                                            Severity: Minor
                                            Found in lib/dm-core/collection.rb - About 1 hr 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 _save has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.

                                                    def _save(execute_hooks = true)
                                                      via = self.via
                                            
                                                      if @removed.any?
                                                        # delete only intermediaries linked to the removed targets
                                            Severity: Minor
                                            Found in lib/dm-core/associations/many_to_many.rb - About 1 hr 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 assert_valid_options has 39 lines of code (exceeds 25 allowed). Consider refactoring.

                                                  def assert_valid_options(options)
                                                    # TODO: update to match Query#assert_valid_options
                                                    #   - perform options normalization elsewhere
                                            
                                                    if options.key?(:min) && options.key?(:max)
                                            Severity: Minor
                                            Found in lib/dm-core/model/relationship.rb - About 1 hr to fix

                                              Method scoped_query has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.

                                                  def scoped_query(query)
                                                    if query.kind_of?(Query)
                                                      query.dup
                                                    else
                                                      repository = if query.key?(:repository)
                                              Severity: Minor
                                              Found in lib/dm-core/model.rb - About 1 hr 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 assert_valid_options has 35 lines of code (exceeds 25 allowed). Consider refactoring.

                                                  def assert_valid_options(options)
                                                    keys = options.keys
                                              
                                                    if (unknown_keys = keys - self.class.accepted_options).any?
                                                      raise ArgumentError, "options #{unknown_keys.map { |key| key.inspect }.join(' and ')} are unknown"
                                              Severity: Minor
                                              Found in lib/dm-core/property.rb - About 1 hr to fix

                                                Consider simplifying this complex logical expression.

                                                      if other_query.links.empty?                 &&
                                                        (unique || (!unique && !query.unique?))   &&
                                                        !other_query.reload?                      &&
                                                        !other_query.raw?                         &&
                                                        other_query.fields.to_set.subset?(fields) &&
                                                Severity: Critical
                                                Found in lib/dm-core/collection.rb - About 1 hr to fix

                                                  Method target_conditions has 32 lines of code (exceeds 25 allowed). Consider refactoring.

                                                      def self.target_conditions(source, source_key, target_key)
                                                        target_key_size = target_key.size
                                                        source_values   = []
                                                  
                                                        if source.nil?
                                                  Severity: Minor
                                                  Found in lib/dm-core/query.rb - About 1 hr to fix

                                                    Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.

                                                          def initialize(model, name, options = {})
                                                            super
                                                    
                                                            if kind_of?(Decimal) || kind_of?(Float)
                                                              @precision = @options.fetch(:precision)
                                                    Severity: Minor
                                                    Found in lib/dm-core/property/numeric.rb - About 1 hr 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 property has 30 lines of code (exceeds 25 allowed). Consider refactoring.

                                                          def property(name, type, options = {})
                                                            # if the type can be found within Property then
                                                            # use that class rather than the primitive
                                                            klass = DataMapper::Property.determine_class(type)
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in lib/dm-core/model/property.rb - About 1 hr to fix

                                                      Method property has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

                                                            def property(name, type, options = {})
                                                              # if the type can be found within Property then
                                                              # use that class rather than the primitive
                                                              klass = DataMapper::Property.determine_class(type)
                                                      
                                                      
                                                      Severity: Minor
                                                      Found in lib/dm-core/model/property.rb - About 1 hr 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 extract_slice_arguments has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

                                                        def extract_slice_arguments(*args)
                                                          first_arg, second_arg = args
                                                      
                                                          if args.size == 2 && first_arg.kind_of?(Integer) && second_arg.kind_of?(Integer)
                                                            return first_arg, second_arg
                                                      Severity: Minor
                                                      Found in lib/dm-core/support/lazy_array.rb - About 1 hr 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 cmp? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

                                                        def cmp?(other, operator)
                                                          unless loaded?
                                                            # compare the head against the beginning of other.  start at index
                                                            # 0 and incrementally compare each entry. if other is a LazyArray
                                                            # this has a lesser likelyhood of triggering a lazy load
                                                      Severity: Minor
                                                      Found in lib/dm-core/support/lazy_array.rb - About 1 hr 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 new has 27 lines of code (exceeds 25 allowed). Consider refactoring.

                                                          def self.new(repository_name, options)
                                                            options = normalize_options(options)
                                                      
                                                            case options.fetch(:adapter)
                                                            when 'java'      
                                                      Severity: Minor
                                                      Found in lib/dm-core/adapters.rb - About 1 hr to fix

                                                        Method initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.

                                                            def initialize(model, name, options = {})
                                                              options = options.to_hash.dup
                                                        
                                                              if INVALID_NAMES.include?(name.to_s) || (kind_of?(Boolean) && INVALID_NAMES.include?("#{name}?"))
                                                                raise ArgumentError,
                                                        Severity: Minor
                                                        Found in lib/dm-core/property.rb - About 1 hr to fix

                                                          Method has has 26 lines of code (exceeds 25 allowed). Consider refactoring.

                                                                def has(cardinality, name, *args)
                                                                  name    = name.to_sym
                                                                  model   = extract_model(args)
                                                                  options = extract_options(args)
                                                          
                                                          
                                                          Severity: Minor
                                                          Found in lib/dm-core/model/relationship.rb - About 1 hr to fix

                                                            Method lazy_load has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

                                                                    def lazy_load(source)
                                                                      source_key_different = source_key_different?(source)
                                                            
                                                                      if (loaded?(source) && !source_key_different) || !valid_source?(source)
                                                                        return
                                                            Severity: Minor
                                                            Found in lib/dm-core/associations/many_to_one.rb - About 55 mins 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 parent_relationships has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

                                                                def parent_relationships
                                                                  parent_relationships = []
                                                            
                                                                  relationships.each do |relationship|
                                                                    next unless relationship.respond_to?(:resource_for)
                                                            Severity: Minor
                                                            Found in lib/dm-core/resource.rb - About 55 mins 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 attributes= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

                                                                def attributes=(attributes)
                                                                  model = self.model
                                                                  attributes.each do |name, value|
                                                                    case name
                                                                      when String, Symbol
                                                            Severity: Minor
                                                            Found in lib/dm-core/resource.rb - About 55 mins 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 inline_call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

                                                                  def inline_call(method_info, scope)
                                                                    DataMapper::Hook::ClassMethods.hook_scopes << method_info[:from]
                                                                    name = method_info[:name]
                                                                    if scope == :instance
                                                                      args = method_defined?(name) && instance_method(name).arity != 0 ? '*args' : ''
                                                            Severity: Minor
                                                            Found in lib/dm-core/support/hook.rb - About 55 mins 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 first has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

                                                                def first(*args)
                                                                  first_arg = args.first
                                                                  last_arg  = args.last
                                                            
                                                                  limit_specified = first_arg.kind_of?(Integer)
                                                            Severity: Minor
                                                            Found in lib/dm-core/model.rb - About 45 mins 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