Dynamoid/dynamoid

View on GitHub

Showing 58 of 81 total issues

File aws_sdk_v3.rb has 370 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative 'aws_sdk_v3/query'
require_relative 'aws_sdk_v3/scan'
require_relative 'aws_sdk_v3/execute_statement'
require_relative 'aws_sdk_v3/create_table'
require_relative 'aws_sdk_v3/batch_get_item'
Severity: Minor
Found in lib/dynamoid/adapter_plugin/aws_sdk_v3.rb - About 4 hrs to fix

    Class Chain has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Chain
          attr_reader :source, :consistent_read, :key_fields_detector
    
          include Enumerable
    
    
    Severity: Minor
    Found in lib/dynamoid/criteria/chain.rb - About 4 hrs to fix

      Class AwsSdkV3 has 29 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class AwsSdkV3
            EQ = 'EQ'
            HASH_KEY  = 'HASH'
            RANGE_KEY = 'RANGE'
            STRING_TYPE  = 'S'
      Severity: Minor
      Found in lib/dynamoid/adapter_plugin/aws_sdk_v3.rb - About 3 hrs to fix

        File chain.rb has 300 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require_relative 'key_fields_detector'
        require_relative 'nonexistent_fields_detector'
        require_relative 'where_conditions'
        
        module Dynamoid
        Severity: Minor
        Found in lib/dynamoid/criteria/chain.rb - About 3 hrs to fix

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

                def _find_all(ids, options = {})
                  raise Errors::MissingRangeKey if range_key && ids.any? { |_pk, sk| sk.nil? }
          
                  if range_key
                    ids = ids.map do |pk, sk|
          Severity: Minor
          Found in lib/dynamoid/finders.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

          Method call has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

                def call
                  @model.hash_key = SecureRandom.uuid if @model.hash_key.blank?
          
                  return true unless @model.changed?
          
          
          Severity: Minor
          Found in lib/dynamoid/persistence/save.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 dynamodb_type has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.dynamodb_type(type, options)
                if type.is_a?(Class)
                  type = type.respond_to?(:dynamoid_field_type) ? type.dynamoid_field_type : :string
                end
          
          
          Severity: Minor
          Found in lib/dynamoid/primary_key_type_mapping.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 call has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def call
                    billing_mode = options[:billing_mode]
                    read_capacity = options[:read_capacity] || Dynamoid::Config.read_capacity
                    write_capacity = options[:write_capacity] || Dynamoid::Config.write_capacity
          
          
          Severity: Major
          Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/create_table.rb - About 2 hrs to fix

            File type_casting.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Dynamoid
              # @private
              module TypeCasting
                def self.cast_attributes(attributes, attributes_options)
                  {}.tap do |h|
            Severity: Minor
            Found in lib/dynamoid/type_casting.rb - About 2 hrs to fix

              Method call has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                      def call
                        results = {}
              
                        tables_with_ids.each do |table, ids|
                          if ids.blank?
              Severity: Minor
              Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/batch_get_item.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 _find_all has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def _find_all(ids, options = {})
                      raise Errors::MissingRangeKey if range_key && ids.any? { |_pk, sk| sk.nil? }
              
                      if range_key
                        ids = ids.map do |pk, sk|
              Severity: Minor
              Found in lib/dynamoid/finders.rb - About 1 hr to fix

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

                        def call
                          billing_mode = options[:billing_mode]
                          read_capacity = options[:read_capacity] || Dynamoid::Config.read_capacity
                          write_capacity = options[:write_capacity] || Dynamoid::Config.write_capacity
                
                
                Severity: Minor
                Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/create_table.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 build has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def build
                          clauses = @conditions.map do |name, attribute_conditions|
                            attribute_conditions.map do |operator, value|
                              name_or_placeholder = name_or_placeholder_for(name)
                
                

                  Method build_request has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def build_request
                            # expressions
                            name_placeholder = +'#_a0'
                            value_placeholder = +':_a0'
                  
                  
                  Severity: Minor
                  Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/query.rb - About 1 hr to fix

                    Method to_h has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def to_h
                            if model
                              # model.hash_key = SecureRandom.uuid if model.hash_key.blank?
                              touch_model_timestamps(skip_created_at: true)
                              changes = model.changes.map { |k, v| [k.to_sym, v[1]] }.to_h # hash of dirty attributes
                    Severity: Minor
                    Found in lib/dynamoid/transaction_write/update_upsert.rb - About 1 hr to fix

                      Method call has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def call
                              @model.hash_key = SecureRandom.uuid if @model.hash_key.blank?
                      
                              return true unless @model.changed?
                      
                      
                      Severity: Minor
                      Found in lib/dynamoid/persistence/save.rb - About 1 hr to fix

                        Method build_request has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                def build_request
                                  # expressions
                                  name_placeholder = +'#_a0'
                                  value_placeholder = +':_a0'
                        
                        
                        Severity: Minor
                        Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/scan.rb - About 1 hr to fix

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

                                def find_from_attributes(model_or_model_class, attributes)
                                  model_class = model_or_model_class.is_a?(Dynamoid::Document) ? model_or_model_class.class : model_or_model_class
                                  if attributes.is_a?(Hash)
                                    raise Dynamoid::Errors::MissingHashKey unless attributes[model_class.hash_key].present?
                          
                          
                          Severity: Minor
                          Found in lib/dynamoid/transaction_write/action.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 field_condition has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def field_condition(key, value_before_type_casting)
                                  name, operator = key.to_s.split('.')
                                  value = type_cast_condition_parameter(name, value_before_type_casting)
                                  operator ||= 'eq'
                          
                          
                          Severity: Minor
                          Found in lib/dynamoid/criteria/chain.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 delete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def delete
                                options = range_key ? { range_key: Dumping.dump_field(read_attribute(range_key), self.class.attributes[range_key]) } : {}
                          
                                # Add an optimistic locking check if the lock_version column exists
                                if self.class.attributes[:lock_version]
                          Severity: Minor
                          Found in lib/dynamoid/persistence.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

                          Severity
                          Category
                          Status
                          Source
                          Language