Dynamoid/dynamoid

View on GitHub

Showing 58 of 81 total issues

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

        def initialize(client, table, key_conditions, non_key_conditions, options)
Severity: Minor
Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/query.rb - About 35 mins to fix

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

          def initialize(model_or_model_class, key_or_attributes = {}, options = {})
            model = if model_or_model_class.is_a?(Dynamoid::Document)
                      model_or_model_class
                    else
                      find_from_attributes(model_or_model_class, key_or_attributes)
    Severity: Minor
    Found in lib/dynamoid/transaction_write/destroy.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 connection_config has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def connection_config
            @connection_hash = {}
    
            (Dynamoid::Config.settings.compact.keys & CONNECTION_CONFIG_OPTIONS).each do |option|
              @connection_hash[option] = Dynamoid::Config.send(option)
    Severity: Minor
    Found in lib/dynamoid/adapter_plugin/aws_sdk_v3.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.
    Open

          def initialize(model_or_model_class, key_or_attributes = {}, options = {})
            options = options.reverse_merge(skip_validation: true)
            super(model_or_model_class, {}, options)
            self.attributes = if key_or_attributes.is_a?(Hash)
                                key_or_attributes
    Severity: Minor
    Found in lib/dynamoid/transaction_write/delete.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 sanitize_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def sanitize_attributes(attributes)
              # rubocop:disable Lint/DuplicateBranch
              attributes.transform_values do |v|
                if v.is_a?(Hash)
                  v.stringify_keys
    Severity: Minor
    Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/item_updater.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 add_timestamps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def add_timestamps(attributes, skip_created_at: false)
            return attributes if options[:skip_timestamps] || !model_class&.timestamps_enabled?
    
            result = attributes.clone
            timestamp = DateTime.now.in_time_zone(Time.zone)
    Severity: Minor
    Found in lib/dynamoid/transaction_write/action.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def call(request)
                # Adjust the limit down if the remaining record and/or scan limit are
                # lower to obey limits. We can assume the difference won't be
                # negative due to break statements below but choose smaller limit
                # which is why we have 2 separate if statements.
    Severity: Minor
    Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/middleware/limit.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 table has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def table(options)
            self.options = options
    
            # a default 'id' column is created when Dynamoid::Document is included
            unless attributes.key? hash_key
    Severity: Minor
    Found in lib/dynamoid/fields.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 local_secondary_index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def local_secondary_index(options = {})
            unless options.present?
              raise Dynamoid::Errors::InvalidIndex, 'empty index definition'
            end
    
    
    Severity: Minor
    Found in lib/dynamoid/indexes.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 build_request has a Cognitive Complexity of 6 (exceeds 5 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 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 delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def delete(table, ids, options = {})
          range_key = options[:range_key] # array of range keys that matches the ids passed in
          if ids.respond_to?(:each)
            ids = if range_key.respond_to?(:each)
                    # turn ids into array of arrays each element being hash_key, range_key
    Severity: Minor
    Found in lib/dynamoid/adapter.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 query_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def query_options
            opts = {}
            # Don't specify select = ALL_ATTRIBUTES option explicitly because it's
            # already a default value of Select statement. Explicite Select value
            # conflicts with AttributesToGet statement (project option).
    Severity: Minor
    Found in lib/dynamoid/criteria/chain.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 scan_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def scan_options
            opts = {}
            opts[:index_name] = @key_fields_detector.index_name if @key_fields_detector.index_name
            opts[:record_limit] = @record_limit if @record_limit
            opts[:scan_limit] = @scan_limit if @scan_limit
    Severity: Minor
    Found in lib/dynamoid/criteria/chain.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 set_additions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def set_additions(expression_attribute_values, update_expression)
            return update_expression unless additions.present?
    
            # ADD statements can be used to increment a counter:
            # txn.update!(UserCount, "UserCount#Red", {}, options: {add: {record_count: 1}})
    Severity: Minor
    Found in lib/dynamoid/transaction_write/update_upsert.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 conditions_for_write has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def conditions_for_write
            conditions = {}
    
            # Add an 'exists' check to prevent overwriting existing records with new ones
            if @model.new_record?
    Severity: Minor
    Found in lib/dynamoid/persistence/save.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 delete_table has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def delete_table(table_name, options = {})
            resp = client.delete_table(table_name: table_name)
    
            if options[:sync]
              status = PARSE_TABLE_STATUS.call(resp, :table_description)
    Severity: Minor
    Found in lib/dynamoid/adapter_plugin/aws_sdk_v3.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 start_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def start_key
            return @start if @start.is_a?(Hash)
    
            hash_key = @key_fields_detector.hash_key || source.hash_key
            range_key = @key_fields_detector.range_key || source.range_key
    Severity: Minor
    Found in lib/dynamoid/criteria/chain.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 find_all_by_secondary_index has a Cognitive Complexity of 6 (exceeds 5 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 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
    Status
    Source
    Language