datamapper/dm-core

View on GitHub

Showing 91 of 115 total issues

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

    def lazy_load
      if loaded?
        return self
      end

Severity: Minor
Found in lib/dm-core/collection.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

Method create_intermediary has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

        def create_intermediary(execute_hooks, resource = nil)
          intermediary_for = self.intermediary_for

          intermediary_resource = intermediary_for[resource]
          return intermediary_resource if intermediary_resource
Severity: Minor
Found in lib/dm-core/associations/many_to_many.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

Method new has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

        def new(*args, &block)
          if args.size == 1 && args.first.kind_of?(Hash)
            discriminator = properties(repository_name).discriminator

            if discriminator_value = args.first[discriminator.name]
Severity: Minor
Found in lib/dm-core/property/discriminator.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

Method child_relationships has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

    def child_relationships
      child_relationships = []

      relationships.each do |relationship|
        next unless relationship.respond_to?(:collection_for)
Severity: Minor
Found in lib/dm-core/resource.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

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

Method last has a Cognitive Complexity of 8 (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/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

Consider simplifying this complex logical expression.

      if required? && dumped_value.nil?
        negated || false
      else
        value_dumped?(dumped_value) || (dumped_value.nil? && (allow_nil? || negated))
      end
Severity: Major
Found in lib/dm-core/property.rb - About 40 mins to fix

    Method install_hook has 5 arguments (exceeds 4 allowed). Consider refactoring.

          def install_hook(type, target_method, method_sym, scope, &block)
    Severity: Minor
    Found in lib/dm-core/support/hook.rb - About 35 mins to fix

      Method normalize_order has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def normalize_order
            return if @order.nil?
      
            @order = Array(@order).map do |order|
              case order
      Severity: Minor
      Found in lib/dm-core/query.rb - About 35 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 conditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def conditions
            key = self.key
            if key
              model.key_conditions(repository, key)
            else
      Severity: Minor
      Found in lib/dm-core/resource.rb - About 35 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 merge_conditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def merge_conditions(conditions)
            @conditions = Conditions::Operation.new(:and) << @conditions unless @conditions.nil?
      
            conditions.compact!
            conditions.each do |condition|
      Severity: Minor
      Found in lib/dm-core/query.rb - About 35 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 assert_valid_links has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def assert_valid_links(links)
            if links.empty?
              raise ArgumentError, '+options[:links]+ should not be empty'
            end
      
      
      Severity: Minor
      Found in lib/dm-core/query.rb - About 35 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 save_self has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def save_self(execute_hooks = true)
            # short-circuit if the resource is not dirty
            return saved? unless dirty_self?
      
            if execute_hooks
      Severity: Minor
      Found in lib/dm-core/resource.rb - About 35 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 valid? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def valid?(value, negated = false)
            dumped_value = dump(value)
      
            if required? && dumped_value.nil?
              negated || false
      Severity: Minor
      Found in lib/dm-core/property.rb - About 35 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 initialize_log has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def initialize_log(log)
            close if @log # be sure that we don't leave open files laying around.
      
            if log.respond_to?(:write)
              @log = log
      Severity: Minor
      Found in lib/dm-core/support/logger.rb - About 35 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 valid_target_collection? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

            def valid_target_collection?(collection, negated)
              if collection.kind_of?(Collection)
                # TODO: move the check for model_key into Collection#reloadable?
                # since what we're really checking is a Collection's ability
                # to reload itself, which is (currently) only possible if the
      Severity: Minor
      Found in lib/dm-core/associations/relationship.rb - About 35 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 initialize has a Cognitive Complexity of 7 (exceeds 5 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 35 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 update! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def update!(attributes)
            assert_update_clean_only(:update!)
      
            model = self.model
      
      
      Severity: Minor
      Found in lib/dm-core/collection.rb - About 35 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 pluralize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def pluralize(word)
            result = word.to_s.dup
      
            if word.empty? || inflections.uncountables.include?(result.downcase)
              result
      Severity: Minor
      Found in lib/dm-core/support/inflector/inflections.rb - About 35 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 constantize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

            def constantize(camel_cased_word) #:nodoc:
              names = camel_cased_word.split('::')
              names.shift if names.empty? || names.first.empty?
      
              constant = Object
      Severity: Minor
      Found in lib/dm-core/support/inflector/methods.rb - About 35 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 constantize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

            def constantize(camel_cased_word)
              names = camel_cased_word.split('::')
              names.shift if names.empty? || names.first.empty?
      
              constant = Object
      Severity: Minor
      Found in lib/dm-core/support/inflector/methods.rb - About 35 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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

            def initialize(model, name, options = {})
              super
      
              [ :scale, :precision ].each do |key|
                unless @options.key?(key)
      Severity: Minor
      Found in lib/dm-core/property/decimal.rb - About 35 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 singularize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def singularize(word)
            result = word.to_s.dup
      
            if inflections.uncountables.any? { |inflection| result =~ /\b(#{inflection})\Z/i }
              result
      Severity: Minor
      Found in lib/dm-core/support/inflector/inflections.rb - About 25 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 full_const_set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def self.full_const_set(obj, name, value = nil)
            obj, name, value = ::Object, obj, name if value.nil?
      
            list = name.split("::")
            toplevel = DataMapper::Ext.blank?(list.first)
      Severity: Minor
      Found in lib/dm-core/support/ext/object.rb - About 25 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 at has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def at(offset)
            if loaded? || partially_loaded?(offset)
              super
            elsif offset == 0
              first
      Severity: Minor
      Found in lib/dm-core/collection.rb - About 25 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 dump has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

              def dump(value)
                value.dup.force_encoding("BINARY") unless value.nil?
              rescue
                value
              end
      Severity: Minor
      Found in lib/dm-core/property/binary.rb - About 25 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def update(other)
            other_options = if kind_of?(other.class)
              return self if self.eql?(other)
              assert_valid_other(other)
              other.options
      Severity: Minor
      Found in lib/dm-core/query.rb - About 25 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 assert_valid_order has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def assert_valid_order(order, fields)
            Array(order).each do |order_entry|
              case order_entry
                when Symbol, String
                  unless @properties.named?(order_entry)
      Severity: Minor
      Found in lib/dm-core/query.rb - About 25 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 setup_hook has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

              def setup_hook(type, name, method, proc)
                types = hooks[name]
                if types && types[type]
                  types[type] << if proc
                    ProcCommand.new(proc)
      Severity: Minor
      Found in lib/dm-core/model/hook.rb - About 25 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 condition_properties has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def condition_properties
            properties = Set.new
      
            each_comparison do |comparison|
              next unless comparison.respond_to?(:subject)
      Severity: Minor
      Found in lib/dm-core/query.rb - About 25 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 append_property_condition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def append_property_condition(subject, bind_value, operator)
            negated = operator == :not
      
            if operator == :eql || negated
              # transform :relationship => nil into :relationship.not => association
      Severity: Minor
      Found in lib/dm-core/query.rb - About 25 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 load_adapter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

            def load_adapter(name)
              require "dm-#{name}-adapter"
            rescue LoadError => original_error
              begin
                require in_memory_adapter?(name) ? in_memory_adapter_path : legacy_path(name)
      Severity: Minor
      Found in lib/dm-core/adapters.rb - About 25 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 define_hook_stack_execution_methods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

            def define_hook_stack_execution_methods(target_method, scope)
              unless registered_as_hook?(target_method, scope)
                raise ArgumentError, "#{target_method} has not be registered as a hookable #{scope} method"
              end
      
      
      Severity: Minor
      Found in lib/dm-core/support/hook.rb - About 25 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 <=> has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

            def <=>(other)
              other_value = other.value
              value_nil   = @value.nil?
              other_nil   = other_value.nil?
      
      
      Severity: Minor
      Found in lib/dm-core/query/sort.rb - About 25 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 normalize_links has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def normalize_links
            stack = @links.dup
      
            @links.clear
      
      
      Severity: Minor
      Found in lib/dm-core/query.rb - About 25 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 values_at has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

        def values_at(*args)
          accumulator = []
      
          lazy_possible = args.all? do |arg|
            index, length = extract_slice_arguments(arg)
      Severity: Minor
      Found in lib/dm-core/support/lazy_array.rb - About 25 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 assert_valid_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def assert_valid_fields(fields, unique)
            valid_properties = model.properties
      
            model.descendants.each do |descendant|
              valid_properties += descendant.properties
      Severity: Minor
      Found in lib/dm-core/query.rb - About 25 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 typecast_to_numeric has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

              def typecast_to_numeric(value, method)
                if value.respond_to?(:to_str)
                  if value.to_str =~ /\A(-?(?:0|[1-9]\d*)(?:\.\d+)?|(?:\.\d+))\z/
                    $1.send(method)
                  else
      Severity: Minor
      Found in lib/dm-core/property/typecast/numeric.rb - About 25 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 typecast_to_primitive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

            def typecast_to_primitive(value)
              if value.respond_to?(:to_time)
                value.to_time
              elsif value.is_a?(::Hash) || value.respond_to?(:to_mash)
                typecast_hash_to_time(value)
      Severity: Minor
      Found in lib/dm-core/property/time.rb - About 25 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 typecast_to_primitive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

            def typecast_to_primitive(value)
              if value.respond_to?(:to_date)
                value.to_date
              elsif value.is_a?(::Hash) || value.respond_to?(:to_mash)
                typecast_hash_to_date(value)
      Severity: Minor
      Found in lib/dm-core/property/date.rb - About 25 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 key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

          def key
            return @_key if defined?(@_key)
      
            model_key = model.key(repository_name)
      
      
      Severity: Minor
      Found in lib/dm-core/resource.rb - About 25 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