Dynamoid/dynamoid

View on GitHub

Showing 59 of 80 total issues

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

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 find_all_by_secondary_index has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def find_all_by_secondary_index(hash, options = {})
        ActiveSupport::Deprecation.warn('[Dynamoid] .find_all_by_secondary_index is deprecated! Call .where instead of')

        range = options[:range] || {}
        hash_key_field, hash_key_value = hash.first
Severity: Minor
Found in lib/dynamoid/finders.rb - About 1 hr to fix

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

            def build_all_attribute_definitions(key_schema, secondary_indexes = {})
              ls_indexes = secondary_indexes[:local_secondary_indexes]
              gs_indexes = secondary_indexes[:global_secondary_indexes]
    
              attribute_definitions = []
    Severity: Minor
    Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/create_table.rb - About 1 hr to fix

      Method to_h has a Cognitive Complexity of 9 (exceeds 5 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 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 sanitize_item has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def sanitize_item(attributes)
              config_value = Dynamoid.config.store_attribute_with_nil_value
              store_attribute_with_nil_value = config_value.nil? ? false : !!config_value
      
              attributes.reject do |_, v|
      Severity: Minor
      Found in lib/dynamoid/transaction_write/action.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 set_deletions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_deletions(expression_attribute_values, update_expression)
              return update_expression unless deletions.present?
      
              delete_keys = deletions.keys
              update_expression += " DELETE #{delete_keys.each_with_index.map { |k, i| "#{k} :_d#{i}" }.join(', ')}"
      Severity: Minor
      Found in lib/dynamoid/transaction_write/update_upsert.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(attrs = {}, &block)
            run_callbacks :initialize do
              @new_record = true
              @attributes ||= {}
              @associations ||= {}
      Severity: Minor
      Found in lib/dynamoid/document.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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def call
                counter = 0
                resp = nil
                begin
                  check = { again: true }
      Severity: Minor
      Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/until_past_table_status.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 batch_write_item has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def batch_write_item(table_name, objects, options = {})
              items = objects.map { |o| sanitize_item(o) }
      
              while items.present?
                batch = items.shift(BATCH_WRITE_ITEM_REQUESTS_LIMIT)
      Severity: Minor
      Found in lib/dynamoid/adapter_plugin/aws_sdk_v3.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 process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def process(value)
              # rubocop:disable Lint/DuplicateBranch
              if value == true
                1
              elsif value == false
      Severity: Minor
      Found in lib/dynamoid/type_casting.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 run_callbacks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def run_callbacks
              unless model
                yield if block_given?
                return
              end
      Severity: Minor
      Found in lib/dynamoid/transaction_write/update.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 delete_all has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def delete_all
              ids = []
              ranges = []
      
              if @key_fields_detector.key_present?
      Severity: Minor
      Found in lib/dynamoid/criteria/chain.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 _find_by_id has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def _find_by_id(id, options = {})
              raise Errors::MissingRangeKey if range_key && options[:range_key].nil?
      
              if range_key
                key = options[:range_key]
      Severity: Minor
      Found in lib/dynamoid/finders.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 process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def process(value)
              # rubocop:disable Lint/DuplicateBranch
              if value == true
                1
              elsif value == false
      Severity: Minor
      Found in lib/dynamoid/type_casting.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 add_action_and_validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_action_and_validate(action)
            if !action.skip_validation? && !action.valid?
              raise Dynamoid::Errors::DocumentNotValid, action.model if action.raise_validation_error?
      
              return false
      Severity: Minor
      Found in lib/dynamoid/transaction_write.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 format_datetime has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def format_datetime(value, options)
              use_string_format = if options[:store_as_string].nil?
                                    Dynamoid.config.store_datetime_as_string
                                  else
                                    options[:store_as_string]
      Severity: Minor
      Found in lib/dynamoid/dumping.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 process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def process(value)
              if !value.respond_to?(:to_datetime)
                nil
              elsif value.is_a?(String)
                dt = begin
      Severity: Minor
      Found in lib/dynamoid/type_casting.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 process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def process(value)
              unless value.nil?
                store_as_boolean = if @options[:store_as_native_boolean].nil?
                                     Dynamoid.config.store_boolean_as_native
                                   else
      Severity: Minor
      Found in lib/dynamoid/dumping.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def initialize(conditions, name_placeholders, value_placeholders, name_placeholder_sequence, value_placeholder_sequence)
      Severity: Minor
      Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/filter_expression_convertor.rb - About 35 mins to fix
        Severity
        Category
        Status
        Source
        Language