datamapper/dm-core

View on GitHub
lib/dm-core/query.rb

Summary

Maintainability
F
3 days
Test Coverage

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

      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

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

        There are no issues that match your filters.

        Category