datamapper/dm-core

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

Summary

Maintainability
F
3 days
Test Coverage

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

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

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

        There are no issues that match your filters.

        Category